mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-03-04 06:44:40 +01:00
Bug fixes
- Fixed synced storage no longer syncing after world reload - Fixed trains disappearing on assembly
This commit is contained in:
parent
80850134ad
commit
18e6d90a37
3 changed files with 29 additions and 16 deletions
|
@ -824,8 +824,8 @@ public abstract class Contraption {
|
|||
superglueNBT.add(c);
|
||||
}
|
||||
}
|
||||
|
||||
(spawnPacket ? getStorageForSpawnPacket() : storage).write(nbt, spawnPacket);
|
||||
|
||||
writeStorage(nbt, spawnPacket);
|
||||
|
||||
ListTag interactorNBT = new ListTag();
|
||||
for (BlockPos pos : interactors.keySet()) {
|
||||
|
@ -867,9 +867,9 @@ public abstract class Contraption {
|
|||
|
||||
return nbt;
|
||||
}
|
||||
|
||||
protected MountedStorageManager getStorageForSpawnPacket() {
|
||||
return storage;
|
||||
|
||||
public void writeStorage(CompoundTag nbt, boolean spawnPacket) {
|
||||
storage.write(nbt, spawnPacket);
|
||||
}
|
||||
|
||||
private CompoundTag writeBlocksCompound() {
|
||||
|
@ -1470,7 +1470,7 @@ public abstract class Contraption {
|
|||
}
|
||||
|
||||
public void tickStorage(AbstractContraptionEntity entity) {
|
||||
this.storage.tick(entity);
|
||||
getStorage().tick(entity);
|
||||
}
|
||||
|
||||
public boolean containsBlockBreakers() {
|
||||
|
|
|
@ -255,7 +255,11 @@ public class MountedStorageManager {
|
|||
MountedItemStorage.CODEC.decode(NbtOps.INSTANCE, data)
|
||||
.result()
|
||||
.map(Pair::getFirst)
|
||||
.ifPresent(storage -> this.itemsBuilder.put(pos, storage));
|
||||
.ifPresent(storage -> {
|
||||
this.itemsBuilder.put(pos, storage);
|
||||
if (storage instanceof SyncedMountedStorage sms)
|
||||
this.syncedItemsBuilder.put(pos, sms);
|
||||
});
|
||||
});
|
||||
|
||||
NBTHelper.iterateCompoundList(nbt.getList("fluids", Tag.TAG_COMPOUND), tag -> {
|
||||
|
@ -264,7 +268,11 @@ public class MountedStorageManager {
|
|||
MountedFluidStorage.CODEC.decode(NbtOps.INSTANCE, data)
|
||||
.result()
|
||||
.map(Pair::getFirst)
|
||||
.ifPresent(storage -> this.fluidsBuilder.put(pos, storage));
|
||||
.ifPresent(storage -> {
|
||||
this.fluidsBuilder.put(pos, storage);
|
||||
if (storage instanceof SyncedMountedStorage sms)
|
||||
this.syncedFluidsBuilder.put(pos, sms);
|
||||
});
|
||||
});
|
||||
|
||||
this.readLegacy(nbt);
|
||||
|
@ -411,7 +419,7 @@ public class MountedStorageManager {
|
|||
if (info == null)
|
||||
return false;
|
||||
|
||||
MountedStorageManager storageManager = contraption.getStorageForSpawnPacket();
|
||||
MountedStorageManager storageManager = contraption.getStorage();
|
||||
MountedItemStorage storage = storageManager.getAllItemStorages().get(localPos);
|
||||
|
||||
if (storage != null) {
|
||||
|
|
|
@ -121,7 +121,8 @@ public class CarriageContraption extends Contraption {
|
|||
StructureBlockInfo info = blocks.get(controlsPos);
|
||||
if (!AllBlocks.TRAIN_CONTROLS.has(info.state()))
|
||||
return false;
|
||||
return info.state().getValue(ControlsBlock.FACING) == direction.getOpposite();
|
||||
return info.state()
|
||||
.getValue(ControlsBlock.FACING) == direction.getOpposite();
|
||||
}
|
||||
|
||||
public void swapStorageAfterAssembly(CarriageContraptionEntity cce) {
|
||||
|
@ -226,17 +227,12 @@ public class CarriageContraption extends Contraption {
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected MountedStorageManager getStorageForSpawnPacket() {
|
||||
return storageProxy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContraptionType getType() {
|
||||
return ContraptionType.CARRIAGE;
|
||||
}
|
||||
|
||||
public Direction getAssemblyDirection() {
|
||||
public Direction getAssemblyDirection() {
|
||||
return assemblyDirection;
|
||||
}
|
||||
|
||||
|
@ -322,4 +318,13 @@ public class CarriageContraption extends Contraption {
|
|||
public MountedStorageManager getStorage() {
|
||||
return storageProxy == null ? fallbackStorage : storageProxy;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeStorage(CompoundTag nbt, boolean spawnPacket) {
|
||||
if (!spawnPacket)
|
||||
return;
|
||||
if (storageProxy != null)
|
||||
storageProxy.write(nbt, spawnPacket);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue