mirror of
https://github.com/Creators-of-Create/Create.git
synced 2025-01-27 05:18:08 +01:00
Mechanical arm tweaks
- Don't dance if arm speed is zero - Rerender arm after switching back from dancing state (flywheel only) - Formatting
This commit is contained in:
parent
06ca8b0d1c
commit
1d476160cc
2 changed files with 23 additions and 19 deletions
|
@ -37,7 +37,7 @@ public class ArmInstance extends SingleRotatingInstance implements IDynamicInsta
|
|||
private final ArmTileEntity arm;
|
||||
private final Boolean ceiling;
|
||||
|
||||
private boolean firstTick = true;
|
||||
private boolean firstRender = true;
|
||||
|
||||
private float baseAngle = Float.NaN;
|
||||
private float lowerArmAngle = Float.NaN;
|
||||
|
@ -69,8 +69,9 @@ public class ArmInstance extends SingleRotatingInstance implements IDynamicInsta
|
|||
|
||||
@Override
|
||||
public void beginFrame() {
|
||||
if (arm.phase == ArmTileEntity.Phase.DANCING) {
|
||||
if (arm.phase == ArmTileEntity.Phase.DANCING && tile.getSpeed() != 0) {
|
||||
animateArm(true);
|
||||
firstRender = true;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -91,20 +92,19 @@ public class ArmInstance extends SingleRotatingInstance implements IDynamicInsta
|
|||
this.upperArmAngle = upperArmAngleNow;
|
||||
this.headAngle = headAngleNow;
|
||||
|
||||
if (!settled || firstTick)
|
||||
if (!settled || firstRender)
|
||||
animateArm(false);
|
||||
|
||||
if (settled)
|
||||
firstTick = false;
|
||||
if (firstRender)
|
||||
firstRender = false;
|
||||
}
|
||||
|
||||
private void animateArm(boolean rave) {
|
||||
|
||||
int color;
|
||||
float baseAngle;
|
||||
float lowerArmAngle;
|
||||
float upperArmAngle;
|
||||
float headAngle;
|
||||
int color;
|
||||
|
||||
if (rave) {
|
||||
float renderTick = AnimationTickHolder.getRenderTime(this.arm.getWorld()) + (tile.hashCode() % 64);
|
||||
|
@ -112,14 +112,12 @@ public class ArmInstance extends SingleRotatingInstance implements IDynamicInsta
|
|||
lowerArmAngle = MathHelper.lerp((MathHelper.sin(renderTick / 4) + 1) / 2, -45, 15);
|
||||
upperArmAngle = MathHelper.lerp((MathHelper.sin(renderTick / 8) + 1) / 4, -45, 95);
|
||||
headAngle = -lowerArmAngle;
|
||||
|
||||
color = ColorHelper.rainbowColor(AnimationTickHolder.getTicks() * 100);
|
||||
} else {
|
||||
baseAngle = this.baseAngle;
|
||||
lowerArmAngle = this.lowerArmAngle - 135;
|
||||
upperArmAngle = this.upperArmAngle - 90;
|
||||
headAngle = this.headAngle;
|
||||
|
||||
color = 0xFFFFFF;
|
||||
}
|
||||
|
||||
|
@ -182,4 +180,5 @@ public class ArmInstance extends SingleRotatingInstance implements IDynamicInsta
|
|||
super.remove();
|
||||
models.forEach(InstanceData::delete);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -40,12 +40,11 @@ public class ArmRenderer extends KineticTileEntityRenderer {
|
|||
protected void renderSafe(KineticTileEntity te, float pt, MatrixStack ms, IRenderTypeBuffer buffer, int light,
|
||||
int overlay) {
|
||||
super.renderSafe(te, pt, ms, buffer, light, overlay);
|
||||
|
||||
ArmTileEntity arm = (ArmTileEntity) te;
|
||||
|
||||
boolean usingFlywheel = FastRenderDispatcher.available(te.getWorld());
|
||||
|
||||
ItemStack item = arm.heldItem;
|
||||
boolean hasItem = !item.isEmpty();
|
||||
boolean usingFlywheel = FastRenderDispatcher.available(te.getWorld());
|
||||
|
||||
if (usingFlywheel && !hasItem) return;
|
||||
|
||||
|
@ -61,21 +60,27 @@ public class ArmRenderer extends KineticTileEntityRenderer {
|
|||
|
||||
MatrixStack msLocal = new MatrixStack();
|
||||
MatrixStacker msr = MatrixStacker.of(msLocal);
|
||||
int color = 0xFFFFFF;
|
||||
|
||||
float baseAngle = arm.baseAngle.get(pt);
|
||||
float lowerArmAngle = arm.lowerArmAngle.get(pt) - 135;
|
||||
float upperArmAngle = arm.upperArmAngle.get(pt) - 90;
|
||||
float headAngle = arm.headAngle.get(pt);
|
||||
float baseAngle;
|
||||
float lowerArmAngle;
|
||||
float upperArmAngle;
|
||||
float headAngle;
|
||||
int color;
|
||||
|
||||
boolean rave = arm.phase == Phase.DANCING;
|
||||
float renderTick = AnimationTickHolder.getRenderTime(te.getWorld()) + (te.hashCode() % 64);
|
||||
boolean rave = arm.phase == Phase.DANCING && te.getSpeed() != 0;
|
||||
if (rave) {
|
||||
float renderTick = AnimationTickHolder.getRenderTime(te.getWorld()) + (te.hashCode() % 64);
|
||||
baseAngle = (renderTick * 10) % 360;
|
||||
lowerArmAngle = MathHelper.lerp((MathHelper.sin(renderTick / 4) + 1) / 2, -45, 15);
|
||||
upperArmAngle = MathHelper.lerp((MathHelper.sin(renderTick / 8) + 1) / 4, -45, 95);
|
||||
headAngle = -lowerArmAngle;
|
||||
color = ColorHelper.rainbowColor(AnimationTickHolder.getTicks() * 100);
|
||||
} else {
|
||||
baseAngle = arm.baseAngle.get(pt);
|
||||
lowerArmAngle = arm.lowerArmAngle.get(pt) - 135;
|
||||
upperArmAngle = arm.upperArmAngle.get(pt) - 90;
|
||||
headAngle = arm.headAngle.get(pt);
|
||||
color = 0xFFFFFF;
|
||||
}
|
||||
|
||||
msr.centre();
|
||||
|
|
Loading…
Reference in a new issue