diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java index 41e20d42b..fd27685ce 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/Contraption.java @@ -112,7 +112,8 @@ public abstract class Contraption { private List pendingSubContraptions; // Client - public Map renderedTileEntities; + public Map presentTileEntities; + public List renderedTileEntities; public Contraption() { blocks = new HashMap<>(); @@ -124,7 +125,8 @@ public abstract class Contraption { fluidStorage = new HashMap<>(); glueToRemove = new ArrayList<>(); initialPassengers = new HashMap<>(); - renderedTileEntities = new HashMap<>(); + presentTileEntities = new HashMap<>(); + renderedTileEntities = new ArrayList<>(); pendingSubContraptions = new ArrayList<>(); stabilizedSubContraptions = new HashMap<>(); } @@ -512,6 +514,7 @@ public abstract class Contraption { public void readNBT(World world, CompoundNBT nbt, boolean spawnData) { blocks.clear(); + presentTileEntities.clear(); renderedTileEntities.clear(); nbt.getList("Blocks", 10) @@ -549,7 +552,8 @@ public abstract class Contraption { if (te instanceof KineticTileEntity) ((KineticTileEntity) te).setSpeed(0); te.getBlockState(); - renderedTileEntities.put(info.pos, te); + presentTileEntities.put(info.pos, te); + renderedTileEntities.add(te); } }); @@ -587,7 +591,7 @@ public abstract class Contraption { if (spawnData) fluidStorage.forEach((pos, mfs) -> { - TileEntity tileEntity = renderedTileEntities.get(pos); + TileEntity tileEntity = presentTileEntities.get(pos); if (!(tileEntity instanceof FluidTankTileEntity)) return; FluidTankTileEntity tank = (FluidTankTileEntity) tileEntity; diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionRenderer.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionRenderer.java index 32398f9e5..7892307d8 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionRenderer.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/ContraptionRenderer.java @@ -71,7 +71,7 @@ public class ContraptionRenderer { private static void renderTileEntities(World world, Contraption c, MatrixStack ms, MatrixStack msLocal, IRenderTypeBuffer buffer) { - TileEntityRenderHelper.renderTileEntities(world, c.renderedTileEntities.values(), ms, msLocal, buffer); + TileEntityRenderHelper.renderTileEntities(world, c.renderedTileEntities, ms, msLocal, buffer); } private static SuperByteBuffer buildStructureBuffer(Contraption c, RenderType layer) { @@ -86,7 +86,7 @@ public class ContraptionRenderer { Random random = new Random(); BufferBuilder builder = new BufferBuilder(DefaultVertexFormats.BLOCK.getIntegerSize()); builder.begin(GL11.GL_QUADS, DefaultVertexFormats.BLOCK); - renderWorld.setTileEntities(c.renderedTileEntities.values()); + renderWorld.setTileEntities(c.presentTileEntities.values()); for (BlockInfo info : c.getBlocks() .values()) diff --git a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinMovementBehaviour.java b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinMovementBehaviour.java index 4412e0b0c..a3de35c6c 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/processing/BasinMovementBehaviour.java +++ b/src/main/java/com/simibubi/create/content/contraptions/processing/BasinMovementBehaviour.java @@ -52,7 +52,7 @@ public class BasinMovementBehaviour extends MovementBehaviour { } context.tileData.put(key, itemStackHandler.serializeNBT()); }); - TileEntity tileEntity = context.contraption.renderedTileEntities.get(context.localPos); + TileEntity tileEntity = context.contraption.presentTileEntities.get(context.localPos); if (tileEntity instanceof BasinTileEntity) ((BasinTileEntity) tileEntity).readOnlyItems(context.tileData); context.temporaryData = false; // did already dump, so can't any more