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 {
/**
* Called when a section this visual is contained in receives a light update. It is not called
* unconditionally after visual creation or {@link SectionCollector#sections}.
* Called after visual construction and when a section this visual is contained in receives a light update.
*
* <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);
if (out != null) {
setup(out);
setup(out, partialTick);
}
return out;
@ -139,7 +139,7 @@ public abstract class Storage<T> {
var visual = createRaw(obj, partialTick);
if (visual != null) {
setup(visual);
setup(visual, partialTick);
visuals.put(obj, visual);
}
}
@ -147,7 +147,7 @@ public abstract class Storage<T> {
@Nullable
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 SimpleDynamicVisual simpleDynamic) {
simpleDynamicVisuals.add(simpleDynamic);
@ -172,6 +172,7 @@ public abstract class Storage<T> {
if (visual instanceof LightUpdatedVisual lightUpdated) {
lightUpdatedVisuals.add(lightUpdated, tracker);
lightUpdated.updateLight(partialTick);
}
if (visual instanceof ShaderLightVisual shaderLight) {

View file

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

View file

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

View file

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