diff --git a/src/main/java/com/jozufozu/flywheel/lib/instance/ColoredLitInstance.java b/src/main/java/com/jozufozu/flywheel/lib/instance/ColoredLitInstance.java index d3a407a02..2c1690fa9 100644 --- a/src/main/java/com/jozufozu/flywheel/lib/instance/ColoredLitInstance.java +++ b/src/main/java/com/jozufozu/flywheel/lib/instance/ColoredLitInstance.java @@ -5,7 +5,7 @@ import com.jozufozu.flywheel.api.instance.InstanceType; import net.minecraft.client.renderer.LightTexture; -public abstract class ColoredLitInstance extends AbstractInstance implements FlatLit { +public abstract class ColoredLitInstance extends AbstractInstance implements FlatLit { public byte blockLight; public byte skyLight; @@ -21,14 +21,12 @@ public abstract class ColoredLitInstance extends AbstractInstance implements Fla @Override public ColoredLitInstance setBlockLight(int blockLight) { this.blockLight = (byte) blockLight; - setChanged(); return this; } @Override public ColoredLitInstance setSkyLight(int skyLight) { this.skyLight = (byte) skyLight; - setChanged(); return this; } @@ -62,7 +60,6 @@ public abstract class ColoredLitInstance extends AbstractInstance implements Fla this.r = r; this.g = g; this.b = b; - setChanged(); return this; } @@ -71,7 +68,6 @@ public abstract class ColoredLitInstance extends AbstractInstance implements Fla this.g = g; this.b = b; this.a = a; - setChanged(); return this; } } diff --git a/src/main/java/com/jozufozu/flywheel/lib/instance/FlatLit.java b/src/main/java/com/jozufozu/flywheel/lib/instance/FlatLit.java index 17d81b96b..01a77c9ea 100644 --- a/src/main/java/com/jozufozu/flywheel/lib/instance/FlatLit.java +++ b/src/main/java/com/jozufozu/flywheel/lib/instance/FlatLit.java @@ -11,29 +11,27 @@ import net.minecraft.world.level.LightLayer; * if they wish to make use of Flywheel's provided light update methods. *

