package mcjty.rftools.blocks.screens.modules;

public class ScreenModuleHelper {
    private boolean showdiff = false;
    private long prevMillis = 0;
    private long prevContents = 0;
    private long lastPerTick = 0;

    public Object[] getContentsValue(long millis, long contents, long maxContents) {
        if (showdiff) {
            if (prevMillis == 0 || millis <= prevMillis + 100) {        // <= prevMillis + 100 to make sure we show last value if the timing is too short
                prevMillis = millis;
                prevContents = contents;
                return new Object[] { contents, maxContents, lastPerTick };
            } else {
                long diff = millis - prevMillis;
                int ticks = (int) (diff * 20 / 1000);
                if (ticks == 0) {
                    ticks = 1;
                }
                long diffEnergy = contents - prevContents;
                prevMillis = millis;
                prevContents = contents;
                lastPerTick = diffEnergy / ticks;
                return new Object[] { contents, maxContents, lastPerTick };
            }
        } else {
            return new Object[] { contents, maxContents, 0L };
        }
    }

    public void setShowdiff(boolean showdiff) {
        this.showdiff = showdiff;
    }
}

package mcjty.rftools.blocks.screens.modules;

public class ScreenModuleHelper {
    private boolean showdiff = false;
    private long prevMillis = 0;
    private long prevContents = 0;

    public Object[] getContentsValue(long millis, long contents, long maxContents) {
        if (showdiff) {
            if (prevMillis == 0 || millis <= prevMillis) {
                prevMillis = millis;
                prevContents = contents;
                return new Object[] { contents, maxContents, 0L };
            } else {
                long diff = millis - prevMillis;
                int ticks = (int) (diff * 20 / 1000);
                if (ticks == 0) {
                    ticks = 1;
                }
                long diffEnergy = contents - prevContents;
                prevMillis = millis;
                prevContents = contents;
                return new Object[] { contents, maxContents, diffEnergy / ticks };
            }
        } else {
            return new Object[] { contents, maxContents, 0L };
        }
    }

    public void setShowdiff(boolean showdiff) {
        this.showdiff = showdiff;
    }
}

--- 
+++ 
@@ -4,13 +4,14 @@
     private boolean showdiff = false;
     private long prevMillis = 0;
     private long prevContents = 0;
+    private long lastPerTick = 0;
 
     public Object[] getContentsValue(long millis, long contents, long maxContents) {
         if (showdiff) {
-            if (prevMillis == 0 || millis <= prevMillis) {
+            if (prevMillis == 0 || millis <= prevMillis + 100) {        // <= prevMillis + 100 to make sure we show last value if the timing is too short
                 prevMillis = millis;
                 prevContents = contents;
-                return new Object[] { contents, maxContents, 0L };
+                return new Object[] { contents, maxContents, lastPerTick };
             } else {
                 long diff = millis - prevMillis;
                 int ticks = (int) (diff * 20 / 1000);
@@ -20,7 +21,8 @@
                 long diffEnergy = contents - prevContents;
                 prevMillis = millis;
                 prevContents = contents;
-                return new Object[] { contents, maxContents, diffEnergy / ticks };
+                lastPerTick = diffEnergy / ticks;
+                return new Object[] { contents, maxContents, lastPerTick };
             }
         } else {
             return new Object[] { contents, maxContents, 0L };
Fix a bug where multiple people looking at the same RF/t energy module in a screen would not see the same thing.
