mirror of
https://github.com/GTNewHorizons/EnderIO.git
synced 2026-11-19 11:59:17 +00:00
Move getProgressScaled into a sensible place
This commit is contained in:
1 parent
57f665a03e
commit
5019dd1c3f
7 files changed
+19
-15
No files matched your search
@@ -10,6 +10,7 @@ import crazypants.enderio.machine.gui.AbstractMachineContainer;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.IProgressTile;
|
||||
import crazypants.util.Util;
|
||||
|
||||
public abstract class TileEntityEio extends TileEntity {
|
||||
|
||||
@@ -36,7 +37,7 @@ public abstract class TileEntityEio extends TileEntity {
|
||||
public final void updateEntity() {
|
||||
doUpdate();
|
||||
if(isProgressTile) {
|
||||
int curScaled = AbstractMachineContainer.getProgressScaled(16, (IProgressTile) this);
|
||||
int curScaled = getProgressScaled(16);
|
||||
if(++ticksSinceLastProgressUpdate >= getProgressUpdateFreq() || curScaled != lastProgressScaled) {
|
||||
sendTaskProgressPacket();
|
||||
lastProgressScaled = curScaled;
|
||||
@@ -44,6 +45,13 @@ public abstract class TileEntityEio extends TileEntity {
|
||||
}
|
||||
}
|
||||
|
||||
public final int getProgressScaled(int scale) {
|
||||
if(isProgressTile) {
|
||||
return Util.getProgressScaled(scale, (IProgressTile) this);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected void doUpdate() {
|
||||
|
||||
}
|
||||
|
||||
@@ -390,11 +390,6 @@ public class TileFarmStation extends AbstractPoweredTaskEntity {
|
||||
setNotification("noPower");
|
||||
return false;
|
||||
}
|
||||
int curScaled = AbstractMachineContainer.getProgressScaled(16, this);
|
||||
if(curScaled != lastProgressScaled) {
|
||||
sendTaskProgressPacket();
|
||||
lastProgressScaled = curScaled;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ import net.minecraft.item.ItemStack;
|
||||
import crazypants.enderio.machine.AbstractMachineEntity;
|
||||
import crazypants.enderio.machine.SlotDefinition;
|
||||
import crazypants.util.IProgressTile;
|
||||
import crazypants.util.Util;
|
||||
|
||||
public abstract class AbstractMachineContainer extends Container {
|
||||
|
||||
@@ -246,12 +247,8 @@ public abstract class AbstractMachineContainer extends Container {
|
||||
|
||||
protected int getProgressScaled(int scale) {
|
||||
if(getTileEntity() instanceof IProgressTile) {
|
||||
getProgressScaled(scale, (IProgressTile) getTileEntity());
|
||||
Util.getProgressScaled(scale, (IProgressTile) getTileEntity());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static int getProgressScaled(int scale, IProgressTile tile) {
|
||||
return (int) (tile.getProgress() * scale);
|
||||
}
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import crazypants.render.RenderUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.IProgressTile;
|
||||
import crazypants.util.Lang;
|
||||
import crazypants.util.Util;
|
||||
import crazypants.vecmath.Vector4f;
|
||||
|
||||
public abstract class GuiMachineBase<T extends AbstractMachineEntity> extends GuiContainerBase {
|
||||
@@ -201,7 +202,7 @@ public abstract class GuiMachineBase<T extends AbstractMachineEntity> extends Gu
|
||||
|
||||
protected int getProgressScaled(int scale) {
|
||||
if(getTileEntity() instanceof IProgressTile) {
|
||||
return AbstractMachineContainer.getProgressScaled(scale, (IProgressTile) getTileEntity());
|
||||
return Util.getProgressScaled(scale, (IProgressTile) getTileEntity());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ import crazypants.enderio.GuiHandler;
|
||||
import crazypants.enderio.config.Config;
|
||||
import crazypants.enderio.gui.IconEIO;
|
||||
import crazypants.enderio.gui.TextFieldEIO;
|
||||
import crazypants.enderio.machine.gui.AbstractMachineContainer;
|
||||
import crazypants.enderio.machine.power.PowerDisplayUtil;
|
||||
import crazypants.enderio.network.PacketHandler;
|
||||
import crazypants.gui.GuiContainerBase;
|
||||
@@ -28,6 +27,7 @@ import crazypants.gui.GuiToolTip;
|
||||
import crazypants.render.RenderUtil;
|
||||
import crazypants.util.BlockCoord;
|
||||
import crazypants.util.Lang;
|
||||
import crazypants.util.Util;
|
||||
|
||||
public class GuiTelePad extends GuiContainerBase implements IToggleableGui {
|
||||
|
||||
@@ -170,7 +170,7 @@ public class GuiTelePad extends GuiContainerBase implements IToggleableGui {
|
||||
|
||||
int powerScaled = te.getPowerScaled(powerScale);
|
||||
drawTexturedModalRect(sx + powerX, sy + powerY + powerScale - powerScaled, xSize, 0, 10, powerScaled);
|
||||
int progressScaled = AbstractMachineContainer.getProgressScaled(progressScale, te);
|
||||
int progressScaled = Util.getProgressScaled(progressScale, te);
|
||||
drawTexturedModalRect(sx + progressX, sy + progressY, 0, ySize, progressScaled, 10);
|
||||
|
||||
FontRenderer fnt = getFontRenderer();
|
||||
|
||||
@@ -19,5 +19,4 @@ public interface IProgressTile {
|
||||
void setProgress(float progress);
|
||||
|
||||
TileEntity getTileEntity();
|
||||
|
||||
}
|
||||
@@ -513,6 +513,10 @@ public class Util {
|
||||
return ForgeDirection.UNKNOWN;
|
||||
}
|
||||
|
||||
public static int getProgressScaled(int scale, IProgressTile tile) {
|
||||
return (int) (tile.getProgress() * scale);
|
||||
}
|
||||
|
||||
// copied from WAILA source to avoid API dependency
|
||||
public static String WailaStyle = "\u00A4";
|
||||
public static String WailaIcon = "\u00A5";
|
||||
|
||||
Reference in new issue
Block a user