From 678ddfa7642c1e819b76ff9633a88f408395fb4e Mon Sep 17 00:00:00 2001 From: simibubi <31564874+simibubi@users.noreply.github.com> Date: Fri, 12 Mar 2021 18:44:05 +0100 Subject: [PATCH] Spoutput blockage - Fixed basin auto-output not working on stopped belts - Basin auto-output can now share a space with funnels - Linear chassis no longer allow sticky sides facing a directly attached linear chassis of the same type --- .../chassis/AbstractChassisBlock.java | 9 ++++- .../chassis/LinearChassisBlock.java | 17 ++++++++++ .../glue/SuperGlueEntity.java | 9 +++++ .../contraptions/processing/BasinBlock.java | 34 ++++++++++++------- 4 files changed, 56 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/AbstractChassisBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/AbstractChassisBlock.java index 68b053ab6..21a847143 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/AbstractChassisBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/AbstractChassisBlock.java @@ -59,7 +59,7 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements if (isSlimeBall && state.get(affectedSide)) { for (Direction face : Iterate.directions) { BooleanProperty glueableSide = getGlueableSide(state, face); - if (glueableSide != null && !state.get(glueableSide)) { + if (glueableSide != null && !state.get(glueableSide) && glueAllowedOnSide(worldIn, pos, state, face)) { if (worldIn.isRemote) { Vec3d vec = hit.getHitVec(); worldIn.addParticle(ParticleTypes.ITEM_SLIME, vec.x, vec.y, vec.z, 0, 0, 0); @@ -78,6 +78,8 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements return ActionResultType.PASS; if (state.get(affectedSide) == isSlimeBall) return ActionResultType.PASS; + if (!glueAllowedOnSide(worldIn, pos, state, hit.getFace())) + return ActionResultType.PASS; if (worldIn.isRemote) { Vec3d vec = hit.getHitVec(); worldIn.addParticle(ParticleTypes.ITEM_SLIME, vec.x, vec.y, vec.z, 0, 0, 0); @@ -94,6 +96,7 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements if (rotation == Rotation.NONE) return state; + @SuppressWarnings("deprecation") BlockState rotated = super.rotate(state, rotation); for (Direction face : Iterate.directions) { BooleanProperty glueableSide = getGlueableSide(rotated, face); @@ -141,4 +144,8 @@ public abstract class AbstractChassisBlock extends RotatedPillarBlock implements public abstract BooleanProperty getGlueableSide(BlockState state, Direction face); + protected boolean glueAllowedOnSide(IBlockReader world, BlockPos pos, BlockState state, Direction side) { + return true; + } + } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/LinearChassisBlock.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/LinearChassisBlock.java index 7450247d2..fe1073432 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/LinearChassisBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/chassis/LinearChassisBlock.java @@ -14,7 +14,9 @@ import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; import net.minecraft.util.Direction.AxisDirection; import net.minecraft.util.math.BlockPos; +import net.minecraft.world.IBlockReader; import net.minecraft.world.ILightReader; +import net.minecraft.world.IWorld; public class LinearChassisBlock extends AbstractChassisBlock { @@ -50,6 +52,15 @@ public class LinearChassisBlock extends AbstractChassisBlock { } return super.getStateForPlacement(context); } + + @Override + public BlockState updatePostPlacement(BlockState state, Direction side, BlockState other, IWorld p_196271_4_, + BlockPos p_196271_5_, BlockPos p_196271_6_) { + BooleanProperty property = getGlueableSide(state, side); + if (property == null || !sameKind(state, other) || state.get(AXIS) != other.get(AXIS)) + return state; + return state.with(property, false); + } @Override public BooleanProperty getGlueableSide(BlockState state, Direction face) { @@ -58,6 +69,12 @@ public class LinearChassisBlock extends AbstractChassisBlock { return face.getAxisDirection() == AxisDirection.POSITIVE ? STICKY_TOP : STICKY_BOTTOM; } + @Override + protected boolean glueAllowedOnSide(IBlockReader world, BlockPos pos, BlockState state, Direction side) { + BlockState other = world.getBlockState(pos.offset(side)); + return !sameKind(other, state) || state.get(AXIS) != other.get(AXIS); + } + public static boolean isChassis(BlockState state) { return AllBlocks.LINEAR_CHASSIS.has(state) || AllBlocks.SECONDARY_LINEAR_CHASSIS.has(state); } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueEntity.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueEntity.java index c5a019872..21af0fd87 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/glue/SuperGlueEntity.java @@ -15,6 +15,7 @@ import com.simibubi.create.foundation.networking.AllPackets; import com.simibubi.create.foundation.utility.AnimationTickHolder; import com.simibubi.create.foundation.utility.BlockFace; import net.minecraft.block.BlockState; +import net.minecraft.block.Blocks; import net.minecraft.block.DirectionalBlock; import net.minecraft.client.Minecraft; import net.minecraft.client.entity.player.ClientPlayerEntity; @@ -186,6 +187,14 @@ public class SuperGlueEntity extends Entity implements IEntityAdditionalSpawnDat if (AllBlocks.STICKER.has(state)) return state.get(DirectionalBlock.FACING) == direction; + + if (state.getBlock() == Blocks.SLIME_BLOCK) + return true; + if (state.getBlock() == Blocks.field_226907_mc_) // honey block + return true; + + if (AllBlocks.CART_ASSEMBLER.has(state)) + return Direction.UP == direction; if (AllBlocks.GANTRY_CARRIAGE.has(state)) return state.get(DirectionalKineticBlock.FACING) == direction; diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinBlock.java b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinBlock.java index 2b2e32757..d11a5a6fc 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinBlock.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinBlock.java @@ -4,7 +4,9 @@ import com.simibubi.create.AllBlocks; import com.simibubi.create.AllShapes; import com.simibubi.create.AllTileEntities; import com.simibubi.create.content.contraptions.fluids.actors.GenericItemFilling; +import com.simibubi.create.content.contraptions.relays.belt.BeltTileEntity; import com.simibubi.create.content.contraptions.wrench.IWrenchable; +import com.simibubi.create.content.logistics.block.funnel.FunnelBlock; import com.simibubi.create.foundation.advancement.AllTriggers; import com.simibubi.create.foundation.block.ITE; import com.simibubi.create.foundation.fluid.FluidHelper; @@ -170,11 +172,9 @@ public class BasinBlock extends Block implements ITE, IWrenchab @Override public int getComparatorInputOverride(BlockState blockState, World worldIn, BlockPos pos) { - try { - return ItemHelper.calcRedstoneFromInventory(getTileEntity(worldIn, pos).inputInventory); - } catch (TileEntityException e) { - } - return 0; + return getTileEntityOptional(worldIn, pos).map(BasinTileEntity::getInputInventory) + .map(ItemHelper::calcRedstoneFromInventory) + .orElse(0); } @Override @@ -184,15 +184,25 @@ public class BasinBlock extends Block implements ITE, IWrenchab public static boolean canOutputTo(IBlockReader world, BlockPos basinPos, Direction direction) { BlockPos neighbour = basinPos.offset(direction); - if (!world.getBlockState(neighbour) - .getCollisionShape(world, neighbour) - .isEmpty()) - return false; + BlockPos output = neighbour.down(); + BlockState blockState = world.getBlockState(neighbour); + + if (FunnelBlock.isFunnel(blockState)) { + if (FunnelBlock.getFunnelFacing(blockState) == direction) + return false; + } else if (!blockState.getCollisionShape(world, neighbour) + .isEmpty()) { + return false; + } else { + TileEntity tileEntity = world.getTileEntity(output); + if (tileEntity instanceof BeltTileEntity) { + BeltTileEntity belt = (BeltTileEntity) tileEntity; + return belt.getSpeed() == 0 || belt.getMovementFacing() != direction.getOpposite(); + } + } - BlockPos offset = basinPos.down() - .offset(direction); DirectBeltInputBehaviour directBeltInputBehaviour = - TileEntityBehaviour.get(world, offset, DirectBeltInputBehaviour.TYPE); + TileEntityBehaviour.get(world, output, DirectBeltInputBehaviour.TYPE); if (directBeltInputBehaviour != null) return directBeltInputBehaviour.canInsertFromSide(direction); return false;