Redrawals

- Fixed schematic rendering offset by a tick
- Fixed item vaults not marking themselves as needed to be saved
- Fixed steam engines not rotating with their shaft when not animating
This commit is contained in:
simibubi 2025-02-11 14:28:11 +01:00
parent 0c21da9899
commit e67d8da904
4 changed files with 18 additions and 19 deletions

View file

@ -26,6 +26,7 @@ public class SteamEngineVisual extends AbstractBlockEntityVisual<SteamEngineBloc
protected final TransformedInstance connector; protected final TransformedInstance connector;
private Float lastAngle = Float.NaN; private Float lastAngle = Float.NaN;
private Axis lastAxis = null;
public SteamEngineVisual(VisualizationContext context, SteamEngineBlockEntity blockEntity, float partialTick) { public SteamEngineVisual(VisualizationContext context, SteamEngineBlockEntity blockEntity, float partialTick) {
super(context, blockEntity, partialTick); super(context, blockEntity, partialTick);
@ -47,11 +48,18 @@ public class SteamEngineVisual extends AbstractBlockEntityVisual<SteamEngineBloc
private void animate() { private void animate() {
Float angle = blockEntity.getTargetAngle(); Float angle = blockEntity.getTargetAngle();
Axis axis = Axis.Y;
if (Objects.equals(angle, lastAngle)) { PoweredShaftBlockEntity shaft = blockEntity.getShaft();
if (shaft != null)
axis = KineticBlockEntityRenderer.getRotationAxisOf(shaft);
if (Objects.equals(angle, lastAngle) && lastAxis == axis) {
return; return;
} }
lastAngle = angle; lastAngle = angle;
lastAxis = axis;
if (angle == null) { if (angle == null) {
piston.setVisible(false); piston.setVisible(false);
@ -66,11 +74,6 @@ public class SteamEngineVisual extends AbstractBlockEntityVisual<SteamEngineBloc
Direction facing = SteamEngineBlock.getFacing(blockState); Direction facing = SteamEngineBlock.getFacing(blockState);
Axis facingAxis = facing.getAxis(); Axis facingAxis = facing.getAxis();
Axis axis = Axis.Y;
PoweredShaftBlockEntity shaft = blockEntity.getShaft();
if (shaft != null)
axis = KineticBlockEntityRenderer.getRotationAxisOf(shaft);
boolean roll90 = facingAxis.isHorizontal() && axis == Axis.Y || facingAxis.isVertical() && axis == Axis.Z; boolean roll90 = facingAxis.isHorizontal() && axis == Axis.Y || facingAxis.isVertical() && axis == Axis.Z;
float sine = Mth.sin(angle); float sine = Mth.sin(angle);

View file

@ -47,6 +47,7 @@ public class ItemVaultBlockEntity extends SmartBlockEntity implements IMultiBloc
protected void onContentsChanged(int slot) { protected void onContentsChanged(int slot) {
super.onContentsChanged(slot); super.onContentsChanged(slot);
updateComparators(); updateComparators();
level.blockEntityChanged(worldPosition);
} }
}; };

View file

@ -98,8 +98,6 @@ public class SchematicHandler implements IGuiOverlay {
if (activeSchematicItem != null && transformation != null) if (activeSchematicItem != null && transformation != null)
transformation.tick(); transformation.tick();
renderers.forEach(SchematicRenderer::tick);
LocalPlayer player = mc.player; LocalPlayer player = mc.player;
ItemStack stack = findBlueprintInHand(player); ItemStack stack = findBlueprintInHand(player);
if (stack == null) { if (stack == null) {

View file

@ -53,20 +53,17 @@ public class SchematicRenderer {
changed = true; changed = true;
} }
public void tick() {
if (!active)
return;
Minecraft mc = Minecraft.getInstance();
if (mc.level == null || mc.player == null || !changed)
return;
redraw();
changed = false;
}
public void render(PoseStack ms, SuperRenderTypeBuffer buffers) { public void render(PoseStack ms, SuperRenderTypeBuffer buffers) {
if (!active) if (!active)
return; return;
Minecraft mc = Minecraft.getInstance();
if (mc.level == null || mc.player == null)
return;
if (changed)
redraw();
changed = false;
bufferCache.forEach((layer, buffer) -> { bufferCache.forEach((layer, buffer) -> {
buffer.renderInto(ms, buffers.getBuffer(layer)); buffer.renderInto(ms, buffers.getBuffer(layer));
}); });