#tick and #beginFrame on creation

- Fixes weird delay in object appearance when reloading chunks
This commit is contained in:
Jozufozu 2021-12-08 12:28:22 -08:00
parent 008c6c1e3f
commit e575b1c580
3 changed files with 11 additions and 5 deletions

View file

@ -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.
* <br>
* <em>DISPATCHED IN PARALLEL</em>, don't attempt to mutate anything outside of this instance.
* <em>DISPATCHED IN PARALLEL</em>, don't attempt to mutate anything outside this instance.
* <br>
* {@link Instancer}/{@link InstanceData} creation/acquisition is safe here.
*/

View file

@ -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.
* <br>
* <em>DISPATCHED IN PARALLEL</em>, don't attempt to mutate anything outside of this instance.
* <br>

View file

@ -294,9 +294,15 @@ public abstract class InstanceManager<T> 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;