diff --git a/JAVA_MIGRATION.md b/JAVA_MIGRATION.md index 1004758..978525f 100644 --- a/JAVA_MIGRATION.md +++ b/JAVA_MIGRATION.md @@ -36,9 +36,9 @@ Schematica's reflective lookup. The remaining source-only member guards, `TileMu compact mixed-part NBT/description packet, generated Scala and Java traits, and a server-only pass-through interface are also frozen. -Phase 1 has not properly started: GTNHLib is present but was added at `api` scope to satisfy a test compile rather -than because a migration change needed it, and no Forge mod dependency was declared. Revisit that entry only when a -real migration change needs it. Phase 8 is answered and deferred. +Phase 1 has not properly started: GTNHLib is not declared because no migration change currently needs it. Select a +pack-aligned version only when a concrete port or measured data-structure change requires it. Phase 8 is answered and +deferred. The working rules established while converting, which apply to every remaining area: @@ -705,3 +705,10 @@ generated-trait compatibility work. Scala-runtime removal remains a later projec - The paired 50,000,000-iteration run fell from 4,023,855,000 bytes / 80.5 B per three-query iteration to zero measured allocation, while throughput rose 20.3% from 6,636,424 to 7,986,213 iterations/s. The checksum remained `3315999992`, and all 145 plain-JVM plus 46 Forge tests pass. +- Characterized mutable-`Seq` read behavior, direct ordered indexing, and `BlockMultipart.getTile` filtering, then + extended the focused workload with `getLightValue` and `getTile` phases before changing production code. +- Removed the Java-port-only `ArrayList` snapshots from all read paths and Java wrappers from internal block, + renderer, and scheduler paths. The public `jPartList()` bridge is unchanged; add/remove retain intentional mutable + snapshots before publishing a replacement immutable `Seq`. +- In the paired run, `getLightValue` fell from 183.9 B to 0.0 B per call with 11.42x throughput, and `getTile` fell + from 24.0 B to 0.0 B per call with 2.89x throughput. All 147 plain-JVM and 46 Forge tests pass. diff --git a/JAVA_MIGRATION_DIVERGENCES.md b/JAVA_MIGRATION_DIVERGENCES.md index c47bb3f..94d65c8 100644 --- a/JAVA_MIGRATION_DIVERGENCES.md +++ b/JAVA_MIGRATION_DIVERGENCES.md @@ -664,8 +664,7 @@ same messages, since Scala's `assert` is always enabled here and Java's is not. five jars link against. Mutations copy to a Java list, mutate, and republish through `JavaConversions`, matching the reference's allocate-a-new-Seq semantics exactly. The focused Phase 4 baseline later found that the Java port's `parts()` read helper also materializes an `ArrayList`, backing array, iterator and conversion wrappers on every -traversal. That read-side cost is not required by the reference and is the next measured optimization target; see -`JAVA_MIGRATION_PROFILE.md`. +traversal. That read-side cost was later removed after focused characterization; see `JAVA_MIGRATION_PROFILE.md`. `operate` keeps its `(Lscala/Function1;)V` descriptor and internal callers still go through it, wrapping their action in an `AbstractFunction1`. That preserves both the virtual dispatch, so any trait overriding `operate` still sees @@ -1509,3 +1508,24 @@ to 7,986,213 iterations/s (20.3%). Both runs produced checksum `3315999992`. - Complete plain-JVM suite: 145 tests, 0 failures, 0 errors. - Java 8 Forge dedicated-server suite: 46 tests, 0 failures, 0 errors. - Clean formatting, checkstyle, build, generated runtime reflection, and paired profile checksum. + +## 2026-08-28 — multipart read-path cleanup + +### Observable behavior and ABI + +No known runtime divergence. Focused tests pin max-or-zero lighting, torch support, live reads through a mutable `Seq`, +direct ordered indexing, and `BlockMultipart.getTile`'s non-multipart/empty/non-empty filtering. Internal code now reads +the published `Seq` directly. The public `partList`, `partList_$eq`, and `jPartList` descriptors and live-view behavior +are unchanged; add/remove still snapshot before publishing a replacement immutable `Seq`. + +### Performance result + +The paired 50,000,000-iteration Forge/JFR run reduced `getLightValue` from 9,196,067,864 allocated bytes / 183.9 B per +call to zero and raised throughput 11.42x. `BlockMultipart.getTile` fell from 1,200,000,000 bytes / 24.0 B per call to +zero and rose 2.89x. Both runs used the same eight-part tile and produced the same checksum. + +### Validation + +- Complete plain-JVM suite: 147 tests, 0 failures, 0 errors. +- Java 8 Forge dedicated-server suite: 46 tests, 0 failures, 0 errors. +- The public Java list bridge remains for downstream consumers; there are no internal `jPartList()` callers. diff --git a/JAVA_MIGRATION_HANDOFF.md b/JAVA_MIGRATION_HANDOFF.md index 1a13588..99e26e1 100644 --- a/JAVA_MIGRATION_HANDOFF.md +++ b/JAVA_MIGRATION_HANDOFF.md @@ -243,6 +243,12 @@ one-argument `weakPowerLevel` call are covered, the runtime interface remains fi methods, and the paired workload fell from 80.5 B to 0.0 B per three-query iteration with 20.3% higher throughput and the same checksum. Its package-private access shim is required by current inherited-member transformer limitations. +The Java-port-only multipart read allocations are also resolved. Focused tests pin mutable-`Seq` reads and +`BlockMultipart.getTile`; internal tile/block/renderer/scheduler paths now use the published `Seq` directly while the +public `jPartList()` bridge remains. In the paired workload, `getLightValue` fell from 183.9 B to 0.0 B per call and +`BlockMultipart.getTile` from 24.0 B to 0.0 B per call. Mutable snapshots remain only where add/remove publishes a +replacement immutable `Seq`. + `MicroRecipe` is now Java. The complete 17-method static/companion surface, immutable Scala split map, exact material and tag matching, all five recipe forms, class-specific gluing, saw position, and hollow-over-gluing precedence are frozen. Its internal scans are ordinary loops, and only the published `getSaw` call still constructs its required @@ -288,10 +294,9 @@ all of `multipart/asm/`. The ASM subsystem should be last; freeze generated-clas source-compatible rebuilds. - Microblock-specific NBT and packet payloads still need characterization immediately before that subsystem changes; the compact core tile/part fixture is complete. -- `TileMultipart`'s `partList` still republishes an immutable Scala `Seq` on every mutation. `operate` no longer calls - the Java port's copying `parts()` helper, but less frequent read and mutation paths still do. Optimize those only if - a representative profile identifies them; their mutable snapshots are intentional at mutation sites. +- `TileMultipart` still republishes an immutable Scala `Seq` on every mutation. Its internal read paths now avoid Java + list copies and wrappers; the remaining mutable snapshots at add/remove sites are intentional. - The focused synthetic redstone allocation is resolved (80.5 B to 0.0 B per three-query iteration). A representative full-pack profile remains the authority for choosing any further optimization target. -- Phase 1 never properly started. GTNHLib is currently commented out in `dependencies.gradle`; it had been added at - `api` scope to satisfy a test compile rather than because a migration change needed it. +- Phase 1 never properly started. GTNHLib is not declared because no migration change currently needs it; choose a + pack-aligned version only when one does. diff --git a/JAVA_MIGRATION_MANUAL_CHECKS.md b/JAVA_MIGRATION_MANUAL_CHECKS.md index e22c396..4f7b505 100644 --- a/JAVA_MIGRATION_MANUAL_CHECKS.md +++ b/JAVA_MIGRATION_MANUAL_CHECKS.md @@ -48,4 +48,5 @@ release that includes those ports. - A focused pre-optimization CPU/allocation baseline now exists in `JAVA_MIGRATION_PROFILE.md`. A representative full-pack capture and the matching post-optimization comparison still need to be performed. -- NBT and packet layout fixtures beyond the material id carrier. Phase 0 still lists this as open. +- Microblock-specific NBT and packet payloads. The compact core tile/part NBT and logical chunk-description fixtures + are complete. diff --git a/JAVA_MIGRATION_PROFILE.md b/JAVA_MIGRATION_PROFILE.md index 8e717a9..b6c8ac8 100644 --- a/JAVA_MIGRATION_PROFILE.md +++ b/JAVA_MIGRATION_PROFILE.md @@ -167,3 +167,17 @@ queries over the mutable `Seq` implementations accepted by the public setter. Th `lightValue` pays for `TileMultipart.parts()`'s copied `ArrayList`; `getTile` pays for the Java list wrapper returned by `jPartList()`. Both are absent from the reference Scala implementation, which reads the published `Seq` directly. Mutation paths still require a snapshot before publishing a replacement immutable `Seq`. + +### Read-path result captured 2026-08-28 + +The paired run used the same JVM, eight-part tiles, warm-up, iteration count, and checksum: + +| Phase | Baseline elapsed | Result elapsed | Baseline B/op | Result B/op | Throughput change | +| --- | ---: | ---: | ---: | ---: | ---: | +| `lightValue` | 3.170 s | 0.278 s | 183.9 | 0.0 | 11.42x | +| `getTile` | 0.271 s | 0.094 s | 24.0 | 0.0 | 2.89x | + +Internal read paths now traverse or index the published Scala `Seq` directly. The normal immutable-list light query +walks the existing head/tail chain; arbitrary `Seq` implementations retain an iterator fallback. The public +`jPartList()` bridge remains unchanged for downstream ABI compatibility, and only add/remove paths take mutable +snapshots before publishing a replacement immutable `Seq`. diff --git a/dependencies.gradle b/dependencies.gradle index 83a105e..b27f057 100644 --- a/dependencies.gradle +++ b/dependencies.gradle @@ -1,8 +1,6 @@ // Add your dependencies here dependencies { - //compileOnly('com.github.GTNewHorizons:GTNHLib:0.11.37:dev') - testImplementation(platform("org.junit:junit-bom:5.11.4")) testImplementation("org.junit.jupiter:junit-jupiter") testRuntimeOnly("org.junit.platform:junit-platform-launcher") diff --git a/src/main/scala/codechicken/multipart/BlockMultipart.java b/src/main/scala/codechicken/multipart/BlockMultipart.java index 1da9f40..162e1be 100644 --- a/src/main/scala/codechicken/multipart/BlockMultipart.java +++ b/src/main/scala/codechicken/multipart/BlockMultipart.java @@ -25,6 +25,7 @@ import codechicken.lib.raytracer.RayTracer; import codechicken.lib.render.TextureUtils; import codechicken.lib.vec.Cuboid6; import scala.Tuple2; +import scala.collection.Iterator; /** Block class for all multiparts, should be internal use only. */ public class BlockMultipart extends Block { @@ -35,7 +36,7 @@ public class BlockMultipart extends Block { public static TileMultipart getTile(IBlockAccess world, int x, int y, int z) { net.minecraft.tileentity.TileEntity t = world.getTileEntity(x, y, z); - if (t instanceof TileMultipart && !((TileMultipart) t).jPartList().isEmpty()) { + if (t instanceof TileMultipart && !((TileMultipart) t).partList().isEmpty()) { return (TileMultipart) t; } return null; @@ -43,7 +44,7 @@ public class BlockMultipart extends Block { public static TileMultipartClient getClientTile(IBlockAccess world, int x, int y, int z) { net.minecraft.tileentity.TileEntity t = world.getTileEntity(x, y, z); - if (t instanceof TileMultipartClient && !((TileMultipart) t).jPartList().isEmpty()) { + if (t instanceof TileMultipartClient && !((TileMultipart) t).partList().isEmpty()) { return (TileMultipartClient) t; } return null; @@ -64,11 +65,11 @@ public class BlockMultipart extends Block { Tuple2 reduced = reduceMOP(hit); int index = (Integer) reduced._1(); - if (tile.jPartList().get(index).drawHighlight(reduced._2(), player, frame)) { + if (tile.partList().apply(index).drawHighlight(reduced._2(), player, frame)) { return true; } - tile.jPartList().get(index).collisionRayTrace(RayTracer.getStartVec(player), RayTracer.getEndVec(player)); + tile.partList().apply(index).collisionRayTrace(RayTracer.getStartVec(player), RayTracer.getEndVec(player)); return false; } @@ -126,7 +127,7 @@ public class BlockMultipart extends Block { Tuple2 reduced = reduceMOP(hit); int index = (Integer) reduced._1(); if (world.isRemote) { - tile.jPartList().get(index).addDestroyEffects(reduced._2(), Minecraft.getMinecraft().effectRenderer); + tile.partList().apply(index).addDestroyEffects(reduced._2(), Minecraft.getMinecraft().effectRenderer); return true; } @@ -157,7 +158,9 @@ public class BlockMultipart extends Block { TileMultipart tile = getTile(world, x, y, z); if (tile != null) { - for (TMultiPart part : tile.jPartList()) { + Iterator iterator = tile.partList().iterator(); + while (iterator.hasNext()) { + TMultiPart part = iterator.next(); for (ItemStack item : part.getDrops()) { ai.add(item); } @@ -174,7 +177,9 @@ public class BlockMultipart extends Block { List list = list$; TileMultipart tile = getTile(world, x, y, z); if (tile != null) { - for (TMultiPart part : tile.jPartList()) { + Iterator iterator = tile.partList().iterator(); + while (iterator.hasNext()) { + TMultiPart part = iterator.next(); for (Cuboid6 c : part.getCollisionBoxes()) { AxisAlignedBB aabb = c.toAABB().offset(x, y, z); if (aabb.intersectsWith(ebb)) { @@ -194,8 +199,8 @@ public class BlockMultipart extends Block { TileMultipart parts = (TileMultipart) tile; Tuple2 reduced = reduceMOP(hit); int index = (Integer) reduced._1(); - if (index < parts.jPartList().size()) { - parts.jPartList().get(index).addHitEffects(reduced._2(), effectRenderer); + if (index < parts.partList().size()) { + parts.partList().apply(index).addHitEffects(reduced._2(), effectRenderer); } } @@ -225,7 +230,7 @@ public class BlockMultipart extends Block { @Override public boolean isAir(IBlockAccess world, int x, int y, int z) { TileMultipart tile = getTile(world, x, y, z); - return tile == null || tile.jPartList().isEmpty(); + return tile == null || tile.partList().isEmpty(); } @Override @@ -251,7 +256,7 @@ public class BlockMultipart extends Block { return null; } Tuple2 reduced = reduceMOP(hit); - return tile.jPartList().get((Integer) reduced._1()).pickItem(reduced._2()); + return tile.partList().apply((Integer) reduced._1()).pickItem(reduced._2()); } return null; } @@ -262,7 +267,7 @@ public class BlockMultipart extends Block { TileMultipart tile = getTile(world, x, y, z); if (hit != null && tile != null) { Tuple2 reduced = reduceMOP(hit); - return tile.jPartList().get((Integer) reduced._1()).getStrength(reduced._2(), player) / 30f; + return tile.partList().apply((Integer) reduced._1()).getStrength(reduced._2(), player) / 30f; } return 1 / 100f; @@ -304,7 +309,7 @@ public class BlockMultipart extends Block { } Tuple2 reduced = reduceMOP(hit); - return tile.jPartList().get((Integer) reduced._1()).activate(player, reduced._2(), player.getHeldItem()); + return tile.partList().apply((Integer) reduced._1()).activate(player, reduced._2(), player.getHeldItem()); } @Override @@ -320,7 +325,7 @@ public class BlockMultipart extends Block { } Tuple2 reduced = reduceMOP(hit); - tile.jPartList().get((Integer) reduced._1()).click(player, reduced._2(), player.getHeldItem()); + tile.partList().apply((Integer) reduced._1()).click(player, reduced._2(), player.getHeldItem()); } @Override diff --git a/src/main/scala/codechicken/multipart/MultipartRenderer$.java b/src/main/scala/codechicken/multipart/MultipartRenderer$.java index c2f9ef7..1a4b15f 100644 --- a/src/main/scala/codechicken/multipart/MultipartRenderer$.java +++ b/src/main/scala/codechicken/multipart/MultipartRenderer$.java @@ -41,7 +41,7 @@ public final class MultipartRenderer$ extends TileEntitySpecialRenderer implemen public void renderTileEntityAt(TileEntity t, double x, double y, double z, float f) { TileMultipartClient client = (TileMultipartClient) t; TileMultipart tile = (TileMultipart) t; - if (tile.jPartList().isEmpty() || !client.hasDynamicParts()) { + if (tile.partList().isEmpty() || !client.hasDynamicParts()) { return; } @@ -68,7 +68,7 @@ public final class MultipartRenderer$ extends TileEntitySpecialRenderer implemen TileMultipartClient client = (TileMultipartClient) t; TileMultipart tile = (TileMultipart) t; - if (tile.jPartList().isEmpty()) { + if (tile.partList().isEmpty()) { return false; } @@ -106,8 +106,8 @@ public final class MultipartRenderer$ extends TileEntitySpecialRenderer implemen } int i = (Integer) index; - if (i >= 0 && i < tile.jPartList().size()) { - tile.jPartList().get(i).drawBreaking(renderer); + if (i >= 0 && i < tile.partList().size()) { + tile.partList().apply(i).drawBreaking(renderer); } } diff --git a/src/main/scala/codechicken/multipart/TickScheduler.java b/src/main/scala/codechicken/multipart/TickScheduler.java index a93d791..ef5dafe 100644 --- a/src/main/scala/codechicken/multipart/TickScheduler.java +++ b/src/main/scala/codechicken/multipart/TickScheduler.java @@ -267,7 +267,7 @@ public final class TickScheduler { if (part.tile() != null && !e.random()) { NBTTagCompound tag = new NBTTagCompound(); tag.setShort("pos", (short) MultipartProxy.indexInChunk(new BlockCoord(part.tile()))); - tag.setByte("i", (byte) part.tile().jPartList().indexOf(part)); + tag.setByte("i", (byte) part.tile().partList().indexOf(part)); tag.setLong("time", e.time()); tagList.appendTag(tag); } @@ -293,7 +293,7 @@ public final class TickScheduler { if (tile instanceof TileMultipart) { tickList.add( new PartTickEntry( - ((TileMultipart) tile).jPartList().get(tag.getByte("i")), + ((TileMultipart) tile).partList().apply(tag.getByte("i")), tag.getLong("time"), false)); } diff --git a/src/main/scala/codechicken/multipart/TileMultipart.java b/src/main/scala/codechicken/multipart/TileMultipart.java index 3b513f0..d814600 100644 --- a/src/main/scala/codechicken/multipart/TileMultipart.java +++ b/src/main/scala/codechicken/multipart/TileMultipart.java @@ -28,6 +28,7 @@ import codechicken.multipart.handler.MultipartProxy; import codechicken.multipart.handler.MultipartSPH; import scala.Function1; import scala.Tuple2; +import scala.collection.Iterator; import scala.collection.JavaConversions; import scala.collection.Seq; import scala.runtime.AbstractFunction1; @@ -63,8 +64,9 @@ public class TileMultipart extends TileEntity implements IChunkLoadTile { } public void loadFrom(TileMultipart that) { - for (TMultiPart part : parts()) { - part.bind(this); + Iterator iterator = partList.iterator(); + while (iterator.hasNext()) { + iterator.next().bind(this); } if (doesTick) { doesTick = false; @@ -144,8 +146,9 @@ public class TileMultipart extends TileEntity implements IChunkLoadTile { if (!isInvalid()) { super.invalidate(); if (worldObj != null) { - for (TMultiPart part : parts()) { - part.onWorldSeparate(); + Iterator iterator = partList.iterator(); + while (iterator.hasNext()) { + iterator.next().onWorldSeparate(); } if (worldObj.isRemote) { TileCache.remove(this); @@ -212,26 +215,35 @@ public class TileMultipart extends TileEntity implements IChunkLoadTile { return false; } + @SuppressWarnings("unchecked") public int getLightValue() { int max = 0; - for (TMultiPart part : parts()) { - int l = part.getLightValue(); - if (l > max) { - max = l; + Seq current = partList; + if (!(current instanceof scala.collection.immutable.List)) { + Iterator iterator = current.iterator(); + while (iterator.hasNext()) { + max = Math.max(max, iterator.next().getLightValue()); } + return max; + } + + scala.collection.immutable.List list = (scala.collection.immutable.List) current; + while (!list.isEmpty()) { + max = Math.max(max, list.head().getLightValue()); + list = (scala.collection.immutable.List) list.tail(); } return max; } public float getExplosionResistance(Entity entity) { - List parts = parts(); - if (parts.isEmpty()) { + if (partList.isEmpty()) { // Matches the reference, where max on an empty view throws. throw new UnsupportedOperationException("empty.max"); } float max = Float.NEGATIVE_INFINITY; - for (TMultiPart part : parts) { - max = Math.max(max, part.explosionResistance(entity)); + Iterator iterator = partList.iterator(); + while (iterator.hasNext()) { + max = Math.max(max, iterator.next().explosionResistance(entity)); } return max; } @@ -259,8 +271,9 @@ public class TileMultipart extends TileEntity implements IChunkLoadTile { } public boolean canPlaceTorchOnTop() { - for (TMultiPart part : parts()) { - if (part.canPlaceTorchOnTop()) { + Iterator iterator = partList.iterator(); + while (iterator.hasNext()) { + if (iterator.next().canPlaceTorchOnTop()) { return true; } } @@ -284,7 +297,7 @@ public class TileMultipart extends TileEntity implements IChunkLoadTile { /** Returns true if part can be added to this space. */ public boolean canAddPart(TMultiPart part) { - return compatibilityAllows(worldObj, xCoord, yCoord, zCoord) && !parts().contains(part) + return compatibilityAllows(worldObj, xCoord, yCoord, zCoord) && !partList.contains(part) && occlusionTest(partList, part); } @@ -298,7 +311,9 @@ public class TileMultipart extends TileEntity implements IChunkLoadTile { */ public boolean canReplacePart(TMultiPart opart, TMultiPart npart) { List olist = new ArrayList<>(); - for (TMultiPart part : parts()) { + Iterator iterator = partList.iterator(); + while (iterator.hasNext()) { + TMultiPart part = iterator.next(); if (part != opart) { olist.add(part); } @@ -322,7 +337,7 @@ public class TileMultipart extends TileEntity implements IChunkLoadTile { /** Get the write stream for updates to part. */ public MCDataOutput getWriteStream(TMultiPart part) { - return writeStream().writeByte(parts().indexOf(part)); + return writeStream().writeByte(partList.indexOf(part)); } private MCDataOutput writeStream() { @@ -355,7 +370,7 @@ public class TileMultipart extends TileEntity implements IChunkLoadTile { "assertion failed: Tried to add more than 250 parts to the one tile. You're doing it wrong"); } - List next = parts(); + List next = mutablePartsSnapshot(); next.add(part); partList = toSeq(next); bindPart(part); @@ -398,7 +413,7 @@ public class TileMultipart extends TileEntity implements IChunkLoadTile { } private int remPart_do(TMultiPart part, boolean sendPacket) { - List current = parts(); + List current = mutablePartsSnapshot(); int r = current.indexOf(part); if (r < 0) { throw new IllegalArgumentException("Tried to remove a non-existant part"); @@ -455,7 +470,9 @@ public class TileMultipart extends TileEntity implements IChunkLoadTile { /** Writes the description of this tile, and all parts composing it, to packet. */ public void writeDesc(MCDataOutput packet) { packet.writeByte(partList.size()); - for (TMultiPart part : parts()) { + Iterator iterator = partList.iterator(); + while (iterator.hasNext()) { + TMultiPart part = iterator.next(); MultiPartRegistry.writePartID(packet, part); part.writeDesc(packet); } @@ -464,14 +481,16 @@ public class TileMultipart extends TileEntity implements IChunkLoadTile { /** Perform a raytrace returning all intersecting parts sorted nearest to farthest. */ public Iterable rayTraceAll(Vec3 start, Vec3 end) { List list = new ArrayList<>(); - List parts = parts(); - for (int i = 0; i < parts.size(); i++) { - Object mop = parts.get(i).collisionRayTrace(start, end); + Iterator iterator = partList.iterator(); + int i = 0; + while (iterator.hasNext()) { + Object mop = iterator.next().collisionRayTrace(start, end); if (mop instanceof ExtendedMOP) { ExtendedMOP extended = (ExtendedMOP) mop; extended.data = new Tuple2<>(i, extended.data); list.add(extended); } + i++; } Collections.sort(list); @@ -488,7 +507,7 @@ public class TileMultipart extends TileEntity implements IChunkLoadTile { /** Drop and remove part at index (internal mining callback). */ public void harvestPart(int index, ExtendedMOP hit, EntityPlayer player) { - TMultiPart part = parts().get(index); + TMultiPart part = partList.apply(index); if (part != null) { part.harvest(hit, player); } @@ -506,7 +525,9 @@ public class TileMultipart extends TileEntity implements IChunkLoadTile { public final void writeToNBT(NBTTagCompound tag) { super.writeToNBT(tag); NBTTagList taglist = new NBTTagList(); - for (TMultiPart part : parts()) { + Iterator iterator = partList.iterator(); + while (iterator.hasNext()) { + TMultiPart part = iterator.next(); NBTTagCompound parttag = new NBTTagCompound(); parttag.setString("id", part.getType()); part.save(parttag); @@ -535,8 +556,8 @@ public class TileMultipart extends TileEntity implements IChunkLoadTile { return false; } - /** Mutable snapshot of the current parts. Mutating it does not affect the published Seq. */ - private List parts() { + /** Mutable snapshot used only while publishing a replacement Seq. */ + private List mutablePartsSnapshot() { return new ArrayList<>(JavaConversions.seqAsJavaList(partList)); }