From 6329d5bd59c0efed894fe61f90b9cda79a8877f0 Mon Sep 17 00:00:00 2001 From: Sollace Date: Thu, 7 Feb 2019 16:31:15 +0200 Subject: [PATCH] Fixed cloud fences and banisters connecting to each other --- .../unicopia/block/BlockCloudBanister.java | 16 ++++++++++++++++ .../unicopia/block/BlockCloudFence.java | 8 ++++++++ 2 files changed, 24 insertions(+) diff --git a/src/main/java/com/minelittlepony/unicopia/block/BlockCloudBanister.java b/src/main/java/com/minelittlepony/unicopia/block/BlockCloudBanister.java index e9e0f0e9..0dfc7228 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/BlockCloudBanister.java +++ b/src/main/java/com/minelittlepony/unicopia/block/BlockCloudBanister.java @@ -52,6 +52,22 @@ public class BlockCloudBanister extends BlockCloudFence { return BlockRenderLayer.SOLID; } + @Override + public boolean canConnectTo(IBlockAccess world, BlockPos pos, EnumFacing facing) { + IBlockState myState = world.getBlockState(pos); + + return myState.getBlock() instanceof BlockCloudBanister + && super.canConnectTo(world, pos, facing); + } + + @Override + public boolean canBeConnectedTo(IBlockAccess world, BlockPos pos, EnumFacing facing) { + IBlockState state = world.getBlockState(pos.offset(facing)); + + return state.getBlock() instanceof BlockCloudBanister + && state.getMaterial() == world.getBlockState(pos).getMaterial(); + } + @Deprecated @Override public void addCollisionBoxToList(IBlockState state, World world, BlockPos pos, AxisAlignedBB entityBox, List collidingBoxes, @Nullable Entity entity, boolean isActualState) { diff --git a/src/main/java/com/minelittlepony/unicopia/block/BlockCloudFence.java b/src/main/java/com/minelittlepony/unicopia/block/BlockCloudFence.java index 5f5cc97d..598ac570 100644 --- a/src/main/java/com/minelittlepony/unicopia/block/BlockCloudFence.java +++ b/src/main/java/com/minelittlepony/unicopia/block/BlockCloudFence.java @@ -13,6 +13,7 @@ import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.util.BlockRenderLayer; +import net.minecraft.util.EnumFacing; import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.RayTraceResult; @@ -83,6 +84,13 @@ public class BlockCloudFence extends BlockFence implements ICloudBlock { } } + public boolean canConnectTo(IBlockAccess world, BlockPos pos, EnumFacing facing) { + IBlockState myState = world.getBlockState(pos); + + return !(myState.getBlock() instanceof BlockCloudBanister) + && super.canConnectTo(world, pos, facing); + } + @Override public void onEntityCollision(World w, BlockPos pos, IBlockState state, Entity entity) { if (!applyBouncyness(state, entity)) {