diff --git a/src/main/java/com/minelittlepony/unicopia/block/AbstractSlabBlock.java b/src/main/java/com/minelittlepony/unicopia/block/AbstractSlabBlock.java index 289927ca..b11f7bab 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/AbstractSlabBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/AbstractSlabBlock.java @@ -6,58 +6,61 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.SlabBlock; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.world.ServerWorld; import net.minecraft.util.math.BlockPos; import net.minecraft.world.BlockView; import net.minecraft.world.World; -public abstract class AbstractSlabBlock extends SlabBlock { +public abstract class AbstractSlabBlock extends SlabBlock { - protected final T modelBlock; protected final BlockState modelState; - @SuppressWarnings("unchecked") public AbstractSlabBlock(BlockState inherited, Block.Settings settings) { super(settings); modelState = inherited; - modelBlock = (T)inherited.getBlock(); } @Deprecated @Override 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 public boolean isAir(BlockState state) { - return modelBlock.isAir(state); + return modelState.isAir(); } @Override public void scheduledTick(BlockState state, ServerWorld world, BlockPos pos, Random rand) { - modelBlock.scheduledTick(state, world, pos, rand); + modelState.scheduledTick(world, pos, rand); } @Override 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 public void onEntityLand(BlockView w, Entity entity) { - modelBlock.onEntityLand(w, entity); + modelState.getBlock().onEntityLand(w, entity); } @Override public void onEntityCollision(BlockState state, World w, BlockPos pos, Entity entity) { - modelBlock.onEntityCollision(state, w, pos, entity); + modelState.onEntityCollision(w, pos, entity); } @Deprecated @Override public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView worldIn, BlockPos pos) { - return modelBlock.calcBlockBreakingDelta(state, player, worldIn, pos); + return modelState.calcBlockBreakingDelta(player, worldIn, pos); } } diff --git a/src/main/java/com/minelittlepony/unicopia/block/AbstractStairsBlock.java b/src/main/java/com/minelittlepony/unicopia/block/AbstractStairsBlock.java index 054ca87e..d38731cb 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/AbstractStairsBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/block/AbstractStairsBlock.java @@ -1,39 +1,41 @@ package com.minelittlepony.unicopia.block; -import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.block.StairsBlock; import net.minecraft.entity.Entity; +import net.minecraft.entity.EntityType; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.util.math.BlockPos; import net.minecraft.world.BlockView; import net.minecraft.world.World; -public abstract class AbstractStairsBlock extends StairsBlock { +public abstract class AbstractStairsBlock extends StairsBlock { - protected final T baseBlock; protected final BlockState baseBlockState; - @SuppressWarnings("unchecked") public AbstractStairsBlock(BlockState inherited, Settings settings) { super(inherited, settings); - baseBlock = (T)inherited.getBlock(); baseBlockState = inherited; } @Override - public boolean canSuffocate(BlockState state, BlockView world, BlockPos pos) { - return baseBlock.canSuffocate(baseBlockState, world, pos); + public boolean isTranslucent(BlockState state, BlockView world, BlockPos 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 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 public void onEntityLand(BlockView w, Entity entity) { - baseBlock.onEntityLand(w, entity); + baseBlockState.getBlock().onEntityLand(w, entity); } @Override @@ -41,14 +43,9 @@ public abstract class AbstractStairsBlock extends StairsBlock { baseBlockState.onEntityCollision(w, pos, entity); } - @Override - public void onSteppedOn(World w, BlockPos pos, Entity entity) { - baseBlock.onSteppedOn(w, pos, entity); - } - @Deprecated @Override public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) { - return baseBlock.calcBlockBreakingDelta(state, player, world, pos); + return baseBlockState.calcBlockBreakingDelta(player, world, pos); } } diff --git a/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java b/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java index b65f371c..d826cc82 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java +++ b/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java @@ -11,6 +11,7 @@ import com.minelittlepony.unicopia.gas.CloudSoilBlock; import com.minelittlepony.unicopia.gas.CloudStairsBlock; import com.minelittlepony.unicopia.gas.CoverableCloudBlock; import com.minelittlepony.unicopia.gas.GasState; +import com.minelittlepony.unicopia.gas.PillarCloudBlock; import com.minelittlepony.unicopia.item.UItems; import com.minelittlepony.unicopia.structure.CustomSaplingGenerator; @@ -32,12 +33,13 @@ public interface UBlocks { CloudBlock CLOUD_BLOCK = register("cloud_block", new CloudSoilBlock(GasState.NORMAL)); 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_PILLAR = register("dense_cloud_pillar", new PillarCloudBlock(GasState.DENSE)); - CloudStairsBlock 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 CLOUD_SLAB = register("cloud_slab", new CloudSlabBlock<>(CLOUD_BLOCK.getDefaultState(), GasState.NORMAL.configure().build())); - CloudSlabBlock ENCHANTED_CLOUD_SLAB = register("enchanted_cloud_slab", new CloudSlabBlock<>(ENCHANTED_CLOUD_BLOCK.getDefaultState(), GasState.ENCHANTED.configure().build())); - CloudSlabBlock DENSE_CLOUD_SLAB = register("dense_cloud_slab", new CloudSlabBlock<>(DENSE_CLOUD_BLOCK.getDefaultState(), GasState.DENSE.configure().build())); + CloudSlabBlock CLOUD_SLAB = register("cloud_slab", new CloudSlabBlock(CLOUD_BLOCK.getDefaultState(), GasState.NORMAL.configure().build())); + CloudSlabBlock ENCHANTED_CLOUD_SLAB = register("enchanted_cloud_slab", new CloudSlabBlock(ENCHANTED_CLOUD_BLOCK.getDefaultState(), GasState.ENCHANTED.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) .sounds(BlockSoundGroup.GLASS) diff --git a/src/main/java/com/minelittlepony/unicopia/client/URenderers.java b/src/main/java/com/minelittlepony/unicopia/client/URenderers.java index 43b5f017..7d17851b 100644 --- a/src/main/java/com/minelittlepony/unicopia/client/URenderers.java +++ b/src/main/java/com/minelittlepony/unicopia/client/URenderers.java @@ -46,8 +46,7 @@ public interface URenderers { UBlocks.BAKERY_DOOR, UBlocks.LIBRARY_DOOR, UBlocks.MISTED_GLASS_DOOR, UBlocks.DIAMOND_DOOR); BlockRenderLayerMap.INSTANCE.putBlocks(RenderLayer.getTranslucent(), UBlocks.CLOUD_ANVIL, UBlocks.CLOUD_FARMLAND, - UBlocks.CLOUD_BLOCK, UBlocks.CLOUD_SLAB, UBlocks.CLOUD_STAIRS, UBlocks.CLOUD_FENCE, - UBlocks.DENSE_CLOUD_BLOCK, UBlocks.DENSE_CLOUD_SLAB, + UBlocks.CLOUD_BLOCK, UBlocks.CLOUD_SLAB, UBlocks.CLOUD_STAIRS, UBlocks.ENCHANTED_CLOUD_BLOCK, UBlocks.ENCHANTED_CLOUD_SLAB, UBlocks.SLIME_DROP, UBlocks.SLIME_LAYER diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudAnvilBlock.java b/src/main/java/com/minelittlepony/unicopia/gas/CloudAnvilBlock.java index 6bec2a60..03424af5 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudAnvilBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/gas/CloudAnvilBlock.java @@ -79,33 +79,27 @@ public class CloudAnvilBlock extends AnvilBlock implements Gas { @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { - CloudInteractionContext ctx = (CloudInteractionContext)context; - - if (!getGasState(state).canPlace(ctx)) { - return VoxelShapes.empty(); + if (getGasState(state).canPlace((CloudInteractionContext)context)) { + return super.getOutlineShape(state, view, pos, context); } - - return super.getOutlineShape(state, view, pos, context); + return VoxelShapes.empty(); } @Override public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { - CloudInteractionContext ctx = (CloudInteractionContext)context; - - if (!getGasState(state).canTouch(ctx)) { - return VoxelShapes.empty(); + if (getGasState(state).canTouch((CloudInteractionContext)context)) { + return super.getCollisionShape(state, view, pos, context); } - - return super.getCollisionShape(state, view, pos, context); + return VoxelShapes.empty(); } @Deprecated @Override public float calcBlockBreakingDelta(BlockState state, PlayerEntity player, BlockView world, BlockPos pos) { - if (!GasState.NORMAL.canTouch(player)) { - return -1; + if (GasState.NORMAL.canTouch(player)) { + return super.calcBlockBreakingDelta(state, player, world, pos); } - return super.calcBlockBreakingDelta(state, player, world, pos); + return -1; } diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudBlock.java b/src/main/java/com/minelittlepony/unicopia/gas/CloudBlock.java index 56e76771..054bb726 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/gas/CloudBlock.java @@ -9,6 +9,7 @@ import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityContext; +import net.minecraft.entity.EntityType; import net.minecraft.entity.player.PlayerEntity; import net.minecraft.server.world.ServerWorld; 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.math.BlockPos; import net.minecraft.world.BlockView; -import net.minecraft.world.EmptyBlockView; import net.minecraft.world.World; public class CloudBlock extends Block implements Gas { @@ -31,31 +31,45 @@ public class CloudBlock extends Block implements Gas { 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 public boolean isTranslucent(BlockState state, BlockView world, BlockPos pos) { 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 public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { - CloudInteractionContext ctx = (CloudInteractionContext)context; - - if (!getGasState(state).canPlace(ctx)) { - return VoxelShapes.empty(); + if (getGasState(state).canPlace((CloudInteractionContext)context)) { + return VoxelShapes.fullCube(); } - - return VoxelShapes.fullCube(); + return VoxelShapes.empty(); } @Override public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { - CloudInteractionContext ctx = (CloudInteractionContext)context; - - if (!getGasState(state).canTouch(ctx)) { - return VoxelShapes.empty(); + if (getGasState(state).canTouch((CloudInteractionContext)context)) { + return collidable ? VoxelShapes.fullCube() : VoxelShapes.empty(); } - - return collidable ? VoxelShapes.fullCube() : VoxelShapes.empty(); + return VoxelShapes.empty(); } @Override @@ -75,14 +89,7 @@ public class CloudBlock extends Block implements Gas { @Override @Environment(EnvType.CLIENT) public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) { - if (beside.getBlock() instanceof Gas && ((Gas)beside.getBlock()).getGasState(beside) == getGasState(state)) { - 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); + return isFaceCoverd(state, beside, face); } @Override @@ -114,9 +121,4 @@ public class CloudBlock extends Block implements Gas { } return -1; } - - @Override - public GasState getGasState(BlockState blockState) { - return variant; - } } diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudSlabBlock.java b/src/main/java/com/minelittlepony/unicopia/gas/CloudSlabBlock.java index c596a503..573c93ae 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudSlabBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/gas/CloudSlabBlock.java @@ -4,7 +4,6 @@ import com.minelittlepony.unicopia.block.AbstractSlabBlock; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.EntityContext; 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.VoxelShapes; import net.minecraft.world.BlockView; -import net.minecraft.world.EmptyBlockView; -public class CloudSlabBlock extends AbstractSlabBlock implements Gas { +public class CloudSlabBlock extends AbstractSlabBlock implements Gas { public CloudSlabBlock(BlockState inherited, Settings settings) { super(inherited, settings); @@ -22,43 +20,28 @@ public class CloudSlabBlock extends AbstractSlabBlock @Override public GasState getGasState(BlockState blockState) { - return modelBlock.getGasState(blockState); + return ((Gas)modelState.getBlock()).getGasState(blockState); } @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { - CloudInteractionContext ctx = (CloudInteractionContext)context; - - if (!getGasState(state).canTouch(ctx)) { - return VoxelShapes.empty(); + if (getGasState(state).canPlace((CloudInteractionContext)context)) { + return super.getOutlineShape(state, view, pos, context); } - - return super.getOutlineShape(state, view, pos, context); + return VoxelShapes.empty(); } @Override public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { - CloudInteractionContext ctx = (CloudInteractionContext)context; - - if (!getGasState(state).canPlace(ctx)) { - return VoxelShapes.empty(); + if (getGasState(state).canTouch((CloudInteractionContext)context)) { + return super.getCollisionShape(state, view, pos, context); } - - return super.getCollisionShape(state, view, pos, context); + return VoxelShapes.empty(); } @Override @Environment(EnvType.CLIENT) public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) { - if (beside.getBlock() instanceof Gas) { - 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); + return isFaceCoverd(state, beside, face); } - - } diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudStairsBlock.java b/src/main/java/com/minelittlepony/unicopia/gas/CloudStairsBlock.java index 3bd8b113..bc22dfdb 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudStairsBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/gas/CloudStairsBlock.java @@ -4,7 +4,6 @@ import com.minelittlepony.unicopia.block.AbstractStairsBlock; import net.fabricmc.api.EnvType; import net.fabricmc.api.Environment; -import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.EntityContext; 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.VoxelShapes; import net.minecraft.world.BlockView; -import net.minecraft.world.EmptyBlockView; -public class CloudStairsBlock extends AbstractStairsBlock implements Gas { +public class CloudStairsBlock extends AbstractStairsBlock implements Gas { public CloudStairsBlock(BlockState inherited, Settings settings) { super(inherited, settings); @@ -22,41 +20,28 @@ public class CloudStairsBlock extends AbstractStairsBlock @Override public GasState getGasState(BlockState state) { - return baseBlock.getGasState(baseBlockState); + return ((Gas)baseBlockState.getBlock()).getGasState(baseBlockState); } @Override public VoxelShape getOutlineShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { - CloudInteractionContext ctx = (CloudInteractionContext)context; - - if (!getGasState(state).canPlace(ctx)) { - return VoxelShapes.empty(); + if (getGasState(state).canPlace((CloudInteractionContext)context)) { + return super.getOutlineShape(state, view, pos, context); } - - return super.getOutlineShape(state, view, pos, context); + return VoxelShapes.empty(); } @Override public VoxelShape getCollisionShape(BlockState state, BlockView view, BlockPos pos, EntityContext context) { - CloudInteractionContext ctx = (CloudInteractionContext)context; - - if (!getGasState(state).canTouch(ctx)) { - return VoxelShapes.empty(); + if (getGasState(state).canTouch((CloudInteractionContext)context)) { + return super.getCollisionShape(state, view, pos, context); } - - return super.getCollisionShape(state, view, pos, context); + return VoxelShapes.empty(); } @Override @Environment(EnvType.CLIENT) public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) { - if (beside.getBlock() instanceof Gas) { - 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); + return isFaceCoverd(state, beside, face); } } \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/unicopia/gas/Gas.java b/src/main/java/com/minelittlepony/unicopia/gas/Gas.java index a1f609b6..8c0f76c2 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/Gas.java +++ b/src/main/java/com/minelittlepony/unicopia/gas/Gas.java @@ -2,7 +2,11 @@ package com.minelittlepony.unicopia.gas; import net.minecraft.block.BlockState; 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.shape.VoxelShapes; +import net.minecraft.world.EmptyBlockView; public interface Gas { @@ -17,6 +21,14 @@ public interface Gas { 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) { double y = entity.getVelocity().y; diff --git a/src/main/java/com/minelittlepony/unicopia/gas/GasState.java b/src/main/java/com/minelittlepony/unicopia/gas/GasState.java index b95c46ff..87081674 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/GasState.java +++ b/src/main/java/com/minelittlepony/unicopia/gas/GasState.java @@ -3,6 +3,7 @@ package com.minelittlepony.unicopia.gas; import com.minelittlepony.unicopia.EquinePredicates; import com.minelittlepony.unicopia.block.UMaterials; import net.fabricmc.fabric.api.block.FabricBlockSettings; +import net.minecraft.block.AbstractRailBlock; import net.minecraft.block.BedBlock; import net.minecraft.block.Block; import net.minecraft.block.ChestBlock; @@ -58,14 +59,15 @@ public enum GasState { if (main.getItem() instanceof BlockItem) { Block block = ((BlockItem)main.getItem()).getBlock(); - if (block instanceof Gas && ((Gas)block).getGasState(block.getDefaultState()).canTouch(context)) { + if (block instanceof Gas) { return true; } - return this == NORMAL && ( + return this == DENSE && ( block instanceof TorchBlock || block instanceof BedBlock - || block instanceof ChestBlock); + || block instanceof ChestBlock + || block instanceof AbstractRailBlock); } return true; diff --git a/src/main/java/com/minelittlepony/unicopia/gas/PillarCloudBlock.java b/src/main/java/com/minelittlepony/unicopia/gas/PillarCloudBlock.java new file mode 100644 index 00000000..bdaae6bb --- /dev/null +++ b/src/main/java/com/minelittlepony/unicopia/gas/PillarCloudBlock.java @@ -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 builder) { + builder.add(Properties.AXIS); + } + + @Override + public BlockState getPlacementState(ItemPlacementContext ctx) { + return getDefaultState().with(Properties.AXIS, ctx.getSide().getAxis()); + } +} diff --git a/src/main/java/com/minelittlepony/unicopia/item/UItems.java b/src/main/java/com/minelittlepony/unicopia/item/UItems.java index d5dd8ab4..7a3a7efe 100644 --- a/src/main/java/com/minelittlepony/unicopia/item/UItems.java +++ b/src/main/java/com/minelittlepony/unicopia/item/UItems.java @@ -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 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_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_FENCE = register("cloud_fence", new PredicatedBlockItem(UBlocks.CLOUD_FENCE, new Settings().group(ItemGroup.DECORATIONS), PLAYER_PEGASUS)); diff --git a/src/main/resources/assets/unicopia/blockstates/dense_cloud_block.json b/src/main/resources/assets/unicopia/blockstates/dense_cloud_block.json index 1d77f3cf..a7bf1bde 100644 --- a/src/main/resources/assets/unicopia/blockstates/dense_cloud_block.json +++ b/src/main/resources/assets/unicopia/blockstates/dense_cloud_block.json @@ -1,5 +1,5 @@ { "variants": { - "": { "model": "unicopia:block/dense_cloud_block" } + "": { "model": "unicopia:block/dense_cloud_block" } } } diff --git a/src/main/resources/assets/unicopia/blockstates/dense_cloud_pillar.json b/src/main/resources/assets/unicopia/blockstates/dense_cloud_pillar.json new file mode 100644 index 00000000..9a802e08 --- /dev/null +++ b/src/main/resources/assets/unicopia/blockstates/dense_cloud_pillar.json @@ -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 } + } +} diff --git a/src/main/resources/assets/unicopia/lang/en_us.json b/src/main/resources/assets/unicopia/lang/en_us.json index 19cd7e48..bd1a0f7b 100644 --- a/src/main/resources/assets/unicopia/lang/en_us.json +++ b/src/main/resources/assets/unicopia/lang/en_us.json @@ -3,6 +3,8 @@ "block.unicopia.dense_cloud_block": "Dense Cloud", "block.unicopia.enchanted_cloud_block": "Enchanted Cloud", + "block.unicopia.dense_cloud_pillar": "Dense Cloud Pillar", + "block.unicopia.cloud_slab": "Cloud Slab", "block.unicopia.dense_cloud_slab": "Dense Cloud Slab", "block.unicopia.enchanted_cloud_slab": "Enchanted Cloud Slab", diff --git a/src/main/resources/assets/unicopia/models/block/dense_cloud_block.json b/src/main/resources/assets/unicopia/models/block/dense_cloud_block.json index 2defdad6..248cb21d 100644 --- a/src/main/resources/assets/unicopia/models/block/dense_cloud_block.json +++ b/src/main/resources/assets/unicopia/models/block/dense_cloud_block.json @@ -1,7 +1,6 @@ { - "parent": "block/cube_column", + "parent": "block/cube_all", "textures": { - "end": "unicopia:blocks/dense_cloud_block_top", - "side": "unicopia:blocks/dense_cloud_block" + "all": "unicopia:blocks/dense_cloud_block" } } diff --git a/src/main/resources/assets/unicopia/models/block/dense_cloud_pillar.json b/src/main/resources/assets/unicopia/models/block/dense_cloud_pillar.json new file mode 100644 index 00000000..489e74ba --- /dev/null +++ b/src/main/resources/assets/unicopia/models/block/dense_cloud_pillar.json @@ -0,0 +1,7 @@ +{ + "parent": "block/cube_column", + "textures": { + "end": "unicopia:blocks/dense_cloud_pillar", + "side": "unicopia:blocks/dense_cloud_pillar" + } +} diff --git a/src/main/resources/assets/unicopia/models/block/dense_cloud_slab.json b/src/main/resources/assets/unicopia/models/block/dense_cloud_slab.json index 5c631906..cc1cd112 100644 --- a/src/main/resources/assets/unicopia/models/block/dense_cloud_slab.json +++ b/src/main/resources/assets/unicopia/models/block/dense_cloud_slab.json @@ -2,7 +2,7 @@ "parent": "block/slab", "textures": { "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" } } diff --git a/src/main/resources/assets/unicopia/models/block/dense_cloud_slab_top.json b/src/main/resources/assets/unicopia/models/block/dense_cloud_slab_top.json index 2d117e73..2ab860b2 100644 --- a/src/main/resources/assets/unicopia/models/block/dense_cloud_slab_top.json +++ b/src/main/resources/assets/unicopia/models/block/dense_cloud_slab_top.json @@ -1,7 +1,7 @@ { "parent": "block/slab_top", "textures": { - "bottom": "unicopia:blocks/dense_cloud_block_top", + "bottom": "unicopia:blocks/dense_cloud_block", "top": "unicopia:blocks/dense_cloud_block", "side": "unicopia:blocks/dense_cloud_block" } diff --git a/src/main/resources/assets/unicopia/models/item/dense_cloud_pillar.json b/src/main/resources/assets/unicopia/models/item/dense_cloud_pillar.json new file mode 100644 index 00000000..3a126ba4 --- /dev/null +++ b/src/main/resources/assets/unicopia/models/item/dense_cloud_pillar.json @@ -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 ] + } + } +} diff --git a/src/main/resources/assets/unicopia/textures/blocks/dense_cloud_block.png b/src/main/resources/assets/unicopia/textures/blocks/dense_cloud_block.png index 07937b38..1393e598 100644 Binary files a/src/main/resources/assets/unicopia/textures/blocks/dense_cloud_block.png and b/src/main/resources/assets/unicopia/textures/blocks/dense_cloud_block.png differ diff --git a/src/main/resources/assets/unicopia/textures/blocks/dense_cloud_block_top.png b/src/main/resources/assets/unicopia/textures/blocks/dense_cloud_pillar.png similarity index 88% rename from src/main/resources/assets/unicopia/textures/blocks/dense_cloud_block_top.png rename to src/main/resources/assets/unicopia/textures/blocks/dense_cloud_pillar.png index 1393e598..07937b38 100644 Binary files a/src/main/resources/assets/unicopia/textures/blocks/dense_cloud_block_top.png and b/src/main/resources/assets/unicopia/textures/blocks/dense_cloud_pillar.png differ diff --git a/src/main/resources/data/unicopia/loot_tables/blocks/dense_cloud_pillar.json b/src/main/resources/data/unicopia/loot_tables/blocks/dense_cloud_pillar.json new file mode 100644 index 00000000..4c3bb1a4 --- /dev/null +++ b/src/main/resources/data/unicopia/loot_tables/blocks/dense_cloud_pillar.json @@ -0,0 +1,11 @@ +{ + "type": "minecraft:block", + "pools": [ + { + "rolls": 1, + "entries": [ + { "type": "minecraft:item", "name": "unicopia:dense_cloud_pillar" } + ] + } + ] +} diff --git a/src/main/resources/data/unicopia/recipes/dense_cloud_pillar.json b/src/main/resources/data/unicopia/recipes/dense_cloud_pillar.json new file mode 100644 index 00000000..66300403 --- /dev/null +++ b/src/main/resources/data/unicopia/recipes/dense_cloud_pillar.json @@ -0,0 +1,14 @@ +{ + "type": "minecraft:crafting_shaped", + "pattern": [ + "##", + "##", + "##" + ], + "key": { + "#": [ + { "item": "unicopia:dense_cloud_block" } + ] + }, + "result": { "item": "unicopia:dense_cloud_pillar" } +}