Mildly problematic
- Fixed broken kinetic propagation caused by bracket handling - Fixed crash when fluid-interfacing with a contraption loaded from disk
This commit is contained in:
parent
6c6760ef17
commit
62621f8bdd
7 changed files with 25 additions and 14 deletions
|
@ -607,7 +607,14 @@ public abstract class Contraption {
|
|||
int index = 0;
|
||||
for (MountedStorage mountedStorage : storage.values())
|
||||
handlers[index++] = mountedStorage.getItemHandler();
|
||||
|
||||
IFluidHandler[] fluidHandlers = new IFluidHandler[fluidStorage.size()];
|
||||
index = 0;
|
||||
for (MountedFluidStorage mountedStorage : fluidStorage.values())
|
||||
fluidHandlers[index++] = mountedStorage.getFluidHandler();
|
||||
|
||||
inventory = new CombinedInvWrapper(handlers);
|
||||
fluidInventory = new CombinedTankWrapper(fluidHandlers);
|
||||
|
||||
if (nbt.contains("BoundsFront"))
|
||||
bounds = NBTHelper.readAABB(nbt.getList("BoundsFront", 5));
|
||||
|
|
|
@ -123,7 +123,8 @@ public class MechanicalBearingTileEntity extends GeneratingKineticTileEntity imp
|
|||
if (!contraption.assemble(world, pos))
|
||||
return;
|
||||
|
||||
AllTriggers.triggerForNearbyPlayers(AllTriggers.WINDMILL, world, pos, 5);
|
||||
if (isWindmill())
|
||||
AllTriggers.triggerForNearbyPlayers(AllTriggers.WINDMILL, world, pos, 5);
|
||||
if (contraption.getSailBlocks() >= 16 * 8)
|
||||
AllTriggers.triggerForNearbyPlayers(AllTriggers.MAXED_WINDMILL, world, pos, 5);
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ public class AxisPipeBlock extends RotatedPillarBlock implements IWrenchableWith
|
|||
if (blockTypeChanged && !world.isRemote)
|
||||
FluidPropagator.propagateChangedPipe(world, pos, state);
|
||||
if (state != newState && !isMoving)
|
||||
removeBracket(world, pos).ifPresent(stack -> Block.spawnAsEntity(world, pos, stack));
|
||||
removeBracket(world, pos, true).ifPresent(stack -> Block.spawnAsEntity(world, pos, stack));
|
||||
if (state.hasTileEntity() && (blockTypeChanged || !newState.hasTileEntity()))
|
||||
world.removeTileEntity(pos);
|
||||
}
|
||||
|
@ -127,12 +127,12 @@ public class AxisPipeBlock extends RotatedPillarBlock implements IWrenchableWith
|
|||
}
|
||||
|
||||
@Override
|
||||
public Optional<ItemStack> removeBracket(IBlockReader world, BlockPos pos) {
|
||||
public Optional<ItemStack> removeBracket(IBlockReader world, BlockPos pos, boolean inOnReplacedContext) {
|
||||
BracketedTileEntityBehaviour behaviour = TileEntityBehaviour.get(world, pos, BracketedTileEntityBehaviour.TYPE);
|
||||
if (behaviour == null)
|
||||
return Optional.empty();
|
||||
BlockState bracket = behaviour.getBracket();
|
||||
behaviour.removeBracket();
|
||||
behaviour.removeBracket(inOnReplacedContext);
|
||||
if (bracket == Blocks.AIR.getDefaultState())
|
||||
return Optional.empty();
|
||||
return Optional.of(new ItemStack(bracket.getBlock()));
|
||||
|
|
|
@ -103,7 +103,7 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren
|
|||
if (blockTypeChanged && !world.isRemote)
|
||||
FluidPropagator.propagateChangedPipe(world, pos, state);
|
||||
if (state != newState && !isMoving)
|
||||
removeBracket(world, pos).ifPresent(stack -> Block.spawnAsEntity(world, pos, stack));
|
||||
removeBracket(world, pos, true).ifPresent(stack -> Block.spawnAsEntity(world, pos, stack));
|
||||
if (state.hasTileEntity() && (blockTypeChanged || !newState.hasTileEntity()))
|
||||
world.removeTileEntity(pos);
|
||||
}
|
||||
|
@ -260,13 +260,13 @@ public class FluidPipeBlock extends SixWayBlock implements IWaterLoggable, IWren
|
|||
}
|
||||
|
||||
@Override
|
||||
public Optional<ItemStack> removeBracket(IBlockReader world, BlockPos pos) {
|
||||
public Optional<ItemStack> removeBracket(IBlockReader world, BlockPos pos, boolean inOnReplacedContext) {
|
||||
BracketedTileEntityBehaviour behaviour =
|
||||
BracketedTileEntityBehaviour.get(world, pos, BracketedTileEntityBehaviour.TYPE);
|
||||
if (behaviour == null)
|
||||
return Optional.empty();
|
||||
BlockState bracket = behaviour.getBracket();
|
||||
behaviour.removeBracket();
|
||||
behaviour.removeBracket(inOnReplacedContext);
|
||||
if (bracket == Blocks.AIR.getDefaultState())
|
||||
return Optional.empty();
|
||||
return Optional.of(new ItemStack(bracket.getBlock()));
|
||||
|
|
|
@ -55,7 +55,7 @@ public abstract class AbstractShaftBlock extends RotatedPillarKineticBlock imple
|
|||
@SuppressWarnings("deprecation")
|
||||
public void onReplaced(BlockState state, World world, BlockPos pos, BlockState newState, boolean isMoving) {
|
||||
if (state != newState && !isMoving)
|
||||
removeBracket(world, pos).ifPresent(stack -> Block.spawnAsEntity(world, pos, stack));
|
||||
removeBracket(world, pos, true).ifPresent(stack -> Block.spawnAsEntity(world, pos, stack));
|
||||
super.onReplaced(state, world, pos, newState, isMoving);
|
||||
}
|
||||
|
||||
|
@ -102,12 +102,12 @@ public abstract class AbstractShaftBlock extends RotatedPillarKineticBlock imple
|
|||
}
|
||||
|
||||
@Override
|
||||
public Optional<ItemStack> removeBracket(IBlockReader world, BlockPos pos) {
|
||||
public Optional<ItemStack> removeBracket(IBlockReader world, BlockPos pos, boolean inOnReplacedContext) {
|
||||
BracketedTileEntityBehaviour behaviour = TileEntityBehaviour.get(world, pos, BracketedTileEntityBehaviour.TYPE);
|
||||
if (behaviour == null)
|
||||
return Optional.empty();
|
||||
BlockState bracket = behaviour.getBracket();
|
||||
behaviour.removeBracket();
|
||||
behaviour.removeBracket(inOnReplacedContext);
|
||||
if (bracket == Blocks.AIR.getDefaultState())
|
||||
return Optional.empty();
|
||||
return Optional.of(new ItemStack(bracket.getBlock()));
|
||||
|
|
|
@ -62,13 +62,16 @@ public class BracketedTileEntityBehaviour extends TileEntityBehaviour {
|
|||
AllTriggers.triggerFor(trigger.apply(state), player);
|
||||
}
|
||||
|
||||
public void removeBracket() {
|
||||
public void removeBracket(boolean inOnReplacedContext) {
|
||||
World world = getWorld();
|
||||
if (!world.isRemote)
|
||||
world.playEvent(2001, getPos(), Block.getStateId(getBracket()));
|
||||
this.bracket = Optional.empty();
|
||||
reRender = true;
|
||||
tileEntity.notifyUpdate();
|
||||
if (inOnReplacedContext)
|
||||
tileEntity.sendData();
|
||||
else
|
||||
tileEntity.notifyUpdate();
|
||||
}
|
||||
|
||||
public boolean isBacketPresent() {
|
||||
|
|
|
@ -19,7 +19,7 @@ import net.minecraft.world.World;
|
|||
|
||||
public interface IWrenchableWithBracket extends IWrenchable {
|
||||
|
||||
public Optional<ItemStack> removeBracket(IBlockReader world, BlockPos pos);
|
||||
public Optional<ItemStack> removeBracket(IBlockReader world, BlockPos pos, boolean inOnReplacedContext);
|
||||
|
||||
@Override
|
||||
default ActionResultType onWrenched(BlockState state, ItemUseContext context) {
|
||||
|
@ -31,7 +31,7 @@ public interface IWrenchableWithBracket extends IWrenchable {
|
|||
default boolean tryRemoveBracket(ItemUseContext context) {
|
||||
World world = context.getWorld();
|
||||
BlockPos pos = context.getPos();
|
||||
Optional<ItemStack> bracket = removeBracket(world, pos);
|
||||
Optional<ItemStack> bracket = removeBracket(world, pos, false);
|
||||
BlockState blockState = world.getBlockState(pos);
|
||||
if (bracket.isPresent()) {
|
||||
PlayerEntity player = context.getPlayer();
|
||||
|
|
Loading…
Reference in a new issue