mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-08-10 17:55:44 +00:00
Can deactivate leading zeroes
This commit is contained in:
parent
778d83c284
commit
1b1dc6f998
@ -56,7 +56,8 @@ public class RenderRBMKNumitron extends TileEntitySpecialRenderer {
|
||||
double yOffset = 0.5625D;
|
||||
|
||||
String value = BobMathUtil.getShortNumber(unit.value);
|
||||
while(value.length() < 7) value = "0" + value;
|
||||
String fill_char = unit.no_leading_zeroes?" ":"0";
|
||||
while(value.length() < 7) value = fill_char + value;
|
||||
|
||||
Tessellator tess = Tessellator.instance;
|
||||
tess.startDrawingQuads();
|
||||
@ -65,6 +66,7 @@ public class RenderRBMKNumitron extends TileEntitySpecialRenderer {
|
||||
char c = value.charAt(j);
|
||||
double u = -1;
|
||||
double v = 0;
|
||||
if(c == ' ') continue;
|
||||
if(c == '.') {u = 0.9; v = 0.5;}
|
||||
if(c == '-') {u = 0.8; v = 0.5;}
|
||||
else if(c == 'k') {u = 0.0; v = 0.5;}
|
||||
|
||||
@ -88,6 +88,8 @@ public class TileEntityRBMKNumitron extends TileEntityLoadedBase implements IGUI
|
||||
public long value;
|
||||
/** Whether this display is visible on the panel */
|
||||
public boolean active;
|
||||
/** If leading zeros should not be added */
|
||||
public boolean no_leading_zeroes;
|
||||
|
||||
public DisplayUnit(int initialIndex) {
|
||||
label = "Display " + (initialIndex + 1);
|
||||
@ -113,6 +115,7 @@ public class TileEntityRBMKNumitron extends TileEntityLoadedBase implements IGUI
|
||||
}
|
||||
|
||||
public void serialize(ByteBuf buf) {
|
||||
buf.writeBoolean(no_leading_zeroes);
|
||||
buf.writeBoolean(active);
|
||||
buf.writeBoolean(polling);
|
||||
BufferUtil.writeString(buf, label);
|
||||
@ -121,6 +124,7 @@ public class TileEntityRBMKNumitron extends TileEntityLoadedBase implements IGUI
|
||||
}
|
||||
|
||||
public void deserialize(ByteBuf buf) {
|
||||
no_leading_zeroes = buf.readBoolean();
|
||||
active = buf.readBoolean();
|
||||
polling = buf.readBoolean();
|
||||
label = BufferUtil.readString(buf);
|
||||
@ -129,6 +133,7 @@ public class TileEntityRBMKNumitron extends TileEntityLoadedBase implements IGUI
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbt, int index) {
|
||||
this.no_leading_zeroes = nbt.getBoolean("no_leading_zeroes" + index);
|
||||
this.active = nbt.getBoolean("active" + index);
|
||||
this.polling = nbt.getBoolean("polling" + index);
|
||||
this.label = nbt.getString("label" + index);
|
||||
@ -137,6 +142,7 @@ public class TileEntityRBMKNumitron extends TileEntityLoadedBase implements IGUI
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbt, int index) {
|
||||
nbt.setBoolean("no_leading_zeroes" + index, no_leading_zeroes);
|
||||
nbt.setBoolean("active" + index, active);
|
||||
nbt.setBoolean("polling" + index, polling);
|
||||
nbt.setString("label" + index, label);
|
||||
@ -183,6 +189,7 @@ public class TileEntityRBMKNumitron extends TileEntityLoadedBase implements IGUI
|
||||
int idx = args.checkInteger(0) - 1;
|
||||
if(idx < 0 || idx >= 2) return new Object[] {null, "Invalid index (1-2)"};
|
||||
java.util.LinkedHashMap<String, Object> map = new java.util.LinkedHashMap<>();
|
||||
map.put("no_leading_zeroes", displays[idx].no_leading_zeroes);
|
||||
map.put("active", displays[idx].active);
|
||||
map.put("polling", displays[idx].polling);
|
||||
map.put("label", displays[idx].label);
|
||||
@ -241,4 +248,14 @@ public class TileEntityRBMKNumitron extends TileEntityLoadedBase implements IGUI
|
||||
markDirty();
|
||||
return new Object[] {true};
|
||||
}
|
||||
|
||||
@Callback(direct = true, limit = 2)
|
||||
@Optional.Method(modid = "OpenComputers")
|
||||
public Object[] setDisplayNoLeadingZeroes(Context context, Arguments args) {
|
||||
int idx = args.checkInteger(0) - 1;
|
||||
if(idx < 0 || idx >= 2) return new Object[] {false, "Invalid index (1-2)"};
|
||||
displays[idx].no_leading_zeroes = args.checkBoolean(1);
|
||||
markDirty();
|
||||
return new Object[] {true};
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user