-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
b45130b
commit e0d74e1
Showing
6 changed files
with
85 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
accessWidener v1 named | ||
accessWidener v2 named | ||
accessible method net/minecraft/client/gui/Gui drawRect (IIIII)V | ||
accessible method net/minecraft/client/gui/Gui drawRectWidthHeight (IIIII)V |
Binary file modified
BIN
-1018 Bytes
(70%)
output/production/commander-bta.main/net/pedroricardo/commander/Commander.class
Binary file not shown.
76 changes: 76 additions & 0 deletions
76
src/main/java/net/pedroricardo/commander/BeautifulNbt.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
package net.pedroricardo.commander; | ||
|
||
import com.mojang.nbt.*; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
import java.util.List; | ||
|
||
public class BeautifulNbt { | ||
public static String toBeautifulNbt(@NotNull CompoundTag nbt) { | ||
StringBuilder builder = new StringBuilder("{"); | ||
boolean comma = false; | ||
for (Tag<?> tag : nbt.getValue().values()) { | ||
if (comma) builder.append(", "); | ||
builder.append(tag.getTagName()).append(": ").append(element(tag instanceof CompoundTag ? tag : tag.getValue())); | ||
comma = true; | ||
} | ||
return builder.append("}").toString(); | ||
} | ||
|
||
private static String element(Object o) { | ||
if (o instanceof byte[] || o instanceof short[] || o instanceof double[] || o instanceof List<?>) { | ||
return collection(o); | ||
} | ||
if (o instanceof Byte) { | ||
return o + "b"; | ||
} | ||
if (o instanceof Short) { | ||
return o + "s"; | ||
} | ||
if (o instanceof Long) { | ||
return o + "l"; | ||
} | ||
if (o instanceof Float) { | ||
return o + "f"; | ||
} | ||
if (o instanceof String) { | ||
return "\"" + o + "\""; | ||
} | ||
return o instanceof CompoundTag ? toBeautifulNbt((CompoundTag) o) : o.toString(); | ||
} | ||
|
||
private static String collection(Object o) { | ||
StringBuilder result = new StringBuilder("["); | ||
boolean comma = false; | ||
if (o instanceof byte[]) { | ||
result.append("B; "); | ||
for (double element : ((byte[])o)) { | ||
if (comma) result.append(", "); | ||
result.append(element(element)); | ||
comma = true; | ||
} | ||
} else if (o instanceof short[]) { | ||
result.append("S; "); | ||
for (double element : ((short[])o)) { | ||
if (comma) result.append(", "); | ||
result.append(element(element)); | ||
comma = true; | ||
} | ||
} else if (o instanceof double[]) { | ||
result.append("D; "); | ||
for (double element : ((double[])o)) { | ||
if (comma) result.append(", "); | ||
result.append(element(element)); | ||
comma = true; | ||
} | ||
} else if (o instanceof List<?>) { | ||
//noinspection unchecked | ||
for (Tag<?> element : ((List<Tag<?>>)o)) { | ||
if (comma) result.append(", "); | ||
result.append(element(element.getValue())); | ||
comma = true; | ||
} | ||
} | ||
return result.append("]").toString(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
accessWidener v1 named | ||
accessWidener v2 named | ||
accessible method net/minecraft/client/gui/Gui drawRect (IIIII)V | ||
accessible method net/minecraft/client/gui/Gui drawRectWidthHeight (IIIII)V |