Hook up node speed to KineticTileEntity speed

This commit is contained in:
reidbhuntley 2021-12-28 21:25:08 -05:00
parent 28a8358b22
commit 371cae7e5a
3 changed files with 15 additions and 12 deletions

View file

@ -241,15 +241,16 @@ public class KineticTileEntity extends SmartTileEntity
@Override @Override
protected void read(CompoundTag compound, boolean clientPacket) { protected void read(CompoundTag compound, boolean clientPacket) {
boolean overStressedBefore = overStressed; //boolean overStressedBefore = overStressed;
clearKineticInformation(); //clearKineticInformation();
// DO NOT READ kinetic information when placed after movement // DO NOT READ kinetic information when placed after movement
if (wasMoved) { //if (wasMoved) {
super.read(compound, clientPacket); // super.read(compound, clientPacket);
return; // return;
} //}
if (clientPacket)
speed = compound.getFloat("Speed"); speed = compound.getFloat("Speed");
// if (compound.contains("Source")) // if (compound.contains("Source"))
@ -268,8 +269,8 @@ public class KineticTileEntity extends SmartTileEntity
super.read(compound, clientPacket); super.read(compound, clientPacket);
if (clientPacket && overStressedBefore != overStressed && speed != 0) // if (clientPacket && overStressedBefore != overStressed && speed != 0)
effects.triggerOverStressedEffect(); // effects.triggerOverStressedEffect();
if (clientPacket) if (clientPacket)
DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> InstancedRenderDispatcher.enqueueUpdate(this)); DistExecutor.unsafeRunWhenOn(Dist.CLIENT, () -> () -> InstancedRenderDispatcher.enqueueUpdate(this));
@ -294,7 +295,10 @@ public class KineticTileEntity extends SmartTileEntity
} }
public void setSpeed(float speed) { public void setSpeed(float speed) {
float prevSpeed = this.speed;
this.speed = speed; this.speed = speed;
onSpeedChanged(prevSpeed);
sendData();
} }
public boolean hasSource() { public boolean hasSource() {

View file

@ -71,7 +71,7 @@ public class KineticNetwork {
return SolveResult.CONTRADICTION; return SolveResult.CONTRADICTION;
} }
// find the generator that would maximize the root speed // search over all generators to maximize the root speed
float newSpeed = 0; float newSpeed = 0;
float sign = 0; float sign = 0;
for (KineticNode generator : generators) { for (KineticNode generator : generators) {

View file

@ -170,8 +170,7 @@ public class KineticNode {
public void flushChangedSpeed() { public void flushChangedSpeed() {
if (speedCur != speedNext) { if (speedCur != speedNext) {
speedCur = speedNext; speedCur = speedNext;
// TODO: update entity's speed entity.setSpeed(speedCur);
System.out.printf("Set speed of %s to %f\n", this, speedNext);
} }
} }