Lit on init

- Automatically call updateLight upon visual creation
This commit is contained in:
Jozufozu 2024-07-19 12:50:08 -07:00
parent fe0eacad8e
commit cc0ad90242
5 changed files with 5 additions and 9 deletions

View file

@ -9,8 +9,7 @@ package dev.engine_room.flywheel.api.visual;
*/ */
public non-sealed interface LightUpdatedVisual extends SectionTrackedVisual { public non-sealed interface LightUpdatedVisual extends SectionTrackedVisual {
/** /**
* Called when a section this visual is contained in receives a light update. It is not called * Called after visual construction and when a section this visual is contained in receives a light update.
* unconditionally after visual creation or {@link SectionCollector#sections}.
* *
* <p>Even if multiple sections are updated at the same time, this method will only be called once.</p> * <p>Even if multiple sections are updated at the same time, this method will only be called once.</p>
* *

View file

@ -128,7 +128,7 @@ public abstract class Storage<T> {
var out = createRaw(obj, partialTick); var out = createRaw(obj, partialTick);
if (out != null) { if (out != null) {
setup(out); setup(out, partialTick);
} }
return out; return out;
@ -139,7 +139,7 @@ public abstract class Storage<T> {
var visual = createRaw(obj, partialTick); var visual = createRaw(obj, partialTick);
if (visual != null) { if (visual != null) {
setup(visual); setup(visual, partialTick);
visuals.put(obj, visual); visuals.put(obj, visual);
} }
} }
@ -147,7 +147,7 @@ public abstract class Storage<T> {
@Nullable @Nullable
protected abstract Visual createRaw(T obj, float partialTick); protected abstract Visual createRaw(T obj, float partialTick);
private void setup(Visual visual) { private void setup(Visual visual, float partialTick) {
if (visual instanceof DynamicVisual dynamic) { if (visual instanceof DynamicVisual dynamic) {
if (visual instanceof SimpleDynamicVisual simpleDynamic) { if (visual instanceof SimpleDynamicVisual simpleDynamic) {
simpleDynamicVisuals.add(simpleDynamic); simpleDynamicVisuals.add(simpleDynamic);
@ -172,6 +172,7 @@ public abstract class Storage<T> {
if (visual instanceof LightUpdatedVisual lightUpdated) { if (visual instanceof LightUpdatedVisual lightUpdated) {
lightUpdatedVisuals.add(lightUpdated, tracker); lightUpdatedVisuals.add(lightUpdated, tracker);
lightUpdated.updateLight(partialTick);
} }
if (visual instanceof ShaderLightVisual shaderLight) { if (visual instanceof ShaderLightVisual shaderLight) {

View file

@ -38,7 +38,6 @@ public class BellVisual extends AbstractBlockEntityVisual<BellBlockEntity> imple
bell.setChanged(); bell.setChanged();
updateRotation(partialTick); updateRotation(partialTick);
updateLight(partialTick);
} }
private OrientedInstance createBellInstance() { private OrientedInstance createBellInstance() {

View file

@ -88,7 +88,6 @@ public class ChestVisual<T extends BlockEntity & LidBlockEntity> extends Abstrac
bottom.setChanged(); bottom.setChanged();
applyLidTransform(lidProgress.get(partialTick)); applyLidTransform(lidProgress.get(partialTick));
updateLight(partialTick);
} }
private OrientedInstance createBottomInstance(Material texture) { private OrientedInstance createBottomInstance(Material texture) {

View file

@ -67,8 +67,6 @@ public class ShulkerBoxVisual extends AbstractBlockEntityVisual<ShulkerBoxBlockE
base.setChanged(); base.setChanged();
lid = createLidInstance(texture).setTransform(stack); lid = createLidInstance(texture).setTransform(stack);
lid.setChanged(); lid.setChanged();
updateLight(partialTick);
} }
private TransformedInstance createBaseInstance(Material texture) { private TransformedInstance createBaseInstance(Material texture) {