mirror of
https://github.com/Jozufozu/Flywheel.git
synced 2024-12-27 07:26:48 +01:00
Un unchanged
- Call setChanged in various visuals' #init. - Not everything needs it because some just call their frame update methods right away. - Improve lazy update logic for bells.
This commit is contained in:
parent
1d318ecb02
commit
ec6dbfbf49
3 changed files with 17 additions and 13 deletions
|
@ -31,7 +31,7 @@ public class BellVisual extends AbstractBlockEntityVisual<BellBlockEntity> imple
|
|||
|
||||
private OrientedInstance bell;
|
||||
|
||||
private float lastRingTime = Float.NaN;
|
||||
private boolean wasShaking = false;
|
||||
|
||||
public BellVisual(VisualizationContext ctx, BellBlockEntity blockEntity) {
|
||||
super(ctx, blockEntity);
|
||||
|
@ -42,6 +42,8 @@ public class BellVisual extends AbstractBlockEntityVisual<BellBlockEntity> imple
|
|||
bell = createBellInstance().setPivot(0.5f, 0.75f, 0.5f)
|
||||
.setPosition(getVisualPosition());
|
||||
|
||||
bell.setChanged();
|
||||
|
||||
updateRotation(partialTick);
|
||||
|
||||
super.init(partialTick);
|
||||
|
@ -62,25 +64,23 @@ public class BellVisual extends AbstractBlockEntityVisual<BellBlockEntity> imple
|
|||
}
|
||||
|
||||
private void updateRotation(float partialTick) {
|
||||
float ringTime = (float) blockEntity.ticks + partialTick;
|
||||
|
||||
if (ringTime == lastRingTime) {
|
||||
return;
|
||||
}
|
||||
lastRingTime = ringTime;
|
||||
|
||||
if (blockEntity.shaking) {
|
||||
float ringTime = (float) blockEntity.ticks + partialTick;
|
||||
float angle = Mth.sin(ringTime / (float) Math.PI) / (4.0F + ringTime / 3.0F);
|
||||
|
||||
Vector3f ringAxis = blockEntity.clickDirection.getCounterClockWise()
|
||||
.step();
|
||||
|
||||
bell.setRotation(new Quaternionf(new AxisAngle4f(angle, ringAxis)));
|
||||
} else {
|
||||
bell.setRotation(new Quaternionf());
|
||||
}
|
||||
bell.setRotation(new Quaternionf(new AxisAngle4f(angle, ringAxis)))
|
||||
.setChanged();
|
||||
|
||||
bell.setChanged();
|
||||
wasShaking = true;
|
||||
} else if (wasShaking) {
|
||||
bell.setRotation(new Quaternionf())
|
||||
.setChanged();
|
||||
|
||||
wasShaking = false;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -90,6 +90,7 @@ public class ChestVisual<T extends BlockEntity & LidBlockEntity> extends Abstrac
|
|||
}
|
||||
|
||||
bottom.setRotation(baseRotation);
|
||||
bottom.setChanged();
|
||||
|
||||
applyLidTransform(lidProgress.get(partialTick));
|
||||
|
||||
|
|
|
@ -71,6 +71,9 @@ public class ShulkerBoxVisual extends AbstractBlockEntityVisual<ShulkerBoxBlockE
|
|||
base = createBaseInstance(texture).setTransform(stack);
|
||||
lid = createLidInstance(texture).setTransform(stack);
|
||||
|
||||
base.setChanged();
|
||||
lid.setChanged();
|
||||
|
||||
super.init(partialTick);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue