mirror of
https://github.com/Sollace/Unicopia.git
synced 2025-02-01 19:46:42 +01:00
Refactor and tidy up cloud implementation and add cloud pillars
This commit is contained in:
parent
f5cfe302a5
commit
a595348dbd
24 changed files with 207 additions and 132 deletions
|
@ -6,58 +6,61 @@ import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.SlabBlock;
|
import net.minecraft.block.SlabBlock;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.BlockView;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public abstract class AbstractSlabBlock<T extends Block> extends SlabBlock {
|
public abstract class AbstractSlabBlock extends SlabBlock {
|
||||||
|
|
||||||
protected final T modelBlock;
|
|
||||||
protected final BlockState modelState;
|
protected final BlockState modelState;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public AbstractSlabBlock(BlockState inherited, Block.Settings settings) {
|
public AbstractSlabBlock(BlockState inherited, Block.Settings settings) {
|
||||||
super(settings);
|
super(settings);
|
||||||
modelState = inherited;
|
modelState = inherited;
|
||||||
modelBlock = (T)inherited.getBlock();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public boolean isTranslucent(BlockState state, BlockView world, BlockPos pos) {
|
public boolean isTranslucent(BlockState state, BlockView world, BlockPos pos) {
|
||||||
return modelBlock.isTranslucent(state, world, pos);
|
return modelState.isTranslucent(world, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean allowsSpawning(BlockState state, BlockView view, BlockPos pos, EntityType<?> type) {
|
||||||
|
return modelState.allowsSpawning(view, pos, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isAir(BlockState state) {
|
public boolean isAir(BlockState state) {
|
||||||
return modelBlock.isAir(state);
|
return modelState.isAir();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random rand) {
|
public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random rand) {
|
||||||
modelBlock.scheduledTick(state, world, pos, rand);
|
modelState.scheduledTick(world, pos, rand);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLandedUpon(World w, BlockPos pos, Entity entity, float fallDistance) {
|
public void onLandedUpon(World w, BlockPos pos, Entity entity, float fallDistance) {
|
||||||
modelBlock.onLandedUpon(w, pos, entity, fallDistance);
|
modelState.getBlock().onLandedUpon(w, pos, entity, fallDistance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEntityLand(BlockView w, Entity entity) {
|
public void onEntityLand(BlockView w, Entity entity) {
|
||||||
modelBlock.onEntityLand(w, entity);
|
modelState.getBlock().onEntityLand(w, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEntityCollision(BlockState state, World w, BlockPos pos, Entity entity) {
|
public void onEntityCollision(BlockState state, World w, BlockPos pos, Entity entity) {
|
||||||
modelBlock.onEntityCollision(state, w, pos, entity);
|
modelState.onEntityCollision(w, pos, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView worldIn, BlockPos pos) {
|
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView worldIn, BlockPos pos) {
|
||||||
return modelBlock.calcBlockBreakingDelta(state, player, worldIn, pos);
|
return modelState.calcBlockBreakingDelta(player, worldIn, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,39 +1,41 @@
|
||||||
package com.minelittlepony.unicopia.block;
|
package com.minelittlepony.unicopia.block;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.block.StairsBlock;
|
import net.minecraft.block.StairsBlock;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.BlockView;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public abstract class AbstractStairsBlock<T extends Block> extends StairsBlock {
|
public abstract class AbstractStairsBlock extends StairsBlock {
|
||||||
|
|
||||||
protected final T baseBlock;
|
|
||||||
protected final BlockState baseBlockState;
|
protected final BlockState baseBlockState;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
|
||||||
public AbstractStairsBlock(BlockState inherited, Settings settings) {
|
public AbstractStairsBlock(BlockState inherited, Settings settings) {
|
||||||
super(inherited, settings);
|
super(inherited, settings);
|
||||||
baseBlock = (T)inherited.getBlock();
|
|
||||||
baseBlockState = inherited;
|
baseBlockState = inherited;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canSuffocate(BlockState state, BlockView world, BlockPos pos) {
|
public boolean isTranslucent(BlockState state, BlockView world, BlockPos pos) {
|
||||||
return baseBlock.canSuffocate(baseBlockState, world, pos);
|
return baseBlockState.isTranslucent(world, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean allowsSpawning(BlockState state, BlockView view, BlockPos pos, EntityType<?> type) {
|
||||||
|
return baseBlockState.allowsSpawning(view, pos, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLandedUpon(World w, BlockPos pos, Entity entity, float fallDistance) {
|
public void onLandedUpon(World w, BlockPos pos, Entity entity, float fallDistance) {
|
||||||
baseBlock.onLandedUpon(w, pos, entity, fallDistance);
|
baseBlockState.getBlock().onLandedUpon(w, pos, entity, fallDistance);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEntityLand(BlockView w, Entity entity) {
|
public void onEntityLand(BlockView w, Entity entity) {
|
||||||
baseBlock.onEntityLand(w, entity);
|
baseBlockState.getBlock().onEntityLand(w, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -41,14 +43,9 @@ public abstract class AbstractStairsBlock<T extends Block> extends StairsBlock {
|
||||||
baseBlockState.onEntityCollision(w, pos, entity);
|
baseBlockState.onEntityCollision(w, pos, entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onSteppedOn(World w, BlockPos pos, Entity entity) {
|
|
||||||
baseBlock.onSteppedOn(w, pos, entity);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) {
|
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) {
|
||||||
return baseBlock.calcBlockBreakingDelta(state, player, world, pos);
|
return baseBlockState.calcBlockBreakingDelta(player, world, pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import com.minelittlepony.unicopia.gas.CloudSoilBlock;
|
||||||
import com.minelittlepony.unicopia.gas.CloudStairsBlock;
|
import com.minelittlepony.unicopia.gas.CloudStairsBlock;
|
||||||
import com.minelittlepony.unicopia.gas.CoverableCloudBlock;
|
import com.minelittlepony.unicopia.gas.CoverableCloudBlock;
|
||||||
import com.minelittlepony.unicopia.gas.GasState;
|
import com.minelittlepony.unicopia.gas.GasState;
|
||||||
|
import com.minelittlepony.unicopia.gas.PillarCloudBlock;
|
||||||
import com.minelittlepony.unicopia.item.UItems;
|
import com.minelittlepony.unicopia.item.UItems;
|
||||||
import com.minelittlepony.unicopia.structure.CustomSaplingGenerator;
|
import com.minelittlepony.unicopia.structure.CustomSaplingGenerator;
|
||||||
|
|
||||||
|
@ -32,12 +33,13 @@ public interface UBlocks {
|
||||||
CloudBlock CLOUD_BLOCK = register("cloud_block", new CloudSoilBlock(GasState.NORMAL));
|
CloudBlock CLOUD_BLOCK = register("cloud_block", new CloudSoilBlock(GasState.NORMAL));
|
||||||
CloudBlock ENCHANTED_CLOUD_BLOCK = register("enchanted_cloud_block", new CoverableCloudBlock(GasState.ENCHANTED));
|
CloudBlock ENCHANTED_CLOUD_BLOCK = register("enchanted_cloud_block", new CoverableCloudBlock(GasState.ENCHANTED));
|
||||||
CloudBlock DENSE_CLOUD_BLOCK = register("dense_cloud_block", new CloudBlock(GasState.DENSE));
|
CloudBlock DENSE_CLOUD_BLOCK = register("dense_cloud_block", new CloudBlock(GasState.DENSE));
|
||||||
|
CloudBlock DENSE_CLOUD_PILLAR = register("dense_cloud_pillar", new PillarCloudBlock(GasState.DENSE));
|
||||||
|
|
||||||
CloudStairsBlock<CloudBlock> CLOUD_STAIRS = register("cloud_stairs", new CloudStairsBlock<>(CLOUD_BLOCK.getDefaultState(), GasState.NORMAL.configure().build()));
|
CloudStairsBlock CLOUD_STAIRS = register("cloud_stairs", new CloudStairsBlock(CLOUD_BLOCK.getDefaultState(), GasState.NORMAL.configure().build()));
|
||||||
|
|
||||||
CloudSlabBlock<CloudBlock> CLOUD_SLAB = register("cloud_slab", new CloudSlabBlock<>(CLOUD_BLOCK.getDefaultState(), GasState.NORMAL.configure().build()));
|
CloudSlabBlock CLOUD_SLAB = register("cloud_slab", new CloudSlabBlock(CLOUD_BLOCK.getDefaultState(), GasState.NORMAL.configure().build()));
|
||||||
CloudSlabBlock<CloudBlock> ENCHANTED_CLOUD_SLAB = register("enchanted_cloud_slab", new CloudSlabBlock<>(ENCHANTED_CLOUD_BLOCK.getDefaultState(), GasState.ENCHANTED.configure().build()));
|
CloudSlabBlock ENCHANTED_CLOUD_SLAB = register("enchanted_cloud_slab", new CloudSlabBlock(ENCHANTED_CLOUD_BLOCK.getDefaultState(), GasState.ENCHANTED.configure().build()));
|
||||||
CloudSlabBlock<CloudBlock> DENSE_CLOUD_SLAB = register("dense_cloud_slab", new CloudSlabBlock<>(DENSE_CLOUD_BLOCK.getDefaultState(), GasState.DENSE.configure().build()));
|
CloudSlabBlock DENSE_CLOUD_SLAB = register("dense_cloud_slab", new CloudSlabBlock(DENSE_CLOUD_BLOCK.getDefaultState(), GasState.DENSE.configure().build()));
|
||||||
|
|
||||||
CloudDoorBlock MISTED_GLASS_DOOR = register("misted_glass_door", new CloudDoorBlock(FabricBlockSettings.of(Material.GLASS)
|
CloudDoorBlock MISTED_GLASS_DOOR = register("misted_glass_door", new CloudDoorBlock(FabricBlockSettings.of(Material.GLASS)
|
||||||
.sounds(BlockSoundGroup.GLASS)
|
.sounds(BlockSoundGroup.GLASS)
|
||||||
|
|
|
@ -46,8 +46,7 @@ public interface URenderers {
|
||||||
UBlocks.BAKERY_DOOR, UBlocks.LIBRARY_DOOR, UBlocks.MISTED_GLASS_DOOR, UBlocks.DIAMOND_DOOR);
|
UBlocks.BAKERY_DOOR, UBlocks.LIBRARY_DOOR, UBlocks.MISTED_GLASS_DOOR, UBlocks.DIAMOND_DOOR);
|
||||||
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getTranslucent(),
|
BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getTranslucent(),
|
||||||
UBlocks.CLOUD_ANVIL, UBlocks.CLOUD_FARMLAND,
|
UBlocks.CLOUD_ANVIL, UBlocks.CLOUD_FARMLAND,
|
||||||
UBlocks.CLOUD_BLOCK, UBlocks.CLOUD_SLAB, UBlocks.CLOUD_STAIRS, UBlocks.CLOUD_FENCE,
|
UBlocks.CLOUD_BLOCK, UBlocks.CLOUD_SLAB, UBlocks.CLOUD_STAIRS,
|
||||||
UBlocks.DENSE_CLOUD_BLOCK, UBlocks.DENSE_CLOUD_SLAB,
|
|
||||||
UBlocks.ENCHANTED_CLOUD_BLOCK, UBlocks.ENCHANTED_CLOUD_SLAB,
|
UBlocks.ENCHANTED_CLOUD_BLOCK, UBlocks.ENCHANTED_CLOUD_SLAB,
|
||||||
|
|
||||||
UBlocks.SLIME_DROP, UBlocks.SLIME_LAYER
|
UBlocks.SLIME_DROP, UBlocks.SLIME_LAYER
|
||||||
|
|
|
@ -79,33 +79,27 @@ public class CloudAnvilBlock extends AnvilBlock implements Gas {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) {
|
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) {
|
||||||
CloudInteractionContext ctx = (CloudInteractionContext)context;
|
if (getGasState(state).canPlace((CloudInteractionContext)context)) {
|
||||||
|
return super.getOutlineShape(state, view, pos, context);
|
||||||
if (!getGasState(state).canPlace(ctx)) {
|
|
||||||
return VoxelShapes.empty();
|
|
||||||
}
|
}
|
||||||
|
return VoxelShapes.empty();
|
||||||
return super.getOutlineShape(state, view, pos, context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) {
|
public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) {
|
||||||
CloudInteractionContext ctx = (CloudInteractionContext)context;
|
if (getGasState(state).canTouch((CloudInteractionContext)context)) {
|
||||||
|
return super.getCollisionShape(state, view, pos, context);
|
||||||
if (!getGasState(state).canTouch(ctx)) {
|
|
||||||
return VoxelShapes.empty();
|
|
||||||
}
|
}
|
||||||
|
return VoxelShapes.empty();
|
||||||
return super.getCollisionShape(state, view, pos, context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Override
|
@Override
|
||||||
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) {
|
public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) {
|
||||||
if (!GasState.NORMAL.canTouch(player)) {
|
if (GasState.NORMAL.canTouch(player)) {
|
||||||
return -1;
|
return super.calcBlockBreakingDelta(state, player, world, pos);
|
||||||
}
|
}
|
||||||
return super.calcBlockBreakingDelta(state, player, world, pos);
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
import net.minecraft.entity.EntityContext;
|
import net.minecraft.entity.EntityContext;
|
||||||
|
import net.minecraft.entity.EntityType;
|
||||||
import net.minecraft.entity.player.PlayerEntity;
|
import net.minecraft.entity.player.PlayerEntity;
|
||||||
import net.minecraft.server.world.ServerWorld;
|
import net.minecraft.server.world.ServerWorld;
|
||||||
import net.minecraft.util.math.Direction;
|
import net.minecraft.util.math.Direction;
|
||||||
|
@ -16,7 +17,6 @@ import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.util.shape.VoxelShapes;
|
import net.minecraft.util.shape.VoxelShapes;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.BlockView;
|
||||||
import net.minecraft.world.EmptyBlockView;
|
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
public class CloudBlock extends Block implements Gas {
|
public class CloudBlock extends Block implements Gas {
|
||||||
|
@ -31,31 +31,45 @@ public class CloudBlock extends Block implements Gas {
|
||||||
this.variant = variant;
|
this.variant = variant;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public GasState getGasState(BlockState blockState) {
|
||||||
|
return variant;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canSuffocate(BlockState state, BlockView view, BlockPos pos) {
|
||||||
|
return !getGasState(state).isTranslucent();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isTranslucent(BlockState state, BlockView world, BlockPos pos) {
|
public boolean isTranslucent(BlockState state, BlockView world, BlockPos pos) {
|
||||||
return getGasState(state).isTranslucent();
|
return getGasState(state).isTranslucent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isSimpleFullBlock(BlockState state, BlockView view, BlockPos pos) {
|
||||||
|
return !getGasState(state).isTranslucent() && super.isSimpleFullBlock(state, view, pos);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean allowsSpawning(BlockState state, BlockView view, BlockPos pos, EntityType<?> type) {
|
||||||
|
return getGasState(state).isTranslucent();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) {
|
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) {
|
||||||
CloudInteractionContext ctx = (CloudInteractionContext)context;
|
if (getGasState(state).canPlace((CloudInteractionContext)context)) {
|
||||||
|
return VoxelShapes.fullCube();
|
||||||
if (!getGasState(state).canPlace(ctx)) {
|
|
||||||
return VoxelShapes.empty();
|
|
||||||
}
|
}
|
||||||
|
return VoxelShapes.empty();
|
||||||
return VoxelShapes.fullCube();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) {
|
public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) {
|
||||||
CloudInteractionContext ctx = (CloudInteractionContext)context;
|
if (getGasState(state).canTouch((CloudInteractionContext)context)) {
|
||||||
|
return collidable ? VoxelShapes.fullCube() : VoxelShapes.empty();
|
||||||
if (!getGasState(state).canTouch(ctx)) {
|
|
||||||
return VoxelShapes.empty();
|
|
||||||
}
|
}
|
||||||
|
return VoxelShapes.empty();
|
||||||
return collidable ? VoxelShapes.fullCube() : VoxelShapes.empty();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -75,14 +89,7 @@ public class CloudBlock extends Block implements Gas {
|
||||||
@Override
|
@Override
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) {
|
public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) {
|
||||||
if (beside.getBlock() instanceof Gas && ((Gas)beside.getBlock()).getGasState(beside) == getGasState(state)) {
|
return isFaceCoverd(state, beside, face);
|
||||||
VoxelShape myShape = state.getCollisionShape(EmptyBlockView.INSTANCE, BlockPos.ORIGIN);
|
|
||||||
VoxelShape otherShape = beside.getCollisionShape(EmptyBlockView.INSTANCE, BlockPos.ORIGIN);
|
|
||||||
|
|
||||||
return VoxelShapes.isSideCovered(myShape, otherShape, face);
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.isSideInvisible(state, beside, face);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -114,9 +121,4 @@ public class CloudBlock extends Block implements Gas {
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public GasState getGasState(BlockState blockState) {
|
|
||||||
return variant;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import com.minelittlepony.unicopia.block.AbstractSlabBlock;
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.EntityContext;
|
import net.minecraft.entity.EntityContext;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -12,9 +11,8 @@ import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.util.shape.VoxelShapes;
|
import net.minecraft.util.shape.VoxelShapes;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.BlockView;
|
||||||
import net.minecraft.world.EmptyBlockView;
|
|
||||||
|
|
||||||
public class CloudSlabBlock<T extends Block & Gas> extends AbstractSlabBlock<T> implements Gas {
|
public class CloudSlabBlock extends AbstractSlabBlock implements Gas {
|
||||||
|
|
||||||
public CloudSlabBlock(BlockState inherited, Settings settings) {
|
public CloudSlabBlock(BlockState inherited, Settings settings) {
|
||||||
super(inherited, settings);
|
super(inherited, settings);
|
||||||
|
@ -22,43 +20,28 @@ public class CloudSlabBlock<T extends Block & Gas> extends AbstractSlabBlock<T>
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GasState getGasState(BlockState blockState) {
|
public GasState getGasState(BlockState blockState) {
|
||||||
return modelBlock.getGasState(blockState);
|
return ((Gas)modelState.getBlock()).getGasState(blockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) {
|
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) {
|
||||||
CloudInteractionContext ctx = (CloudInteractionContext)context;
|
if (getGasState(state).canPlace((CloudInteractionContext)context)) {
|
||||||
|
return super.getOutlineShape(state, view, pos, context);
|
||||||
if (!getGasState(state).canTouch(ctx)) {
|
|
||||||
return VoxelShapes.empty();
|
|
||||||
}
|
}
|
||||||
|
return VoxelShapes.empty();
|
||||||
return super.getOutlineShape(state, view, pos, context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) {
|
public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) {
|
||||||
CloudInteractionContext ctx = (CloudInteractionContext)context;
|
if (getGasState(state).canTouch((CloudInteractionContext)context)) {
|
||||||
|
return super.getCollisionShape(state, view, pos, context);
|
||||||
if (!getGasState(state).canPlace(ctx)) {
|
|
||||||
return VoxelShapes.empty();
|
|
||||||
}
|
}
|
||||||
|
return VoxelShapes.empty();
|
||||||
return super.getCollisionShape(state, view, pos, context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) {
|
public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) {
|
||||||
if (beside.getBlock() instanceof Gas) {
|
return isFaceCoverd(state, beside, face);
|
||||||
VoxelShape myShape = state.getCollisionShape(EmptyBlockView.INSTANCE, BlockPos.ORIGIN);
|
|
||||||
VoxelShape otherShape = beside.getCollisionShape(EmptyBlockView.INSTANCE, BlockPos.ORIGIN);
|
|
||||||
|
|
||||||
return VoxelShapes.isSideCovered(myShape, otherShape, face);
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.isSideInvisible(state, beside, face);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,6 @@ import com.minelittlepony.unicopia.block.AbstractStairsBlock;
|
||||||
|
|
||||||
import net.fabricmc.api.EnvType;
|
import net.fabricmc.api.EnvType;
|
||||||
import net.fabricmc.api.Environment;
|
import net.fabricmc.api.Environment;
|
||||||
import net.minecraft.block.Block;
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.EntityContext;
|
import net.minecraft.entity.EntityContext;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
@ -12,9 +11,8 @@ import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.shape.VoxelShape;
|
import net.minecraft.util.shape.VoxelShape;
|
||||||
import net.minecraft.util.shape.VoxelShapes;
|
import net.minecraft.util.shape.VoxelShapes;
|
||||||
import net.minecraft.world.BlockView;
|
import net.minecraft.world.BlockView;
|
||||||
import net.minecraft.world.EmptyBlockView;
|
|
||||||
|
|
||||||
public class CloudStairsBlock<T extends Block & Gas> extends AbstractStairsBlock<T> implements Gas {
|
public class CloudStairsBlock extends AbstractStairsBlock implements Gas {
|
||||||
|
|
||||||
public CloudStairsBlock(BlockState inherited, Settings settings) {
|
public CloudStairsBlock(BlockState inherited, Settings settings) {
|
||||||
super(inherited, settings);
|
super(inherited, settings);
|
||||||
|
@ -22,41 +20,28 @@ public class CloudStairsBlock<T extends Block & Gas> extends AbstractStairsBlock
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GasState getGasState(BlockState state) {
|
public GasState getGasState(BlockState state) {
|
||||||
return baseBlock.getGasState(baseBlockState);
|
return ((Gas)baseBlockState.getBlock()).getGasState(baseBlockState);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) {
|
public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) {
|
||||||
CloudInteractionContext ctx = (CloudInteractionContext)context;
|
if (getGasState(state).canPlace((CloudInteractionContext)context)) {
|
||||||
|
return super.getOutlineShape(state, view, pos, context);
|
||||||
if (!getGasState(state).canPlace(ctx)) {
|
|
||||||
return VoxelShapes.empty();
|
|
||||||
}
|
}
|
||||||
|
return VoxelShapes.empty();
|
||||||
return super.getOutlineShape(state, view, pos, context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) {
|
public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) {
|
||||||
CloudInteractionContext ctx = (CloudInteractionContext)context;
|
if (getGasState(state).canTouch((CloudInteractionContext)context)) {
|
||||||
|
return super.getCollisionShape(state, view, pos, context);
|
||||||
if (!getGasState(state).canTouch(ctx)) {
|
|
||||||
return VoxelShapes.empty();
|
|
||||||
}
|
}
|
||||||
|
return VoxelShapes.empty();
|
||||||
return super.getCollisionShape(state, view, pos, context);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Environment(EnvType.CLIENT)
|
@Environment(EnvType.CLIENT)
|
||||||
public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) {
|
public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) {
|
||||||
if (beside.getBlock() instanceof Gas) {
|
return isFaceCoverd(state, beside, face);
|
||||||
VoxelShape myShape = state.getCollisionShape(EmptyBlockView.INSTANCE, BlockPos.ORIGIN);
|
|
||||||
VoxelShape otherShape = beside.getCollisionShape(EmptyBlockView.INSTANCE, BlockPos.ORIGIN);
|
|
||||||
|
|
||||||
return VoxelShapes.isSideCovered(myShape, otherShape, face);
|
|
||||||
}
|
|
||||||
|
|
||||||
return super.isSideInvisible(state, beside, face);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -2,7 +2,11 @@ package com.minelittlepony.unicopia.gas;
|
||||||
|
|
||||||
import net.minecraft.block.BlockState;
|
import net.minecraft.block.BlockState;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
import net.minecraft.util.math.Vec3d;
|
import net.minecraft.util.math.Vec3d;
|
||||||
|
import net.minecraft.util.shape.VoxelShapes;
|
||||||
|
import net.minecraft.world.EmptyBlockView;
|
||||||
|
|
||||||
public interface Gas {
|
public interface Gas {
|
||||||
|
|
||||||
|
@ -17,6 +21,14 @@ public interface Gas {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default boolean isFaceCoverd(BlockState state, BlockState beside, Direction face) {
|
||||||
|
return beside.getBlock() instanceof Gas
|
||||||
|
&& ((Gas)beside.getBlock()).getGasState(beside) == getGasState(state)
|
||||||
|
&& VoxelShapes.isSideCovered(
|
||||||
|
state.getCollisionShape(EmptyBlockView.INSTANCE, BlockPos.ORIGIN),
|
||||||
|
beside.getCollisionShape(EmptyBlockView.INSTANCE, BlockPos.ORIGIN), face);
|
||||||
|
}
|
||||||
|
|
||||||
default boolean applyRebound(Entity entity) {
|
default boolean applyRebound(Entity entity) {
|
||||||
double y = entity.getVelocity().y;
|
double y = entity.getVelocity().y;
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package com.minelittlepony.unicopia.gas;
|
||||||
import com.minelittlepony.unicopia.EquinePredicates;
|
import com.minelittlepony.unicopia.EquinePredicates;
|
||||||
import com.minelittlepony.unicopia.block.UMaterials;
|
import com.minelittlepony.unicopia.block.UMaterials;
|
||||||
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
import net.fabricmc.fabric.api.block.FabricBlockSettings;
|
||||||
|
import net.minecraft.block.AbstractRailBlock;
|
||||||
import net.minecraft.block.BedBlock;
|
import net.minecraft.block.BedBlock;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.ChestBlock;
|
import net.minecraft.block.ChestBlock;
|
||||||
|
@ -58,14 +59,15 @@ public enum GasState {
|
||||||
if (main.getItem() instanceof BlockItem) {
|
if (main.getItem() instanceof BlockItem) {
|
||||||
Block block = ((BlockItem)main.getItem()).getBlock();
|
Block block = ((BlockItem)main.getItem()).getBlock();
|
||||||
|
|
||||||
if (block instanceof Gas && ((Gas)block).getGasState(block.getDefaultState()).canTouch(context)) {
|
if (block instanceof Gas) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
return this == NORMAL && (
|
return this == DENSE && (
|
||||||
block instanceof TorchBlock
|
block instanceof TorchBlock
|
||||||
|| block instanceof BedBlock
|
|| block instanceof BedBlock
|
||||||
|| block instanceof ChestBlock);
|
|| block instanceof ChestBlock
|
||||||
|
|| block instanceof AbstractRailBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -0,0 +1,45 @@
|
||||||
|
package com.minelittlepony.unicopia.gas;
|
||||||
|
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockState;
|
||||||
|
import net.minecraft.item.ItemPlacementContext;
|
||||||
|
import net.minecraft.state.StateManager;
|
||||||
|
import net.minecraft.state.property.Properties;
|
||||||
|
import net.minecraft.util.BlockRotation;
|
||||||
|
import net.minecraft.util.math.Direction;
|
||||||
|
|
||||||
|
public class PillarCloudBlock extends CloudBlock {
|
||||||
|
|
||||||
|
public PillarCloudBlock(GasState variant) {
|
||||||
|
super(variant);
|
||||||
|
setDefaultState(getDefaultState().with(Properties.AXIS, Direction.Axis.Y));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState rotate(BlockState state, BlockRotation rotation) {
|
||||||
|
switch(rotation) {
|
||||||
|
case COUNTERCLOCKWISE_90:
|
||||||
|
case CLOCKWISE_90:
|
||||||
|
switch(state.get(Properties.AXIS)) {
|
||||||
|
case X:
|
||||||
|
return state.with(Properties.AXIS, Direction.Axis.Z);
|
||||||
|
case Z:
|
||||||
|
return state.with(Properties.AXIS, Direction.Axis.X);
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
return state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void appendProperties(StateManager.Builder<Block, BlockState> builder) {
|
||||||
|
builder.add(Properties.AXIS);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getPlacementState(ItemPlacementContext ctx) {
|
||||||
|
return getDefaultState().with(Properties.AXIS, ctx.getSide().getAxis());
|
||||||
|
}
|
||||||
|
}
|
|
@ -49,6 +49,7 @@ public interface UItems {
|
||||||
Item CLOUD_BLOCK = register("cloud_block", new PredicatedBlockItem(UBlocks.CLOUD_BLOCK, new Settings().group(ItemGroup.MATERIALS), PLAYER_PEGASUS));
|
Item CLOUD_BLOCK = register("cloud_block", new PredicatedBlockItem(UBlocks.CLOUD_BLOCK, new Settings().group(ItemGroup.MATERIALS), PLAYER_PEGASUS));
|
||||||
Item ENCHANTED_CLOUD_BLOCK = register("enchanted_cloud_block", new PredicatedBlockItem(UBlocks.ENCHANTED_CLOUD_BLOCK, new Settings().group(ItemGroup.MATERIALS), PLAYER_PEGASUS));
|
Item ENCHANTED_CLOUD_BLOCK = register("enchanted_cloud_block", new PredicatedBlockItem(UBlocks.ENCHANTED_CLOUD_BLOCK, new Settings().group(ItemGroup.MATERIALS), PLAYER_PEGASUS));
|
||||||
Item DENSE_CLOUD_BLOCK = register("dense_cloud_block", new PredicatedBlockItem(UBlocks.DENSE_CLOUD_BLOCK, new Settings().group(ItemGroup.MATERIALS), PLAYER_PEGASUS));
|
Item DENSE_CLOUD_BLOCK = register("dense_cloud_block", new PredicatedBlockItem(UBlocks.DENSE_CLOUD_BLOCK, new Settings().group(ItemGroup.MATERIALS), PLAYER_PEGASUS));
|
||||||
|
Item DENSE_CLOUD_PILLAR = register("dense_cloud_pillar", new PredicatedBlockItem(UBlocks.DENSE_CLOUD_PILLAR, new Settings().group(ItemGroup.MATERIALS), PLAYER_PEGASUS));
|
||||||
|
|
||||||
Item CLOUD_STAIRS = register("cloud_stairs", new PredicatedBlockItem(UBlocks.CLOUD_STAIRS, new Settings().group(ItemGroup.BUILDING_BLOCKS), PLAYER_PEGASUS));
|
Item CLOUD_STAIRS = register("cloud_stairs", new PredicatedBlockItem(UBlocks.CLOUD_STAIRS, new Settings().group(ItemGroup.BUILDING_BLOCKS), PLAYER_PEGASUS));
|
||||||
Item CLOUD_FENCE = register("cloud_fence", new PredicatedBlockItem(UBlocks.CLOUD_FENCE, new Settings().group(ItemGroup.DECORATIONS), PLAYER_PEGASUS));
|
Item CLOUD_FENCE = register("cloud_fence", new PredicatedBlockItem(UBlocks.CLOUD_FENCE, new Settings().group(ItemGroup.DECORATIONS), PLAYER_PEGASUS));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
{
|
{
|
||||||
"variants": {
|
"variants": {
|
||||||
"": { "model": "unicopia:block/dense_cloud_block" }
|
"": { "model": "unicopia:block/dense_cloud_block" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"variants": {
|
||||||
|
"axis=y": { "model": "unicopia:block/dense_cloud_pillar" },
|
||||||
|
"axis=z": { "model": "unicopia:block/dense_cloud_pillar", "x": 90 },
|
||||||
|
"axis=x": { "model": "unicopia:block/dense_cloud_pillar", "x": 90, "y": 90 }
|
||||||
|
}
|
||||||
|
}
|
|
@ -3,6 +3,8 @@
|
||||||
"block.unicopia.dense_cloud_block": "Dense Cloud",
|
"block.unicopia.dense_cloud_block": "Dense Cloud",
|
||||||
"block.unicopia.enchanted_cloud_block": "Enchanted Cloud",
|
"block.unicopia.enchanted_cloud_block": "Enchanted Cloud",
|
||||||
|
|
||||||
|
"block.unicopia.dense_cloud_pillar": "Dense Cloud Pillar",
|
||||||
|
|
||||||
"block.unicopia.cloud_slab": "Cloud Slab",
|
"block.unicopia.cloud_slab": "Cloud Slab",
|
||||||
"block.unicopia.dense_cloud_slab": "Dense Cloud Slab",
|
"block.unicopia.dense_cloud_slab": "Dense Cloud Slab",
|
||||||
"block.unicopia.enchanted_cloud_slab": "Enchanted Cloud Slab",
|
"block.unicopia.enchanted_cloud_slab": "Enchanted Cloud Slab",
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
{
|
{
|
||||||
"parent": "block/cube_column",
|
"parent": "block/cube_all",
|
||||||
"textures": {
|
"textures": {
|
||||||
"end": "unicopia:blocks/dense_cloud_block_top",
|
"all": "unicopia:blocks/dense_cloud_block"
|
||||||
"side": "unicopia:blocks/dense_cloud_block"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
{
|
||||||
|
"parent": "block/cube_column",
|
||||||
|
"textures": {
|
||||||
|
"end": "unicopia:blocks/dense_cloud_pillar",
|
||||||
|
"side": "unicopia:blocks/dense_cloud_pillar"
|
||||||
|
}
|
||||||
|
}
|
|
@ -2,7 +2,7 @@
|
||||||
"parent": "block/slab",
|
"parent": "block/slab",
|
||||||
"textures": {
|
"textures": {
|
||||||
"bottom": "unicopia:blocks/dense_cloud_block",
|
"bottom": "unicopia:blocks/dense_cloud_block",
|
||||||
"top": "unicopia:blocks/dense_cloud_block_top",
|
"top": "unicopia:blocks/dense_cloud_block",
|
||||||
"side": "unicopia:blocks/dense_cloud_block"
|
"side": "unicopia:blocks/dense_cloud_block"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"parent": "block/slab_top",
|
"parent": "block/slab_top",
|
||||||
"textures": {
|
"textures": {
|
||||||
"bottom": "unicopia:blocks/dense_cloud_block_top",
|
"bottom": "unicopia:blocks/dense_cloud_block",
|
||||||
"top": "unicopia:blocks/dense_cloud_block",
|
"top": "unicopia:blocks/dense_cloud_block",
|
||||||
"side": "unicopia:blocks/dense_cloud_block"
|
"side": "unicopia:blocks/dense_cloud_block"
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
{
|
||||||
|
"parent": "unicopia:block/dense_cloud_pillar",
|
||||||
|
"display": {
|
||||||
|
"thirdperson": {
|
||||||
|
"rotation": [ 10, -45, 170 ],
|
||||||
|
"translation": [ 0, 1.5, -2.75 ],
|
||||||
|
"scale": [ 0.375, 0.375, 0.375 ]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Binary file not shown.
Before Width: | Height: | Size: 3 KiB After Width: | Height: | Size: 2.9 KiB |
Binary file not shown.
Before Width: | Height: | Size: 2.9 KiB After Width: | Height: | Size: 3 KiB |
|
@ -0,0 +1,11 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:block",
|
||||||
|
"pools": [
|
||||||
|
{
|
||||||
|
"rolls": 1,
|
||||||
|
"entries": [
|
||||||
|
{ "type": "minecraft:item", "name": "unicopia:dense_cloud_pillar" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
|
@ -0,0 +1,14 @@
|
||||||
|
{
|
||||||
|
"type": "minecraft:crafting_shaped",
|
||||||
|
"pattern": [
|
||||||
|
"##",
|
||||||
|
"##",
|
||||||
|
"##"
|
||||||
|
],
|
||||||
|
"key": {
|
||||||
|
"#": [
|
||||||
|
{ "item": "unicopia:dense_cloud_block" }
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"result": { "item": "unicopia:dense_cloud_pillar" }
|
||||||
|
}
|
Loading…
Reference in a new issue