Skip to content

Commit 7212ceb

Browse files
committed
Issues with ReflectionHelper
1 parent f319cf0 commit 7212ceb

File tree

8 files changed

+33
-24
lines changed

8 files changed

+33
-24
lines changed

src/main/java/llc/redstone/hysentials/Hysentials.java

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@ public class Hysentials {
127127

128128
public String rank;
129129

130-
public CubitCompanion cubitCompanion;
131-
public PepperCompanion pepperCompanion;
132-
public MiyaCompanion miyaCompanion;
133-
public HamsterCompanion hamsterCompanion;
134-
public TechnoCrown technoCrown;
135-
public BlackCat blackCat;
136-
public KzeroBundle kzeroBundle;
137-
public TdarthCosmetic tdarthCosmetic;
138-
public DragonCosmetic dragonCosmetic;
130+
public CubitCompanion cubitCompanion = new CubitCompanion();
131+
public PepperCompanion pepperCompanion = new PepperCompanion();
132+
public MiyaCompanion miyaCompanion = new MiyaCompanion();
133+
public HamsterCompanion hamsterCompanion = new HamsterCompanion();
134+
public TechnoCrown technoCrown = new TechnoCrown();
135+
public BlackCat blackCat = new BlackCat();
136+
public KzeroBundle kzeroBundle = new KzeroBundle();
137+
public TdarthCosmetic tdarthCosmetic = new TdarthCosmetic();
138+
public DragonCosmetic dragonCosmetic = new DragonCosmetic();
139139

140140

141141

@@ -431,14 +431,14 @@ private void registerHandlers() {
431431
eventBus.register(new CapeHandler());
432432
eventBus.register(new PacketRecievedHandler());
433433
eventBus.register(new OneConfigHudClickHandler());
434-
eventBus.register(cubitCompanion = new CubitCompanion());
435-
eventBus.register(pepperCompanion = new PepperCompanion());
436-
eventBus.register(miyaCompanion = new MiyaCompanion());
437-
eventBus.register(hamsterCompanion = new HamsterCompanion());
438-
eventBus.register(technoCrown = new TechnoCrown());
439-
eventBus.register(kzeroBundle = new KzeroBundle());
440-
eventBus.register(tdarthCosmetic = new TdarthCosmetic());
441-
eventBus.register(dragonCosmetic = new DragonCosmetic());
434+
eventBus.register(cubitCompanion);
435+
eventBus.register(pepperCompanion);
436+
eventBus.register(miyaCompanion);
437+
eventBus.register(hamsterCompanion);
438+
eventBus.register(technoCrown);
439+
eventBus.register(kzeroBundle);
440+
eventBus.register(tdarthCosmetic);
441+
eventBus.register(dragonCosmetic);
442442
blackCat = LayerBlackCatHat.hat;
443443
CatHat.loadCatHats();
444444
BackpackCosmetic.loadBackpacks();

src/main/java/llc/redstone/hysentials/config/EditorConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@
88
import cc.polyfrost.oneconfig.config.data.ModType;
99
import cc.polyfrost.oneconfig.gui.OneConfigGui;
1010
import cc.polyfrost.oneconfig.gui.pages.ModConfigPage;
11+
import cc.polyfrost.oneconfig.hud.Hud;
12+
import cc.polyfrost.oneconfig.internal.hud.HudCore;
1113
import cc.polyfrost.oneconfig.utils.gui.GuiUtils;
1214
import llc.redstone.hysentials.Hysentials;
1315
import llc.redstone.hysentials.guis.utils.SBBoxes;
16+
import llc.redstone.hysentials.guis.utils.SBBoxesHud;
1417
import net.minecraft.client.Minecraft;
1518
import org.json.JSONArray;
1619
import org.json.JSONObject;
@@ -93,6 +96,7 @@ public class EditorConfig extends Config {
9396
text = "Delete"
9497
)
9598
public void delete() {
99+
HudCore.huds.remove(line.entry, line.hud);
96100
SBBoxes.boxes.remove(line);
97101
Minecraft.getMinecraft().thePlayer.closeScreen();
98102
}

src/main/java/llc/redstone/hysentials/guis/misc/SetTextureGui.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public SetTextureGui() {
5656
cataItems.put("Armor", new ArrayList<>());
5757
cataItems.put("Seasonal", new ArrayList<>());
5858
try {
59-
guiTopField = ReflectionHelper.findField(GuiContainer.class, "guiTop", "field_147004_r");
59+
guiTopField = ReflectionHelper.findField(GuiContainer.class, "guiTop", "field_147009_r");
6060
xSizeField = ReflectionHelper.findField(GuiContainer.class, "xSize", "field_146999_f");
6161
guiTopField.setAccessible(true);
6262
xSizeField.setAccessible(true);

src/main/java/llc/redstone/hysentials/guis/utils/SBBoxes.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import org.jetbrains.annotations.NotNull;
1414
import org.json.JSONObject;
1515

16+
import java.beans.Transient;
1617
import java.lang.reflect.Field;
1718
import java.util.ArrayList;
1819
import java.util.List;
@@ -36,6 +37,8 @@ public class SBBoxes {
3637
private float scale = 0;
3738
private String title = "";
3839
private boolean enabled = false;
40+
transient public SBBoxesHud hud;
41+
transient public Map.Entry<Field, Object> entry;
3942

4043
public SBBoxes(@NotNull JSONObject line) {
4144
this.display = line.getString("display");
@@ -50,7 +53,9 @@ public SBBoxes(@NotNull JSONObject line) {
5053

5154
position = new Position(x, y, getWidth(text), getHeight(text));
5255

53-
HudCore.huds.put(new Map.Entry<Field, Object>() {
56+
hud = new SBBoxesHud(this);
57+
58+
HudCore.huds.put(entry = new Map.Entry<Field, Object>() {
5459
@Override
5560
public Field getKey() {
5661
return null;
@@ -65,7 +70,7 @@ public Object getValue() {
6570
public Object setValue(Object o) {
6671
return null;
6772
}
68-
}, new SBBoxesHud(this));
73+
}, hud);
6974

7075
}
7176

src/main/java/llc/redstone/hysentials/handlers/htsl/ActionGUIHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public ActionGUIHandler() {
6262
file = new Input.Button(0, 0, 0, 20, "File");
6363
library = new Input.Button(0, 0, 0, 20, "Action Library");
6464

65-
guiTopField = ReflectionHelper.findField(GuiContainer.class, "guiTop", "field_147004_r");
65+
guiTopField = ReflectionHelper.findField(GuiContainer.class, "guiTop", "field_147009_r");
6666
guiTopField.setAccessible(true);
6767
guiLeftField = ReflectionHelper.findField(GuiContainer.class, "guiLeft", "field_147003_i");
6868
guiLeftField.setAccessible(true);

src/main/java/llc/redstone/hysentials/handlers/htsl/FunctionsGUIHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public FunctionsGUIHandler() {
4646
file = new Input.Button(0, 0, 0, 20, "File");
4747
library = new Input.Button(0, 0, 0, 20, "Action Library");
4848

49-
guiTopField = ReflectionHelper.findField(GuiContainer.class, "guiTop", "field_147004_r");
49+
guiTopField = ReflectionHelper.findField(GuiContainer.class, "guiTop", "field_147009_r");
5050
guiTopField.setAccessible(true);
5151
guiLeftField = ReflectionHelper.findField(GuiContainer.class, "guiLeft", "field_147003_i");
5252
guiLeftField.setAccessible(true);

src/main/java/llc/redstone/hysentials/handlers/htsl/Navigator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public Navigator() {
8686
throw new RuntimeException(e);
8787
}
8888
try {
89-
guiTop = ReflectionHelper.findField(GuiContainer.class, "guiTop", "field_147004_r");
89+
guiTop = ReflectionHelper.findField(GuiContainer.class, "guiTop", "field_147009_r");
9090
guiTop.setAccessible(true);
9191
guiLeft = ReflectionHelper.findField(GuiContainer.class, "guiLeft", "field_147003_i");
9292
guiLeft.setAccessible(true);

src/main/java/llc/redstone/hysentials/handlers/npc/NPC.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ public void setName(String name) {
9797
try {
9898
entity.setCustomNameTag(name);
9999
GameProfile profile = new GameProfile(UUID.randomUUID(), name);
100-
Field gameProfile = ReflectionHelper.findField(Entity.class, "field_184245_j", "gameProfile");
100+
Field gameProfile = ReflectionHelper.findField(EntityPlayer.class, "field_146106_i", "gameProfile");
101101
gameProfile.setAccessible(true);
102102
gameProfile.set(entity, profile);
103103
NetworkPlayerInfo info = new NetworkPlayerInfo(profile);

0 commit comments

Comments
 (0)