Put a lid on it

- Apply lid transform in ChestVisual#init.
- Fixes a horrifying bug where all chest lids you haven't looked
  directly at yet appear coinciding at the origin.
This commit is contained in:
Jozufozu 2023-11-30 17:14:09 -08:00
parent 59a03ad811
commit f6cf019486

View File

@ -82,7 +82,6 @@ public class ChestVisual<T extends BlockEntity & LidBlockEntity> extends Abstrac
if (block instanceof AbstractChestBlock<?> chestBlock) { if (block instanceof AbstractChestBlock<?> chestBlock) {
float horizontalAngle = blockState.getValue(ChestBlock.FACING).toYRot(); float horizontalAngle = blockState.getValue(ChestBlock.FACING).toYRot();
baseRotation.setAngleAxis(Math.toRadians(-horizontalAngle), 0, 1, 0); baseRotation.setAngleAxis(Math.toRadians(-horizontalAngle), 0, 1, 0);
bottom.setRotation(baseRotation);
DoubleBlockCombiner.NeighborCombineResult<? extends ChestBlockEntity> wrapper = chestBlock.combine(blockState, level, pos, true); DoubleBlockCombiner.NeighborCombineResult<? extends ChestBlockEntity> wrapper = chestBlock.combine(blockState, level, pos, true);
lidProgress = wrapper.apply(ChestBlock.opennessCombiner(blockEntity)); lidProgress = wrapper.apply(ChestBlock.opennessCombiner(blockEntity));
@ -91,6 +90,10 @@ public class ChestVisual<T extends BlockEntity & LidBlockEntity> extends Abstrac
lidProgress = $ -> 0f; lidProgress = $ -> 0f;
} }
bottom.setRotation(baseRotation);
applyLidTransform(lidProgress.get(partialTick));
super.init(partialTick); super.init(partialTick);
} }
@ -126,6 +129,10 @@ public class ChestVisual<T extends BlockEntity & LidBlockEntity> extends Abstrac
} }
lastProgress = progress; lastProgress = progress;
applyLidTransform(progress);
}
private void applyLidTransform(float progress) {
progress = 1.0F - progress; progress = 1.0F - progress;
progress = 1.0F - progress * progress * progress; progress = 1.0F - progress * progress * progress;