diff --git a/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java b/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java index e06ed7a6..1434772e 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java +++ b/src/main/java/com/minelittlepony/unicopia/block/UBlocks.java @@ -28,11 +28,11 @@ public interface UBlocks { CloudBlock ENCHANTED_CLOUD_BLOCK = register(new CloudBlock(CloudType.ENCHANTED), "enchanted_cloud_block"); CloudBlock DENSE_CLOUD_BLOCK = register(new CloudBlock(CloudType.DENSE), "dense_cloud_block"); - CloudStairsBlock CLOUD_STAIRS = register(new CloudStairsBlock<>(CLOUD_BLOCK.getDefaultState(), FabricBlockSettings.of(UMaterials.CLOUD).build()), "cloud_stairs"); + CloudStairsBlock CLOUD_STAIRS = register(new CloudStairsBlock<>(CLOUD_BLOCK.getDefaultState(), CloudType.NORMAL.configure().build()), "cloud_stairs"); - CloudSlabBlock CLOUD_SLAB = register(new CloudSlabBlock<>(CLOUD_BLOCK.getDefaultState(), UMaterials.CLOUD), "cloud_slab"); - CloudSlabBlock ENCHANTED_CLOUD_SLAB = register(new CloudSlabBlock<>(ENCHANTED_CLOUD_BLOCK.getDefaultState(), UMaterials.CLOUD), "enchanted_cloud_slab"); - CloudSlabBlock DENSE_CLOUD_SLAB = register(new CloudSlabBlock<>(ENCHANTED_CLOUD_BLOCK.getDefaultState(), UMaterials.CLOUD), "dense_cloud_slab"); + CloudSlabBlock CLOUD_SLAB = register(new CloudSlabBlock<>(CLOUD_BLOCK.getDefaultState(), CloudType.NORMAL.configure().build()), "cloud_slab"); + CloudSlabBlock ENCHANTED_CLOUD_SLAB = register(new CloudSlabBlock<>(ENCHANTED_CLOUD_BLOCK.getDefaultState(), CloudType.ENCHANTED.configure().build()), "enchanted_cloud_slab"); + CloudSlabBlock DENSE_CLOUD_SLAB = register(new CloudSlabBlock<>(ENCHANTED_CLOUD_BLOCK.getDefaultState(), CloudType.DENSE.configure().build()), "dense_cloud_slab"); CloudDoorBlock MISTED_GLASS_DOOR = register(new CloudDoorBlock(), "misted_glass_door"); DutchDoorBlock LIBRARY_DOOR = register(new DutchDoorBlock(FabricBlockSettings.of(Material.WOOD).sounds(BlockSoundGroup.WOOD).hardness(3).build()), "library_door"); diff --git a/src/main/java/com/minelittlepony/unicopia/block/UMaterials.java b/src/main/java/com/minelittlepony/unicopia/block/UMaterials.java index 86d561d1..114fbc3d 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/UMaterials.java +++ b/src/main/java/com/minelittlepony/unicopia/block/UMaterials.java @@ -4,6 +4,6 @@ import net.minecraft.block.Material; import net.minecraft.block.MaterialColor; public interface UMaterials { - Material CLOUD = new Material.Builder(MaterialColor.WHITE).build(); + Material CLOUD = new Material.Builder(MaterialColor.WHITE).allowsMovement().build(); Material HIVE = new Material.Builder(MaterialColor.NETHER).build(); } diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudBlock.java b/src/main/java/com/minelittlepony/unicopia/gas/CloudBlock.java index 44dc3b1e..a666f910 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/gas/CloudBlock.java @@ -7,6 +7,8 @@ import com.minelittlepony.unicopia.blockstate.StateMaps; import com.minelittlepony.unicopia.entity.player.Pony; import com.minelittlepony.unicopia.util.HoeUtil; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.block.Block; import net.minecraft.block.BlockState; import net.minecraft.entity.Entity; @@ -19,6 +21,7 @@ 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, HoeUtil.Tillable { @@ -76,13 +79,13 @@ public class CloudBlock extends Block implements Gas, HoeUtil.Tillable { } @Override + @Environment(EnvType.CLIENT) public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) { if (beside.getBlock() instanceof Gas) { - Gas cloud = ((Gas)beside.getBlock()); + VoxelShape myShape = state.getCollisionShape(EmptyBlockView.INSTANCE, BlockPos.ORIGIN); + VoxelShape otherShape = beside.getCollisionShape(EmptyBlockView.INSTANCE, BlockPos.ORIGIN); - if (cloud.getGasType(beside) == getGasType(state)) { - return true; - } + return VoxelShapes.isSideCovered(myShape, otherShape, face); } return super.isSideInvisible(state, beside, face); diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudSlabBlock.java b/src/main/java/com/minelittlepony/unicopia/gas/CloudSlabBlock.java index a3820cf7..031e604f 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudSlabBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/gas/CloudSlabBlock.java @@ -2,24 +2,22 @@ package com.minelittlepony.unicopia.gas; import com.minelittlepony.unicopia.block.AbstractSlabBlock; -import net.fabricmc.fabric.api.block.FabricBlockSettings; +import net.fabricmc.api.EnvType; +import net.fabricmc.api.Environment; import net.minecraft.block.Block; import net.minecraft.block.BlockState; -import net.minecraft.block.Material; -import net.minecraft.block.StairsBlock; -import net.minecraft.block.enums.SlabType; import net.minecraft.entity.EntityContext; -import net.minecraft.state.property.Properties; import net.minecraft.util.math.BlockPos; 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 CloudSlabBlock(BlockState inherited, Material material) { - super(inherited, FabricBlockSettings.of(material).build()); + public CloudSlabBlock(BlockState inherited, Settings settings) { + super(inherited, settings); } @Override @@ -50,46 +48,16 @@ public class CloudSlabBlock extends AbstractSlabBlock } @Override + @Environment(EnvType.CLIENT) public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) { - if (state.get(TYPE) == SlabType.DOUBLE) { - if (beside.getBlock() instanceof Gas) { - Gas cloud = ((Gas)beside.getBlock()); + if (beside.getBlock() instanceof Gas) { + VoxelShape myShape = state.getCollisionShape(EmptyBlockView.INSTANCE, BlockPos.ORIGIN); + VoxelShape otherShape = beside.getCollisionShape(EmptyBlockView.INSTANCE, BlockPos.ORIGIN); - if (cloud.getGasType(beside) == getGasType(state)) { - return true; - } - } - - return false; - } else { - if (beside.getBlock() instanceof Gas) { - Gas cloud = ((Gas)beside.getBlock()); - - if (cloud.getGasType(beside) == getGasType(state)) { - - SlabType half = state.get(TYPE); - - if (beside.getBlock() instanceof CloudStairsBlock) { - return beside.get(StairsBlock.HALF).ordinal() == state.get(TYPE).ordinal() - && beside.get(Properties.FACING) == face; - } - - if (face == Direction.DOWN) { - return half == SlabType.BOTTOM; - } - - if (face == Direction.UP) { - return half == SlabType.TOP; - } - - if (beside.getBlock() == this) { - return beside.get(TYPE) == state.get(TYPE); - } - } - } + return VoxelShapes.isSideCovered(myShape, otherShape, face); } - return false; + return super.isSideInvisible(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 e74edb85..dda03153 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudStairsBlock.java +++ b/src/main/java/com/minelittlepony/unicopia/gas/CloudStairsBlock.java @@ -2,17 +2,17 @@ package com.minelittlepony.unicopia.gas; 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.block.SlabBlock; -import net.minecraft.block.enums.BlockHalf; -import net.minecraft.block.enums.SlabType; import net.minecraft.entity.EntityContext; import net.minecraft.util.math.BlockPos; 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 { @@ -48,57 +48,15 @@ public class CloudStairsBlock extends AbstractStairsBlock } @Override + @Environment(EnvType.CLIENT) public boolean isSideInvisible(BlockState state, BlockState beside, Direction face) { if (beside.getBlock() instanceof Gas) { - Gas cloud = ((Gas)beside.getBlock()); + VoxelShape myShape = state.getCollisionShape(EmptyBlockView.INSTANCE, BlockPos.ORIGIN); + VoxelShape otherShape = beside.getCollisionShape(EmptyBlockView.INSTANCE, BlockPos.ORIGIN); - if (cloud.getGasType(beside) == getGasType(state)) { - Direction front = state.get(FACING); - BlockHalf half = state.get(HALF); - - VoxelShape shape = getOutlineShape(state, null, null, EntityContext.absent()); - - boolean sideIsBack = Block.isFaceFullSquare(shape, face); - boolean sideIsFront = Block.isFaceFullSquare(shape, face.getOpposite()); - boolean sideIsSide = !(sideIsBack || sideIsFront); - - if (beside.getBlock() == this) { - Direction bfront = beside.get(FACING); - BlockHalf bhalf = beside.get(HALF); - - if (face == Direction.UP || face == Direction.DOWN) { - return half != bhalf - && ( (face == Direction.UP && half == BlockHalf.TOP) - || (face == Direction.DOWN && half == BlockHalf.BOTTOM) - ); - } - - VoxelShape shapeBeside = getOutlineShape(beside, null, null, EntityContext.absent()); - - boolean bsideIsBack = Block.isFaceFullSquare(shapeBeside, face); - boolean bsideIsFront = Block.isFaceFullSquare(shapeBeside, face.getOpposite()); - boolean bsideIsSide = !(bsideIsBack || bsideIsFront); - - return sideIsBack - || (sideIsSide && bsideIsSide && front == bfront && half == bhalf); - } else if (beside.getBlock() instanceof CloudSlabBlock) { - SlabType bhalf = beside.get(SlabBlock.TYPE); - - if (face == Direction.UP || face == Direction.DOWN) { - return bhalf == SlabType.TOP && half == BlockHalf.BOTTOM; - } - - return bhalf == SlabType.TOP && half == BlockHalf.BOTTOM; - } else { - if (face == Direction.UP || face == Direction.DOWN) { - return half == BlockHalf.BOTTOM && face == Direction.DOWN; - } - } - - return front == face; - } + return VoxelShapes.isSideCovered(myShape, otherShape, face); } - return false; + return super.isSideInvisible(state, beside, face); } } \ No newline at end of file diff --git a/src/main/java/com/minelittlepony/unicopia/gas/CloudType.java b/src/main/java/com/minelittlepony/unicopia/gas/CloudType.java index cf4c892e..d4032194 100644 --- a/src/main/java/com/minelittlepony/unicopia/gas/CloudType.java +++ b/src/main/java/com/minelittlepony/unicopia/gas/CloudType.java @@ -11,13 +11,10 @@ public enum CloudType { ENCHANTED; public FabricBlockSettings configure() { - FabricBlockSettings settings = FabricBlockSettings.of(UMaterials.CLOUD) + return FabricBlockSettings.of(UMaterials.CLOUD) .strength(0.5F, 1) - .sounds(BlockSoundGroup.WOOL); - if (this != NORMAL ) { - settings.nonOpaque(); - } - return settings; + .sounds(BlockSoundGroup.WOOL) + .nonOpaque(); } public boolean isTranslucent() {