No more hexadecimal display

This commit is contained in:
DaSH 2026-04-30 10:36:16 +02:00
parent d57a8c9dc4
commit 70e1f48de0
3 changed files with 13 additions and 53 deletions

View File

@ -54,7 +54,6 @@ public class RenderRBMKNumitron extends TileEntitySpecialRenderer {
double w = 8D / scale;
double h = 13D / scale;
double yOffset = 0.5625D;
double line_height = 0.25D;
String value = "";
switch((int)unit.display_mode) {
@ -74,39 +73,6 @@ public class RenderRBMKNumitron extends TileEntitySpecialRenderer {
}
value = Long.toString(unit.value);
break;
case 2: // Signed Hexadecimal display
// Overflow handling
if (unit.value > 0x7FFFFFF) {
value = "7ffffff";
break;
}
// Underflow handling
// Theoretically this value is equal to 0x8000000 in a 28bit signed integer, but it's a long so we have to adapt
if (unit.value < -134217728) {
value = "8000000";
break;
}
value = Long.toHexString(unit.value);
long length = value.length();
// A negative number will have many leading F's, so this needs to be accounted for
if(length > 7) {
value = value.substring((int)length-7);
}
break;
case 3: // Unsigned Hexadecimal display
// Overflow handling
if (unit.value > 0xFFFFFFF) {
value = "fffffff";
break;
}
// Underflow handling
if (unit.value < 0) {
value = "-0";
break;
}
value = Long.toHexString(unit.value);
break;
default:
value = BobMathUtil.getShortNumber(unit.value);
break;
@ -136,28 +102,22 @@ public class RenderRBMKNumitron extends TileEntitySpecialRenderer {
double u = -1;
double v = 0;
if(c == ' ') continue;
if(c == '.') {u = 0.9; v = 1*line_height;}
if(c == '-') {u = 0.8; v = 1*line_height;}
else if(c == 'k') {u = 0.0; v = 1*line_height;}
else if(c == 'M') {u = 0.1; v = 1*line_height;}
else if(c == 'G') {u = 0.2; v = 1*line_height;}
else if(c == 'T') {u = 0.3; v = 1*line_height;}
else if(c == 'P') {u = 0.4; v = 1*line_height;}
else if(c == 'E') {u = 0.5; v = 1*line_height;}
else if(c == 'a') {u = 0.0; v = 2*line_height;}
else if(c == 'b') {u = 0.1; v = 2*line_height;}
else if(c == 'c') {u = 0.2; v = 2*line_height;}
else if(c == 'd') {u = 0.3; v = 2*line_height;}
else if(c == 'e') {u = 0.4; v = 2*line_height;}
else if(c == 'f') {u = 0.5; v = 2*line_height;} // i would love to say this sucks, but this is actually surprisingly easy to read and probably the most performant way of doing it
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;}
else if(c == 'M') {u = 0.1; v = 0.5;}
else if(c == 'G') {u = 0.2; v = 0.5;}
else if(c == 'T') {u = 0.3; v = 0.5;}
else if(c == 'P') {u = 0.4; v = 0.5;}
else if(c == 'E') {u = 0.5; v = 0.5;} // i would love to say this sucks, but this is actually surprisingly easy to read and probably the most performant way of doing it
int charVal = c - '0'; // no string operations, no int parsing, no nothing, we just rawdog this shit
if(charVal >= 0 && charVal <= 9) {u = 0.1 * charVal; v = 0.0;}
if(u == -1) {u = 0.8; v = 1*line_height;}
if(u == -1) {u = 0.8; v = 0.5;}
tess.setNormal(0F, 1F, 0F);
tess.addVertexWithUV(0.03135, -h + yOffset, w - zOffset, u, v + line_height);
tess.addVertexWithUV(0.03135, -h + yOffset, w - zOffset, u, v + 0.5);
tess.addVertexWithUV(0.03135, h + yOffset, w - zOffset, u, v);
tess.addVertexWithUV(0.03135, h + yOffset, -w - zOffset, u + 0.1, v);
tess.addVertexWithUV(0.03135, -h + yOffset, -w - zOffset, u + 0.1, v + line_height);
tess.addVertexWithUV(0.03135, -h + yOffset, -w - zOffset, u + 0.1, v + 0.5);
}
tess.draw();

View File

@ -92,7 +92,7 @@ public class TileEntityRBMKNumitron extends TileEntityLoadedBase implements IGUI
public boolean no_leading_zeroes;
/** Which digits are activated (bit mask, msb ignored) */
public long active_digits;
/** Display mode 0=normal, 1=integer, 2=signed hexadecimal 3=unsigned hexadecimal */
/** Display mode 0=normal, 1=integer */
public long display_mode;
public DisplayUnit(int initialIndex) {
@ -292,7 +292,7 @@ public class TileEntityRBMKNumitron extends TileEntityLoadedBase implements IGUI
int idx = args.checkInteger(0) - 1;
if(idx < 0 || idx >= 2) return new Object[] {false, "Invalid index (1-2)"};
long val = (long) args.checkInteger(1) - 1;
if(val < 0 || val >= 4) throw new IllegalArgumentException("Invalid value (1-4)");
if(val < 0 || val >= 2) throw new IllegalArgumentException("Invalid value (1-2)");
displays[idx].display_mode = val;
markDirty();
return new Object[] {true};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 487 B

After

Width:  |  Height:  |  Size: 712 B