mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-12-14 05:23:47 +01:00
Bad Acting
- Fixed crash when loading contraptions with missing blocks which had provided movement behaviours
This commit is contained in:
parent
c420048a88
commit
d6e8ac73df
1 changed files with 13 additions and 6 deletions
|
@ -744,10 +744,12 @@ public abstract class Contraption {
|
|||
|
||||
ListTag actorsNBT = new ListTag();
|
||||
for (MutablePair<StructureBlockInfo, MovementContext> actor : getActors()) {
|
||||
MovementBehaviour behaviour = AllMovementBehaviours.getBehaviour(actor.left.state);
|
||||
if (behaviour == null)
|
||||
continue;
|
||||
CompoundTag compound = new CompoundTag();
|
||||
compound.put("Pos", NbtUtils.writeBlockPos(actor.left.pos));
|
||||
AllMovementBehaviours.getBehaviour(actor.left.state)
|
||||
.writeExtraData(actor.right);
|
||||
behaviour.writeExtraData(actor.right);
|
||||
actor.right.writeToNBT(compound);
|
||||
actorsNBT.add(compound);
|
||||
}
|
||||
|
@ -1120,8 +1122,9 @@ public abstract class Contraption {
|
|||
public void startMoving(Level world) {
|
||||
for (MutablePair<StructureBlockInfo, MovementContext> pair : actors) {
|
||||
MovementContext context = new MovementContext(world, pair.left, this);
|
||||
AllMovementBehaviours.getBehaviour(pair.left.state)
|
||||
.startMoving(context);
|
||||
MovementBehaviour behaviour = AllMovementBehaviours.getBehaviour(pair.left.state);
|
||||
if (behaviour != null)
|
||||
behaviour.startMoving(context);
|
||||
pair.setRight(context);
|
||||
}
|
||||
}
|
||||
|
@ -1137,8 +1140,12 @@ public abstract class Contraption {
|
|||
}
|
||||
|
||||
public void forEachActor(Level world, BiConsumer<MovementBehaviour, MovementContext> callBack) {
|
||||
for (MutablePair<StructureBlockInfo, MovementContext> pair : actors)
|
||||
callBack.accept(AllMovementBehaviours.getBehaviour(pair.getLeft().state), pair.getRight());
|
||||
for (MutablePair<StructureBlockInfo, MovementContext> pair : actors) {
|
||||
MovementBehaviour behaviour = AllMovementBehaviours.getBehaviour(pair.getLeft().state);
|
||||
if (behaviour == null)
|
||||
continue;
|
||||
callBack.accept(behaviour, pair.getRight());
|
||||
}
|
||||
}
|
||||
|
||||
protected boolean shouldUpdateAfterMovement(StructureBlockInfo info) {
|
||||
|
|
Loading…
Reference in a new issue