fix a contraption lighting glitch

This commit is contained in:
JozsefA 2021-01-25 01:58:39 -08:00
parent 93353b61d6
commit 1874b267b3
3 changed files with 11 additions and 7 deletions

View file

@ -21,6 +21,7 @@ public class NonStationaryLighter<C extends Contraption> extends ContraptionLigh
@Override @Override
public void tick(RenderedContraption owner) { public void tick(RenderedContraption owner) {
super.tick(owner);
GridAlignedBB contraptionBounds = getContraptionBounds(); GridAlignedBB contraptionBounds = getContraptionBounds();
if (!contraptionBounds.sameAs(bounds)) { if (!contraptionBounds.sameAs(bounds)) {

View file

@ -32,7 +32,7 @@ public class RenderedContraption {
public final ContraptionKineticRenderer kinetics; public final ContraptionKineticRenderer kinetics;
private Contraption contraption; public Contraption contraption;
private Matrix4f model; private Matrix4f model;

View file

@ -2,11 +2,6 @@ package com.simibubi.create.foundation.render.light;
import com.simibubi.create.content.contraptions.components.structureMovement.Contraption; import com.simibubi.create.content.contraptions.components.structureMovement.Contraption;
import com.simibubi.create.foundation.render.contraption.RenderedContraption; import com.simibubi.create.foundation.render.contraption.RenderedContraption;
import net.minecraft.util.math.SectionPos;
import net.minecraft.world.ILightReader;
import net.minecraft.world.LightType;
import static com.simibubi.create.foundation.render.RenderMath.nextPowerOf2;
public abstract class ContraptionLighter<C extends Contraption> { public abstract class ContraptionLighter<C extends Contraption> {
protected final C contraption; protected final C contraption;
@ -14,6 +9,8 @@ public abstract class ContraptionLighter<C extends Contraption> {
protected GridAlignedBB bounds; protected GridAlignedBB bounds;
protected boolean scheduleRebuild;
protected ContraptionLighter(C contraption) { protected ContraptionLighter(C contraption) {
this.contraption = contraption; this.contraption = contraption;
@ -22,6 +19,7 @@ public abstract class ContraptionLighter<C extends Contraption> {
lightVolume = new LightVolume(contraptionBoundsToVolume(bounds)); lightVolume = new LightVolume(contraptionBoundsToVolume(bounds));
lightVolume.initialize(contraption.entity.world); lightVolume.initialize(contraption.entity.world);
scheduleRebuild = true;
} }
protected GridAlignedBB contraptionBoundsToVolume(GridAlignedBB bounds) { protected GridAlignedBB contraptionBoundsToVolume(GridAlignedBB bounds) {
@ -33,7 +31,12 @@ public abstract class ContraptionLighter<C extends Contraption> {
return bounds; return bounds;
} }
public void tick(RenderedContraption owner) {} public void tick(RenderedContraption owner) {
if (scheduleRebuild) {
lightVolume.initialize(owner.contraption.entity.world);
scheduleRebuild = false;
}
}
public abstract GridAlignedBB getContraptionBounds(); public abstract GridAlignedBB getContraptionBounds();
} }