fix my horrible shit code

This commit is contained in:
GlodBlock committed 2022-05-21 20:55:42 +08:00
1 parent b2aee3cb7b
commit 72667593f1
10 files changed
+156 -123

No files matched your search

@@ -32,6 +32,10 @@ public class Ae2Reflect {
private static final Field fInventory_width;
private static final Field fAEPass_internal;
private static final Field fAEInv_partitionList;
private static final Field fCPU_cpu;
private static final Field fCPU_myName;
private static final Field fCPU_processors;
private static final Field fCPU_size;
private static final Method mItemSlot_setExtractable;
static {
@@ -40,6 +44,10 @@ public class Ae2Reflect {
fInventory_width = reflectField(InventoryCrafting.class, "inventoryWidth", "field_70464_b", "b");
fAEPass_internal = reflectField(MEPassThrough.class, "internal");
fAEInv_partitionList = reflectField(MEInventoryHandler.class, "myPartitionList");
fCPU_cpu = Ae2Reflect.reflectField(CraftingCPURecord.class, "cpu");
fCPU_myName = Ae2Reflect.reflectField(CraftingCPURecord.class, "myName");
fCPU_processors = Ae2Reflect.reflectField(CraftingCPURecord.class, "processors");
fCPU_size = Ae2Reflect.reflectField(CraftingCPURecord.class, "size");
mItemSlot_setExtractable = reflectMethod(ItemSlot.class, "setExtractable", boolean.class);
} catch (Exception e) {
throw new IllegalStateException("Failed to initialize AE2 reflection hacks!", e);
@@ -108,65 +116,6 @@ public class Ae2Reflect {
}
}
private static final Field fAEBaseGui_stackSizeRenderer;
private static final Field fGuiCraftingStatus_originalGuiBtn;
private static final Field fGuiPatternTerm_container;
private static final Field fGuiCPUStatus_icon;
private static final Field fGuiMEMonitorable_monitorableContainer;
private static final Field fGuiMEMonitorable_configSrc;
private static final Field fGuiMEMonitorable_craftingStatusBtn;
private static final Field fGuiContainer_guiLeft;
private static final Field fGuiContainer_guiTop;
private static final Field fCPU_cpu;
private static final Field fCPU_myName;
private static final Field fCPU_processors;
private static final Field fCPU_size;
private static final Field fGui_drag;
private static final Method mGuiPatternTerm_inventorySlots;
private static final Method mGuiPatternTerm_reservedSpace;
private static final Method mGuiPatternTerm_reservedSpaceSetter;
static {
try {
fAEBaseGui_stackSizeRenderer = Ae2Reflect.reflectField(AEBaseGui.class, "aeRenderItem");
fGuiCraftingStatus_originalGuiBtn = Ae2Reflect.reflectField(GuiCraftingStatus.class, "originalGuiBtn");
fGuiPatternTerm_container = Ae2Reflect.reflectField(GuiBaseFluidPatternTerminal.class, "container");
fGuiMEMonitorable_monitorableContainer = Ae2Reflect.reflectField(GuiFCBaseMonitor.class, "monitorableContainer");
fGuiMEMonitorable_configSrc = Ae2Reflect.reflectField(GuiFCBaseMonitor.class, "configSrc");
fGuiMEMonitorable_craftingStatusBtn = Ae2Reflect.reflectField(GuiFCBaseMonitor.class, "craftingStatusBtn");
fGuiCPUStatus_icon = Ae2Reflect.reflectField(GuiCraftingStatus.class, "myIcon");
fGuiContainer_guiLeft = Ae2Reflect.reflectField(GuiContainer.class, "guiLeft", "field_147003_i", "i");
fGuiContainer_guiTop = Ae2Reflect.reflectField(GuiContainer.class, "guiTop", "field_147009_r", "r");
fCPU_cpu = Ae2Reflect.reflectField(CraftingCPURecord.class, "cpu");
fCPU_myName = Ae2Reflect.reflectField(CraftingCPURecord.class, "myName");
fCPU_processors = Ae2Reflect.reflectField(CraftingCPURecord.class, "processors");
fCPU_size = Ae2Reflect.reflectField(CraftingCPURecord.class, "size");
fGui_drag = Ae2Reflect.reflectField(AEBaseGui.class, "drag_click");
mGuiPatternTerm_inventorySlots = Ae2Reflect.reflectMethod(AEBaseGui.class, "getInventorySlots");
mGuiPatternTerm_reservedSpace = Ae2Reflect.reflectMethod(GuiFCBaseMonitor.class, "getReservedSpace");
mGuiPatternTerm_reservedSpaceSetter = Ae2Reflect.reflectMethod(GuiFCBaseMonitor.class, "setReservedSpace", int.class);
} catch (Exception e) {
throw new IllegalStateException("Failed to initialize AE2 reflection hacks!", e);
}
}
@SuppressWarnings("unchecked")
public static List<Slot> getInventorySlots(AEBaseGui gui) {
try {
return (List<Slot>) mGuiPatternTerm_inventorySlots.invoke(gui);
} catch (Exception e) {
throw new IllegalStateException("Failed to invoke method: " + mGuiPatternTerm_inventorySlots, e);
}
}
public static void rewriteIcon(GuiCraftingStatus gui, ItemStack icon) {
Ae2Reflect.writeField(gui, fGuiCPUStatus_icon, icon);
}
public static Set<Slot> getDragClick(AEBaseGui gui) {
return Ae2Reflect.readField(gui, fGui_drag);
}
public static ICraftingCPU getCPU(CraftingCPURecord cpu) {
return Ae2Reflect.readField(cpu, fCPU_cpu);
}
@@ -183,46 +132,4 @@ public class Ae2Reflect {
return Ae2Reflect.readField(cpu, fCPU_size);
}
public static int getGuiLeft(GuiContainer gui) {
return Ae2Reflect.readField(gui, fGuiContainer_guiLeft);
}
public static int getGuiTop(GuiContainer gui) {
return Ae2Reflect.readField(gui, fGuiContainer_guiTop);
}
public static void setReservedSpace(GuiFCBaseMonitor gui, int size) {
try {
mGuiPatternTerm_reservedSpaceSetter.invoke(gui, size);
} catch (Exception e) {
throw new IllegalStateException("Failed to invoke method: " + mGuiPatternTerm_reservedSpaceSetter, e);
}
}
public static int getReservedSpace(GuiFCBaseMonitor gui) {
try {
return (int) mGuiPatternTerm_reservedSpace.invoke(gui);
} catch (Exception e) {
throw new IllegalStateException("Failed to invoke method: " + mGuiPatternTerm_reservedSpace, e);
}
}
public static AppEngRenderItem getStackSizeRenderer(AEBaseGui gui) {
return Ae2Reflect.readField(gui, fAEBaseGui_stackSizeRenderer);
}
public static GuiTabButton getOriginalGuiButton(GuiCraftingStatus gui) {
return Ae2Reflect.readField(gui, fGuiCraftingStatus_originalGuiBtn);
}
public static void setGuiContainer(GuiBaseFluidPatternTerminal instance, ContainerFluidPatternTerminal container) {
Ae2Reflect.writeField(instance, fGuiPatternTerm_container, container);
Ae2Reflect.writeField(instance, fGuiMEMonitorable_monitorableContainer, container);
Ae2Reflect.writeField(instance, fGuiMEMonitorable_configSrc, container.getConfigManager());
}
public static GuiTabButton getCraftingStatusButton(GuiFCBaseMonitor gui) {
return Ae2Reflect.readField(gui, fGuiMEMonitorable_craftingStatusBtn);
}
}