Fix grinding ball bar not rendering most of the time

This commit is contained in:
tterrag1098 committed 2014-12-28 17:22:58 -05:00
1 parent 4a83569eb7
commit ecfe78fc24
3 files changed
+10 -5

No files matched your search

@@ -30,6 +30,7 @@ public class GuiCrusher extends GuiPoweredMachineBase<TileCrusher> {
drawTexturedModalRect(guiLeft + 79, guiTop + 31, 200, 0, 18, barHeight + 1);
barHeight = getTileEntity().getBallDurationScaled(16);
System.out.println(barHeight);
if(barHeight > 0) {
drawTexturedModalRect(guiLeft + 142, guiTop + 23 + (16 - barHeight), 186, 31, 4, barHeight);
}
@@ -16,9 +16,9 @@ public class PacketGrindingBall implements IMessage, IMessageHandler<PacketGrind
int currGbUse;
public PacketGrindingBall() {
public PacketGrindingBall() {
}
public PacketGrindingBall(TileCrusher ent) {
x = ent.xCoord;
y = ent.yCoord;
@@ -15,6 +15,7 @@ public class TileCrusher extends AbstractPoweredTaskEntity {
protected IGrindingMultiplier gb;
protected int currGbUse = 0;
protected int maxGbUse = 0; // client only
protected int lastSendGbScaled = 0;
private boolean useGrindingBall;
@@ -43,10 +44,13 @@ public class TileCrusher extends AbstractPoweredTaskEntity {
public int getBallDurationScaled(int scale) {
if(gb == null) {
return 0;
return worldObj.isRemote ? calcScaled(currGbUse, maxGbUse, scale) : 0;
}
float res = 1 - (float) currGbUse / (float) gb.getDurationMJ();
return (int) (res * scale);
return calcScaled(currGbUse, gb.getDurationMJ(), scale);
}
private int calcScaled(float cur, float max, int scale) {
return max == 0 ? 0 : (int) (scale * (1 - ((float) cur / (float) max)));
}
@Override