* This only covers flat lighting, smooth lighting is still TODO. - * - * @param The name of the class that implements this interface. */ -public interface FlatLit> { +public interface FlatLit extends Instance { /** * @param blockLight An integer in the range [0, 15] representing the * amount of block light this instance should receive. * @return {@code this} */ - I setBlockLight(int blockLight); + FlatLit setBlockLight(int blockLight); /** * @param skyLight An integer in the range [0, 15] representing the * amount of sky light this instance should receive. * @return {@code this} */ - I setSkyLight(int skyLight); + FlatLit setSkyLight(int skyLight); - default I setLight(int blockLight, int skyLight) { + default FlatLit setLight(int blockLight, int skyLight) { return setBlockLight(blockLight).setSkyLight(skyLight); } - default I updateLight(BlockAndTintGetter level, BlockPos pos) { + default FlatLit updateLight(BlockAndTintGetter level, BlockPos pos) { return setLight(level.getBrightness(LightLayer.BLOCK, pos), level.getBrightness(LightLayer.SKY, pos)); } diff --git a/src/main/java/com/jozufozu/flywheel/lib/instance/OrientedInstance.java b/src/main/java/com/jozufozu/flywheel/lib/instance/OrientedInstance.java index ac6c7e4b8..82bb7be6f 100644 --- a/src/main/java/com/jozufozu/flywheel/lib/instance/OrientedInstance.java +++ b/src/main/java/com/jozufozu/flywheel/lib/instance/OrientedInstance.java @@ -26,25 +26,21 @@ public class OrientedInstance extends ColoredLitInstance implements Rotate If your instances need it, update light here. + *
+ * If your instances need it, update light here. */ public void updateLight() { } @@ -73,21 +73,25 @@ public abstract class AbstractVisual implements Visual, LightListener { return deleted; } - protected void relight(BlockPos pos, FlatLit... instances) { + protected void relight(BlockPos pos, FlatLit... instances) { relight(level.getBrightness(LightLayer.BLOCK, pos), level.getBrightness(LightLayer.SKY, pos), instances); } - protected void relight(int block, int sky, FlatLit... instances) { - for (FlatLit instance : instances) { + protected void relight(int block, int sky, FlatLit... instances) { + for (FlatLit instance : instances) { instance.setLight(block, sky); + instance.handle() + .setChanged(); } } - protected > void relight(BlockPos pos, Stream instances) { + protected void relight(BlockPos pos, Stream instances) { relight(level.getBrightness(LightLayer.BLOCK, pos), level.getBrightness(LightLayer.SKY, pos), instances); } - protected > void relight(int block, int sky, Stream instances) { - instances.forEach(model -> model.setLight(block, sky)); + protected void relight(int block, int sky, Stream instances) { + instances.forEach(model -> model.setLight(block, sky) + .handle() + .setChanged()); } } diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/BellVisual.java b/src/main/java/com/jozufozu/flywheel/vanilla/BellVisual.java index f23e0d33f..479bde389 100644 --- a/src/main/java/com/jozufozu/flywheel/vanilla/BellVisual.java +++ b/src/main/java/com/jozufozu/flywheel/vanilla/BellVisual.java @@ -79,6 +79,8 @@ public class BellVisual extends AbstractBlockEntityVisual imple } else { bell.setRotation(new Quaternionf()); } + + bell.setChanged(); } @Override diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/ChestVisual.java b/src/main/java/com/jozufozu/flywheel/vanilla/ChestVisual.java index af6fae6e1..15311ce24 100644 --- a/src/main/java/com/jozufozu/flywheel/vanilla/ChestVisual.java +++ b/src/main/java/com/jozufozu/flywheel/vanilla/ChestVisual.java @@ -59,7 +59,6 @@ public class ChestVisual extends Abstrac private TransformedInstance lock; private ChestType chestType; - private Material texture; private final Quaternionf baseRotation = new Quaternionf(); private Float2FloatFunction lidProgress; @@ -72,11 +71,11 @@ public class ChestVisual extends Abstrac @Override public void init(float partialTick) { chestType = blockState.hasProperty(ChestBlock.TYPE) ? blockState.getValue(ChestBlock.TYPE) : ChestType.SINGLE; - texture = Sheets.chooseMaterial(blockEntity, chestType, isChristmas()); + Material texture = Sheets.chooseMaterial(blockEntity, chestType, isChristmas()); - bottom = createBottomInstance().setPosition(getVisualPosition()); - lid = createLidInstance(); - lock = createLockInstance(); + bottom = createBottomInstance(texture).setPosition(getVisualPosition()); + lid = createLidInstance(texture); + lock = createLockInstance(texture); Block block = blockState.getBlock(); if (block instanceof AbstractChestBlock chestBlock) { @@ -97,17 +96,17 @@ public class ChestVisual extends Abstrac super.init(partialTick); } - private OrientedInstance createBottomInstance() { + private OrientedInstance createBottomInstance(Material texture) { return instancerProvider.instancer(InstanceTypes.ORIENTED, BOTTOM_MODELS.get(Pair.of(chestType, texture)), RenderStage.AFTER_BLOCK_ENTITIES) .createInstance(); } - private TransformedInstance createLidInstance() { + private TransformedInstance createLidInstance(Material texture) { return instancerProvider.instancer(InstanceTypes.TRANSFORMED, LID_MODELS.get(Pair.of(chestType, texture)), RenderStage.AFTER_BLOCK_ENTITIES) .createInstance(); } - private TransformedInstance createLockInstance() { + private TransformedInstance createLockInstance(Material texture) { return instancerProvider.instancer(InstanceTypes.TRANSFORMED, LOCK_MODELS.get(Pair.of(chestType, texture)), RenderStage.AFTER_BLOCK_ENTITIES) .createInstance(); } @@ -143,14 +142,16 @@ public class ChestVisual extends Abstrac .rotateCentered(baseRotation) .translate(0, 9f / 16f, 1f / 16f) .rotateX(angleX) - .translate(0, -9f / 16f, -1f / 16f); + .translate(0, -9f / 16f, -1f / 16f) + .setChanged(); lock.loadIdentity() .translate(getVisualPosition()) .rotateCentered(baseRotation) .translate(0, 8f / 16f, 0) .rotateX(angleX) - .translate(0, -8f / 16f, 0); + .translate(0, -8f / 16f, 0) + .setChanged(); } @Override diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/MinecartVisual.java b/src/main/java/com/jozufozu/flywheel/vanilla/MinecartVisual.java index a00a3ebed..45606dfcf 100644 --- a/src/main/java/com/jozufozu/flywheel/vanilla/MinecartVisual.java +++ b/src/main/java/com/jozufozu/flywheel/vanilla/MinecartVisual.java @@ -163,12 +163,14 @@ public class MinecartVisual extends AbstractEntityVi stack.scale(0.75F, 0.75F, 0.75F); stack.translate(-0.5D, (float) (displayOffset - 8) / 16, 0.5D); stack.mulPose(Axis.YP.rotationDegrees(90)); - contents.setTransform(stack); + contents.setTransform(stack) + .setChanged(); stack.popPose(); } stack.scale(-1.0F, -1.0F, 1.0F); - body.setTransform(stack); + body.setTransform(stack) + .setChanged(); } @Override diff --git a/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxVisual.java b/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxVisual.java index 5fcd540cc..b0c99e4fb 100644 --- a/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxVisual.java +++ b/src/main/java/com/jozufozu/flywheel/vanilla/ShulkerBoxVisual.java @@ -39,7 +39,6 @@ public class ShulkerBoxVisual extends AbstractBlockEntityVisual