From dc20f7091c048c9362c314b6b192a370619e1146 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Wed, 22 Jun 2022 13:44:34 -0700 Subject: [PATCH] Mopping up - Fixes contraption world leak twofold. - Bump flywheel - 0.6.3.81 --- gradle.properties | 2 +- .../render/ContraptionInstanceManager.java | 46 ++++++++++++++++++- src/main/resources/META-INF/mods.toml | 2 +- 3 files changed, 46 insertions(+), 4 deletions(-) diff --git a/gradle.properties b/gradle.properties index bd8bf3487..3d944f571 100644 --- a/gradle.properties +++ b/gradle.properties @@ -19,7 +19,7 @@ parchment_version = 2022.03.13 # dependency versions registrate_version = MC1.18.2-1.0.25 -flywheel_version = 1.18-0.6.2.66 +flywheel_version = 1.18-0.6.3.81 jei_minecraft_version = 1.18.2 jei_version = 9.5.3.143 curios_minecraft_version = 1.18.2 diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionInstanceManager.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionInstanceManager.java index 97a8925a1..bd0f85cd6 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionInstanceManager.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionInstanceManager.java @@ -8,6 +8,8 @@ import org.apache.commons.lang3.tuple.Pair; import com.jozufozu.flywheel.api.MaterialManager; import com.jozufozu.flywheel.api.instance.DynamicInstance; +import com.jozufozu.flywheel.api.instance.TickableInstance; +import com.jozufozu.flywheel.backend.instancing.AbstractInstance; import com.jozufozu.flywheel.backend.instancing.TaskEngine; import com.jozufozu.flywheel.backend.instancing.blockentity.BlockEntityInstanceManager; import com.jozufozu.flywheel.core.virtual.VirtualRenderWorld; @@ -37,7 +39,7 @@ public class ContraptionInstanceManager extends BlockEntityInstanceManager { public void tick() { actors.forEach(ActorInstance::tick); } - + @Override protected boolean canCreateInstance(BlockEntity blockEntity) { return !contraption.isHiddenInPortal(blockEntity.getBlockPos()); @@ -59,7 +61,7 @@ public class ContraptionInstanceManager extends BlockEntityInstanceManager { public ActorInstance createActor(Pair actor) { StructureBlockInfo blockInfo = actor.getLeft(); MovementContext context = actor.getRight(); - + if (contraption.isHiddenInPortal(context.localPos)) return null; @@ -75,5 +77,45 @@ public class ContraptionInstanceManager extends BlockEntityInstanceManager { return null; } + + // ----------------------------------------------------------------- + // The following methods should be identical to the base methods, + // but without reference to LightUpdater. + // ----------------------------------------------------------------- + + @Override + protected AbstractInstance createInternal(BlockEntity obj) { + AbstractInstance renderer = createRaw(obj); + + if (renderer != null) { + renderer.init(); + renderer.updateLight(); + instances.put(obj, renderer); + + if (renderer instanceof TickableInstance r) { + tickableInstances.put(obj, r); + r.tick(); + } + + if (renderer instanceof DynamicInstance r) { + dynamicInstances.put(obj, r); + r.beginFrame(); + } + } + + return renderer; + } + + protected void removeInternal(BlockEntity obj, AbstractInstance instance) { + instance.remove(); + instances.remove(obj); + dynamicInstances.remove(obj); + tickableInstances.remove(obj); + } + + @Override + public void detachLightListeners() { + // noop + } } diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 8a89c38d4..8f3659b0b 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -32,6 +32,6 @@ Technology that empowers the player.''' [[dependencies.create]] modId="flywheel" mandatory=true - versionRange="[1.18-0.6.2,1.18-0.6.3)" + versionRange="[1.18-0.6.3,1.18-0.6.4)" ordering="AFTER" side="CLIENT"