mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-18 16:02:19 +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();
|
ListTag actorsNBT = new ListTag();
|
||||||
for (MutablePair<StructureBlockInfo, MovementContext> actor : getActors()) {
|
for (MutablePair<StructureBlockInfo, MovementContext> actor : getActors()) {
|
||||||
|
MovementBehaviour behaviour = AllMovementBehaviours.getBehaviour(actor.left.state);
|
||||||
|
if (behaviour == null)
|
||||||
|
continue;
|
||||||
CompoundTag compound = new CompoundTag();
|
CompoundTag compound = new CompoundTag();
|
||||||
compound.put("Pos", NbtUtils.writeBlockPos(actor.left.pos));
|
compound.put("Pos", NbtUtils.writeBlockPos(actor.left.pos));
|
||||||
AllMovementBehaviours.getBehaviour(actor.left.state)
|
behaviour.writeExtraData(actor.right);
|
||||||
.writeExtraData(actor.right);
|
|
||||||
actor.right.writeToNBT(compound);
|
actor.right.writeToNBT(compound);
|
||||||
actorsNBT.add(compound);
|
actorsNBT.add(compound);
|
||||||
}
|
}
|
||||||
|
@ -1120,8 +1122,9 @@ public abstract class Contraption {
|
||||||
public void startMoving(Level world) {
|
public void startMoving(Level world) {
|
||||||
for (MutablePair<StructureBlockInfo, MovementContext> pair : actors) {
|
for (MutablePair<StructureBlockInfo, MovementContext> pair : actors) {
|
||||||
MovementContext context = new MovementContext(world, pair.left, this);
|
MovementContext context = new MovementContext(world, pair.left, this);
|
||||||
AllMovementBehaviours.getBehaviour(pair.left.state)
|
MovementBehaviour behaviour = AllMovementBehaviours.getBehaviour(pair.left.state);
|
||||||
.startMoving(context);
|
if (behaviour != null)
|
||||||
|
behaviour.startMoving(context);
|
||||||
pair.setRight(context);
|
pair.setRight(context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1137,8 +1140,12 @@ public abstract class Contraption {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void forEachActor(Level world, BiConsumer<MovementBehaviour, MovementContext> callBack) {
|
public void forEachActor(Level world, BiConsumer<MovementBehaviour, MovementContext> callBack) {
|
||||||
for (MutablePair<StructureBlockInfo, MovementContext> pair : actors)
|
for (MutablePair<StructureBlockInfo, MovementContext> pair : actors) {
|
||||||
callBack.accept(AllMovementBehaviours.getBehaviour(pair.getLeft().state), pair.getRight());
|
MovementBehaviour behaviour = AllMovementBehaviours.getBehaviour(pair.getLeft().state);
|
||||||
|
if (behaviour == null)
|
||||||
|
continue;
|
||||||
|
callBack.accept(behaviour, pair.getRight());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean shouldUpdateAfterMovement(StructureBlockInfo info) {
|
protected boolean shouldUpdateAfterMovement(StructureBlockInfo info) {
|
||||||
|
|
Loading…
Reference in a new issue