From e575b1c58094f91e3374fbf8c526aec1deb11237 Mon Sep 17 00:00:00 2001 From: Jozufozu Date: Wed, 8 Dec 2021 12:28:22 -0800 Subject: [PATCH] #tick and #beginFrame on creation - Fixes weird delay in object appearance when reloading chunks --- .../flywheel/backend/instancing/IDynamicInstance.java | 4 ++-- .../flywheel/backend/instancing/ITickableInstance.java | 2 +- .../flywheel/backend/instancing/InstanceManager.java | 10 ++++++++-- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/IDynamicInstance.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/IDynamicInstance.java index e801d16f8..5f598022a 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/IDynamicInstance.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/IDynamicInstance.java @@ -13,9 +13,9 @@ import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance; */ public interface IDynamicInstance extends IInstance { /** - * Called every frame. + * Called every frame, and after initialization. *
- * DISPATCHED IN PARALLEL, don't attempt to mutate anything outside of this instance. + * DISPATCHED IN PARALLEL, don't attempt to mutate anything outside this instance. *
* {@link Instancer}/{@link InstanceData} creation/acquisition is safe here. */ diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/ITickableInstance.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/ITickableInstance.java index 71e5e1d8d..0e97b5327 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/ITickableInstance.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/ITickableInstance.java @@ -21,7 +21,7 @@ import com.jozufozu.flywheel.backend.instancing.tile.TileEntityInstance; public interface ITickableInstance extends IInstance { /** - * Called every tick. + * Called every tick, and after initialization. *
* DISPATCHED IN PARALLEL, don't attempt to mutate anything outside of this instance. *
diff --git a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceManager.java b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceManager.java index 2eee2f458..535357ff3 100644 --- a/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceManager.java +++ b/src/main/java/com/jozufozu/flywheel/backend/instancing/InstanceManager.java @@ -294,9 +294,15 @@ public abstract class InstanceManager implements InstancingEngine.OriginShift .addListener(renderer); instances.put(obj, renderer); - if (renderer instanceof IDynamicInstance) dynamicInstances.put(obj, (IDynamicInstance) renderer); + if (renderer instanceof ITickableInstance r) { + tickableInstances.put(obj, r); + r.tick(); + } - if (renderer instanceof ITickableInstance) tickableInstances.put(obj, ((ITickableInstance) renderer)); + if (renderer instanceof IDynamicInstance r) { + dynamicInstances.put(obj, r); + r.beginFrame(); + } } return renderer;