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
This commit is contained in:
simibubi 2021-03-12 18:44:05 +01:00
parent af9ed3e44b
commit 678ddfa764
4 changed files with 56 additions and 13 deletions

View File

@ -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;
}
}

View File

@ -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);
}

View File

@ -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;

View File

@ -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<BasinTileEntity>, 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<BasinTileEntity>, 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;