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

View file

@ -71,7 +71,7 @@ public class KineticNetwork {
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 sign = 0;
for (KineticNode generator : generators) {

View file

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