From f03bf9839cdc14ace97aa1fbd496863fb0e6d12f Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Sun, 10 Jul 2022 15:44:15 -0400 Subject: [PATCH] A pulley good day - Fix crash when moving pulleys on a contraption - Bump forge and parchment versions - Bump flywheel version --- gradle.properties | 6 +-- .../NonStationaryLighter.java | 9 ++--- .../pulley/AbstractPulleyInstance.java | 20 +++++----- .../render/ContraptionInstanceManager.java | 37 +------------------ .../render/ContraptionLighter.java | 18 ++++----- .../relays/belt/BeltTileEntity.java | 8 ++-- src/main/resources/META-INF/mods.toml | 2 +- 7 files changed, 29 insertions(+), 71 deletions(-) diff --git a/gradle.properties b/gradle.properties index 2fdc49db7..9191ff8de 100644 --- a/gradle.properties +++ b/gradle.properties @@ -6,7 +6,7 @@ org.gradle.daemon = false # mod version info mod_version = 0.5.0 minecraft_version = 1.18.2 -forge_version = 40.1.54 +forge_version = 40.1.60 # build dependency versions forgegradle_version = 5.1.+ @@ -15,11 +15,11 @@ mixin_version = 0.8.5 librarian_version = 1.+ shadow_version = 7.1.0 cursegradle_version = 1.4.0 -parchment_version = 2022.07.03 +parchment_version = 2022.07.10 # dependency versions registrate_version = MC1.18.2-1.1.3 -flywheel_version = 1.18-0.6.3.81 +flywheel_version = 1.18-0.6.4.83 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/NonStationaryLighter.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/NonStationaryLighter.java index 9a94608dd..3c66e2c60 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/NonStationaryLighter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/NonStationaryLighter.java @@ -1,19 +1,18 @@ package com.simibubi.create.content.contraptions.components.structureMovement; -import com.jozufozu.flywheel.light.LightProvider; -import com.jozufozu.flywheel.light.MovingListener; +import com.jozufozu.flywheel.light.TickingLightListener; import com.jozufozu.flywheel.util.box.GridAlignedBB; import com.jozufozu.flywheel.util.box.ImmutableBox; import com.simibubi.create.content.contraptions.components.structureMovement.render.ContraptionLighter; import com.simibubi.create.foundation.config.AllConfigs; -public class NonStationaryLighter extends ContraptionLighter implements MovingListener { +public class NonStationaryLighter extends ContraptionLighter implements TickingLightListener { public NonStationaryLighter(C contraption) { super(contraption); } @Override - public boolean update(LightProvider provider) { + public boolean tickLightListener() { if (getVolume().volume() > AllConfigs.CLIENT.maxContraptionLightVolume.get()) return false; @@ -25,7 +24,7 @@ public class NonStationaryLighter extends ContraptionLigh bounds.assign(contraptionBounds); growBoundsForEdgeData(bounds); - lightVolume.move(provider, bounds); + lightVolume.move(bounds); return true; } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java index 8e10efb1a..75ff9156a 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/pulley/AbstractPulleyInstance.java @@ -8,10 +8,8 @@ import com.jozufozu.flywheel.core.instancing.GroupInstance; import com.jozufozu.flywheel.core.instancing.SelectInstance; import com.jozufozu.flywheel.core.materials.oriented.OrientedData; import com.jozufozu.flywheel.light.LightPacking; -import com.jozufozu.flywheel.light.LightProvider; -import com.jozufozu.flywheel.light.LightUpdater; import com.jozufozu.flywheel.light.LightVolume; -import com.jozufozu.flywheel.light.MovingListener; +import com.jozufozu.flywheel.light.TickingLightListener; import com.jozufozu.flywheel.util.box.GridAlignedBB; import com.jozufozu.flywheel.util.box.ImmutableBox; import com.mojang.math.Vector3f; @@ -22,7 +20,7 @@ import net.minecraft.core.Direction; import net.minecraft.util.Mth; import net.minecraft.world.level.LightLayer; -public abstract class AbstractPulleyInstance extends ShaftInstance implements DynamicInstance, MovingListener { +public abstract class AbstractPulleyInstance extends ShaftInstance implements DynamicInstance, TickingLightListener { final OrientedData coil; final SelectInstance magnet; @@ -55,8 +53,8 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements Dy updateOffset(); updateVolume(); - light = new LightVolume(volume); - light.initialize(LightUpdater.get(world).getProvider()); + light = new LightVolume(world, volume); + light.initialize(); } @Override @@ -139,9 +137,9 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements Dy protected abstract boolean isRunning(); @Override - public boolean update(LightProvider provider) { + public boolean tickLightListener() { if (updateVolume()) { - light.move(provider, volume); + light.move(volume); return true; } return false; @@ -190,8 +188,8 @@ public abstract class AbstractPulleyInstance extends ShaftInstance implements Dy } @Override - public void onLightUpdate(LightProvider world, LightLayer type, ImmutableBox changed) { - super.onLightUpdate(world, type, changed); - light.onLightUpdate(world, type, changed); + public void onLightUpdate(LightLayer type, ImmutableBox changed) { + super.onLightUpdate(type, changed); + light.onLightUpdate(type, changed); } } 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 d6a2bfdda..df1ed3059 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 @@ -78,44 +78,9 @@ 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 + // noop, no light updater for contraption levels } } diff --git a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionLighter.java b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionLighter.java index 4f6c01008..4ecd4c3cd 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionLighter.java +++ b/src/main/java/com/simibubi/create/content/contraptions/components/structureMovement/render/ContraptionLighter.java @@ -2,9 +2,7 @@ package com.simibubi.create.content.contraptions.components.structureMovement.re import com.jozufozu.flywheel.light.GPULightVolume; import com.jozufozu.flywheel.light.LightListener; -import com.jozufozu.flywheel.light.LightProvider; import com.jozufozu.flywheel.light.LightUpdater; -import com.jozufozu.flywheel.light.ListenerStatus; import com.jozufozu.flywheel.util.box.GridAlignedBB; import com.jozufozu.flywheel.util.box.ImmutableBox; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; @@ -27,9 +25,9 @@ public abstract class ContraptionLighter implements Light bounds = getContraptionBounds(); growBoundsForEdgeData(bounds); - lightVolume = new GPULightVolume(bounds); + lightVolume = new GPULightVolume(contraption.entity.level, bounds); - lightVolume.initialize(lightUpdater.getProvider()); + lightVolume.initialize(); scheduleRebuild = true; lightUpdater.addListener(this); @@ -38,18 +36,18 @@ public abstract class ContraptionLighter implements Light public abstract GridAlignedBB getContraptionBounds(); @Override - public ListenerStatus status() { - return ListenerStatus.OKAY; + public boolean isListenerInvalid() { + return lightVolume.isListenerInvalid(); } @Override - public void onLightUpdate(LightProvider world, LightLayer type, ImmutableBox changed) { - lightVolume.onLightUpdate(world, type, changed); + public void onLightUpdate(LightLayer type, ImmutableBox changed) { + lightVolume.onLightUpdate(type, changed); } @Override - public void onLightPacket(LightProvider world, int chunkX, int chunkZ) { - lightVolume.onLightPacket(world, chunkX, chunkZ); + public void onLightPacket(int chunkX, int chunkZ) { + lightVolume.onLightPacket(chunkX, chunkZ); } protected static void growBoundsForEdgeData(GridAlignedBB bounds) { diff --git a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java index 3723b968c..6405eaf32 100644 --- a/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java +++ b/src/main/java/com/simibubi/create/content/contraptions/relays/belt/BeltTileEntity.java @@ -14,9 +14,7 @@ import java.util.function.Function; import com.jozufozu.flywheel.backend.instancing.InstancedRenderDispatcher; import com.jozufozu.flywheel.light.LightListener; -import com.jozufozu.flywheel.light.LightProvider; import com.jozufozu.flywheel.light.LightUpdater; -import com.jozufozu.flywheel.light.ListenerStatus; import com.jozufozu.flywheel.util.box.GridAlignedBB; import com.jozufozu.flywheel.util.box.ImmutableBox; import com.simibubi.create.AllBlocks; @@ -582,12 +580,12 @@ public class BeltTileEntity extends KineticTileEntity { } @Override - public ListenerStatus status() { - return remove ? ListenerStatus.REMOVE : ListenerStatus.OKAY; + public boolean isListenerInvalid() { + return remove; } @Override - public void onLightUpdate(LightProvider world, LightLayer type, ImmutableBox changed) { + public void onLightUpdate(LightLayer type, ImmutableBox changed) { if (remove) return; if (level == null) diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 8f3659b0b..4f50f76eb 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.3,1.18-0.6.4)" + versionRange="[1.18-0.6.4,1.18-0.6.5)" ordering="AFTER" side="CLIENT"