Merge pull request #623 from Voxelstice/turbine-anim

turbine blades now fade in/out when spinning
This commit is contained in:
HbmMods 2022-06-12 20:48:58 +02:00 committed by GitHub
commit fa176c6a5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 17 deletions

View File

@ -35,6 +35,7 @@ public class TileEntityChungus extends TileEntityLoadedBase implements IFluidAcc
private int turnTimer; private int turnTimer;
public float rotor; public float rotor;
public float lastRotor; public float lastRotor;
public float fanAcceleration = 0F;
public List<IFluidAcceptor> list2 = new ArrayList(); public List<IFluidAcceptor> list2 = new ArrayList();
@ -101,16 +102,17 @@ public class TileEntityChungus extends TileEntityLoadedBase implements IFluidAcc
} else { } else {
this.lastRotor = this.rotor; this.lastRotor = this.rotor;
this.rotor += this.fanAcceleration;
if(this.rotor >= 360) {
this.rotor -= 360;
this.lastRotor -= 360;
}
if(turnTimer > 0) { if(turnTimer > 0) {
this.rotor += 25F; this.fanAcceleration = Math.max(0F, Math.min(25F, this.fanAcceleration += 0.1F));
if(this.rotor >= 360) {
this.rotor -= 360;
this.lastRotor -= 360;
}
Random rand = worldObj.rand; Random rand = worldObj.rand;
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset); ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - BlockDummyable.offset);
ForgeDirection side = dir.getRotation(ForgeDirection.UP); ForgeDirection side = dir.getRotation(ForgeDirection.UP);
@ -123,6 +125,9 @@ public class TileEntityChungus extends TileEntityLoadedBase implements IFluidAcc
-dir.offsetX * 0.2, 0, -dir.offsetZ * 0.2); -dir.offsetX * 0.2, 0, -dir.offsetZ * 0.2);
} }
} }
if(turnTimer < 0) {
this.fanAcceleration = Math.max(0F, Math.min(25F, this.fanAcceleration -= 0.1F));
}
} }
} }

View File

@ -33,7 +33,8 @@ public class TileEntityMachineLargeTurbine extends TileEntityMachineBase impleme
private boolean shouldTurn; private boolean shouldTurn;
public float rotor; public float rotor;
public float lastRotor; public float lastRotor;
public float fanAcceleration = 0F;
public TileEntityMachineLargeTurbine() { public TileEntityMachineLargeTurbine() {
super(7); super(7);
@ -104,17 +105,20 @@ public class TileEntityMachineLargeTurbine extends TileEntityMachineBase impleme
data.setBoolean("operational", operational); data.setBoolean("operational", operational);
this.networkPack(data, 50); this.networkPack(data, 50);
} else { } else {
this.lastRotor = this.rotor; this.lastRotor = this.rotor;
this.rotor += this.fanAcceleration;
if(this.rotor >= 360) {
this.rotor -= 360;
this.lastRotor -= 360;
}
if(shouldTurn) { if(shouldTurn) {
this.rotor += 15F; this.fanAcceleration = Math.max(0F, Math.min(15F, this.fanAcceleration += 0.1F));
}
if(this.rotor >= 360) { if(!shouldTurn) {
this.rotor -= 360; this.fanAcceleration = Math.max(0F, Math.min(15F, this.fanAcceleration -= 0.1F));
this.lastRotor -= 360;
}
} }
} }
} }