Skip to content

Commit

Permalink
remove shift active check
Browse files Browse the repository at this point in the history
  • Loading branch information
MCTBL committed Feb 11, 2025
1 parent 523323c commit b7c7486
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 35 deletions.
4 changes: 3 additions & 1 deletion src/main/java/appeng/core/settings/TickRates.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ public enum TickRates {

OpenComputersTunnel(1, 5),

PressureTunnel(1, 120);
PressureTunnel(1, 120),

ThroughputMonitor(20, 100);

private int min;
private int max;
Expand Down
59 changes: 28 additions & 31 deletions src/main/java/appeng/parts/reporting/PartThroughputMonitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import appeng.api.networking.ticking.TickingRequest;
import appeng.api.storage.data.IAEItemStack;
import appeng.client.texture.CableBusTextures;
import appeng.core.settings.TickRates;
import appeng.helpers.Reflected;
import appeng.util.IWideReadableNumberConverter;
import appeng.util.Platform;
Expand Down Expand Up @@ -109,15 +110,10 @@ public boolean onPartShiftActivate(final EntityPlayer player, final Vec3 pos) {
return false;
}

final TileEntity te = this.getTile();
final ItemStack eq = player.getCurrentEquippedItem();
this.timeMode = (this.timeMode + TIME_UNIT.length - 1) % TIME_UNIT.length;
this.host.markForUpdate();

if (!Platform.isWrench(player, eq, te.xCoord, te.yCoord, te.zCoord) && this.isLocked()) {
this.timeMode = (this.timeMode + TIME_UNIT.length - 1) % TIME_UNIT.length;
return true;
} else {
return super.onPartShiftActivate(player, pos);
}
return true;
}

@Override
Expand All @@ -139,32 +135,13 @@ public boolean onPartActivate(final EntityPlayer player, final Vec3 pos) {

if (!Platform.isWrench(player, eq, te.xCoord, te.yCoord, te.zCoord) && this.isLocked()) {
this.timeMode = (this.timeMode + 1) % TIME_UNIT.length;
this.host.markForUpdate();
return true;
} else {
return super.onPartActivate(player, pos);
}
}

public void updateThroughput(int tick) {
if (Platform.isClient()) {
return;
}

if (this.getDisplayed() == null) {
this.lastStackSize = -1;
this.host.markForUpdate();
return;
} else {
long nowStackSize = this.getDisplayed().getStackSize();
if (this.lastStackSize != -1) {
long changeStackSize = nowStackSize - this.lastStackSize;
this.itemNumsChange = (changeStackSize * NUMBER_MULTIPLIER[this.timeMode]) / tick;
this.host.markForUpdate();
}
this.lastStackSize = nowStackSize;
}
}

@Override
public void tesrRenderItemNumber(final IAEItemStack ais) {
GL11.glTranslatef(0.0f, 0.14f, -0.24f);
Expand Down Expand Up @@ -196,13 +173,33 @@ public void tesrRenderItemNumber(final IAEItemStack ais) {

@Override
public TickingRequest getTickingRequest(IGridNode node) {
return new TickingRequest(20, 100, false, false);
return new TickingRequest(
TickRates.ThroughputMonitor.getMin(),
TickRates.ThroughputMonitor.getMax(),
false,
false);
}

@Override
public TickRateModulation tickingRequest(IGridNode node, int TicksSinceLastCall) {
this.updateThroughput(TicksSinceLastCall);
return TickRateModulation.SAME;
if (Platform.isClient()) {
return TickRateModulation.SAME;
}

if (this.getDisplayed() == null) {
this.lastStackSize = -1;
this.host.markForUpdate();
return TickRateModulation.IDLE;
} else {
long nowStackSize = this.getDisplayed().getStackSize();
if (this.lastStackSize != -1) {
long changeStackSize = nowStackSize - this.lastStackSize;
this.itemNumsChange = (changeStackSize * NUMBER_MULTIPLIER[this.timeMode]) / TicksSinceLastCall;
this.host.markForUpdate();
}
this.lastStackSize = nowStackSize;
}
return TickRateModulation.FASTER;
}

}
6 changes: 3 additions & 3 deletions src/main/java/appeng/util/Platform.java
Original file line number Diff line number Diff line change
Expand Up @@ -1924,14 +1924,14 @@ public static String formatNumberLongRestrictedByWidth(final double n, final int
postFix = String.valueOf(NUM_UNIT[exponent]);
}

final String withPrecision = df.format(last / DIVISION_BASE) + postFix;
final String withoutPrecision = Long.toString((long) base) + postFix;
final String withPrecision = df.format(last / DIVISION_BASE);
final String withoutPrecision = Long.toString((long) base);

final String slimResult = (withPrecision.length() <= width) ? withPrecision : withoutPrecision;

// post condition
assert slimResult.length() <= width;

return slimResult;
return slimResult + postFix;
}
}

0 comments on commit b7c7486

Please sign in to comment.