Skip to content

Commit

Permalink
Lit on init
Browse files Browse the repository at this point in the history
- Automatically call updateLight upon visual creation
  • Loading branch information
Jozufozu committed Jul 19, 2024
1 parent fe0eaca commit cc0ad90
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@
*/
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>
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public void recreateAll(float partialTick) {
var out = createRaw(obj, partialTick);

if (out != null) {
setup(out);
setup(out, partialTick);
}

return out;
Expand All @@ -139,15 +139,15 @@ private void create(T obj, float partialTick) {
var visual = createRaw(obj, partialTick);

if (visual != null) {
setup(visual);
setup(visual, partialTick);
visuals.put(obj, visual);
}
}

@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);
Expand All @@ -172,6 +172,7 @@ private void setup(Visual visual) {

if (visual instanceof LightUpdatedVisual lightUpdated) {
lightUpdatedVisuals.add(lightUpdated, tracker);
lightUpdated.updateLight(partialTick);
}

if (visual instanceof ShaderLightVisual shaderLight) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ public BellVisual(VisualizationContext ctx, BellBlockEntity blockEntity, float p
bell.setChanged();

updateRotation(partialTick);
updateLight(partialTick);
}

private OrientedInstance createBellInstance() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ public ChestVisual(VisualizationContext ctx, T blockEntity, float partialTick) {
bottom.setChanged();

applyLidTransform(lidProgress.get(partialTick));
updateLight(partialTick);
}

private OrientedInstance createBottomInstance(Material texture) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ public ShulkerBoxVisual(VisualizationContext ctx, ShulkerBoxBlockEntity blockEnt
base.setChanged();
lid = createLidInstance(texture).setTransform(stack);
lid.setChanged();

updateLight(partialTick);
}

private TransformedInstance createBaseInstance(Material texture) {
Expand Down

0 comments on commit cc0ad90

Please sign in to comment.