mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2025-01-03 19:06:27 +01:00
Fix contraption sticky block connectivity. Add support to PUSH_ONLY push reaction
This commit is contained in:
parent
d35bdab51a
commit
2c3a866494
3 changed files with 25 additions and 4 deletions
|
@ -227,6 +227,12 @@ public class BlockMovementTraits {
|
|||
if (state.getBlock() instanceof SailBlock)
|
||||
return facing.getAxis() == state.get(SailBlock.FACING)
|
||||
.getAxis();
|
||||
if (AllBlocks.PISTON_EXTENSION_POLE.has(state))
|
||||
return facing.getAxis() != state.get(BlockStateProperties.FACING)
|
||||
.getAxis();
|
||||
if (AllBlocks.MECHANICAL_PISTON_HEAD.has(state))
|
||||
return facing.getAxis() != state.get(BlockStateProperties.FACING)
|
||||
.getAxis();
|
||||
return isBrittle(state);
|
||||
}
|
||||
|
||||
|
|
|
@ -59,6 +59,7 @@ import net.minecraft.block.ChestBlock;
|
|||
import net.minecraft.block.DoorBlock;
|
||||
import net.minecraft.block.IWaterLoggable;
|
||||
import net.minecraft.block.PressurePlateBlock;
|
||||
import net.minecraft.block.material.PushReaction;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.fluid.Fluids;
|
||||
import net.minecraft.fluid.IFluidState;
|
||||
|
@ -240,7 +241,7 @@ public abstract class Contraption {
|
|||
fluidStorage.forEach((pos, mfs) -> mfs.tick(entity, pos, world.isRemote));
|
||||
}
|
||||
|
||||
protected boolean moveBlock(World world, BlockPos pos, Direction forcedDirection, List<BlockPos> frontier,
|
||||
protected boolean moveBlock(World world, BlockPos pos, @Nullable Direction forcedDirection, List<BlockPos> frontier,
|
||||
Set<BlockPos> visited) {
|
||||
visited.add(pos);
|
||||
frontier.remove(pos);
|
||||
|
@ -296,14 +297,13 @@ public abstract class Contraption {
|
|||
Map<Direction, SuperGlueEntity> superglue = SuperGlueHandler.gatherGlue(world, pos);
|
||||
|
||||
// Slime blocks and super glue drag adjacent blocks if possible
|
||||
boolean isStickyBlock = state.isStickyBlock();
|
||||
for (Direction offset : Iterate.directions) {
|
||||
BlockPos offsetPos = pos.offset(offset);
|
||||
BlockState blockState = world.getBlockState(offsetPos);
|
||||
if (isAnchoringBlockAt(offsetPos))
|
||||
continue;
|
||||
if (!movementAllowed(world, offsetPos)) {
|
||||
if (offset == forcedDirection && isStickyBlock)
|
||||
if (offset == forcedDirection)
|
||||
return false;
|
||||
continue;
|
||||
}
|
||||
|
@ -313,8 +313,20 @@ public abstract class Contraption {
|
|||
boolean blockAttachedTowardsFace =
|
||||
BlockMovementTraits.isBlockAttachedTowards(world, offsetPos, blockState, offset.getOpposite());
|
||||
boolean brittle = BlockMovementTraits.isBrittle(blockState);
|
||||
boolean canStick = !brittle && state.canStickTo(blockState) && blockState.canStickTo(state);
|
||||
if (canStick) {
|
||||
if (state.getPushReaction() == PushReaction.PUSH_ONLY || blockState.getPushReaction() == PushReaction.PUSH_ONLY) {
|
||||
canStick = false;
|
||||
}
|
||||
if (BlockMovementTraits.notSupportive(state, offset)) {
|
||||
canStick = false;
|
||||
}
|
||||
if (BlockMovementTraits.notSupportive(blockState, offset.getOpposite())) {
|
||||
canStick = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!wasVisited && ((isStickyBlock && !brittle) || blockAttachedTowardsFace || faceHasGlue))
|
||||
if (!wasVisited && (canStick || blockAttachedTowardsFace || faceHasGlue || (offset == forcedDirection && !BlockMovementTraits.notSupportive(state, forcedDirection))))
|
||||
frontier.add(offsetPos);
|
||||
if (faceHasGlue)
|
||||
addGlue(superglue.get(offset));
|
||||
|
|
|
@ -8,6 +8,7 @@ import com.simibubi.create.foundation.config.AllConfigs;
|
|||
import com.simibubi.create.foundation.utility.VecHelper;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.block.CarpetBlock;
|
||||
import net.minecraft.block.material.PushReaction;
|
||||
import net.minecraft.nbt.CompoundNBT;
|
||||
import net.minecraft.state.properties.BlockStateProperties;
|
||||
import net.minecraft.state.properties.PistonType;
|
||||
|
@ -164,6 +165,8 @@ public class PistonContraption extends TranslatingContraption {
|
|||
return true;
|
||||
if (!BlockMovementTraits.movementAllowed(world, currentPos))
|
||||
return retracting;
|
||||
if (retracting && state.getPushReaction() == PushReaction.PUSH_ONLY)
|
||||
return true;
|
||||
frontier.add(currentPos);
|
||||
if (BlockMovementTraits.notSupportive(state, orientation))
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue