From ba748df81e1de4d5a4522f588d64ed264adf0ef4 Mon Sep 17 00:00:00 2001 From: ayunami2000 Date: Mon, 17 Jan 2022 15:32:08 -0500 Subject: [PATCH] start adding tmi --- .../me/ayunami2000/ayuncraft/tmi/TMI.java | 7 + .../ayuncraft/tmi/TMICompatibility.java | 103 ++ .../ayunami2000/ayuncraft/tmi/TMIConfig.java | 457 +++++ .../ayuncraft/tmi/TMIConfigPanel.java | 26 + .../ayuncraft/tmi/TMIController.java | 574 ++++++ .../ayuncraft/tmi/TMIEnchantControl.java | 44 + .../ayuncraft/tmi/TMIEnchantItemPicker.java | 94 + .../ayuncraft/tmi/TMIEnchantPanel.java | 235 +++ .../ayuncraft/tmi/TMIEnchanting.java | 149 ++ .../ayuncraft/tmi/TMIFavoritesPanel.java | 77 + .../ayuncraft/tmi/TMIFireworkPanel.java | 410 +++++ .../ayunami2000/ayuncraft/tmi/TMIImages.java | 34 + .../ayuncraft/tmi/TMIItemCrop.java | 21 + .../ayuncraft/tmi/TMIItemInfo.java | 171 ++ .../ayuncraft/tmi/TMIItemMushroomCap.java | 21 + .../ayuncraft/tmi/TMIItemPanel.java | 162 ++ .../ayuncraft/tmi/TMIItemSnow.java | 30 + .../ayuncraft/tmi/TMIItemSpawner.java | 97 + .../ayuncraft/tmi/TMIPotionEffectControl.java | 167 ++ .../ayuncraft/tmi/TMIPotionEffectPicker.java | 150 ++ .../ayuncraft/tmi/TMIPotionPanel.java | 295 ++++ .../ayuncraft/tmi/TMIPrivateFields.java | 208 +++ .../ayuncraft/tmi/TMIStateButtonData.java | 16 + .../ayunami2000/ayuncraft/tmi/TMIUtils.java | 1556 +++++++++++++++++ .../me/ayunami2000/ayuncraft/tmi/TMIView.java | 390 +++++ .../ayuncraft/tmi/_tmi_MgButton.java | 149 ++ .../ayuncraft/tmi/_tmi_MgButtonHandler.java | 8 + .../ayuncraft/tmi/_tmi_MgCanvas.java | 341 ++++ .../ayuncraft/tmi/_tmi_MgFocusHandler.java | 8 + .../ayuncraft/tmi/_tmi_MgImage.java | 19 + .../ayuncraft/tmi/_tmi_MgItemButton.java | 41 + .../ayuncraft/tmi/_tmi_MgItemHandler.java | 8 + .../ayuncraft/tmi/_tmi_MgTabView.java | 139 ++ .../ayuncraft/tmi/_tmi_MgTextField.java | 101 ++ .../ayuncraft/tmi/_tmi_MgTooltipHandler.java | 6 + .../ayuncraft/tmi/_tmi_MgWidget.java | 102 ++ .../ayuncraft/tmi/_tmi_MgZOrder.java | 18 + .../eaglercraft/glemu/EaglerAdapterGL30.java | 3 + .../java/net/minecraft/src/GuiContainer.java | 2 +- .../java/net/minecraft/src/GuiScreen.java | 2 +- .../minecraft/src/SlotCreativeInventory.java | 2 +- 41 files changed, 6440 insertions(+), 3 deletions(-) create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMI.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMICompatibility.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMIConfig.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMIConfigPanel.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMIController.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMIEnchantControl.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMIEnchantItemPicker.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMIEnchantPanel.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMIEnchanting.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMIFavoritesPanel.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMIFireworkPanel.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMIImages.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemCrop.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemInfo.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemMushroomCap.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemPanel.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemSnow.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemSpawner.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMIPotionEffectControl.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMIPotionEffectPicker.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMIPotionPanel.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMIPrivateFields.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMIStateButtonData.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMIUtils.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/TMIView.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgButton.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgButtonHandler.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgCanvas.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgFocusHandler.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgImage.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgItemButton.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgItemHandler.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgTabView.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgTextField.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgTooltipHandler.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgWidget.java create mode 100644 src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgZOrder.java diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMI.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMI.java new file mode 100644 index 0000000..45af0d4 --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMI.java @@ -0,0 +1,7 @@ +package me.ayunami2000.ayuncraft.tmi; + +public enum TMI +{ + instance; + public TMIController controller = new TMIController(); +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMICompatibility.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMICompatibility.java new file mode 100644 index 0000000..d72563e --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMICompatibility.java @@ -0,0 +1,103 @@ +package me.ayunami2000.ayuncraft.tmi; + +import java.lang.reflect.Field; +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import net.minecraft.client.Minecraft; +import net.minecraft.src.Container; + +public class TMICompatibility +{ + public static final String COPYRIGHT = "All of TooManyItems except for thesmall portion excerpted from the original Minecraft game is copyright 2011Marglyph. TooManyItems is free for personal use only. Do not redistributeTooManyItems, including in mod packs, and do not use TooManyItems\' sourcecode or graphics in your own mods."; + private static boolean prevZanEnabled = false; + + public static void disableCompetingMods() + { + prevZanEnabled = setZanMinimapEnabled(false); + } + + public static void restoreCompetingMods() + { + setZanMinimapEnabled(prevZanEnabled); + } + + public static boolean setZanMinimapEnabled(boolean var0) + { + try + { + boolean var1 = true; + Class var2 = Class.forName("mod_ZanMinimap"); + Field var3 = var2.getField("instance"); + Object var4 = var3.get((Object)null); + Field[] var5 = var2.getDeclaredFields(); + Field[] var6 = var5; + int var7 = var5.length; + + for (int var8 = 0; var8 < var7; ++var8) + { + Field var9 = var6[var8]; + + if (var9.getName().equals("hide")) + { + var9.setAccessible(true); + var1 = !var9.getBoolean(var4); + var9.setBoolean(var4, !var0); + } + } + + return var1; + } + catch (ClassNotFoundException var10) + { + ; + } + catch (IllegalAccessException var11) + { + System.out.println("IllegalAccessException in setZanMinimapEnabled."); + } + catch (NoSuchFieldException var12) + { + System.out.println("NoSuchFieldException in setZanMinimapEnabled."); + } + + return true; + } + + public static boolean callConvenientInventoryHandler(int var0, int var1, boolean var2, Minecraft var3, Container var4) + { + if (TMIUtils.isCreativeMode()) + { + return false; + } + else + { + try + { + Class var5 = Class.forName("ConvenientInventory"); + Class[] var6 = new Class[] {Integer.TYPE, Integer.TYPE, Boolean.TYPE, Minecraft.class, Container.class}; + Method var7 = var5.getMethod("mod_convenientInventory_handleClickOnSlot", var6); + Object[] var8 = new Object[] {Integer.valueOf(var0), Integer.valueOf(var1), Boolean.valueOf(var2), var3, var4}; + var7.invoke((Object)null, var8); + return true; + } + catch (ClassNotFoundException var9) + { + return false; + } + catch (NoSuchMethodException var10) + { + return false; + } + catch (InvocationTargetException var11) + { + System.out.println("callConvenientInventoryHandler: " + var11.getCause()); + return false; + } + catch (IllegalAccessException var12) + { + System.out.println("callConvenientInventoryHandler: " + var12); + return false; + } + } + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIConfig.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIConfig.java new file mode 100644 index 0000000..c3a2f51 --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIConfig.java @@ -0,0 +1,457 @@ +package me.ayunami2000.ayuncraft.tmi; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; + +import net.lax1dude.eaglercraft.EaglerAdapter; +import net.minecraft.client.Minecraft; +import net.minecraft.src.CreativeTabs; +import net.minecraft.src.GuiContainerCreative; +import net.minecraft.src.Item; +import net.minecraft.src.ItemStack; +import org.lwjgl.input.Keyboard; + +public class TMIConfig +{ + public static final String COPYRIGHT = "All of TooManyItems except for thesmall portion excerpted from the original Minecraft game is copyright 2011Marglyph. TooManyItems is free for personal use only. Do not redistributeTooManyItems, including in mod packs, and do not use TooManyItems\' sourcecode or graphics in your own mods."; + public static final String VERSION = "1.5.2 2013-04-25"; + public static final int NUM_SAVES = 7; + public static final int INVENTORY_SIZE = 44; + public static boolean isModloaderEnabled = false; + private static TMIConfig instance; + private static List items = new ArrayList(); + private static List enchantableItems = new ArrayList(); + private static List favorites = new ArrayList(); + private static HashSet toolIds = new HashSet(); + private static HashSet nonUnlimitedIds; + private Map settings = new LinkedHashMap(); + private static ItemStack[][] states; + public static boolean[] statesSaved; + + public TMIConfig() + { + this.settings.put("enable", "true"); + this.settings.put("enablemp", "true"); + this.settings.put("itemsonly", "false"); + this.settings.put("give-command", "/give {0} {1} {2} {3}"); + this.settings.put("key", "o"); + + for (int var1 = 0; var1 < this.getNumSaves(); ++var1) + { + this.settings.put("save-name" + (var1 + 1), "" + (var1 + 1)); + } + + this.settings.put("replace-items", "true"); + instance = this; + } + + public static boolean isMultiplayer() + { + ThreadGroup var0 = Thread.currentThread().getThreadGroup(); + Thread[] var1 = new Thread[var0.activeCount()]; + var0.enumerate(var1); + + for (int var2 = 0; var2 < var1.length; ++var2) + { + if (var1[var2] != null) + { + String var3 = var1[var2].getName(); + + if (var3 != null && var3.equals("Client read thread")) + { + return true; + } + } + } + + return false; + } + + public static TMIConfig getInstance() + { + if (instance == null) + { + new TMIConfig(); + } + + return instance; + } + + public Map getSettings() + { + return this.settings; + } + + public List getItems() + { + return items; + } + + public List getEnchantableItems() + { + return enchantableItems; + } + + public int getHotkey() + { + String var1 = (String)this.settings.get("key"); + boolean var2 = false; + int var3 = EaglerAdapter.getKeyIndex(var1.toUpperCase()); + + if (var3 == 0) + { + var3 = 24; + } + + return var3; + } + + public int getNumSaves() + { + return 7; + } + + public boolean isStateSaved(int var1) + { + return statesSaved[var1]; + } + + public ItemStack[] getState(int var1) + { + return states[var1]; + } + + public boolean getBooleanSetting(String var1) + { + return Boolean.parseBoolean((String)this.settings.get(var1)); + } + + public boolean isEnabled() + { + return isMultiplayer() && this.getBooleanSetting("enablemp") || !isMultiplayer() && this.getBooleanSetting("enable"); + } + + public void toggleEnabled() + { + String var1 = isMultiplayer() ? "enablemp" : "enable"; + this.settings.put(var1, Boolean.toString(!this.getBooleanSetting(var1))); + } + + public void setEnabled(boolean var1) + { + String var2 = isMultiplayer() ? "enablemp" : "enable"; + this.settings.put(var2, Boolean.toString(var1)); + } + + public static boolean isTool(Item var0) + { + return toolIds.contains(Integer.valueOf(var0.itemID)); + } + + public static boolean canItemBeUnlimited(Item var0) + { + return !nonUnlimitedIds.contains(Integer.valueOf(var0.itemID)); + } + + public boolean areDamageVariantsShown() + { + if (isMultiplayer()) + { + String var1 = (String)this.getSettings().get("give-command"); + return var1.contains("{3}"); + } + else + { + return true; + } + } + + public void clearState(int var1) + { + for (int var2 = 0; var2 < 44; ++var2) + { + states[var1][var2] = null; + statesSaved[var1] = false; + } + + this.settings.put("save" + (var1 + 1), ""); + } + + public void loadState(int var1) + { + if (statesSaved[var1]) + { + try + { + if (Minecraft.getMinecraft().currentScreen instanceof GuiContainerCreative) + { + TMIPrivateFields.setCreativeTab.invoke((GuiContainerCreative)Minecraft.getMinecraft().currentScreen, new Object[] {CreativeTabs.tabInventory}); + } + } + catch (Exception var5) + { + System.out.println(var5); + } + + ItemStack[] var2 = TMIUtils.getPlayer().inventory.mainInventory; + ItemStack[] var3 = TMIUtils.getPlayer().inventory.armorInventory; + int var4; + + for (var4 = 0; var4 < 4; ++var4) + { + var3[var4] = TMIUtils.copyStack(states[var1][var4 + 4]); + } + + for (var4 = 0; var4 < 27; ++var4) + { + var2[var4 + 9] = TMIUtils.copyStack(states[var1][var4 + 8]); + } + + for (var4 = 0; var4 < 9; ++var4) + { + var2[var4] = TMIUtils.copyStack(states[var1][var4 + 8 + 27]); + } + } + } + + public void saveState(int var1) + { + ItemStack[] var2 = TMIUtils.getPlayer().inventory.mainInventory; + ItemStack[] var3 = TMIUtils.getPlayer().inventory.armorInventory; + int var4; + + for (var4 = 0; var4 < 4; ++var4) + { + states[var1][var4 + 4] = TMIUtils.copyStack(var3[var4]); + } + + for (var4 = 0; var4 < 27; ++var4) + { + states[var1][var4 + 8] = TMIUtils.copyStack(var2[var4 + 9]); + } + + for (var4 = 0; var4 < 9; ++var4) + { + states[var1][var4 + 8 + 27] = TMIUtils.copyStack(var2[var4]); + } + + this.settings.put("save" + (var1 + 1), this.encodeState(var1)); + statesSaved[var1] = true; + } + + public String encodeState(int var1) + { + StringBuilder var2 = new StringBuilder(); + + for (int var3 = 0; var3 < 44; ++var3) + { + if (states[var1][var3] != null) + { + var2.append(states[var1][var3].itemID); + var2.append(":"); + var2.append(states[var1][var3].stackSize); + var2.append(":"); + var2.append(states[var1][var3].getItemDamageForDisplay()); + List var4 = TMIUtils.getEnchantments(states[var1][var3]); + Iterator var5 = var4.iterator(); + + while (var5.hasNext()) + { + int[] var6 = (int[])var5.next(); + int var7 = var6[0]; + int var8 = var6[1]; + var2.append(":" + var7 + ":" + var8); + } + } + + var2.append(","); + } + + return var2.toString(); + } + + public void decodeState(int var1, String var2) + { + if (var2.trim().equals("")) + { + statesSaved[var1] = false; + } + else + { + String[] var3 = var2.split(",", 0); + + for (int var4 = 0; var4 < var3.length && var4 < states[var1].length; ++var4) + { + String[] var5 = var3[var4].split(":"); + + if (var5.length >= 3) + { + try + { + states[var1][var4] = new ItemStack(Integer.parseInt(var5[0]), Integer.parseInt(var5[1]), Integer.parseInt(var5[2])); + + for (int var6 = 3; var6 < var5.length - 1; var6 += 2) + { + int var7 = Integer.parseInt(var5[var6]); + int var8 = Integer.parseInt(var5[var6 + 1]); + TMIUtils.addEnchantment(states[var1][var4], var7, var8); + } + } + catch (Exception var9) + { + System.out.println(var9); + } + } + } + + statesSaved[var1] = true; + } + } + + public List getFavorites() + { + return favorites; + } + + public void decodeFavorites() + { + favorites.clear(); + String[] var1 = ((String)this.settings.get("favorites")).trim().split(",", 0); + String[] var2 = var1; + int var3 = var1.length; + + for (int var4 = 0; var4 < var3; ++var4) + { + String var5 = var2[var4]; + String[] var6 = var5.split(":"); + + if (var6.length >= 2) + { + try + { + int var7 = Integer.parseInt(var6[0]); + int var8 = Integer.parseInt(var6[1]); + ItemStack var9 = new ItemStack(var7, TMIUtils.maxStackSize(var7), var8); + + for (int var10 = 2; var10 < var6.length - 1; var10 += 2) + { + int var11 = Integer.parseInt(var6[var10]); + int var12 = Integer.parseInt(var6[var10 + 1]); + TMIUtils.addEnchantment(var9, var11, var12); + } + + favorites.add(var9); + } + catch (Exception var13) + { + System.out.println(var13); + } + } + } + } + + public void encodeFavorites() + { + StringBuilder var1 = new StringBuilder(); + Iterator var2 = favorites.iterator(); + + while (var2.hasNext()) + { + ItemStack var3 = (ItemStack)var2.next(); + var1.append(var3.itemID); + var1.append(":"); + var1.append(var3.getItemDamageForDisplay()); + List var4 = TMIUtils.getEnchantments(var3); + Iterator var5 = var4.iterator(); + + while (var5.hasNext()) + { + int[] var6 = (int[])var5.next(); + int var7 = var6[0]; + int var8 = var6[1]; + var1.append(":" + var7 + ":" + var8); + } + + var1.append(","); + } + + this.settings.put("favorites", var1.toString()); + } + + public static boolean canDelete() + { + return !isMultiplayer(); + } + + public static boolean canChangeWeather() + { + return !getInstance().getBooleanSetting("itemsonly"); + } + + public static boolean canChangeCreativeMode() + { + return !getInstance().getBooleanSetting("itemsonly"); + } + + public static boolean canChangeTime() + { + return !getInstance().getBooleanSetting("itemsonly"); + } + + public static boolean canChangeHealth() + { + return !isMultiplayer() && !getInstance().getBooleanSetting("itemsonly"); + } + + public static boolean canRestoreSaves() + { + return !isMultiplayer(); + } + + public static boolean canChangeDifficulty() + { + return !isMultiplayer(); + } + + static + { + int var0; + + for (var0 = 0; var0 <= 3; ++var0) + { + toolIds.add(Integer.valueOf(TMIItemInfo.addItemOffset(var0))); + } + + for (var0 = 11; var0 <= 23; ++var0) + { + toolIds.add(Integer.valueOf(TMIItemInfo.addItemOffset(var0))); + } + + for (var0 = 27; var0 <= 30; ++var0) + { + toolIds.add(Integer.valueOf(TMIItemInfo.addItemOffset(var0))); + } + + for (var0 = 34; var0 <= 38; ++var0) + { + toolIds.add(Integer.valueOf(TMIItemInfo.addItemOffset(var0))); + } + + for (var0 = 42; var0 <= 61; ++var0) + { + toolIds.add(Integer.valueOf(TMIItemInfo.addItemOffset(var0))); + } + + toolIds.add(Integer.valueOf(TMIItemInfo.addItemOffset(103))); + toolIds.add(Integer.valueOf(TMIItemInfo.addItemOffset(90))); + toolIds.add(Integer.valueOf(TMIItemInfo.addItemOffset(5))); + nonUnlimitedIds = new HashSet(); + nonUnlimitedIds.add(Integer.valueOf(TMIItemInfo.addItemOffset(102))); + states = new ItemStack[7][44]; + statesSaved = new boolean[7]; + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIConfigPanel.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIConfigPanel.java new file mode 100644 index 0000000..0279962 --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIConfigPanel.java @@ -0,0 +1,26 @@ +package me.ayunami2000.ayuncraft.tmi; + +public class TMIConfigPanel extends _tmi_MgWidget +{ + public static final String COPYRIGHT = "All of TooManyItems except for thesmall portion excerpted from the original Minecraft game is copyright 2011Marglyph. TooManyItems is free for personal use only. Do not redistributeTooManyItems, including in mod packs, and do not use TooManyItems\' sourcecode or graphics in your own mods."; + + public TMIConfigPanel() + { + super(0, 0); + } + + public void resize() {} + + public void draw(_tmi_MgCanvas var1, int var2, int var3) + { + if (this.show) + { + this.drawChildren(var1, var2, var3); + } + } + + public boolean click(int var1, int var2, int var3) + { + return this.delegateClickToChildren(var1, var2, var3); + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIController.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIController.java new file mode 100644 index 0000000..f5be230 --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIController.java @@ -0,0 +1,574 @@ +package me.ayunami2000.ayuncraft.tmi; + +import java.util.Iterator; +import net.minecraft.client.Minecraft; +import net.minecraft.src.*; +import net.lax1dude.eaglercraft.EaglerAdapter; + +public class TMIController implements _tmi_MgButtonHandler, _tmi_MgItemHandler, _tmi_MgFocusHandler +{ + public static final String COPYRIGHT = "All of TooManyItems except for thesmall portion excerpted from the original Minecraft game is copyright 2011Marglyph. TooManyItems is free for personal use only. Do not redistributeTooManyItems, including in mod packs, and do not use TooManyItems\' sourcecode or graphics in your own mods."; + private GuiContainer window = null; + private RenderItem drawItems = null; + private TMIConfig config = TMIConfig.getInstance(); + private TMIView view = null; + public _tmi_MgTextField focusedTextField = null; + long lastKeyPressTime = 0L; + long lastPrefsLoadTime = 0L; + long deleteAllWaitUntil = 0L; + public static final long KEY_DELAY = 200L; + public static final long PREFS_DELAY = 2000L; + public boolean deleteMode = false; + private boolean haveReplacedItems = false; + private boolean wasInWindowLastFrame = false; + private long windowLastFocused = 0L; + private int savedChatKeyCode; + private _tmi_MgCanvas canvas; + + public void onCreate(GuiContainer var1) + { + this.window = var1; + this.drawItems = new RenderItem(); + this.canvas = new _tmi_MgCanvas(var1, this.drawItems); + this.view = new TMIView(this.canvas, this.config, this); + TMIUtils.loadItems(this.config); + TMIUtils.replaceCustomItems(); + this.savedChatKeyCode = Minecraft.getMinecraft().gameSettings.keyBindChat.keyCode; + } + + public void onEnterFrame(int var1, int var2, int var3, int var4) + { + try + { + boolean var5 = EaglerAdapter.isFocused(); + + if (var5 && !this.wasInWindowLastFrame) + { + this.windowLastFocused = System.currentTimeMillis(); + } + + this.wasInWindowLastFrame = var5; + TMIUtils.suppressAchievementNotice(); + boolean var6 = false; + + if (this.window instanceof GuiContainerCreative && TMIPrivateFields.creativeTab.getInt(this.window) == CreativeTabs.tabAllSearch.getTabIndex()) + { + var6 = true; + } + + boolean var7 = this.window instanceof GuiRepair; + + if (System.currentTimeMillis() - this.lastKeyPressTime > 200L) + { + if (EaglerAdapter.isKeyDown(this.config.getHotkey()) && this.focusedTextField == null && !var6 && !var7) + { + this.config.toggleEnabled(); + TMIUtils.savePreferences(this.config); + this.lastKeyPressTime = System.currentTimeMillis(); + } + + TMIUtils.updateUnlimitedItems(); + } + + if (System.currentTimeMillis() - this.lastPrefsLoadTime > 2000L) + { + TMIUtils.loadPreferences(this.config); + + if (this.lastPrefsLoadTime == 0L) + { + TMIUtils.savePreferences(this.config); + } + + this.lastPrefsLoadTime = System.currentTimeMillis(); + } + + if (this.config.isEnabled()) + { + this.view.setTooltip((String)null); + this.view.layout(this.window.width, this.window.height, var3, var4); + this.canvas.drawWidgets(var1, var2); + this.view.determineTooltip(var1, var2); + } + } + catch (Exception var8) + { + TMIUtils.safeReportException(var8); + this.disable(); + } + } + + public void focus(_tmi_MgWidget var1) + { + if (this.focusedTextField != null && this.focusedTextField != var1) + { + this.focusedTextField.blur(); + } + + if (var1 instanceof _tmi_MgTextField) + { + this.focusedTextField = (_tmi_MgTextField)var1; + Minecraft.getMinecraft().gameSettings.keyBindChat.keyCode = 0; + + try + { + if (TMIUtils.isCreativeMode() && TMIPrivateFields.creativeTab.getInt(this.window) == CreativeTabs.tabAllSearch.getTabIndex()) + { + TMIPrivateFields.setCreativeTab.invoke((GuiContainerCreative)this.window, new Object[] {CreativeTabs.tabInventory}); + } + } + catch (Exception var3) + { + System.out.println(var3); + } + } + } + + public void blur(_tmi_MgWidget var1) + { + if (this.focusedTextField == var1) + { + this.focusedTextField = null; + Minecraft.getMinecraft().gameSettings.keyBindChat.keyCode = this.savedChatKeyCode; + } + } + + public void onClose() + { + Minecraft.getMinecraft().gameSettings.keyBindChat.keyCode = this.savedChatKeyCode; + } + + public boolean allowRegularTip() + { + return !this.view.hasTooltip(); + } + + public void showToolTip(int var1, int var2) + { + try + { + this.view.showToolTip(var1, var2); + } + catch (Exception var4) + { + TMIUtils.safeReportException(var4); + this.disable(); + } + } + + public void handleScrollWheel(int var1, int var2) + { + if (this.view.itemPanel.contains(var1, var2)) + { + int var3 = EaglerAdapter.mouseGetEventDWheel(); + + if (var3 != 0) + { + TMIItemPanel var10000 = this.view.itemPanel; + TMIItemPanel.page += var3 < 0 ? 1 : -1; + } + + try + { + TMIPrivateFields.lwjglMouseEventDWheel.setInt((Object)null, 0); + TMIPrivateFields.lwjglMouseDWheel.setInt((Object)null, 0); + } + catch (Exception var5) + { + ; + } + } + } + + public boolean onMouseEvent(int var1, int var2, int var3, boolean var4, Slot var5, Container var6) + { + if (!this.config.isEnabled()) + { + return true; + } + else if (this.windowLastFocused > System.currentTimeMillis() - 200L) + { + return false; + } + else if (!this.onClick(var1, var2, var3)) + { + return false; + } + else + { + boolean var7 = var4 && (EaglerAdapter.isKeyDown(42) || EaglerAdapter.isKeyDown(54)); + ItemStack var8 = TMIUtils.getHeldItem(); + ItemStack var9 = null; + Slot var11 = null; + int var12 = -1; + int var13 = -1; + + if (var5 != null) + { + var9 = var5.getStack(); + var12 = var5.slotNumber; + var13 = var5.slotNumber; + + if (var5 instanceof SlotCreativeInventory) + { + try + { + Slot var10 = (Slot)((Slot)TMIPrivateFields.creativeSlot.get((SlotCreativeInventory)var5)); + var12 = var10.slotNumber; + } + catch (Exception var16) + { + System.out.println(var16); + } + } + else if (this.window instanceof GuiContainerCreative) + { + if (var12 >= 45) + { + var12 -= 9; + } + else + { + var12 = 0; + } + } + + if (!TMIConfig.isMultiplayer()) + { + try + { + var11 = (Slot)TMIUtils.getPlayer().openContainer.inventorySlots.get(var12); + } + catch (IndexOutOfBoundsException var15) + { + System.out.println(var15); + } + } + } + + if (!var4) + { + var12 = -999; + var13 = -999; + + if (var8 != null && (var8.stackSize < 0 || var8.stackSize > 64)) + { + var8.stackSize = 1; + } + } + + if (var11 != null && var3 == 0 && this.deleteMode && var12 >= 0 && var5 != null) + { + if (TMIUtils.shiftKey() && var9 != null) + { + TMIUtils.deleteItemsOfType(var9, this.window); + } + else + { + var11.putStack((ItemStack)null); + } + } + else if (!TMICompatibility.callConvenientInventoryHandler(var12, var3, var7, Minecraft.getMinecraft(), var6)) + { + if (var12 == 0 && var3 == 1 && this.isCrafting()) + { + for (int var14 = 0; var14 < 64; ++var14) + { + this.window.handleMouseClick(var5, var13, var3, var7 ? 1 : 0); + } + } + else if (var12 != -1) + { + if (var3 <= 1 && var11 != null && var9 == null && var8 != null && (var8.stackSize < 0 || var8.stackSize > 64)) + { + TMIUtils.deleteHeldItem(); + var9 = TMIUtils.copyStack(var8); + var9.stackSize = 111; + var11.putStack(var9); + } + else + { + if (!TMIUtils.isCreativeMode() || var11 == null || var8 != null || var9 == null || var9.stackSize <= 64) + { + return true; + } + + var11.putStack((ItemStack)null); + TMIUtils.setHeldItem(var9); + } + } + } + + return false; + } + } + + public boolean onClick(int var1, int var2, int var3) + { + try + { + if (this.config.isEnabled()) + { + this.canvas.sortByZOrder(); + Object var4 = null; + _tmi_MgWidget var5 = null; + Iterator var6 = this.canvas.widgets.iterator(); + + while (var6.hasNext()) + { + _tmi_MgWidget var7 = (_tmi_MgWidget)var6.next(); + + if (var7.contains(var1, var2)) + { + var5 = var7; + break; + } + } + + if (this.focusedTextField != null && this.focusedTextField != var5) + { + this.focusedTextField.blur(); + this.focusedTextField = null; + } + + if (var5 != null) + { + return var5.click(var1, var2, var3); + } + } + } + catch (Exception var8) + { + TMIUtils.safeReportException(var8); + this.disable(); + } + + return true; + } + + public boolean onButtonRightClick(Object var1) + { + return true; + } + + public boolean onButtonPress(Object var1) + { + if (var1 instanceof TMIStateButtonData) + { + TMIStateButtonData var4 = (TMIStateButtonData)var1; + + if (var4.action == 1) + { + this.config.clearState(var4.state); + TMIUtils.savePreferences(this.config); + } + else if (this.config.isStateSaved(var4.state)) + { + this.config.loadState(var4.state); + TMIUtils.savePreferences(this.config); + } + else + { + this.config.saveState(var4.state); + TMIUtils.savePreferences(this.config); + } + + return false; + } + else if (var1 instanceof String) + { + String var2 = (String)var1; + + if (var2.equals("rain")) + { + TMIUtils.setRaining(!TMIUtils.isRaining()); + } + else if (var2.equals("survival")) + { + TMIUtils.setGameMode(0); + } + else if (var2.equals("creative")) + { + TMIUtils.setGameMode(1); + } + else if (var2.equals("adventure")) + { + TMIUtils.setGameMode(2); + } + else if (var2.equals("dawn")) + { + TMIUtils.setHourForward(0); + } + else if (var2.equals("noon")) + { + TMIUtils.setHourForward(6); + } + else if (var2.equals("dusk")) + { + TMIUtils.setHourForward(12); + } + else if (var2.equals("midnight")) + { + TMIUtils.setHourForward(18); + } + else + { + TMIItemPanel var10000; + + if (var2.equals("next")) + { + var10000 = this.view.itemPanel; + ++TMIItemPanel.page; + } + else if (var2.equals("prev")) + { + var10000 = this.view.itemPanel; + --TMIItemPanel.page; + } + else if (var2.equals("health")) + { + TMIUtils.setPlayerHealth(20); + TMIUtils.fillHunger(); + } + else if (var2.equals("difficulty")) + { + TMIUtils.incrementDifficulty(); + } + else if (var2.equals("deleteMode")) + { + ItemStack var3 = TMIUtils.getHeldItem(); + + if (var3 != null) + { + if (TMIUtils.shiftKey()) + { + TMIUtils.deleteHeldItem(); + TMIUtils.deleteItemsOfType(var3, this.window); + this.deleteAllWaitUntil = System.currentTimeMillis() + 1000L; + } + else + { + TMIUtils.deleteHeldItem(); + } + } + else if (TMIUtils.shiftKey()) + { + if (System.currentTimeMillis() > this.deleteAllWaitUntil) + { + TMIUtils.deleteInventory(); + } + } + else + { + this.deleteMode = !this.deleteMode; + } + } + } + + return false; + } + else + { + return true; + } + } + + public boolean onItemEvent(ItemStack var1, int var2) + { + if (!TMIConfig.isMultiplayer() && var1.itemID == 52 && TMIUtils.itemDisplayName(var1).contains("Random Firework")) + { + TMIUtils.giveStack(TMIUtils.makeRandomFireworkSpawner(), this.config, 1); + return false; + } + else if (var2 != 0) + { + if (var2 == 1) + { + TMIUtils.giveStack(var1, this.config, 1); + return false; + } + else + { + return true; + } + } + else if (!TMIConfig.isMultiplayer() && (EaglerAdapter.isKeyDown(42) || EaglerAdapter.isKeyDown(54))) + { + Item var3 = Item.itemsList[var1.itemID]; + + if (TMIConfig.isTool(var3)) + { + TMIUtils.giveStack(new ItemStack(var1.itemID, 1, -32000), this.config, 1); + return false; + } + else if (TMIConfig.canItemBeUnlimited(var3)) + { + ItemStack var4 = TMIUtils.copyStack(var1); + NBTTagCompound var5 = TMIUtils.getTagCompoundWithCreate(var4, "TooManyItems"); + var5.setBoolean("Unlimited", true); + TMIUtils.addLore(var4, "TMI Unlimited"); + TMIUtils.giveStack(var4, this.config); + return false; + } + else + { + TMIUtils.giveStack(var1, this.config); + return false; + } + } + else if (!EaglerAdapter.isKeyDown(56) && !EaglerAdapter.isKeyDown(184)) + { + TMIUtils.giveStack(var1, this.config); + return false; + } + else + { + this.config.getFavorites().add(var1); + TMIUtils.savePreferences(this.config); + return false; + } + } + + public boolean onKeypress(char var1, int var2) + { + if (this.focusedTextField != null) + { + boolean var3 = this.focusedTextField.keypress(var1, var2); + + if (this.focusedTextField == this.view.itemPanel.textField) + { + TMIUtils.filterItems(this.focusedTextField.value(), this.config); + } + + return var3; + } + else + { + return false; + } + } + + public boolean shouldPauseGame() + { + return false; + } + + public boolean isChest() + { + return this.window.inventorySlots instanceof ContainerChest; + } + + public boolean isCrafting() + { + return this.window.inventorySlots instanceof ContainerPlayer || this.window.inventorySlots instanceof ContainerWorkbench; + } + + public void disable() + { + this.config.setEnabled(false); + } + + public static void sendWindowClick(Container var0, int var1, int var2, boolean var3) + { + Minecraft.getMinecraft().playerController.windowClick(var0.windowId, var1, var2, var3 ? 1 : 0, Minecraft.getMinecraft().thePlayer); + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIEnchantControl.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIEnchantControl.java new file mode 100644 index 0000000..fc42c10 --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIEnchantControl.java @@ -0,0 +1,44 @@ +package me.ayunami2000.ayuncraft.tmi; + +import net.minecraft.src.Enchantment; + +class TMIEnchantControl extends _tmi_MgWidget +{ + public static final String COPYRIGHT = "All of TooManyItems except for thesmall portion excerpted from the original Minecraft game is copyright 2011Marglyph. TooManyItems is free for personal use only. Do not redistributeTooManyItems, including in mod packs, and do not use TooManyItems\' sourcecode or graphics in your own mods."; + private String name; + private boolean normallyPossible = true; + private Enchantment enchantment; + + public TMIEnchantControl(int var1, int var2, int var3, int var4, int var5, String var6, Enchantment var7, boolean var8) + { + super(var1, var2, var3, var4, var5); + this.name = var6; + this.enchantment = var7; + this.normallyPossible = var8; + } + + public boolean click(int var1, int var2, int var3) + { + boolean var4 = var1 < this.x + 13; + TMIEnchanting.adjustEnchantmentLevel(this.enchantment, var4 ? -1 : 1); + return false; + } + + public void draw(_tmi_MgCanvas var1, int var2, int var3) + { + int var4 = this.normallyPossible ? -1 : -5609882; + var1.drawRect(this.x, this.y, 12, 12, -301989888); + var1.drawRect(this.x + 13, this.y, this.width - 13, 12, -301989888); + var1.drawTextCentered(this.x, this.y, 12, 12, "-", var4); + int var5 = TMIEnchanting.getEnchantmentLevel(this.enchantment); + String var6 = " " + var5; + String var7; + + for (var7 = "+ " + this.name; var1.getTextWidth(var7 + var6) + 14 > this.width; var7 = var7.substring(0, var7.length() - 1)) + { + ; + } + + var1.drawText(this.x + 14, this.y + 2, var7 + var6, var4); + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIEnchantItemPicker.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIEnchantItemPicker.java new file mode 100644 index 0000000..531f78f --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIEnchantItemPicker.java @@ -0,0 +1,94 @@ +package me.ayunami2000.ayuncraft.tmi; + +import net.minecraft.src.ItemStack; + +import java.util.Iterator; + +class TMIEnchantItemPicker extends _tmi_MgWidget implements _tmi_MgButtonHandler +{ + private TMIEnchantPanel enchantPanel; + public long mouseLastInArea = 0L; + public static final int ITEM_SPACING = 18; + public static final int MARGIN = 0; + public static final int ITEM_MARGIN = 1; + + public TMIEnchantItemPicker(TMIEnchantPanel var1) + { + super(0, 0); + this.enchantPanel = var1; + int[] var2 = new int[] {20, 5, 21, 22, 23, 37, 54, 55, 56, 57, 93, 147}; + + for (int var3 = 0; var3 < var2.length; ++var3) + { + ItemStack var4 = new ItemStack(TMIItemInfo.addItemOffset(var2[var3]), 1, 0); + _tmi_MgItemButton var5 = new _tmi_MgItemButton("", var4, this, Integer.valueOf(var2[var3])); + this.children.add(var5); + } + } + + public void resize() + { + int var1 = 0; + int var2 = 0; + Iterator var3 = this.children.iterator(); + + while (var3.hasNext()) + { + _tmi_MgWidget var4 = (_tmi_MgWidget)var3.next(); + this.height = var2 + 18; + var4.x = this.x + var1; + var4.y = this.y + var2; + var1 += 18; + + if (var1 + 18 > this.width) + { + var1 = 0; + var2 += 18; + } + } + } + + public void open() + { + this.show = true; + this.mouseLastInArea = System.currentTimeMillis(); + } + + public void draw(_tmi_MgCanvas var1, int var2, int var3) + { + long var4 = System.currentTimeMillis(); + + if (this.contains(var2, var3)) + { + this.mouseLastInArea = var4; + } + else if (var4 - this.mouseLastInArea > 1200L) + { + this.show = false; + return; + } + + if (this.show) + { + var1.drawRect(this.x, this.y, this.width, this.height, -301989888); + this.drawChildren(var1, var2, var3); + } + } + + public boolean click(int var1, int var2, int var3) + { + return this.delegateClickToChildren(var1, var2, var3); + } + + public boolean onButtonPress(Object var1) + { + this.enchantPanel.chooseItem(new ItemStack(TMIItemInfo.addItemOffset(((Integer)var1).intValue()), 1, 0)); + this.show = false; + return true; + } + + public boolean onButtonRightClick(Object var1) + { + return true; + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIEnchantPanel.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIEnchantPanel.java new file mode 100644 index 0000000..52f50cf --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIEnchantPanel.java @@ -0,0 +1,235 @@ +package me.ayunami2000.ayuncraft.tmi; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import net.minecraft.client.Minecraft; +import net.minecraft.src.Enchantment; +import net.minecraft.src.Item; +import net.minecraft.src.ItemStack; +import net.minecraft.src.StatCollector; + +public class TMIEnchantPanel extends _tmi_MgWidget implements _tmi_MgButtonHandler +{ + public static final String COPYRIGHT = "All of TooManyItems except for thesmall portion excerpted from the original Minecraft game is copyright 2011Marglyph. TooManyItems is free for personal use only. Do not redistributeTooManyItems, including in mod packs, and do not use TooManyItems\' sourcecode or graphics in your own mods."; + private Item selectedItem = null; + private Map enchantmentSettings = new HashMap(); + private List items; + _tmi_MgButton prevButton; + _tmi_MgButton nextButton; + _tmi_MgButton createButton; + _tmi_MgButton favoriteButton; + _tmi_MgItemButton itemButton; + public int page = 0; + private _tmi_MgTooltipHandler tooltipHandler; + private TMIEnchantItemPicker itemPicker; + private boolean showItemPicker = false; + private _tmi_MgTextField nameField; + + public TMIEnchantPanel(_tmi_MgTooltipHandler var1) + { + super(0, 0); + this.nameField = new _tmi_MgTextField(Minecraft.getMinecraft().fontRenderer, "Name...", TMI.instance.controller); + this.tooltipHandler = var1; + this.items = TMIConfig.getInstance().getEnchantableItems(); + + if (this.items.size() > 0) + { + this.selectedItem = (Item)this.items.get(0); + } + + this.itemButton = new _tmi_MgItemButton("", this, "item"); + this.nextButton = new _tmi_MgButton("", this, "next"); + this.nextButton.icon = TMIImages.iconNext; + this.nextButton.width = 16; + this.nextButton.height = 16; + this.prevButton = new _tmi_MgButton("", this, "prev"); + this.prevButton.icon = TMIImages.iconPrev; + this.prevButton.width = 16; + this.prevButton.height = 16; + this.createButton = new _tmi_MgButton("Make", this, "createEnchanted"); + this.createButton.width = 36; + this.createButton.height = 18; + this.favoriteButton = new _tmi_MgButton("Favorite", this, "favoriteEnchanted"); + this.favoriteButton.width = 48; + this.favoriteButton.height = 18; + this.itemPicker = new TMIEnchantItemPicker(this); + this.itemPicker.show = false; + } + + public void resize() + { + this.createChildren(); + this.nextButton.x = this.x + this.width - this.nextButton.width - 2; + this.nextButton.y = this.y + this.height - this.nextButton.height - 2; + this.prevButton.x = this.nextButton.x - this.prevButton.width - 1; + this.prevButton.y = this.nextButton.y; + this.itemButton.x = this.x; + this.itemButton.y = this.y + 8; + this.createButton.x = this.x + 20; + this.createButton.y = this.y + 8; + this.favoriteButton.x = this.createButton.x + this.createButton.width + 2; + this.favoriteButton.y = this.y + 8; + this.nameField.width = this.width - 5; + this.nameField.height = 14; + this.nameField.x = this.x + 1; + this.nameField.y = this.itemButton.y + 21; + this.itemPicker.x = this.x; + this.itemPicker.y = this.itemButton.y + this.itemButton.height + 1; + this.itemPicker.width = this.width; + this.itemPicker.resize(); + this.itemPicker.z = -100; + } + + private void createChildren() + { + this.children.clear(); + this.children.add(this.nextButton); + this.children.add(this.prevButton); + this.children.add(this.createButton); + this.children.add(this.favoriteButton); + this.children.add(this.itemButton); + this.children.add(this.itemPicker); + this.children.add(this.nameField); + byte var1 = 14; + byte var2 = 47; + int var3 = this.height - this.nextButton.height - var2 - 4; + int var4 = var3 / var1; + ArrayList var5 = new ArrayList(TMIEnchanting.currentEnchantmentLevels.keySet()); + int var6 = var5.size(); + + if (this.page < 0) + { + this.page = 0; + } + else if (this.page > var6 / var4) + { + this.page = var6 / var4; + } + + int var7 = this.page * var4; + + for (int var8 = 0; var8 < var4 && var8 + var7 < var6; ++var8) + { + Enchantment var9 = (Enchantment)var5.get(var8 + var7); + int var10 = this.y + var2 + var8 * var1; + String var11 = StatCollector.translateToLocal(var9.getName()); + boolean var12 = TMIUtils.isEnchantmentNormallyPossible(var9, TMIEnchanting.currentItem); + TMIEnchantControl var13 = new TMIEnchantControl(this.x, var10, 100, this.width - 3, 14, var11, var9, var12); + this.children.add(var13); + } + } + + public void draw(_tmi_MgCanvas var1, int var2, int var3) + { + if (this.show) + { + this.itemButton.stack = TMIEnchanting.currentItem; + this.drawChildren(var1, var2, var3); + + if (this.createButton.contains(var2, var3) && TMIConfig.isMultiplayer()) + { + this.tooltipHandler.setTooltip("May not work on MP servers"); + } + } + } + + public boolean click(int var1, int var2, int var3) + { + ItemStack var4 = TMIUtils.getHeldItem(); + + if (var4 == null) + { + return this.delegateClickToChildren(var1, var2, var3); + } + else + { + this.chooseItem(var4); + return false; + } + } + + public void chooseItem(ItemStack var1) + { + TMIEnchanting.setItem(var1); + this.nameField.setValue(""); + this.createChildren(); + } + + public boolean onButtonPress(Object var1) + { + if (var1 instanceof String) + { + String var2 = (String)var1; + + if (var2.equals("next")) + { + ++this.page; + this.resize(); + return false; + } + + if (var2.equals("prev")) + { + --this.page; + this.resize(); + return false; + } + + if (var2.equals("item")) + { + if (this.itemPicker.show) + { + this.itemPicker.show = false; + } + else + { + this.itemPicker.open(); + } + + this.resize(); + return false; + } + + ItemStack var3; + String var4; + + if (var2.equals("createEnchanted")) + { + var3 = TMIEnchanting.createStack(); + var4 = this.nameField.value(); + + if (!var4.equals("")) + { + TMIUtils.nameStack(var3, var4); + } + + TMIUtils.giveStack(var3, TMIConfig.getInstance()); + return false; + } + + if (var2.equals("favoriteEnchanted")) + { + var3 = TMIEnchanting.createStack(); + var4 = this.nameField.value(); + + if (!var4.equals("")) + { + TMIUtils.nameStack(var3, var4); + } + + TMIConfig.getInstance().getFavorites().add(var3); + TMIUtils.savePreferences(TMIConfig.getInstance()); + return false; + } + } + + return true; + } + + public boolean onButtonRightClick(Object var1) + { + return true; + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIEnchanting.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIEnchanting.java new file mode 100644 index 0000000..17081e2 --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIEnchanting.java @@ -0,0 +1,149 @@ +package me.ayunami2000.ayuncraft.tmi; + +import net.minecraft.src.*; + +import java.util.Iterator; +import java.util.LinkedHashMap; + +public class TMIEnchanting +{ + public static ItemStack currentItem; + public static LinkedHashMap currentEnchantmentLevels = new LinkedHashMap(); + + public static void setItem(ItemStack var0) + { + currentItem = TMIUtils.copyStack(var0); + + if (currentItem.stackTagCompound != null && currentItem.stackTagCompound.hasKey("ench")) + { + currentItem.stackTagCompound.removeTag("ench"); + } + + Item var1 = Item.itemsList[currentItem.itemID]; + LinkedHashMap var2 = new LinkedHashMap(currentEnchantmentLevels); + currentEnchantmentLevels.clear(); + Iterator var3 = var2.keySet().iterator(); + Enchantment var4; + + while (var3.hasNext()) + { + var4 = (Enchantment)var3.next(); + + if (var4 != null) + { + if (var4.type == null) + { + System.out.println("ERROR: enchantment lacks type (" + var4 + ")"); + } + else if (var4.type.canEnchantItem(var1)) + { + currentEnchantmentLevels.put(var4, Integer.valueOf(0)); + } + } + } + + var3 = var2.keySet().iterator(); + + while (var3.hasNext()) + { + var4 = (Enchantment)var3.next(); + + if (var4 != null) + { + if (var4.type == null) + { + System.out.println("ERROR: enchantment lacks type (" + var4 + ")"); + } + else if (!var4.type.canEnchantItem(var1)) + { + currentEnchantmentLevels.put(var4, Integer.valueOf(0)); + } + } + } + } + + public static ItemStack createStack() + { + ItemStack var0 = TMIUtils.copyStack(currentItem); + + if (var0.itemID == TMIItemInfo.addItemOffset(147)) + { + NBTTagList var1 = new NBTTagList(); + + for (Iterator var2 = currentEnchantmentLevels.keySet().iterator(); var2.hasNext(); var0.stackTagCompound.setTag("StoredEnchantments", var1)) + { + Enchantment var3 = (Enchantment)var2.next(); + int var4 = ((Integer)currentEnchantmentLevels.get(var3)).intValue(); + + if (var4 > 0) + { + NBTTagCompound var5 = new NBTTagCompound(); + var5.setShort("id", (short)var3.effectId); + var5.setShort("lvl", (short)var4); + var1.appendTag(var5); + } + + if (var0.stackTagCompound == null) + { + var0.stackTagCompound = new NBTTagCompound(); + } + } + } + else + { + Iterator var6 = currentEnchantmentLevels.keySet().iterator(); + + while (var6.hasNext()) + { + Enchantment var7 = (Enchantment)var6.next(); + int var8 = ((Integer)currentEnchantmentLevels.get(var7)).intValue(); + + if (var8 > 0) + { + TMIUtils.addEnchantment(var0, var7.effectId, var8); + } + } + } + + return var0; + } + + public static void adjustEnchantmentLevel(Enchantment var0, int var1) + { + int var2 = ((Integer)currentEnchantmentLevels.get(var0)).intValue() + var1; + + if (var2 < 0) + { + var2 = 0; + } + else if (var2 > 10) + { + var2 = 10; + } + + currentEnchantmentLevels.put(var0, Integer.valueOf(var2)); + } + + public static int getEnchantmentLevel(Enchantment var0) + { + return ((Integer)currentEnchantmentLevels.get(var0)).intValue(); + } + + static + { + Enchantment[] var0 = Enchantment.enchantmentsList; + int var1 = var0.length; + + for (int var2 = 0; var2 < var1; ++var2) + { + Enchantment var3 = var0[var2]; + + if (var3 != null) + { + currentEnchantmentLevels.put(var3, Integer.valueOf(0)); + } + } + + setItem(new ItemStack(TMIItemInfo.addItemOffset(22), 1, 0)); + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIFavoritesPanel.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIFavoritesPanel.java new file mode 100644 index 0000000..6fd7786 --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIFavoritesPanel.java @@ -0,0 +1,77 @@ +package me.ayunami2000.ayuncraft.tmi; + +import net.lax1dude.eaglercraft.EaglerAdapter; +import net.minecraft.src.ItemStack; + +class TMIFavoritesPanel extends TMIItemPanel +{ + private TMIConfig config = null; + private static final String[] blankPanelTip = new String[] {"Favorites:", "Drop items here", "or Alt-click them", "in the items panel."}; + + public TMIFavoritesPanel(TMIConfig var1, TMIController var2) + { + super(0, 0, 0, 0, 0, var1.getFavorites(), var2); + this.config = var1; + this.textField.show = false; + } + + public void draw(_tmi_MgCanvas var1, int var2, int var3) + { + if (this.items.size() > 0) + { + super.draw(var1, var2, var3); + } + else if (this.show) + { + this.hoverItem = null; + this.hoverItemIndex = -1; + int var4 = this.y + (this.height / 2 - 13 * blankPanelTip.length / 2); + String[] var5 = blankPanelTip; + int var6 = var5.length; + + for (int var7 = 0; var7 < var6; ++var7) + { + String var8 = var5[var7]; + var1.drawTextCentered(this.x, var4, this.width, 12, var8, -1); + var4 += 13; + } + } + } + + public boolean click(int var1, int var2, int var3) + { + ItemStack var4 = TMIUtils.getHeldItem(); + + if (var4 != null) + { + ItemStack var5 = TMIUtils.copyStack(var4); + var5.stackSize = TMIUtils.maxStackSize(var5.itemID); + + if (var5.itemID == TMIItemInfo.addItemOffset(117)) + { + var5.stackSize = 64; + } + + this.items.add(var5); + TMIUtils.savePreferences(this.config); + return false; + } + else if (this.hoverItem != null) + { + if (!EaglerAdapter.isKeyDown(56) && !EaglerAdapter.isKeyDown(184)) + { + return this.controller.onItemEvent(this.hoverItem, var3); + } + else + { + this.items.remove(this.hoverItemIndex); + TMIUtils.savePreferences(this.config); + return false; + } + } + else + { + return this.delegateClickToChildren(var1, var2, var3); + } + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIFireworkPanel.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIFireworkPanel.java new file mode 100644 index 0000000..0116927 --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIFireworkPanel.java @@ -0,0 +1,410 @@ +package me.ayunami2000.ayuncraft.tmi; + +import net.minecraft.client.Minecraft; +import net.minecraft.src.ItemDye; +import net.minecraft.src.ItemStack; +import net.minecraft.src.NBTTagCompound; +import net.minecraft.src.StatCollector; + +public class TMIFireworkPanel extends _tmi_MgWidget implements _tmi_MgButtonHandler +{ + private ItemStack firework = new ItemStack(TMIItemInfo.addItemOffset(145), 64, 0); + private ItemStack fireworkCharge = new ItemStack(TMIItemInfo.addItemOffset(146), 64, 0); + private _tmi_MgItemButton itemButton; + private boolean makeCharge; + _tmi_MgButton addButton; + _tmi_MgButton prevButton; + _tmi_MgButton nextButton; + _tmi_MgButton createButton; + _tmi_MgButton favoriteButton; + _tmi_MgButton typeButton; + _tmi_MgButton heightButton; + _tmi_MgButton trailButton; + _tmi_MgButton flickerButton; + _tmi_MgButton[] colorButtons; + _tmi_MgButton[] fadeButtons; + private _tmi_MgTextField nameField; + public int page; + public static boolean trail = false; + public static boolean flicker = false; + public static int height = 1; + public static int type = 0; + public static int[] colors = new int[] {15, -1, -1}; + public static int[] fadeColors = new int[] { -1, -1, -1}; + + public TMIFireworkPanel() + { + super(0, 0); + this.itemButton = new _tmi_MgItemButton("", this.firework, this, "itemType"); + this.makeCharge = false; + this.colorButtons = new _tmi_MgButton[3]; + this.fadeButtons = new _tmi_MgButton[3]; + this.nameField = new _tmi_MgTextField(Minecraft.getMinecraft().fontRenderer, "Name...", TMI.instance.controller); + this.page = 0; + this.createButton = new _tmi_MgButton("Make", this, "make"); + this.createButton.width = 36; + this.createButton.height = 18; + this.favoriteButton = new _tmi_MgButton("Favorite", this, "favorite"); + this.favoriteButton.width = 48; + this.favoriteButton.height = 18; + this.nextButton = new _tmi_MgButton("", this, "next"); + this.nextButton.icon = TMIImages.iconNext; + this.nextButton.width = 16; + this.nextButton.height = 16; + this.prevButton = new _tmi_MgButton("", this, "prev"); + this.prevButton.icon = TMIImages.iconPrev; + this.prevButton.width = 16; + this.prevButton.height = 16; + this.addButton = new _tmi_MgButton("Add effect...", this, "addEffect"); + this.addButton.width = 70; + this.addButton.height = 16; + this.typeButton = new _tmi_MgButton("", this, "type"); + this.heightButton = new _tmi_MgButton("", this, "height"); + this.trailButton = new _tmi_MgButton("", this, "trail"); + this.flickerButton = new _tmi_MgButton("", this, "flicker"); + this.typeButton.width = this.heightButton.width = this.trailButton.width = this.flickerButton.width = 52; + this.typeButton.height = this.heightButton.height = this.trailButton.height = this.flickerButton.height = 16; + int var1; + + for (var1 = 0; var1 < this.colorButtons.length; ++var1) + { + this.colorButtons[var1] = new _tmi_MgButton("", this, Integer.valueOf(var1)); + this.colorButtons[var1].height = 14; + this.children.add(this.colorButtons[var1]); + } + + for (var1 = 0; var1 < this.fadeButtons.length; ++var1) + { + this.fadeButtons[var1] = new _tmi_MgButton("", this, Integer.valueOf(-var1 - 1)); + this.fadeButtons[var1].height = 14; + this.children.add(this.fadeButtons[var1]); + } + + this.children.add(this.itemButton); + this.children.add(this.createButton); + this.children.add(this.favoriteButton); + this.children.add(this.typeButton); + this.children.add(this.heightButton); + this.children.add(this.trailButton); + this.children.add(this.flickerButton); + this.children.add(this.nameField); + } + + public void resize() + { + if (this.width < 106) + { + this.width = 106; + } + + this.itemButton.x = this.x; + this.createButton.x = this.x + 20; + this.favoriteButton.x = this.createButton.x + this.createButton.width + 2; + this.itemButton.y = this.createButton.y = this.favoriteButton.y = this.y + 8; + this.typeButton.x = this.x; + this.flickerButton.x = this.heightButton.x = this.typeButton.x + this.typeButton.width + 2; + this.typeButton.y = this.flickerButton.y = this.itemButton.y + 20; + this.trailButton.x = this.x; + this.trailButton.y = this.heightButton.y = this.typeButton.y + 18; + this.nameField.x = this.x + 1; + this.nameField.width = this.width - 5; + this.nameField.y = this.trailButton.y + 19; + int var1 = this.nameField.y + 18 + 18; + int var2; + + for (var2 = 0; var2 < this.colorButtons.length; ++var2) + { + this.colorButtons[var2].width = this.width; + this.colorButtons[var2].x = this.x; + this.colorButtons[var2].y = var1; + var1 += 15; + } + + var1 += 18; + + for (var2 = 0; var2 < this.fadeButtons.length; ++var2) + { + this.fadeButtons[var2].width = this.width; + this.fadeButtons[var2].x = this.x; + this.fadeButtons[var2].y = var1; + var1 += 15; + } + } + + public ItemStack createCurrentItem() + { + ItemStack var1 = TMIUtils.copyStack(this.itemButton.stack); + var1.stackTagCompound = new NBTTagCompound(); + int var2 = 0; + int var3; + + for (var3 = 0; var3 < colors.length; ++var3) + { + if (colors[var3] > -1 && colors[var3] < 16) + { + ++var2; + } + } + + var3 = 0; + + for (int var4 = 0; var4 < fadeColors.length; ++var4) + { + if (fadeColors[var4] > -1 && fadeColors[var4] < 16) + { + ++var3; + } + } + + int[] var9 = new int[var2]; + int var5 = 0; + + for (int var6 = 0; var6 < colors.length; ++var6) + { + if (colors[var6] > -1 && colors[var6] < 16) + { + var9[var5++] = ItemDye.dyeColors[colors[var6]]; + } + } + + int[] var10 = null; + + if (var3 > 0) + { + var10 = new int[var3]; + var5 = 0; + + for (int var7 = 0; var7 < fadeColors.length; ++var7) + { + if (fadeColors[var7] > -1 && fadeColors[var7] < 16) + { + var10[var5++] = ItemDye.dyeColors[fadeColors[var7]]; + } + } + } + + if (var9 == null || var9.length < 1) + { + var9 = new int[] {16777215}; + } + + NBTTagCompound var11 = TMIUtils.makeExplosionTag(type, var9, var10, flicker, trail); + + if (this.makeCharge) + { + var1.stackTagCompound.setCompoundTag("Explosion", var11); + } + else + { + NBTTagCompound var8 = TMIUtils.makeFireworksTag(height, new NBTTagCompound[] {var11}); + var1.stackTagCompound.setCompoundTag("Fireworks", var8); + } + + String var12 = this.nameField.value(); + + if (var12 != null && !var12.equals("")) + { + TMIUtils.nameStack(var1, var12); + } + + return var1; + } + + public boolean onButtonPress(Object var1) + { + if (var1 instanceof String) + { + String var2 = (String)var1; + + if (var2.equals("itemType")) + { + this.makeCharge = !this.makeCharge; + this.itemButton.stack = this.makeCharge ? this.fireworkCharge : this.firework; + return false; + } + + ItemStack var3; + + if (var2.equals("make")) + { + var3 = this.createCurrentItem(); + TMIUtils.giveStack(var3, TMIConfig.getInstance()); + return false; + } + + if (var2.equals("favorite")) + { + var3 = this.createCurrentItem(); + TMIConfig.getInstance().getFavorites().add(var3); + TMIUtils.savePreferences(TMIConfig.getInstance()); + return false; + } + + if (var2.equals("next")) + { + ++this.page; + this.resize(); + } + else if (var2.equals("prev")) + { + --this.page; + this.resize(); + } + else if (var2.equals("type")) + { + ++type; + + if (type > 4) + { + type = 0; + } + } + else if (var2.equals("height")) + { + ++height; + + if (height > 5) + { + height = 1; + } + } + else if (var2.equals("trail")) + { + trail = !trail; + } + else if (var2.equals("flicker")) + { + flicker = !flicker; + } + } + else if (var1 instanceof Integer) + { + int var4 = ((Integer)var1).intValue(); + + if (var4 < 0) + { + int var5 = -(var4 + 1); + ++fadeColors[var5]; + + if (fadeColors[var5] > 15) + { + fadeColors[var5] = -1; + } + } + else + { + ++colors[var4]; + + if (colors[var4] > 15) + { + colors[var4] = var4 == 0 ? 0 : -1; + } + } + } + + return true; + } + + public boolean onButtonRightClick(Object var1) + { + if (var1 instanceof String) + { + String var2 = (String)var1; + + if (var2.equals("type")) + { + --type; + + if (type < 0) + { + type = 4; + } + } + else if (var2.equals("height")) + { + --height; + + if (height < 1) + { + height = 5; + } + } + } + else if (var1 instanceof Integer) + { + int var4 = ((Integer)var1).intValue(); + + if (var4 < 0) + { + int var3 = -(var4 + 1); + --fadeColors[var3]; + + if (fadeColors[var3] < -1) + { + fadeColors[var3] = 15; + } + } + else + { + --colors[var4]; + + if (colors[var4] < -1 || var4 == 0 && colors[var4] < 0) + { + colors[var4] = 15; + } + } + } + + return true; + } + + public void reLabel() + { + this.heightButton.show = !this.makeCharge; + this.flickerButton.label = flicker ? "Flicker" : "No flicker"; + this.trailButton.label = trail ? "Trail" : "No trail"; + this.heightButton.label = "Flight: " + height; + this.typeButton.label = StatCollector.translateToLocal("item.fireworksCharge.type." + type); + int var1; + + for (var1 = 0; var1 < this.colorButtons.length; ++var1) + { + if (colors[var1] == -1) + { + this.colorButtons[var1].label = "None"; + } + else + { + this.colorButtons[var1].label = StatCollector.translateToLocal("item.fireworksCharge." + ItemDye.dyeColorNames[colors[var1]]); + } + } + + for (var1 = 0; var1 < this.fadeButtons.length; ++var1) + { + if (fadeColors[var1] == -1) + { + this.fadeButtons[var1].label = "None"; + } + else + { + this.fadeButtons[var1].label = StatCollector.translateToLocal("item.fireworksCharge." + ItemDye.dyeColorNames[fadeColors[var1]]); + } + } + } + + public void draw(_tmi_MgCanvas var1, int var2, int var3) + { + if (this.show) + { + this.reLabel(); + var1.drawText(this.x + 1, this.colorButtons[0].y - 12, "Colors:", -1); + var1.drawText(this.x + 1, this.fadeButtons[0].y - 12, "Fade colors:", -1); + this.drawChildren(var1, var2, var3); + } + } + + public boolean click(int var1, int var2, int var3) + { + return this.delegateClickToChildren(var1, var2, var3); + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIImages.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIImages.java new file mode 100644 index 0000000..bd56a8e --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIImages.java @@ -0,0 +1,34 @@ +package me.ayunami2000.ayuncraft.tmi; + +public class TMIImages +{ + public static _tmi_MgImage iconPrev = new _tmi_MgImage(48, 12, 12, 12); + public static _tmi_MgImage iconNext = new _tmi_MgImage(36, 12, 12, 12); + public static _tmi_MgImage iconRain = new _tmi_MgImage(0, 12, 12, 12); + public static _tmi_MgImage iconCreative = new _tmi_MgImage(12, 12, 12, 12); + public static _tmi_MgImage iconDelete = new _tmi_MgImage(24, 12, 12, 12); + public static _tmi_MgImage iconNoon = new _tmi_MgImage(0, 24, 12, 12); + public static _tmi_MgImage iconDawn = new _tmi_MgImage(12, 24, 12, 12); + public static _tmi_MgImage iconDusk = new _tmi_MgImage(24, 24, 12, 12); + public static _tmi_MgImage iconMidnight = new _tmi_MgImage(36, 24, 12, 12); + public static _tmi_MgImage iconDifficulty = new _tmi_MgImage(108, 24, 12, 12); + public static _tmi_MgImage iconHeart = new _tmi_MgImage(48, 24, 12, 12); + public static _tmi_MgImage iconGear = new _tmi_MgImage(60, 24, 12, 12); + public static _tmi_MgImage iconChest = new _tmi_MgImage(72, 24, 12, 12); + public static _tmi_MgImage iconBook = new _tmi_MgImage(84, 24, 12, 12); + public static _tmi_MgImage iconStar = new _tmi_MgImage(96, 24, 12, 12); + public static _tmi_MgImage iconPotion = new _tmi_MgImage(156, 24, 12, 12); + public static _tmi_MgImage iconFirework = new _tmi_MgImage(168, 24, 12, 12); + public static _tmi_MgImage iconGearLight = new _tmi_MgImage(60, 36, 12, 12); + public static _tmi_MgImage iconChestLight = new _tmi_MgImage(72, 36, 12, 12); + public static _tmi_MgImage iconBookLight = new _tmi_MgImage(84, 36, 12, 12); + public static _tmi_MgImage iconStarLight = new _tmi_MgImage(96, 36, 12, 12); + public static _tmi_MgImage buttonStateOff = new _tmi_MgImage(48, 0, 8, 12); + public static _tmi_MgImage buttonStateOn = new _tmi_MgImage(56, 0, 8, 12); + public static _tmi_MgImage iconModeS = new _tmi_MgImage(120, 24, 12, 12); + public static _tmi_MgImage iconModeC = new _tmi_MgImage(132, 24, 12, 12); + public static _tmi_MgImage iconModeA = new _tmi_MgImage(144, 24, 12, 12); + public static _tmi_MgImage iconModeSs = new _tmi_MgImage(120, 36, 12, 12); + public static _tmi_MgImage iconModeCs = new _tmi_MgImage(132, 36, 12, 12); + public static _tmi_MgImage iconModeAs = new _tmi_MgImage(144, 36, 12, 12); +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemCrop.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemCrop.java new file mode 100644 index 0000000..e81e3c4 --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemCrop.java @@ -0,0 +1,21 @@ +package me.ayunami2000.ayuncraft.tmi; + +import net.minecraft.src.ItemBlock; + +public class TMIItemCrop extends ItemBlock +{ + public TMIItemCrop(int var1) + { + super(var1); + this.setMaxDamage(0); + this.setHasSubtypes(true); + } + + /** + * Returns the metadata of the block which this Item (ItemBlock) can place + */ + public int getMetadata(int var1) + { + return var1; + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemInfo.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemInfo.java new file mode 100644 index 0000000..58f756a --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemInfo.java @@ -0,0 +1,171 @@ +package me.ayunami2000.ayuncraft.tmi; + +import net.minecraft.src.EntityList; +import net.minecraft.src.Item; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; + +public class TMIItemInfo +{ + public static final String COPYRIGHT = "All of TooManyItems except for thesmall portion excerpted from the original Minecraft game is copyright 2011Marglyph. TooManyItems is free for personal use only. Do not redistributeTooManyItems, including in mod packs, and do not use TooManyItems\' sourcecode or graphics in your own mods."; + private static final Map fallbackNames = new HashMap(); + private static final Map maxDamageExceptions = new HashMap(); + private static final Set hideItems = new HashSet(); + private static final Set showItems = new HashSet(); + private static final Set tools = new HashSet(); + private static final Set nonUnlimited = new HashSet(); + public static List potionValues = new ArrayList(); + public static int itemOffset = addItemOffset(0); + public static final Set excludedSpawnerIds = new HashSet(); + + public static void hideItem(int var0) + { + hideItems.add(Integer.valueOf(var0)); + } + + public static boolean isHidden(int var0) + { + return hideItems.contains(Integer.valueOf(var0)); + } + + public static void addFallbackName(int var0, int var1, String var2) + { + fallbackNames.put(Integer.valueOf(packItemIDAndDamage(var0, var1)), var2); + } + + public static boolean hasFallbackName(int var0, int var1) + { + return fallbackNames.containsKey(Integer.valueOf(packItemIDAndDamage(var0, var1))); + } + + public static String getFallbackName(int var0, int var1) + { + int var2 = packItemIDAndDamage(var0, var1); + return fallbackNames.containsKey(Integer.valueOf(var2)) ? (String)fallbackNames.get(Integer.valueOf(var2)) : "Unnamed"; + } + + public static void setMaxDamageException(int var0, int var1) + { + maxDamageExceptions.put(Integer.valueOf(var0), Integer.valueOf(var1)); + } + + public static int getMaxDamageException(int var0) + { + return maxDamageExceptions.containsKey(Integer.valueOf(var0)) ? ((Integer)maxDamageExceptions.get(Integer.valueOf(var0))).intValue() : 0; + } + + public static int packItemIDAndDamage(int var0, int var1) + { + return (var0 << 8) + var1; + } + + public static int unpackItemID(int var0) + { + return var0 >> 8; + } + + public static int unpackDamage(int var0) + { + return var0 & 255; + } + + public static void showItemWithDamage(int var0, int var1) + { + showItems.add(Integer.valueOf(packItemIDAndDamage(var0, var1))); + } + + public static void showItemWithDamageRange(int var0, int var1, int var2) + { + for (int var3 = var1; var3 <= var2; ++var3) + { + showItemWithDamage(var0, var3); + } + } + + public static boolean isShown(int var0, int var1) + { + return showItems.contains(Integer.valueOf(packItemIDAndDamage(var0, var1))); + } + + public static int addItemOffset(int var0) + { + return var0 + Item.shovelIron.itemID; + } + + static + { + int[] var0 = new int[] {0, 16, 32, 64, 8192, 8193, 8194, 8195, 8196, 8197, 8198, 8200, 8201, 8202, 8204, 8206, 8225, 8226, 8228, 8229, 8233, 8236, 8257, 8258, 8259, 8260, 8262, 8264, 8265, 8266, 8270, 16385, 16386, 16387, 16388, 16389, 16390, 16392, 16393, 16394, 16396, 16398, 16417, 16418, 16420, 16421, 16425, 16428, 16449, 16450, 16451, 16452, 16454, 16456, 16457, 16458, 16462}; + int[] var1 = var0; + int var2 = var0.length; + + for (int var3 = 0; var3 < var2; ++var3) + { + int var4 = var1[var3]; + potionValues.add(Integer.valueOf(var4)); + } + + showItemWithDamageRange(6, 0, 3); + showItemWithDamageRange(18, 0, 3); + showItemWithDamageRange(43, 0, 0); + showItemWithDamageRange(addItemOffset(66), 0, 1); + showItemWithDamageRange(78, 0, 7); + showItemWithDamageRange(59, 7, 7); + showItemWithDamageRange(104, 7, 7); + showItemWithDamageRange(105, 7, 7); + showItemWithDamageRange(115, 7, 7); + addFallbackName(104, 0, "Pumpkin Stem"); + addFallbackName(105, 0, "Melon Stem"); + addFallbackName(104, 7, "Pumpkin Stem"); + addFallbackName(105, 7, "Melon Stem"); + addFallbackName(119, 0, "End Portal"); + addFallbackName(52, 0, "Pig Spawner"); + Iterator var5 = TMIPrivateFields.getSpawnerEntityIdSet().iterator(); + + while (var5.hasNext()) + { + var2 = ((Integer)var5.next()).intValue(); + addFallbackName(52, var2, EntityList.getStringFromID(var2) + " Spawner"); + } + + excludedSpawnerIds.add(Integer.valueOf(1)); + excludedSpawnerIds.add(Integer.valueOf(9)); + excludedSpawnerIds.add(Integer.valueOf(12)); + excludedSpawnerIds.add(Integer.valueOf(13)); + excludedSpawnerIds.add(Integer.valueOf(15)); + excludedSpawnerIds.add(Integer.valueOf(18)); + excludedSpawnerIds.add(Integer.valueOf(19)); + excludedSpawnerIds.add(Integer.valueOf(21)); + excludedSpawnerIds.add(Integer.valueOf(22)); + excludedSpawnerIds.add(Integer.valueOf(53)); + excludedSpawnerIds.add(Integer.valueOf(48)); + excludedSpawnerIds.add(Integer.valueOf(49)); + excludedSpawnerIds.add(Integer.valueOf(200)); + hideItem(26); + hideItem(34); + hideItem(36); + hideItem(55); + hideItem(63); + hideItem(64); + hideItem(68); + hideItem(71); + hideItem(74); + hideItem(83); + hideItem(93); + hideItem(94); + hideItem(95); + hideItem(117); + hideItem(118); + hideItem(127); + hideItem(132); + hideItem(141); + hideItem(142); + hideItem(addItemOffset(117)); + hideItem(addItemOffset(147)); + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemMushroomCap.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemMushroomCap.java new file mode 100644 index 0000000..e8f15bd --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemMushroomCap.java @@ -0,0 +1,21 @@ +package me.ayunami2000.ayuncraft.tmi; + +import net.minecraft.src.ItemBlock; + +public class TMIItemMushroomCap extends ItemBlock +{ + public TMIItemMushroomCap(int var1) + { + super(var1); + this.setMaxDamage(0); + this.setHasSubtypes(true); + } + + /** + * Returns the metadata of the block which this Item (ItemBlock) can place + */ + public int getMetadata(int var1) + { + return var1; + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemPanel.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemPanel.java new file mode 100644 index 0000000..8eaea44 --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemPanel.java @@ -0,0 +1,162 @@ +package me.ayunami2000.ayuncraft.tmi; + +import java.util.List; +import java.util.regex.Pattern; +import net.minecraft.client.Minecraft; +import net.minecraft.src.ItemStack; + +class TMIItemPanel extends _tmi_MgWidget implements _tmi_MgButtonHandler +{ + public static final String COPYRIGHT = "All of TooManyItems except for thesmall portion excerpted from the original Minecraft game is copyright 2011Marglyph. TooManyItems is free for personal use only. Do not redistributeTooManyItems, including in mod packs, and do not use TooManyItems\' sourcecode or graphics in your own mods."; + protected TMIController controller; + protected List items; + public static int page = 0; + public int numPages = 0; + public static final int SPACING = 18; + protected ItemStack hoverItem = null; + protected int hoverItemIndex = -1; + private int marginLeft; + private int marginTop; + private int cols; + private int rows; + private int itemsPerPage; + private _tmi_MgButton prevButton; + private _tmi_MgButton nextButton; + public _tmi_MgTextField textField; + private static final String BUTTON_PREV = "prev"; + private static final String BUTTON_NEXT = "next"; + + public TMIItemPanel(int var1, int var2, int var3, int var4, int var5, List var6, TMIController var7) + { + super(var1, var2, var3, var4, var5); + this.items = var6; + this.controller = var7; + this.prevButton = new _tmi_MgButton("", this, "prev"); + this.prevButton.icon = TMIImages.iconPrev; + this.prevButton.width = 12; + this.prevButton.height = 12; + this.children.add(this.prevButton); + this.nextButton = new _tmi_MgButton("", this, "next"); + this.nextButton.icon = TMIImages.iconNext; + this.nextButton.width = 12; + this.nextButton.height = 12; + this.children.add(this.nextButton); + this.textField = new _tmi_MgTextField(Minecraft.getMinecraft().fontRenderer, "Search", var7); + this.children.add(this.textField); + } + + public boolean onButtonPress(Object var1) + { + if (var1 == "prev") + { + --page; + return false; + } + else if (var1 == "next") + { + ++page; + return false; + } + else + { + return true; + } + } + + public boolean onButtonRightClick(Object var1) + { + return true; + } + + public void resize() + { + this.marginLeft = this.x + this.width % 18 / 2; + this.marginTop = this.y + this.height % 18 / 2; + this.cols = this.width / 18; + this.rows = this.height / 18 - 1; + this.itemsPerPage = this.rows * this.cols; + this.numPages = (int)Math.ceil((double)(1.0F * (float)this.items.size() / (float)this.itemsPerPage)); + page = page < 0 ? this.numPages - 1 : (page >= this.numPages ? 0 : page); + this.nextButton.x = this.x + this.width - this.nextButton.width - 3; + this.prevButton.x = this.nextButton.x - this.prevButton.width - 1; + this.nextButton.y = this.y + 1; + this.prevButton.y = this.y + 1; + this.textField.x = this.x + 2; + this.textField.y = this.y + 2; + this.textField.height = 14; + this.textField.width = this.prevButton.x - this.textField.x - 2; + } + + public ItemStack getHoverItem() + { + return this.hoverItem; + } + + public void draw(_tmi_MgCanvas var1, int var2, int var3) + { + if (this.show) + { + int var4 = 0; + int var5 = 1; + this.hoverItem = null; + this.hoverItemIndex = -1; + var1.hardSetFlatMode(false); + + for (int var6 = page * this.itemsPerPage; var6 < this.itemsPerPage * (page + 1) && var6 < this.items.size(); ++var6) + { + ItemStack var7 = (ItemStack)this.items.get(var6); + int var8 = this.marginLeft + var4 * 18; + int var9 = this.marginTop + var5 * 18; + + if (var2 >= var8 && var2 < var8 + 18 && var3 >= var9 && var3 < var9 + 18) + { + this.hoverItem = var7; + this.hoverItemIndex = var6; + } + + var1.drawItem(var8, var9, var7); + + if (var7.itemID == 52) + { + String var10 = TMIUtils.itemDisplayName(var7); + Pattern var11 = Pattern.compile("\u00a7."); + var10 = var11.matcher(var10).replaceAll(""); + var10 = var10.substring(0, 3); + var1.drawText(var8 + 1, var9 + 1, var10, -2236963, 0.5F); + var1.hardSetFlatMode(false); + } + else if (var7.itemID == 9 || var7.itemID == 11) + { + var1.drawText(var8 + 1, var9 + 1, "Static", -2236963, 0.5F); + var1.hardSetFlatMode(false); + } + + ++var4; + + if (var4 == this.cols) + { + var4 = 0; + ++var5; + } + } + + this.drawChildren(var1, var2, var3); + var1.drawTextCentered(this.prevButton.x, this.prevButton.y + this.prevButton.height + 2, this.prevButton.width * 2 + 1, 6, "" + (page + 1) + "/" + this.numPages, -2236963, 0.5F); + } + } + + public boolean click(int var1, int var2, int var3) + { + ItemStack var4 = TMIUtils.getHeldItem(); + + if (var4 != null) + { + TMIUtils.deleteHeldItem(); + return false; + } + else + { + return this.hoverItem != null ? this.controller.onItemEvent(this.hoverItem, var3) : this.delegateClickToChildren(var1, var2, var3); + } + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemSnow.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemSnow.java new file mode 100644 index 0000000..6a4471c --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemSnow.java @@ -0,0 +1,30 @@ +package me.ayunami2000.ayuncraft.tmi; + +import net.minecraft.src.Block; +import net.minecraft.src.Icon; +import net.minecraft.src.ItemBlock; + +public class TMIItemSnow extends ItemBlock +{ + public TMIItemSnow(int var1) + { + super(var1); + } + + /** + * Gets an icon index based on an item's damage value + */ + public Icon getIconFromDamage(int var1) + { + try + { + TMIPrivateFields.setBlockBounds.invoke(Block.snow, new Object[] {Float.valueOf(0.0F), Float.valueOf(0.0F), Float.valueOf(0.0F), Float.valueOf(1.0F), Float.valueOf((float)(2 * (1 + var1)) / 16.0F), Float.valueOf(1.0F)}); + } + catch (Exception var3) + { + System.out.println(var3); + } + + return super.getIconFromDamage(var1); + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemSpawner.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemSpawner.java new file mode 100644 index 0000000..2f7306e --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIItemSpawner.java @@ -0,0 +1,97 @@ +package me.ayunami2000.ayuncraft.tmi; + +import net.minecraft.src.*; + +import java.util.Iterator; + +public class TMIItemSpawner extends ItemBlock +{ + public TMIItemSpawner(int var1) + { + super(var1); + this.setMaxDamage(0); + this.setHasSubtypes(true); + } + + /** + * Callback for item usage. If the item does something special on right clicking, he will have one of those. Return + * True if something happen and false if it don't. This is for ITEMS, not BLOCKS + */ + public boolean onItemUse(ItemStack var1, EntityPlayer var2, World var3, int var4, int var5, int var6, int var7, float var8, float var9, float var10) + { + int var11 = var3.getBlockId(var4, var5, var6); + + if (var11 != Block.vine.blockID && var11 != Block.tallGrass.blockID && var11 != Block.deadBush.blockID) + { + var4 += var7 == 4 ? -1 : (var7 == 5 ? 1 : 0); + var5 += var7 == 0 ? -1 : (var7 == 1 ? 1 : 0); + var6 += var7 == 2 ? -1 : (var7 == 3 ? 1 : 0); + } + + if (!var2.canPlayerEdit(var4, var5, var6, var7, var1)) + { + return false; + } + else if (!Block.mobSpawner.canPlaceBlockAt(var3, var4, var5, var6)) + { + return false; + } + else + { + var3.setBlock(var4, var5, var6, 52, 0, 3); + --var1.stackSize; + TileEntityMobSpawner var12 = (TileEntityMobSpawner)var3.getBlockTileEntity(var4, var5, var6); + + if (var12 == null) + { + System.out.println("[TMI] Failed to access TileEntity for spawner."); + return false; + } + else + { + MobSpawnerBaseLogic var13 = var12.func_98049_a(); + + if (var13 == null) + { + System.out.println("[TMI] Failed to access spawner data from TileEntity."); + return false; + } + else + { + int var14 = var1.getItemDamageForDisplay(); + String var15 = null; + + if (!TMIItemInfo.excludedSpawnerIds.contains(Integer.valueOf(var14)) || var1.stackTagCompound != null) + { + var15 = EntityList.getStringFromID(var14); + } + + if (var15 == null || var15.equals("")) + { + var15 = "Pig"; + } + + var13.setMobID(var15); + + if (var1.stackTagCompound != null) + { + NBTTagCompound var16 = new NBTTagCompound(); + var13.writeToNBT(var16); + Iterator var17 = var1.stackTagCompound.getTags().iterator(); + + while (var17.hasNext()) + { + Object var18 = var17.next(); + NBTBase var19 = (NBTBase)var18; + var16.setTag(var19.getName(), var19); + } + + var13.readFromNBT(var16); + } + + return true; + } + } + } + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIPotionEffectControl.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIPotionEffectControl.java new file mode 100644 index 0000000..c87525e --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIPotionEffectControl.java @@ -0,0 +1,167 @@ +package me.ayunami2000.ayuncraft.tmi; + +import net.minecraft.src.Potion; +import net.minecraft.src.StatCollector; + +public class TMIPotionEffectControl extends _tmi_MgWidget implements _tmi_MgButtonHandler +{ + public TMIPotionPanel panel; + public int level = 0; + public int tickDuration = 1200; + public int effectId = 1; + public static final int MAX_TIME = 12000; + private _tmi_MgButton typeButton = new _tmi_MgButton("", this, "type"); + private _tmi_MgButton closeButton = new _tmi_MgButton("x", this, "close"); + private _tmi_MgButton levelButton = new _tmi_MgButton("", this, "level"); + private _tmi_MgButton timeButton = new _tmi_MgButton("", this, "time"); + + public TMIPotionEffectControl(TMIPotionPanel var1) + { + super(0, 0); + this.panel = var1; + this.width = 106; + this.height = 34; + this.typeButton.height = this.closeButton.height = this.levelButton.height = this.timeButton.height = 16; + this.children.add(this.typeButton); + this.children.add(this.closeButton); + this.children.add(this.levelButton); + this.children.add(this.timeButton); + } + + public TMIPotionEffectControl copy(TMIPotionPanel var1) + { + TMIPotionEffectControl var2 = new TMIPotionEffectControl(var1); + var2.level = this.level; + var2.tickDuration = this.tickDuration; + var2.effectId = this.effectId; + return var2; + } + + public void resize() + { + this.typeButton.width = 88; + this.closeButton.width = 16; + this.levelButton.width = 52; + this.timeButton.width = 52; + this.typeButton.x = this.x; + this.typeButton.centerText = false; + this.closeButton.x = this.typeButton.x + this.typeButton.width + 2; + this.closeButton.y = this.typeButton.y = this.y; + this.levelButton.x = this.x; + this.timeButton.x = this.levelButton.x + this.levelButton.width + 2; + this.levelButton.y = this.timeButton.y = this.y + 18; + } + + public void draw(_tmi_MgCanvas var1, int var2, int var3) + { + if (this.show) + { + try + { + this.typeButton.label = StatCollector.translateToLocal(Potion.potionTypes[this.effectId].getName()); + this.timeButton.show = !this.isInstant(); + } + catch (Exception var7) + { + this.typeButton.label = "[Bad ID]"; + } + + this.levelButton.label = "" + (this.level + 1); + int var4 = this.tickDuration / 20; + int var5 = var4 / 60; + int var6 = var4 % 60; + this.timeButton.label = "" + var5 + ":" + (var6 < 10 ? "0" : "") + var6; + this.drawChildren(var1, var2, var3); + } + } + + public boolean click(int var1, int var2, int var3) + { + return this.delegateClickToChildren(var1, var2, var3); + } + + public boolean isInstant() + { + return this.effectId < Potion.potionTypes.length && Potion.potionTypes[this.effectId] != null && Potion.potionTypes[this.effectId].isInstant(); + } + + public boolean onButtonPress(Object var1) + { + if (var1 instanceof String) + { + String var2 = (String)var1; + + if (var2.equals("type")) + { + this.panel.openEffectPicker(this); + return false; + } + + if (var2.equals("close")) + { + this.panel.removeEffectControl(this); + return false; + } + + if (var2.equals("level")) + { + ++this.level; + + if (this.level > 3) + { + this.level = 0; + } + + return false; + } + + if (var2.equals("time")) + { + this.tickDuration += 600; + + if (this.tickDuration > 12000) + { + this.tickDuration = 600; + } + + return false; + } + } + + return true; + } + + public boolean onButtonRightClick(Object var1) + { + if (var1 instanceof String) + { + String var2 = (String)var1; + + if (var2.equals("level")) + { + --this.level; + + if (this.level < 0) + { + this.level = 3; + } + + return false; + } + + if (var2.equals("time")) + { + this.tickDuration -= 600; + + if (this.tickDuration <= 0) + { + this.tickDuration = 12000; + } + + return false; + } + } + + return true; + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIPotionEffectPicker.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIPotionEffectPicker.java new file mode 100644 index 0000000..e200569 --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIPotionEffectPicker.java @@ -0,0 +1,150 @@ +package me.ayunami2000.ayuncraft.tmi; + +import net.minecraft.src.Potion; +import net.minecraft.src.StatCollector; + +public class TMIPotionEffectPicker extends _tmi_MgWidget implements _tmi_MgButtonHandler +{ + int page = 0; + private TMIPotionPanel panel; + private _tmi_MgButton closeButton = new _tmi_MgButton("x", this, "close"); + private _tmi_MgButton nextButton = new _tmi_MgButton("", this, "next"); + private _tmi_MgButton prevButton = new _tmi_MgButton("", this, "prev"); + + public TMIPotionEffectPicker(TMIPotionPanel var1) + { + super(0, 0); + this.show = false; + this.panel = var1; + this.nextButton.icon = TMIImages.iconNext; + this.nextButton.width = 16; + this.nextButton.height = 16; + this.prevButton.icon = TMIImages.iconPrev; + this.prevButton.width = 16; + this.prevButton.height = 16; + this.closeButton.width = 16; + this.closeButton.height = 16; + } + + public void resize() + { + this.children.clear(); + byte var1 = 24; + this.nextButton.y = this.prevButton.y = this.closeButton.y = this.y + 2; + this.prevButton.x = this.x + 52; + this.nextButton.x = this.x + 70; + this.closeButton.x = this.x + 88; + this.children.add(this.nextButton); + this.children.add(this.prevButton); + this.children.add(this.closeButton); + int var2 = this.y + var1; + int var3 = this.height - var1; + int var4 = var3 / 13; + Potion[] var5 = this.getAvailablePotions(); + int var6 = var5.length / var4 + (var5.length % var4 > 0 ? 1 : 0); + this.nextButton.show = this.prevButton.show = var6 > 1; + + if (this.page > var6 - 1 || this.page < 0) + { + this.page = 0; + } + + int var7 = this.page * var4; + + for (int var8 = var7; var8 < var7 + var4 && var8 < var5.length; ++var8) + { + Potion var9 = var5[var8]; + _tmi_MgButton var10 = new _tmi_MgButton(StatCollector.translateToLocal(var9.getName()), this, Integer.valueOf(var9.id)); + var10.x = this.x; + var10.y = var2; + var10.width = this.width; + var10.height = 12; + var10.centerText = false; + var2 += 13; + this.children.add(var10); + } + } + + public int countAvailablePotions() + { + int var1 = 0; + + for (int var2 = 0; var2 < Potion.potionTypes.length; ++var2) + { + if (Potion.potionTypes[var2] != null) + { + ++var1; + } + } + + return var1; + } + + public Potion[] getAvailablePotions() + { + int var1 = this.countAvailablePotions(); + Potion[] var2 = new Potion[var1]; + int var3 = 0; + + for (int var4 = 0; var4 < Potion.potionTypes.length; ++var4) + { + if (Potion.potionTypes[var4] != null) + { + var2[var3++] = Potion.potionTypes[var4]; + } + } + + return var2; + } + + public boolean onButtonPress(Object var1) + { + if (var1 instanceof String) + { + String var2 = (String)var1; + + if (var2.equals("next")) + { + ++this.page; + this.resize(); + } + else if (var2.equals("prev")) + { + --this.page; + this.resize(); + } + else if (var2.equals("close")) + { + this.show = false; + } + } + else if (var1 instanceof Integer) + { + int var3 = ((Integer)var1).intValue(); + this.panel.pickerPicked(var3); + this.show = false; + } + + return true; + } + + public boolean onButtonRightClick(Object var1) + { + return true; + } + + public void draw(_tmi_MgCanvas var1, int var2, int var3) + { + if (this.show) + { + var1.drawRect(this.x, this.y, this.width, this.height, -301989888); + var1.drawText(this.x + 1, this.y + 6, "Effect:", -1); + this.drawChildren(var1, var2, var3); + } + } + + public boolean click(int var1, int var2, int var3) + { + return this.delegateClickToChildren(var1, var2, var3); + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIPotionPanel.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIPotionPanel.java new file mode 100644 index 0000000..b4d75f5 --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIPotionPanel.java @@ -0,0 +1,295 @@ +package me.ayunami2000.ayuncraft.tmi; + +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import net.minecraft.client.Minecraft; +import net.minecraft.src.ItemStack; +import net.minecraft.src.PotionEffect; + +public class TMIPotionPanel extends _tmi_MgWidget implements _tmi_MgButtonHandler +{ + private ItemStack potionTypeRegular = new ItemStack(TMIItemInfo.addItemOffset(117), 1, 1); + private ItemStack potionTypeSplash = new ItemStack(TMIItemInfo.addItemOffset(117), 1, 16385); + private _tmi_MgItemButton potionTypeButton; + private static boolean makeSplashPotion = false; + private TMIPotionEffectPicker picker; + private TMIPotionEffectControl pickerTarget; + private _tmi_MgButton addButton; + private _tmi_MgButton prevButton; + private _tmi_MgButton nextButton; + private _tmi_MgButton createButton; + private _tmi_MgButton favoriteButton; + private _tmi_MgTextField nameField; + public int page; + protected static List controls = new ArrayList(); + + public TMIPotionPanel() + { + super(0, 0); + this.potionTypeButton = new _tmi_MgItemButton("", this.potionTypeRegular, this, "potionType"); + this.picker = new TMIPotionEffectPicker(this); + this.pickerTarget = null; + this.nameField = new _tmi_MgTextField(Minecraft.getMinecraft().fontRenderer, "Name...", TMI.instance.controller); + this.page = 0; + this.createButton = new _tmi_MgButton("Make", this, "createPotion"); + this.createButton.width = 36; + this.createButton.height = 18; + this.favoriteButton = new _tmi_MgButton("Favorite", this, "favoritePotion"); + this.favoriteButton.width = 48; + this.favoriteButton.height = 18; + this.nextButton = new _tmi_MgButton("", this, "next"); + this.nextButton.icon = TMIImages.iconNext; + this.nextButton.width = 16; + this.nextButton.height = 16; + this.prevButton = new _tmi_MgButton("", this, "prev"); + this.prevButton.icon = TMIImages.iconPrev; + this.prevButton.width = 16; + this.prevButton.height = 16; + this.addButton = new _tmi_MgButton("Add effect...", this, "addEffect"); + this.addButton.width = 70; + this.addButton.height = 16; + this.children.add(this.picker); + this.children.add(this.potionTypeButton); + this.children.add(this.createButton); + this.children.add(this.favoriteButton); + this.children.add(this.nextButton); + this.children.add(this.prevButton); + this.children.add(this.addButton); + this.children.add(this.nameField); + + if (controls.size() > 0) + { + Iterator var1 = controls.iterator(); + + while (var1.hasNext()) + { + TMIPotionEffectControl var2 = (TMIPotionEffectControl)var1.next(); + var2.panel = this; + this.children.add(var2); + } + } + else + { + controls.add(new TMIPotionEffectControl(this)); + this.children.add(controls.get(0)); + } + + this.potionTypeButton.stack = makeSplashPotion ? this.potionTypeSplash : this.potionTypeRegular; + } + + public void resize() + { + if (this.width < 106) + { + this.width = 106; + } + + this.potionTypeButton.x = this.x; + this.createButton.x = this.x + 20; + this.favoriteButton.x = this.createButton.x + this.createButton.width + 2; + this.potionTypeButton.y = this.createButton.y = this.favoriteButton.y = this.y + 8; + this.nameField.width = this.width - 5; + this.nameField.height = 14; + this.nameField.x = this.x + 1; + this.nameField.y = this.createButton.y + 21; + List var1 = this.getEffects(); + int var2 = this.x; + int var3 = this.y + 8 + 18 + 2 + 18; + int var4 = var3; + + if (var1.size() > 0) + { + TMIPotionEffectControl var6; + + for (Iterator var5 = var1.iterator(); var5.hasNext(); var6.show = false) + { + var6 = (TMIPotionEffectControl)var5.next(); + } + + int var15 = ((TMIPotionEffectControl)var1.get(0)).width; + int var16 = ((TMIPotionEffectControl)var1.get(0)).height; + int var7 = this.width / var15; + int var8 = (this.height - var3 - 16 - 2) / var16; + int var9 = var7 * var8; + int var10 = var1.size(); + int var11 = var10 / var9 + (var10 % var9 > 0 ? 1 : 0); + this.nextButton.show = this.prevButton.show = var11 > 1; + + if (this.page > var11 - 1 || this.page < 0) + { + this.page = 0; + } + + int var12 = this.page * var9; + + for (int var13 = 0; var13 < var8 && var12 < var1.size(); ++var13) + { + var2 = this.x; + + for (int var14 = 0; var14 < var7 && var12 < var1.size(); ++var14) + { + ((TMIPotionEffectControl)var1.get(var12)).show = true; + ((TMIPotionEffectControl)var1.get(var12)).x = var2; + ((TMIPotionEffectControl)var1.get(var12)).y = var3; + ((TMIPotionEffectControl)var1.get(var12)).resize(); + ++var12; + var2 += var15 + 2; + } + + var3 += var16 + 2; + } + + var4 = ((TMIPotionEffectControl)var1.get(var12 - 1)).y + var16 + 2; + } + + this.addButton.x = this.x; + this.prevButton.x = this.addButton.x + this.addButton.width + 2; + this.nextButton.x = this.prevButton.x + this.prevButton.width + 2; + this.addButton.y = this.prevButton.y = this.nextButton.y = var4; + } + + public List getEffects() + { + ArrayList var1 = new ArrayList(); + Iterator var2 = this.children.iterator(); + + while (var2.hasNext()) + { + _tmi_MgWidget var3 = (_tmi_MgWidget)var2.next(); + + if (var3 instanceof TMIPotionEffectControl) + { + var1.add((TMIPotionEffectControl)var3); + } + } + + return var1; + } + + public ItemStack createCurrentPotion() + { + ItemStack var1 = new ItemStack(TMIItemInfo.addItemOffset(117), 64, makeSplashPotion ? 16384 : 1); + Iterator var2 = this.getEffects().iterator(); + + while (var2.hasNext()) + { + TMIPotionEffectControl var3 = (TMIPotionEffectControl)var2.next(); + PotionEffect var4 = new PotionEffect(var3.effectId, var3.isInstant() ? 0 : var3.tickDuration, var3.level); + TMIUtils.addEffectToPotion(var1, var4); + } + + String var5 = this.nameField.value(); + + if (!var5.equals("")) + { + TMIUtils.nameStack(var1, var5); + } + + return var1; + } + + public void openEffectPicker(TMIPotionEffectControl var1) + { + this.pickerTarget = var1; + this.picker.z = -100; + this.picker.width = this.width; + this.picker.height = this.height; + this.picker.x = this.x; + this.picker.y = this.y; + this.picker.show = true; + this.picker.resize(); + } + + public void pickerPicked(int var1) + { + if (this.pickerTarget == null) + { + TMIPotionEffectControl var2 = new TMIPotionEffectControl(this); + var2.effectId = var1; + controls.add(var2); + this.children.add(var2); + this.resize(); + } + else + { + this.pickerTarget.effectId = var1; + } + } + + public void removeEffectControl(TMIPotionEffectControl var1) + { + this.children.remove(var1); + controls.remove(var1); + this.resize(); + } + + public boolean onButtonPress(Object var1) + { + if (var1 instanceof String) + { + String var2 = (String)var1; + + if (var2.equals("potionType")) + { + makeSplashPotion = !makeSplashPotion; + this.potionTypeButton.stack = makeSplashPotion ? this.potionTypeSplash : this.potionTypeRegular; + return false; + } + + ItemStack var3; + + if (var2.equals("createPotion")) + { + var3 = this.createCurrentPotion(); + TMIUtils.giveStack(var3, TMIConfig.getInstance()); + return false; + } + + if (var2.equals("favoritePotion")) + { + var3 = this.createCurrentPotion(); + TMIConfig.getInstance().getFavorites().add(var3); + TMIUtils.savePreferences(TMIConfig.getInstance()); + return false; + } + + if (var2.equals("addEffect")) + { + this.openEffectPicker((TMIPotionEffectControl)null); + return false; + } + + if (var2.equals("next")) + { + ++this.page; + this.resize(); + } + else if (var2.equals("prev")) + { + --this.page; + this.resize(); + } + } + + return true; + } + + public boolean onButtonRightClick(Object var1) + { + return true; + } + + public void draw(_tmi_MgCanvas var1, int var2, int var3) + { + if (this.show) + { + this.drawChildren(var1, var2, var3); + } + } + + public boolean click(int var1, int var2, int var3) + { + return this.delegateClickToChildren(var1, var2, var3); + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIPrivateFields.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIPrivateFields.java new file mode 100644 index 0000000..75aea72 --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIPrivateFields.java @@ -0,0 +1,208 @@ +package me.ayunami2000.ayuncraft.tmi; + +import java.io.DataInput; +import java.io.DataOutput; +import java.lang.reflect.Field; +import java.lang.reflect.Method; +import java.util.Iterator; +import java.util.Map; +import java.util.SortedSet; +import java.util.TreeSet; + +import net.minecraft.src.*; +import net.lax1dude.eaglercraft.EaglerAdapter; + +public class TMIPrivateFields +{ + public static Field lwjglMouseDWheel; + public static Field lwjglMouseEventDWheel; + public static Field textFieldX; + public static Field textFieldY; + public static Field textFieldWidth; + public static Field textFieldHeight; + public static Field threadTarget; + public static Field creativeTab; + public static Field gameMode; + public static Method setCreativeTab; + public static Field creativeSlot; + public static Field blockSpawner; + public static Field blockSnow; + public static Field entityIdClassMap; + public static Field creativeSearchBox; + public static Method setBlockBounds; + public static Field spawnerProps; + public static Field stackDamage; + public static Method readTagList; + public static Method writeTagList; + public static Method drawGradientRect; + + public static void printFieldsAndMethods(Class var0) + { + Field[] var1 = var0.getDeclaredFields(); + int var2 = var1.length; + int var3; + + for (var3 = 0; var3 < var2; ++var3) + { + Field var4 = var1[var3]; + System.out.println(var0.getName() + " field " + var4.getName()); + } + + Method[] var5 = var0.getDeclaredMethods(); + var2 = var5.length; + + for (var3 = 0; var3 < var2; ++var3) + { + Method var6 = var5[var3]; + System.out.println(var0.getName() + " method " + var6.getName()); + } + } + + public static Field getPrivateField(Class var0, String var1, String var2) + { + Field var3 = null; + + try + { + var3 = var0.getDeclaredField(var1); + } + catch (NoSuchFieldException var7) + { + try + { + var3 = var0.getDeclaredField(var2); + } + catch (NoSuchFieldException var6) + { + System.out.println("[TMI] Disabling TMI, cannot access " + var0.getName() + "." + var1 + ", " + var0.getName() + "." + var2); + TMIConfig.getInstance().setEnabled(false); + } + } + + if (var3 != null) + { + unsetFinalPrivate(var3); + } + + return var3; + } + + public static Method getPrivateMethod(Class var0, String var1, String var2, Class[] var3) + { + Method var4 = null; + + try + { + var4 = var0.getDeclaredMethod(var1, var3); + } + catch (NoSuchMethodException var8) + { + try + { + var4 = var0.getDeclaredMethod(var2, var3); + } + catch (NoSuchMethodException var7) + { + System.out.println("[TMI] Disabling TMI, cannot access " + var0.getName() + "." + var1 + ", " + var0.getName() + "." + var2); + TMIConfig.getInstance().setEnabled(false); + } + } + + if (var4 != null) + { + var4.setAccessible(true); + } + + return var4; + } + + public static SortedSet getSpawnerEntityIdSet() + { + try + { + TreeSet var0 = new TreeSet(((Map)entityIdClassMap.get((Object)null)).keySet()); + Iterator var1 = TMIItemInfo.excludedSpawnerIds.iterator(); + + while (var1.hasNext()) + { + Integer var2 = (Integer)var1.next(); + + if (var0.contains(var2)) + { + var0.remove(var2); + } + } + + return var0; + } + catch (Exception var3) + { + System.out.println(var3); + TreeSet retval=new TreeSet<>(); + retval.add(0); + return retval; + } + } + + public static void unsetFinalPrivate(Class var0, String var1) + { + try + { + unsetFinalPrivate(var0.getDeclaredField(var1)); + } + catch (NoSuchFieldException var3) + { + System.out.println(var3); + } + } + + public static void unsetFinalPrivate(Field var0) + { + try + { + var0.setAccessible(true); + Field var1 = Field.class.getDeclaredField("modifiers"); + var1.setAccessible(true); + var1.setInt(var0, var0.getModifiers() & -17); + } + catch (Exception var2) + { + System.out.println(var2); + } + } + + static + { + try + { + threadTarget = Thread.class.getDeclaredField("target"); + threadTarget.setAccessible(true); + lwjglMouseEventDWheel = EaglerAdapter.class.getDeclaredField("event_dwheel"); + unsetFinalPrivate(lwjglMouseEventDWheel); + lwjglMouseDWheel = EaglerAdapter.class.getDeclaredField("dwheel"); + unsetFinalPrivate(lwjglMouseDWheel); + textFieldX = getPrivateField(GuiTextField.class, "b", "xPos"); + textFieldY = getPrivateField(GuiTextField.class, "c", "yPos"); + textFieldWidth = getPrivateField(GuiTextField.class, "d", "width"); + textFieldHeight = getPrivateField(GuiTextField.class, "e", "height"); + creativeTab = getPrivateField(GuiContainerCreative.class, "s", "selectedTabIndex"); + setCreativeTab = getPrivateMethod(GuiContainerCreative.class, "b", "setCurrentCreativeTab", new Class[] {CreativeTabs.class}); + creativeSearchBox = getPrivateField(GuiContainerCreative.class, "w", "searchField"); + gameMode = getPrivateField(PlayerControllerMP.class, "k", "currentGameType"); + creativeSlot = getPrivateField(SlotCreativeInventory.class, "b", "theSlot"); + stackDamage = getPrivateField(ItemStack.class, "e", "itemDamage"); + blockSpawner = getPrivateField(Block.class, "aw", "mobSpawner"); + blockSnow = getPrivateField(Block.class, "aW", "snow"); + entityIdClassMap = getPrivateField(EntityList.class, "d", "IDtoClassMapping"); + setBlockBounds = getPrivateMethod(Block.class, "a", "setBlockBounds", new Class[] {Float.TYPE, Float.TYPE, Float.TYPE, Float.TYPE, Float.TYPE, Float.TYPE}); + readTagList = getPrivateMethod(NBTTagList.class, "a", "load", new Class[] {DataInput.class}); + writeTagList = getPrivateMethod(NBTTagList.class, "a", "write", new Class[] {DataOutput.class}); + drawGradientRect = getPrivateMethod(Gui.class, "a", "drawGradientRect", new Class[] {Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE, Integer.TYPE}); + } + catch (Exception var1) + { + System.out.println("[TMI] Critical error in TMIPrivateFields"); + var1.printStackTrace(); + } + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIStateButtonData.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIStateButtonData.java new file mode 100644 index 0000000..89f34b4 --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIStateButtonData.java @@ -0,0 +1,16 @@ +package me.ayunami2000.ayuncraft.tmi; + +class TMIStateButtonData +{ + public static final String COPYRIGHT = "All of TooManyItems except for thesmall portion excerpted from the original Minecraft game is copyright 2011Marglyph. TooManyItems is free for personal use only. Do not redistributeTooManyItems, including in mod packs, and do not use TooManyItems\' sourcecode or graphics in your own mods."; + public int state; + public int action; + public static final int STATE = 0; + public static final int CLEAR = 1; + + public TMIStateButtonData(int var1, int var2) + { + this.state = var1; + this.action = var2; + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIUtils.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIUtils.java new file mode 100644 index 0000000..592116b --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIUtils.java @@ -0,0 +1,1556 @@ +package me.ayunami2000.ayuncraft.tmi; + +import java.awt.Color; +import java.io.BufferedReader; +import java.io.DataInputStream; +import java.io.DataOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.PrintWriter; +import java.lang.reflect.Field; +import java.text.FieldPosition; +import java.text.MessageFormat; +import java.text.Normalizer; +import java.text.NumberFormat; +import java.text.SimpleDateFormat; +import java.text.Normalizer.Form; +import java.util.*; +import java.util.regex.Pattern; +import net.minecraft.client.Minecraft; +import net.minecraft.src.*; +import net.lax1dude.eaglercraft.EaglerAdapter; + +public class TMIUtils +{ + public static final String COPYRIGHT = "All of TooManyItems except for thesmall portion excerpted from the original Minecraft game is copyright 2011Marglyph. TooManyItems is free for personal use only. Do not redistributeTooManyItems, including in mod packs, and do not use TooManyItems\' sourcecode or graphics in your own mods."; + public static final String CONFIG_FILENAME = "TooManyItems.txt"; + public static final String NBT_FILENAME = "TMI.nbt"; + public static final int SPAWNER_ID = 52; + public static final int MODE_SURVIVAL = 0; + public static final int MODE_CREATIVE = 1; + public static final int MODE_ADVENTURE = 2; + public static final List EMPTY_NAME = Arrays.asList(""); + public static boolean haveReplacedItems = false; + public static final Random random = new Random(); + private static Map originalItems = new HashMap(); + public static List availableItems = new ArrayList(); + + public static File configFile() + { + return new File(Minecraft.getMinecraftDir(), "TooManyItems.txt"); + } + + public static File nbtFile() + { + return new File(Minecraft.getMinecraftDir(), "TMI.nbt"); + } + + public static void loadPreferences(TMIConfig var0) + { + try + { + Map var1 = var0.getSettings(); + File var2 = configFile(); + + if (var2.exists()) + { + if (!nbtFile().exists()) + { + var1.put("favorites", ""); + + for (int var3 = 0; var3 < 7; ++var3) + { + var1.put("save" + (var3 + 1), ""); + } + } + + BufferedReader var7 = new BufferedReader(new FileReader(var2)); + String var4; + + while ((var4 = var7.readLine()) != null) + { + String[] var5 = var4.split(":", 2); + + if (var5.length > 1 && var1.containsKey(var5[0])) + { + var1.put(var5[0], var5[1]); + } + } + + var7.close(); + + if (!nbtFile().exists()) + { + for (int var8 = 0; var8 < var0.getNumSaves(); ++var8) + { + if (var1.containsKey("save" + (var8 + 1))) + { + var0.decodeState(var8, (String)var1.get("save" + (var8 + 1))); + } + } + + System.out.println("Loading old favorites"); + var0.decodeFavorites(); + } + } + + loadNBTFile(var0); + } + catch (Exception var6) + { + var6.printStackTrace(); + } + } + + public static void savePreferences(TMIConfig var0) + { + try + { + saveNBTFile(var0); + Map var1 = var0.getSettings(); + File var2 = configFile(); + PrintWriter var3 = new PrintWriter(new FileWriter(var2)); + Iterator var4 = var1.keySet().iterator(); + + while (var4.hasNext()) + { + String var5 = (String)var4.next(); + + if (!var5.matches("favorites|save\\d")) + { + var3.println(var5 + ":" + (String)var1.get(var5)); + } + } + + var3.close(); + } + catch (Exception var6) + { + System.out.println(var6); + } + } + + public static void saveNBTFile(TMIConfig var0) + { + try + { + DataOutputStream var1 = new DataOutputStream(new FileOutputStream(nbtFile())); + NBTTagList var2 = new NBTTagList(); + NBTTagList var3 = new NBTTagList(); + List var4 = var0.getFavorites(); + NBTTagCompound var7; + + for (Iterator var5 = var4.iterator(); var5.hasNext(); var3.appendTag(var7)) + { + ItemStack var6 = (ItemStack)var5.next(); + var7 = new NBTTagCompound(); + + if (var6 != null) + { + var6.writeToNBT(var7); + } + } + + var2.appendTag(var3); + + for (int var11 = 0; var11 < 7; ++var11) + { + if (TMIConfig.statesSaved[var11]) + { + ItemStack[] var12 = var0.getState(var11); + NBTTagList var14 = new NBTTagList(); + + for (int var8 = 0; var8 < var12.length; ++var8) + { + NBTTagCompound var9 = new NBTTagCompound(); + + if (var12[var8] != null) + { + var12[var8].writeToNBT(var9); + } + + var14.appendTag(var9); + } + + var2.appendTag(var14); + } + else + { + NBTTagList var13 = new NBTTagList(); + var2.appendTag(var13); + } + } + + TMIPrivateFields.writeTagList.invoke(var2, new Object[] {var1}); + } + catch (Exception var10) + { + System.out.println(var10); + } + } + + public static void loadNBTFile(TMIConfig var0) + { + try + { + File var1 = nbtFile(); + + if (!var1.exists()) + { + return; + } + + DataInputStream var2 = new DataInputStream(new FileInputStream(var1)); + NBTTagList var3 = new NBTTagList(); + TMIPrivateFields.readTagList.invoke(var3, new Object[] {var2}); + boolean var4 = false; + + if (var3.tagCount() > 0) + { + NBTTagList var5 = (NBTTagList)var3.tagAt(0); + List var6 = var0.getFavorites(); + var6.clear(); + + for (int var7 = 0; var7 < var5.tagCount(); ++var7) + { + NBTTagCompound var8 = (NBTTagCompound)var5.tagAt(var7); + ItemStack var9 = new ItemStack(0, 1, 0); + var9.readFromNBT(var8); + var6.add(var9); + } + } + + for (int var14 = 1; var14 < var3.tagCount(); ++var14) + { + int var13 = var14 - 1; + NBTBase var15 = var3.tagAt(var14); + + if (var15 instanceof NBTTagList) + { + NBTTagList var16 = (NBTTagList)var15; + + if (var16.tagCount() > 0 && var13 < 7) + { + ItemStack[] var17 = var0.getState(var13); + + for (int var18 = 0; var18 < var16.tagCount(); ++var18) + { + NBTBase var10 = var16.tagAt(var18); + + if (var10 instanceof NBTTagCompound) + { + NBTTagCompound var11 = (NBTTagCompound)var10; + + if (var11.hasKey("id")) + { + var17[var18] = new ItemStack(0, 1, 0); + var17[var18].readFromNBT(var11); + } + else + { + var17[var18] = null; + } + } + } + + TMIConfig.statesSaved[var13] = true; + } + } + } + } + catch (Exception var12) + { + System.out.println(var12); + } + } + + public static void loadItems(TMIConfig var0) + { + List var1 = availableItems; + List var2 = var0.getEnchantableItems(); + boolean var3 = TMIConfig.isMultiplayer(); + var1.clear(); + var2.clear(); + + try + { + Class var4 = Class.forName("com.eloraam.redpower.RedPowerBase"); + Block var5 = (Block)var4.getDeclaredField("blockMicro").get((Object)null); + Field var6 = Block.class.getDeclaredField("cz"); + TMIItemInfo.setMaxDamageException(var6.getInt(var5), 32000); + } + catch (ClassNotFoundException var19) + { + ; + } + catch (NoClassDefFoundError var20) + { + ; + } + catch (Exception var21) + { + System.out.println(var21); + } + + ArrayList var26 = new ArrayList(); + Item[] var27 = Item.itemsList; + int var30 = var27.length; + ItemStack var37; + label243: + + for (int var7 = 0; var7 < var30; ++var7) + { + Item var8 = var27[var7]; + + if (var8 != null) + { + Iterator var34; + + if (var8.itemID == TMIItemInfo.addItemOffset(127)) + { + if (var0.areDamageVariantsShown()) + { + var34 = EntityList.entityEggs.keySet().iterator(); + + while (var34.hasNext()) + { + Object var40 = var34.next(); + var1.add(new ItemStack(TMIItemInfo.addItemOffset(127), 64, ((Integer)var40).intValue())); + } + } + } + else + { + int var10; + ItemStack var14; + + if (var8.itemID == 52) + { + if (var3) + { + var1.add(new ItemStack(52, 64, 0)); + } + else + { + try + { + var34 = TMIPrivateFields.getSpawnerEntityIdSet().iterator(); + + while (var34.hasNext()) + { + var10 = ((Integer)var34.next()).intValue(); + var1.add(new ItemStack(52, 64, var10)); + } + + ItemStack var35 = makeSingleSpawner(50, 64, "\u00a7r\u00a79Charged Creeper Spawner"); + var35.stackTagCompound.getCompoundTag("SpawnData").setBoolean("powered", true); + var1.add(var35); + var37 = makeSingleSpawner(51, 64, "\u00a7r\u00a79Wither Skeleton Spawner"); + var37.stackTagCompound.getCompoundTag("SpawnData").setTag("SkeletonType", new NBTTagByte("", (byte)1)); + NBTTagList var38 = new NBTTagList(); + ItemStack var41 = new ItemStack(TMIItemInfo.addItemOffset(16), 1, 0); + NBTTagCompound var42 = new NBTTagCompound(); + var41.writeToNBT(var42); + var38.appendTag(var42); + var38.appendTag(new NBTTagCompound()); + var38.appendTag(new NBTTagCompound()); + var38.appendTag(new NBTTagCompound()); + var38.appendTag(new NBTTagCompound()); + var37.stackTagCompound.getCompoundTag("SpawnData").setTag("Equipment", var38); + var1.add(var37); + var14 = makeSingleSpawner(90, 64, "\u00a7r\u00a79Saddled Pig Spawner"); + var14.stackTagCompound.getCompoundTag("SpawnData").setBoolean("Saddle", true); + var1.add(var14); + var1.add(makeRandomFireworkSpawner()); + ItemStack var43 = makeSingleSpawner(21, 64, "\u00a7r\u00a79TMI Wide-Area Torch Spawner"); + addLore(var43, "It\'s full of torches!"); + var43.stackTagCompound.getCompoundTag("SpawnData").setByte("Tile", (byte)50); + var43.stackTagCompound.getCompoundTag("SpawnData").setByte("Time", (byte)2); + var43.stackTagCompound.getCompoundTag("SpawnData").setBoolean("DropItem", false); + var43.stackTagCompound.setShort("MinSpawnDelay", (short)15); + var43.stackTagCompound.setShort("MaxSpawnDelay", (short)15); + var43.stackTagCompound.setShort("SpawnCount", (short)10); + var43.stackTagCompound.setShort("MaxNearbyEntities", (short)15); + var43.stackTagCompound.setShort("RequiredPlayerRange", (short)16); + var43.stackTagCompound.setShort("SpawnRange", (short)136); + } + catch (Exception var22) + { + System.out.println(var22); + var1.add(new ItemStack(52, 64, 0)); + } + } + } + else if (!TMIItemInfo.isHidden(var8.itemID)) + { + if (var8.getItemEnchantability() > 0) + { + var2.add(var8); + } + + if (var8.itemID < Block.blocksList.length && Block.blocksList[var8.itemID] != null) + { + var26.clear(); + Block.blocksList[var8.itemID].getSubBlocks(var8.itemID, (CreativeTabs)null, var26); + + if (var26.size() > 1) + { + var34 = var26.iterator(); + + while (true) + { + if (!var34.hasNext()) + { + continue label243; + } + + var37 = (ItemStack)var34.next(); + var37.stackSize = Item.itemsList[var37.itemID].getItemStackLimit(); + var1.add(var37); + } + } + } + + HashSet var9 = new HashSet(); + var10 = var0.areDamageVariantsShown() ? 15 : 0; + int var11 = TMIItemInfo.getMaxDamageException(var8.itemID); + + if (var11 > var10) + { + var10 = var11; + } + + boolean var12 = false; + + for (int var13 = 0; var13 <= var10; ++var13) + { + if ((var8.itemID != 43 || var13 <= 0) && (var8.itemID != 44 || var13 <= 5) && (var8.itemID != 59 || var13 == 7 && !var3) && (var8.itemID != 104 || var13 == 7 && !var3) && (var8.itemID != 105 || var13 == 7 && !var3) && (var8.itemID != 115 || var13 == 3 && !var3) && (var8.itemID != 78 || var13 <= 0 || !var3) && (var8.itemID != 125 || var13 <= 0) && (var8.itemID != 126 || var13 <= 3)) + { + var14 = new ItemStack(var8, var8.getItemStackLimit(), var13); + + try + { + Icon var15 = var8.getIconIndex(var14); + String var16 = var8.getUnlocalizedName(var14); + + if (itemDisplayName(var14).equals("Unnamed")) + { + if (var13 == 0) + { + break; + } + } + else + { + if (var8.itemID < Block.blocksList.length && Block.blocksList[var8.itemID] != null) + { + try + { + Block.blocksList[var8.itemID].getIcon(1, var13); + } + catch (Exception var23) + { + continue; + } + } + + boolean var17 = !var3 && (var8.itemID == 99 || var8.itemID == 100) && var13 < 16; + String var18 = var16 + "@" + var15.getIconName(); + + if (!var9.contains(var18) || TMIItemInfo.isShown(var8.itemID, var13) || var17) + { + var1.add(var14); + var9.add(var18); + } + } + } + catch (NullPointerException var24) + { + ; + } + catch (IndexOutOfBoundsException var25) + { + ; + } + } + } + } + } + } + } + + ItemStack var32; + + if (var0.areDamageVariantsShown()) + { + Iterator var28 = TMIItemInfo.potionValues.iterator(); + + while (var28.hasNext()) + { + var30 = ((Integer)var28.next()).intValue(); + var32 = new ItemStack(TMIItemInfo.addItemOffset(117), 64, var30); + var1.add(var32); + } + } + + if (var0.areDamageVariantsShown() && !TMIConfig.isMultiplayer()) + { + ItemStack var29 = new ItemStack(TMIItemInfo.addItemOffset(117), 64, 1); + PotionEffect var31 = new PotionEffect(3, 0, 1); + addEffectToPotion(var29, var31); + var1.add(var29); + var32 = new ItemStack(TMIItemInfo.addItemOffset(117), 64, 16384); + PotionEffect var33 = new PotionEffect(7, 0, 3); + addEffectToPotion(var32, var33); + var1.add(var32); + var1.add(makeFirework("Creepy Sparkler", 2, 3, new int[] {4312372}, new int[] {15435844}, true, false)); + var1.add(makeFirework("Star", 4, 2, new int[] {6719955}, (int[])null, false, false)); + var1.add(makeFirework("Big Red", 1, 1, new int[] {11743532}, (int[])null, false, false)); + NBTTagCompound var36 = makeExplosionTag(1, new int[] {11743532, 15790320, 2437522}, new int[] {15790320}, true, true); + var37 = new ItemStack(TMIItemInfo.addItemOffset(145), 64, 0); + var37.stackTagCompound = new NBTTagCompound(); + NBTTagCompound var39 = makeFireworksTag(2, new NBTTagCompound[] {var36, var36}); + var37.stackTagCompound.setCompoundTag("Fireworks", var39); + nameStack(var37, "Old Glory"); + var1.add(var37); + } + + filterItems((String)null, var0); + } + + public static ItemStack makeRandomFireworkSpawner() + { + ItemStack var0 = new ItemStack(52, 1, 22); + var0.stackTagCompound = new NBTTagCompound(); + nameStack(var0, "\u00a7r\u00a79TMI Random Firework Spawner"); + addLore(var0, "Every one is different"); + var0.stackTagCompound.setShort("MinSpawnDelay", (short)20); + var0.stackTagCompound.setShort("MaxSpawnDelay", (short)20); + var0.stackTagCompound.setShort("SpawnCount", (short)1); + var0.stackTagCompound.setShort("MaxNearbyEntities", (short)5); + var0.stackTagCompound.setShort("RequiredPlayerRange", (short)120); + var0.stackTagCompound.setShort("SpawnRange", (short)2); + NBTTagList var1 = new NBTTagList("SpawnPotentials"); + var0.stackTagCompound.setTag("SpawnPotentials", var1); + + for (int var2 = 0; var2 < 10; ++var2) + { + NBTTagCompound var3 = new NBTTagCompound("SpawnData"); + var3.setString("Type", "FireworksRocketEntity"); + var3.setInteger("Weight", 1); + NBTTagCompound var4 = new NBTTagCompound("Properties"); + var3.setCompoundTag("Properties", var4); + NBTTagCompound var5 = makeRandomFirework().writeToNBT(new NBTTagCompound()); + var4.setCompoundTag("FireworksItem", var5); + var4.setInteger("LifeTime", random.nextInt(15) + random.nextInt(15) + 20); + var1.appendTag(var3); + } + + return var0; + } + + public static ItemStack makeSingleSpawner(int var0, int var1, String var2) + { + String var3 = EntityList.getStringFromID(var0); + ItemStack var4 = new ItemStack(52, var1, var0); + var4.stackTagCompound = new NBTTagCompound(); + NBTTagCompound var5 = new NBTTagCompound("SpawnData"); + var4.stackTagCompound.setCompoundTag("SpawnData", var5); + + if (var2 != null) + { + nameStack(var4, var2); + } + + return var4; + } + + public static ItemStack makeFirework(String var0, int var1, int var2, int[] var3, int[] var4, boolean var5, boolean var6) + { + ItemStack var7 = new ItemStack(TMIItemInfo.addItemOffset(145), 64, 0); + var7.stackTagCompound = new NBTTagCompound(); + NBTTagCompound var8 = makeExplosionTag(var2, var3, var4, var5, var6); + NBTTagCompound var9 = makeFireworksTag(var1, new NBTTagCompound[] {var8}); + var7.stackTagCompound.setCompoundTag("Fireworks", var9); + + if (var0 != null && !var0.equals("")) + { + nameStack(var7, var0); + } + + return var7; + } + + public static NBTTagCompound makeExplosionTag(int var0, int[] var1, int[] var2, boolean var3, boolean var4) + { + NBTTagCompound var5 = new NBTTagCompound("Explosion"); + var5.setBoolean("Flicker", var3); + var5.setBoolean("Trail", var4); + var5.setByte("Type", (byte)(var0 & 15)); + + if (var1 != null && var1.length > 0) + { + var5.setIntArray("Colors", var1); + } + + if (var2 != null && var2.length > 0) + { + var5.setIntArray("FadeColors", var2); + } + + return var5; + } + + public static ItemStack makeRandomFirework() + { + int[] var0; + + if (random.nextBoolean()) + { + var0 = new int[] {randomBrightColor(), randomBrightColor()}; + } + else + { + var0 = new int[] {randomBrightColor()}; + } + + int[] var1; + + if (random.nextBoolean()) + { + var1 = new int[] {randomBrightColor()}; + } + else + { + var1 = null; + } + + return makeFirework("Random Firework", random.nextInt(3) + 1, random.nextInt(4), var0, var1, random.nextBoolean(), random.nextBoolean()); + } + + public static int randomBrightColor() + { + return Color.HSBtoRGB(random.nextFloat(), random.nextFloat(), random.nextFloat() * 0.5F + 0.5F); + } + + public static NBTTagCompound makeFireworksTag(int var0, NBTTagCompound ... var1) + { + NBTTagCompound var2 = new NBTTagCompound("Fireworks"); + var2.setByte("Flight", (byte)(var0 & 15)); + NBTTagList var3 = new NBTTagList(); + var2.setTag("Explosions", var3); + NBTTagCompound[] var4 = var1; + int var5 = var1.length; + + for (int var6 = 0; var6 < var5; ++var6) + { + NBTTagCompound var7 = var4[var6]; + var3.appendTag(var7); + } + + return var2; + } + + public static String deaccent(String var0) + { + try + { + Class.forName("java.text.Normalizer"); + } + catch (ClassNotFoundException var3) + { + return var0; + } + + String var1 = Normalizer.normalize(var0, Form.NFD); + Pattern var2 = Pattern.compile("\\p{InCombiningDiacriticalMarks}+"); + return var2.matcher(var1).replaceAll(""); + } + + public static void filterItems(String var0, TMIConfig var1) + { + List var2 = availableItems; + List var3 = var1.getItems(); + var3.clear(); + Iterator var4; + ItemStack var5; + + if (var0 != null && !var0.equals("")) + { + var0 = deaccent(var0.toLowerCase()); + var4 = var2.iterator(); + + while (var4.hasNext()) + { + var5 = (ItemStack)var4.next(); + + if (var5 != null) + { + String var6 = itemDisplayName(var5); + + if (var6 != null && deaccent(var6.toLowerCase()).contains(var0)) + { + var3.add(var5); + } + } + } + } + else + { + var4 = var2.iterator(); + + while (var4.hasNext()) + { + var5 = (ItemStack)var4.next(); + var3.add(var5); + } + } + } + + public static void safeReportException(Exception var0) + { + try + { + SimpleDateFormat var1 = new SimpleDateFormat(".yyyyMMdd.HHmmss"); + StringBuffer var2 = new StringBuffer(); + var1.format(new Date(), var2, new FieldPosition(1)); + String var3 = "tmi" + var2.toString() + ".txt"; + File var4 = new File(Minecraft.getAppDir("minecraft"), var3); + PrintWriter var5 = new PrintWriter(new FileWriter(var4)); + var5.print("[code]TMI Version: 1.5.2 2013-04-25\n"); + var0.printStackTrace(var5); + var5.println("[/code]"); + var5.close(); + } + catch (Exception var6) + { + System.out.println("Error during safeReportException:"); + var6.printStackTrace(); + } + } + + public static List itemDisplayNameMultiline(ItemStack var0, boolean var1) + { + return itemDisplayNameMultiline(var0, var1, false); + } + + public static List itemDisplayNameMultiline(ItemStack var0, boolean var1, boolean var2) + { + if (var0 == null) + { + return EMPTY_NAME; + } + else + { + if (var2) + { + var1 = false; + } + + Object var3 = null; + + if (isValidItem(var0)) + { + try + { + List var4 = var0.getTooltip(Minecraft.getMinecraft().thePlayer, var2); + var3 = var4; + } + catch (Exception var5) + { + ; + } + } + + if (var3 == null || ((List)var3).size() == 0 || var0.itemID == 52 && var0.stackTagCompound == null) + { + var3 = new ArrayList(); + ((List)var3).add(TMIItemInfo.getFallbackName(var0.itemID, var0.getItemDamageForDisplay())); + + if (var2) + { + var1 = true; + } + } + + String var6 = ((String)((List)var3).get(0)).trim(); + + if (var6.length() == 0) + { + var6 = TMIItemInfo.getFallbackName(var0.itemID, var0.getItemDamageForDisplay()); + ((List)var3).set(0, var6); + } + + if (var1 && var0 != null) + { + var6 = var6 + " " + var0.itemID; + + if (var0.getItemDamageForDisplay() != 0) + { + var6 = var6 + " : " + var0.getItemDamageForDisplay(); + } + + ((List)var3).set(0, var6); + } + + return (List)var3; + } + } + + public static String itemDisplayName(ItemStack var0) + { + List var1 = itemDisplayNameMultiline(var0, false); + return (String)var1.get(0); + } + + public static boolean isValidItem(ItemStack var0) + { + return var0 == null || var0.itemID >= 0 && var0.itemID < Item.itemsList.length && Item.itemsList[var0.itemID] != null; + } + + public static ItemStack getValidItem(ItemStack var0) + { + return isValidItem(var0) ? var0 : new ItemStack(Item.itemsList[52]); + } + + public static String getValidItemDisplayName(ItemStack var0) + { + return isValidItem(var0) ? itemDisplayName(var0) : "Undefined Item"; + } + + public static void setHeldItem(ItemStack var0) + { + getPlayer().inventory.setItemStack(var0); + Minecraft.getMinecraft().thePlayer.inventory.setItemStack(var0); + } + + public static void deleteHeldItem() + { + setHeldItem((ItemStack)null); + } + + public static ItemStack getHeldItem() + { + return Minecraft.getMinecraft().thePlayer.inventory.getItemStack(); + } + + public static void giveStack(ItemStack var0, TMIConfig var1) + { + giveStack(var0, var1, var0.stackSize); + } + + public static void giveStack(ItemStack var0, TMIConfig var1, int var2) + { + ItemStack var3 = copyStack(var0, var2); + Minecraft var4 = Minecraft.getMinecraft(); + + if (TMIConfig.isMultiplayer()) + { + NumberFormat var5 = NumberFormat.getIntegerInstance(); + var5.setGroupingUsed(false); + MessageFormat var6 = new MessageFormat((String)var1.getSettings().get("give-command")); + var6.setFormatByArgumentIndex(1, var5); + var6.setFormatByArgumentIndex(2, var5); + var6.setFormatByArgumentIndex(3, var5); + Object[] var7 = new Object[] {var4.thePlayer.username, Integer.valueOf(var3.itemID), Integer.valueOf(var3.stackSize), Integer.valueOf(var3.getItemDamageForDisplay())}; + StringBuilder var8 = new StringBuilder(); + var8.append(var6.format(var7)); + Iterator var9 = getEnchantments(var3).iterator(); + + while (var9.hasNext()) + { + int[] var10 = (int[])var9.next(); + var8.append(" "); + var8.append(var10[0]); + var8.append(":"); + var8.append(var10[1]); + } + + var4.thePlayer.sendChatMessage(var8.toString()); + } + else + { + getPlayer().inventory.addItemStackToInventory(var3); + } + } + + public static ItemStack copyStack(ItemStack var0, int var1) + { + if (var0 == null) + { + return null; + } + else + { + var0.stackSize += var1; + return var0.splitStack(var1); + } + } + + public static ItemStack copyStack(ItemStack var0) + { + return var0 == null ? null : copyStack(var0, var0.stackSize); + } + + public static void updateUnlimitedItems() + { + try + { + if (TMIConfig.isMultiplayer() || !TMIConfig.getInstance().isEnabled()) + { + return; + } + + ItemStack[] var0 = getPlayer().inventory.mainInventory; + int var1 = var0.length; + + for (int var2 = 0; var2 < var1; ++var2) + { + ItemStack var3 = var0[var2]; + + if (var3 != null) + { + if (var3.stackTagCompound != null && var3.stackTagCompound.hasKey("TooManyItems")) + { + NBTTagCompound var4 = var3.stackTagCompound.getCompoundTag("TooManyItems"); + + if (var4.hasKey("Unlimited")) + { + int var5 = maxStackSize(var3.itemID); + + if (var5 == 1) + { + var5 = 64; + } + + var3.stackSize = var5; + } + } + + if (var3.getItemDamageForDisplay() < 0) + { + setStackDamage(var3, -32000); + } + } + } + + ItemStack var7 = getHeldItem(); + + if (var7 != null && var7.stackSize > 64) + { + var7.stackSize = -1; + } + } + catch (NullPointerException var6) + { + ; + } + } + + public static void setStackDamage(ItemStack var0, int var1) + { + try + { + TMIPrivateFields.stackDamage.setInt(var0, var1); + } + catch (Exception var3) + { + System.out.println("[TMI] Error setting stack damage"); + var3.printStackTrace(); + } + } + + public static void deleteInventory() + { + List var0 = getPlayer().openContainer.inventorySlots; + + for (int var1 = 0; var1 < var0.size(); ++var1) + { + Slot var2 = (Slot)var0.get(var1); + + if (var2 != null) + { + var2.putStack((ItemStack)null); + } + } + } + + public static void deleteItemsOfType(ItemStack var0, GuiContainer var1) + { + List var2 = getPlayer().openContainer.inventorySlots; + + for (int var3 = 0; var3 < var2.size(); ++var3) + { + Slot var4 = (Slot)var2.get(var3); + + if (var4 != null) + { + ItemStack var5 = var4.getStack(); + + if (var5 != null && var5.itemID == var0.itemID && var5.getItemDamageForDisplay() == var0.getItemDamageForDisplay()) + { + var4.putStack((ItemStack)null); + } + } + } + } + + public static boolean shiftKey() + { + return EaglerAdapter.isKeyDown(54) || EaglerAdapter.isKeyDown(42); + } + + public static int getGameMode() + { + try + { + return ((EnumGameType)TMIPrivateFields.gameMode.get(Minecraft.getMinecraft().playerController)).getID(); + } + catch (IllegalAccessException var1) + { + System.out.println(var1); + return 0; + } + } + + public static void setGameMode(int var0) + { + Minecraft.getMinecraft().thePlayer.sendChatMessage("/gamemode " + var0); + } + + public static boolean isCreativeMode() + { + return Minecraft.getMinecraft().playerController.isInCreativeMode(); + } + + public static void setCreativeMode(boolean var0) + { + Minecraft.getMinecraft().thePlayer.sendChatMessage("/gamemode " + (var0 ? "1" : "0")); + } + + public static boolean isCreativeSearchTab() + { + return false; + } + + public static boolean isRaining() + { + return Minecraft.getMinecraft().theWorld.isRaining(); + } + + public static void setRaining(boolean var0) + { + Minecraft.getMinecraft().thePlayer.sendChatMessage("/toggledownfall"); + } + + public static long getTime() + { + return Minecraft.getMinecraft().theWorld.getWorldTime(); + } + + public static void setTime(long var0) + { + Minecraft.getMinecraft().thePlayer.sendChatMessage("/time set " + var0); + } + + public static void setHourForward(int var0) + { + long var1 = getTime() / 24000L * 24000L; + long var3 = var1 + 24000L + (long)(var0 * 1000); + setTime(var3); + } + + public static void logWithTrace(String var0) + { + System.out.println(var0); + StackTraceElement[] var1 = Thread.currentThread().getStackTrace(); + + for (int var2 = 0; var2 < var1.length; ++var2) + { + System.out.println(var1[var2].toString()); + } + } + + public static void logWithTrace(String var0, int var1) + { + System.out.println(var0); + StackTraceElement[] var2 = Thread.currentThread().getStackTrace(); + + for (int var3 = 0; var3 < var2.length && var3 < var1; ++var3) + { + System.out.println(var2[var3].toString()); + } + } + + public static boolean playerIsAlive() + { + return !Minecraft.getMinecraft().thePlayer.isDead; + } + + public static void setPlayerHealth(int var0) + { + if (playerIsAlive()) + { + getPlayer().setEntityHealth(var0); + } + } + + public static void fillHunger() + { + if (playerIsAlive()) + { + getPlayer().getFoodStats().setFoodLevel(20); + getPlayer().getFoodStats().setFoodSaturationLevel(5.0F); + } + } + + public static void incrementDifficulty() + { + Minecraft.getMinecraft().gameSettings.setOptionValue(EnumOptions.DIFFICULTY, 1); + } + + public static String getDifficultyString() + { + return Minecraft.getMinecraft().gameSettings.getKeyBinding(EnumOptions.DIFFICULTY); + } + + public static void suppressAchievementNotice() + { + try + { + Field[] var0 = Minecraft.getMinecraft().guiAchievement.getClass().getDeclaredFields(); + int var1 = var0.length; + + for (int var2 = 0; var2 < var1; ++var2) + { + Field var3 = var0[var2]; + + if (var3.getName().equals("_gui_achievement_time")) + { + var3.setAccessible(true); + var3.setInt(Minecraft.getMinecraft().guiAchievement, 0); + } + } + } + catch (Exception var4) + { + System.out.println(var4); + } + } + + public static int maxStackSize(int var0) + { + return Item.itemsList[var0].getItemStackLimit(); + } + + public static List getEnchantments(ItemStack var0) + { + ArrayList var1 = new ArrayList(); + + if (var0 != null) + { + NBTTagList var2 = var0.getEnchantmentTagList(); + + if (var2 != null) + { + for (int var3 = 0; var3 < var2.tagCount(); ++var3) + { + short var4 = ((NBTTagCompound)var2.tagAt(var3)).getShort("id"); + short var5 = ((NBTTagCompound)var2.tagAt(var3)).getShort("lvl"); + int[] var6 = new int[] {var4, var5}; + var1.add(var6); + } + } + } + + return var1; + } + + public static boolean addEnchantment(ItemStack var0, int var1, int var2) + { + if (var1 < Enchantment.enchantmentsList.length && Enchantment.enchantmentsList[var1] != null) + { + var0.addEnchantment(Enchantment.enchantmentsList[var1], var2); + return true; + } + else + { + return false; + } + } + + public static void addEffectToPotion(ItemStack var0, PotionEffect var1) + { + if (var0.itemID == TMIItemInfo.addItemOffset(117)) + { + if (var0.stackTagCompound == null) + { + var0.stackTagCompound = new NBTTagCompound(); + } + + NBTTagList var2; + + if (var0.stackTagCompound.hasKey("CustomPotionEffects")) + { + var2 = var0.stackTagCompound.getTagList("CustomPotionEffects"); + } + else + { + var2 = new NBTTagList(); + var0.stackTagCompound.setTag("CustomPotionEffects", var2); + } + + NBTTagCompound var3 = new NBTTagCompound(); + var1.writeCustomPotionEffectToNBT(var3); + var2.appendTag(var3); + } + } + + public static void nameStack(ItemStack var0, String var1) + { + if (var1 != null) + { + if (var0.stackTagCompound == null) + { + var0.stackTagCompound = new NBTTagCompound(); + } + + NBTTagCompound var2; + + if (var0.stackTagCompound.hasKey("display")) + { + var2 = var0.stackTagCompound.getCompoundTag("display"); + } + else + { + var2 = new NBTTagCompound(); + var0.stackTagCompound.setCompoundTag("display", var2); + } + + var2.setString("Name", var1); + } + } + + public static void addLore(ItemStack var0, String var1) + { + if (var1 != null) + { + if (var0.stackTagCompound == null) + { + var0.stackTagCompound = new NBTTagCompound(); + } + + NBTTagCompound var2; + + if (var0.stackTagCompound.hasKey("display")) + { + var2 = var0.stackTagCompound.getCompoundTag("display"); + } + else + { + var2 = new NBTTagCompound(); + var0.stackTagCompound.setCompoundTag("display", var2); + } + + NBTTagList var3; + + if (var2.hasKey("Lore")) + { + var3 = var2.getTagList("Lore"); + } + else + { + var3 = new NBTTagList(); + var2.setTag("Lore", var3); + } + + NBTTagString var4 = new NBTTagString("Lore", var1); + var3.appendTag(var4); + } + } + + public static NBTTagCompound getTagCompoundWithCreate(ItemStack var0, String var1) + { + if (var0.stackTagCompound == null) + { + var0.stackTagCompound = new NBTTagCompound(); + } + + NBTTagCompound var2; + + if (!var0.stackTagCompound.hasKey(var1)) + { + var2 = new NBTTagCompound(); + var0.stackTagCompound.setCompoundTag(var1, var2); + } + else + { + var2 = var0.stackTagCompound.getCompoundTag(var1); + } + + return var2; + } + + public static EntityClientPlayerMP getPlayer() + { + return Minecraft.getMinecraft().thePlayer; + } + + public static void fastTransfer(int var0, int var1, Container var2) + { + Minecraft var3 = Minecraft.getMinecraft(); + ItemStack var4 = getHeldItem(); + var3.playerController.windowClick(var2.windowId, var0, var1, 0, var3.thePlayer); + int var5 = var2.inventorySlots.size() - 36; + boolean var6 = var0 < var5; + int var7 = 0; + int var8 = var5; + int var9 = var5 - 1; + int var10 = var2.inventorySlots.size(); + + if (var6) + { + var7 = var5; + var8 = var2.inventorySlots.size(); + var9 = -1; + var10 = var5; + } + + boolean var11 = true; + + while (var7 < var8 && var9 < var10) + { + Slot var12 = (Slot)var2.inventorySlots.get(var7); + + if (var12 != null) + { + ItemStack var13 = var12.getStack(); + + if (var13 != null && var13.itemID == var4.itemID && var13.getItemDamageForDisplay() == var4.getItemDamageForDisplay()) + { + Slot var14; + + if (var11) + { + var14 = (Slot)var2.inventorySlots.get(var0); + } + else + { + var14 = (Slot)var2.inventorySlots.get(var9); + } + + if (var14 == null) + { + ++var9; + var11 = false; + continue; + } + + ItemStack var15 = var14.getStack(); + + if (var15 == null) + { + var14.putStack(var13); + var12.putStack((ItemStack)null); + } + else + { + if (var15.itemID != var13.itemID || var15.getItemDamageForDisplay() != var13.getItemDamageForDisplay()) + { + ++var9; + var11 = false; + continue; + } + + int var16 = var13.stackSize + var15.stackSize; + int var17 = Item.itemsList[var13.itemID].getItemStackLimit(); + int var18 = var16 - var17; + + if (var18 > 0) + { + var15.stackSize = var17; + var13.stackSize = var18; + ++var9; + var11 = false; + continue; + } + + var15.stackSize = var16; + var12.putStack((ItemStack)null); + } + } + } + + ++var7; + } + } + + public static boolean isEnchantmentNormallyPossible(Enchantment var0, Item var1) + { + return var0.type.canEnchantItem(var1) || var1.itemID == TMIItemInfo.addItemOffset(147); + } + + public static boolean isEnchantmentNormallyPossible(Enchantment var0, ItemStack var1) + { + return var0.type.canEnchantItem(Item.itemsList[var1.itemID]) || var1.itemID == TMIItemInfo.addItemOffset(147); + } + + public static List getPossibleEnchantments(Item var0) + { + if (var0.getItemEnchantability() > 0) + { + ArrayList var1 = new ArrayList(); + Enchantment[] var2 = Enchantment.enchantmentsList; + int var3 = var2.length; + + for (int var4 = 0; var4 < var3; ++var4) + { + Enchantment var5 = var2[var4]; + + if (var5 != null && var5.type.canEnchantItem(var0)) + { + var1.add(var5); + } + } + + return var1; + } + else + { + return new ArrayList(); + } + } + + public static void replaceCustomItems() + { + if (!haveReplacedItems) + { + TMIConfig.getInstance(); + + if (!TMIConfig.isMultiplayer() && TMIConfig.getInstance().getBooleanSetting("replace-items")) + { + try + { + Class var0 = Class.forName("cpw.mods.fml.common.registry.GameData"); + System.out.println("[TMI] Please ignore Forge item allocation errors. The items are fine."); + } + catch (NoClassDefFoundError var1) + { + ; + } + catch (Exception var2) + { + ; + } + + modMushroomBlock(true); + modMobSpawner(true); + modCrops(true); + modSnowCover(true); + haveReplacedItems = true; + return; + } + } + } + + public static void dumpItemList() + { + try + { + File var0 = new File(Minecraft.getAppDir("minecraft"), "TMIItemList.txt"); + PrintWriter var1 = new PrintWriter(new FileWriter(var0)); + Iterator var2 = TMIConfig.getInstance().getItems().iterator(); + + while (var2.hasNext()) + { + ItemStack var3 = (ItemStack)var2.next(); + var1.println("" + var3.itemID + ":" + var3.getItemDamageForDisplay() + " " + getValidItemDisplayName(var3)); + } + + var1.close(); + } + catch (Exception var4) + { + System.out.println(var4.toString()); + } + } + + public static Item unsetItem(int var0) + { + Item var1 = Item.itemsList[var0]; + Item.itemsList[var0] = null; + + try + { + Class var2 = Class.forName("cpw.mods.fml.common.registry.GameData"); + Field var3 = var2.getDeclaredField("idMap"); + TMIPrivateFields.unsetFinalPrivate(var3); + Map var4 = (Map)var3.get((Object)null); + + if (var4.containsKey(Integer.valueOf(var0))) + { + var4.remove(Integer.valueOf(var0)); + } + } + catch (NoClassDefFoundError var5) + { + ; + } + catch (Exception var6) + { + ; + } + + return var1; + } + + public static void unsetAndSaveItem(int var0) + { + originalItems.put(Integer.valueOf(var0), unsetItem(var0)); + } + + public static void modMobSpawner(boolean var0) + { + unsetAndSaveItem(52); + Item.itemsList[52] = (new TMIItemSpawner(52 - TMIItemInfo.itemOffset)).setUnlocalizedName("mobSpawner"); + } + + public static void modMushroomBlock(boolean var0) + { + unsetAndSaveItem(99); + unsetAndSaveItem(100); + Item.itemsList[99] = (new TMIItemMushroomCap(99 - TMIItemInfo.itemOffset)).setUnlocalizedName("mushroom"); + Item.itemsList[100] = (new TMIItemMushroomCap(100 - TMIItemInfo.itemOffset)).setUnlocalizedName("mushroom"); + } + + public static void modCrops(boolean var0) + { + unsetAndSaveItem(59); + unsetAndSaveItem(104); + unsetAndSaveItem(105); + unsetAndSaveItem(115); + Item.itemsList[59] = (new TMIItemCrop(59 - TMIItemInfo.itemOffset)).setUnlocalizedName("crops"); + Item.itemsList[104] = (new TMIItemCrop(104 - TMIItemInfo.itemOffset)).setUnlocalizedName("pumpkinStem"); + Item.itemsList[105] = (new TMIItemCrop(105 - TMIItemInfo.itemOffset)).setUnlocalizedName("melonStem"); + Item.itemsList[115] = (new TMIItemCrop(115 - TMIItemInfo.itemOffset)).setUnlocalizedName("netherStalk"); + } + + public static void modSnowCover(boolean var0) {} + + public static void resetItems() + { + int var1; + + for (Iterator var0 = originalItems.keySet().iterator(); var0.hasNext(); Item.itemsList[var1] = (Item)originalItems.get(Integer.valueOf(var1))) + { + var1 = ((Integer)var0.next()).intValue(); + unsetItem(var1); + } + + originalItems.clear(); + haveReplacedItems = false; + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIView.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIView.java new file mode 100644 index 0000000..da505fb --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/TMIView.java @@ -0,0 +1,390 @@ +package me.ayunami2000.ayuncraft.tmi; + +import java.util.List; + +import net.lax1dude.eaglercraft.EaglerAdapter; +import net.minecraft.src.ItemStack; + +public class TMIView implements _tmi_MgTooltipHandler +{ + public static final String COPYRIGHT = "All of TooManyItems except for thesmall portion excerpted from the original Minecraft game is copyright 2011Marglyph. TooManyItems is free for personal use only. Do not redistributeTooManyItems, including in mod packs, and do not use TooManyItems\' sourcecode or graphics in your own mods."; + private _tmi_MgCanvas canvas; + private TMIConfig config; + private TMIController controller; + private boolean widgetsCreated = false; + private String activeTooltip = null; + private static String savedTabName = "items"; + private _tmi_MgButton prevButton; + private _tmi_MgButton nextButton; + private _tmi_MgButton trashButton; + private _tmi_MgButton[] stateButtons; + private _tmi_MgButton[] deleteButtons; + public TMIItemPanel itemPanel; + public _tmi_MgTabView tabView = new _tmi_MgTabView(); + public TMIEnchantPanel enchantPanel = new TMIEnchantPanel(this); + public TMIConfigPanel configPanel = new TMIConfigPanel(); + public TMIFavoritesPanel favoritesPanel; + public TMIPotionPanel potionPanel = new TMIPotionPanel(); + public TMIFireworkPanel fireworkPanel = new TMIFireworkPanel(); + public _tmi_MgButton rain; + public _tmi_MgButton survival; + public _tmi_MgButton creative; + public _tmi_MgButton adventure; + public _tmi_MgButton delete; + public _tmi_MgButton noon; + public _tmi_MgButton dawn; + public _tmi_MgButton dusk; + public _tmi_MgButton midnight; + public _tmi_MgButton difficulty; + public _tmi_MgButton health; + + public TMIView(_tmi_MgCanvas var1, TMIConfig var2, TMIController var3) + { + this.canvas = var1; + this.config = var2; + this.controller = var3; + this.stateButtons = new _tmi_MgButton[this.config.getNumSaves()]; + this.deleteButtons = new _tmi_MgButton[this.config.getNumSaves()]; + this.createWidgets(); + } + + public void createWidgets() + { + this.itemPanel = new TMIItemPanel(0, 0, 0, 0, 0, this.config.getItems(), this.controller); + this.favoritesPanel = new TMIFavoritesPanel(this.config, this.controller); + this.tabView.addChild("items", TMIImages.iconChest, TMIImages.iconChestLight, this.itemPanel); + this.tabView.addChild("favorites", TMIImages.iconStar, TMIImages.iconStarLight, this.favoritesPanel); + this.tabView.addChild("enchant", TMIImages.iconBook, TMIImages.iconBookLight, this.enchantPanel); + TMIConfig var10000 = this.config; + + if (!TMIConfig.isMultiplayer()) + { + this.tabView.addChild("potions", TMIImages.iconPotion, TMIImages.iconPotion, this.potionPanel); + this.tabView.addChild("fireworks", TMIImages.iconFirework, TMIImages.iconFirework, this.fireworkPanel); + } + + this.canvas.widgets.add(this.tabView); + this.tabView.setActiveChild(savedTabName); + this.delete = new _tmi_MgButton("", this.controller, "deleteMode"); + this.delete.icon = TMIImages.iconDelete; + this.delete.showState = true; + this.delete.setOwnWidth(this.canvas); + this.delete.height = 14; + this.canvas.widgets.add(this.delete); + this.rain = new _tmi_MgButton("", this.controller, "rain"); + this.rain.showState = true; + this.rain.icon = TMIImages.iconRain; + this.rain.setOwnWidth(this.canvas); + this.rain.height = 14; + this.canvas.widgets.add(this.rain); + this.survival = new _tmi_MgButton("", this.controller, "survival"); + this.survival.icon = TMIImages.iconModeS; + this.survival.setOwnWidth(this.canvas); + this.survival.height = 14; + this.canvas.widgets.add(this.survival); + this.creative = new _tmi_MgButton("", this.controller, "creative"); + this.creative.icon = TMIImages.iconModeC; + this.creative.setOwnWidth(this.canvas); + this.creative.height = 14; + this.canvas.widgets.add(this.creative); + this.adventure = new _tmi_MgButton("", this.controller, "adventure"); + this.adventure.icon = TMIImages.iconModeA; + this.adventure.setOwnWidth(this.canvas); + this.adventure.height = 14; + this.canvas.widgets.add(this.adventure); + this.noon = new _tmi_MgButton("", this.controller, "noon"); + this.noon.icon = TMIImages.iconNoon; + this.noon.setOwnWidth(this.canvas); + this.noon.height = 14; + this.canvas.widgets.add(this.noon); + this.dawn = new _tmi_MgButton("", this.controller, "dawn"); + this.dawn.icon = TMIImages.iconDawn; + this.dawn.setOwnWidth(this.canvas); + this.dawn.height = 14; + this.canvas.widgets.add(this.dawn); + this.dusk = new _tmi_MgButton("", this.controller, "dusk"); + this.dusk.icon = TMIImages.iconDusk; + this.dusk.setOwnWidth(this.canvas); + this.dusk.height = 14; + this.canvas.widgets.add(this.dusk); + this.midnight = new _tmi_MgButton("", this.controller, "midnight"); + this.midnight.icon = TMIImages.iconMidnight; + this.midnight.setOwnWidth(this.canvas); + this.midnight.height = 14; + this.canvas.widgets.add(this.midnight); + this.difficulty = new _tmi_MgButton("", this.controller, "difficulty"); + this.difficulty.icon = TMIImages.iconDifficulty; + this.difficulty.setOwnWidth(this.canvas); + this.difficulty.height = 14; + this.canvas.widgets.add(this.difficulty); + this.health = new _tmi_MgButton("", this.controller, "health"); + this.health.icon = TMIImages.iconHeart; + this.health.setOwnWidth(this.canvas); + this.health.height = 14; + this.canvas.widgets.add(this.health); + this.delete.x = 2; + this.delete.y = 2; + this.canvas.arrangeHorizontally(1, 1001, new _tmi_MgWidget[] {this.delete, this.survival, this.creative, this.adventure, this.rain, this.dawn, this.noon, this.dusk, this.midnight, this.difficulty, this.health}); + this.stateButtons = new _tmi_MgButton[this.config.getNumSaves()]; + + for (int var1 = 0; var1 < this.config.getNumSaves(); ++var1) + { + this.stateButtons[var1] = new _tmi_MgButton("Save " + (var1 + 1), this.controller, new TMIStateButtonData(var1, 0)); + this.canvas.widgets.add(this.stateButtons[var1]); + this.deleteButtons[var1] = new _tmi_MgButton("x", this.controller, new TMIStateButtonData(var1, 1)); + this.canvas.widgets.add(this.deleteButtons[var1]); + } + + this.widgetsCreated = true; + } + + public void layout(int var1, int var2, int var3, int var4) + { + int var5 = (var1 - var3) / 2; + + if (!this.widgetsCreated) + { + this.createWidgets(); + } + + this.itemPanel.x = (var1 + var3) / 2 + 5; + this.itemPanel.y = 20; + this.itemPanel.resize(); + this.tabView.x = (var1 + var3) / 2 + 5; + this.tabView.y = 0; + this.tabView.width = var1 - this.itemPanel.x - 2; + this.tabView.height = var2 - 1; + savedTabName = this.tabView.getActiveChildName(); + this.tabView.resize(); + this.rain.state = TMIUtils.isRaining(); + this.delete.state = this.controller.deleteMode; + int var6 = TMIUtils.getGameMode(); + this.survival.icon = var6 == 0 ? TMIImages.iconModeSs : TMIImages.iconModeS; + this.creative.icon = var6 == 1 ? TMIImages.iconModeCs : TMIImages.iconModeC; + this.adventure.icon = var6 == 2 ? TMIImages.iconModeAs : TMIImages.iconModeA; + this.canvas.drawRect(0, 0, var1, 18, -16445675); + StringBuilder var10000 = (new StringBuilder()).append(""); + TMIItemPanel var10001 = this.itemPanel; + var10000.append(TMIItemPanel.page + 1).append("/").append(this.itemPanel.numPages).toString(); + this.canvas.drawText(2, var2 - 13, "TMI 1.5.2 2013-04-25", -1); + this.rain.show = TMIConfig.canChangeWeather(); + this.creative.show = this.survival.show = this.adventure.show = TMIConfig.canChangeCreativeMode(); + this.delete.show = TMIConfig.canDelete(); + this.dawn.show = this.noon.show = this.dusk.show = this.midnight.show = TMIConfig.canChangeTime(); + this.difficulty.show = TMIConfig.canChangeDifficulty(); + this.health.show = !TMIConfig.isMultiplayer(); + boolean var8 = TMIConfig.canRestoreSaves(); + int var9 = 0; + int var10; + + for (var10 = 0; var10 < this.config.getNumSaves(); ++var10) + { + this.deleteButtons[var10].x = -1000; + this.stateButtons[var10].y = 30 + var10 * 22; + this.stateButtons[var10].height = 20; + String var11 = (String)this.config.getSettings().get("save-name" + (var10 + 1)); + + if (var11 == null) + { + var11 = "" + (var10 + 1); + } + + if (this.config.isStateSaved(var10)) + { + this.stateButtons[var10].label = "Load " + var11; + } + else + { + this.stateButtons[var10].label = "Save " + var11; + } + + int var12 = this.canvas.getTextWidth(this.stateButtons[var10].label) + 26; + + if (var12 + 2 + 20 > var5) + { + var12 = var5 - 20 - 2; + } + + if (var12 > var9) + { + var9 = var12; + } + } + + for (var10 = 0; var10 < this.config.getNumSaves(); ++var10) + { + this.stateButtons[var10].width = var9; + this.stateButtons[var10].show = var8; + this.deleteButtons[var10].show = var8; + + if (this.config.isStateSaved(var10)) + { + this.deleteButtons[var10].x = this.stateButtons[var10].width + 2; + this.deleteButtons[var10].y = this.stateButtons[var10].y; + this.deleteButtons[var10].width = 20; + this.deleteButtons[var10].height = 20; + } + } + } + + public void determineTooltip(int var1, int var2) + { + if (this.rain != null && this.rain.contains(var1, var2)) + { + this.setTooltip("Rain/snow is " + (this.rain.state ? "ON" : "OFF")); + } + else if (this.creative != null && this.creative.contains(var1, var2)) + { + this.setTooltip("Creative mode"); + } + else if (this.survival != null && this.survival.contains(var1, var2)) + { + this.setTooltip("Survival mode"); + } + else if (this.adventure != null && this.adventure.contains(var1, var2)) + { + this.setTooltip("Adventure mode"); + } + else if (this.noon != null && this.noon.contains(var1, var2)) + { + this.setTooltip("Set time to noon"); + } + else if (this.dawn != null && this.dawn.contains(var1, var2)) + { + this.setTooltip("Set time to sunrise"); + } + else if (this.dusk != null && this.dusk.contains(var1, var2)) + { + this.setTooltip("Set time to sunset"); + } + else if (this.midnight != null && this.midnight.contains(var1, var2)) + { + this.setTooltip("Set time to midnight"); + } + else if (this.difficulty != null && this.difficulty.contains(var1, var2)) + { + this.setTooltip(TMIUtils.getDifficultyString()); + } + else if (this.health != null && this.health.contains(var1, var2)) + { + this.setTooltip("Fill health and food"); + } + else + { + ItemStack var3; + + if (this.delete != null && this.delete.contains(var1, var2)) + { + var3 = TMIUtils.getHeldItem(); + + if (var3 == null) + { + if (TMIUtils.shiftKey()) + { + this.setTooltip("DELETE ALL ITEMS from current inventory screen"); + } + else + { + this.setTooltip("Delete mode is " + (this.delete.state ? "ON" : "OFF")); + } + } + else if (TMIUtils.shiftKey()) + { + this.setTooltip("DELETE ALL " + TMIUtils.itemDisplayName(var3)); + } + else + { + this.setTooltip("DELETE " + TMIUtils.itemDisplayName(var3)); + } + } + else + { + ItemStack var4; + List var5; + + if (this.itemPanel.contains(var1, var2)) + { + var3 = TMIUtils.getHeldItem(); + + if (var3 == null) + { + var4 = this.itemPanel.getHoverItem(); + + if (var4 != null) + { + if (!EaglerAdapter.isKeyDown(56) && !EaglerAdapter.isKeyDown(184)) + { + var5 = TMIUtils.itemDisplayNameMultiline(var4, true); + this.canvas.drawMultilineTip(var1, var2, var5, var4); + } + else + { + this.setTooltip("Add " + var4.itemID + ":" + var4.getItemDamageForDisplay() + " to favorites"); + } + } + } + else + { + this.setTooltip("DELETE " + TMIUtils.itemDisplayName(var3)); + } + } + else if (this.favoritesPanel.contains(var1, var2)) + { + var3 = TMIUtils.getHeldItem(); + + if (var3 == null) + { + var4 = this.favoritesPanel.getHoverItem(); + + if (var4 != null) + { + if (!EaglerAdapter.isKeyDown(56) && !EaglerAdapter.isKeyDown(184)) + { + var5 = TMIUtils.itemDisplayNameMultiline(var4, true); + this.canvas.drawMultilineTip(var1, var2, var5, var4); + } + else + { + this.setTooltip("Remove " + TMIUtils.itemDisplayName(var4)); + } + } + } + else + { + this.setTooltip("Add " + TMIUtils.itemDisplayName(var3)); + } + } + } + } + + this.showToolTip(var1, var2); + } + + public boolean isInitialized() + { + return this.widgetsCreated; + } + + public void setTooltip(String var1) + { + this.activeTooltip = var1; + } + + public String getTooltip() + { + return this.activeTooltip; + } + + public boolean hasTooltip() + { + return this.activeTooltip != null; + } + + public void showToolTip(int var1, int var2) + { + if (this.activeTooltip != null) + { + this.canvas.drawTip(var1, var2, this.activeTooltip); + } + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgButton.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgButton.java new file mode 100644 index 0000000..e98bb74 --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgButton.java @@ -0,0 +1,149 @@ +package me.ayunami2000.ayuncraft.tmi; + +public class _tmi_MgButton extends _tmi_MgWidget +{ + public static final String COPYRIGHT = "All of TooManyItems except for thesmall portion excerpted from the original Minecraft game is copyright 2011Marglyph. TooManyItems is free for personal use only. Do not redistributeTooManyItems, including in mod packs, and do not use TooManyItems\' sourcecode or graphics in your own mods."; + public String label; + public _tmi_MgButtonHandler controller; + public Object data; + public _tmi_MgImage icon; + public boolean showState; + public boolean state; + public boolean agateType; + public boolean centerText; + + public _tmi_MgButton(String var1, _tmi_MgButtonHandler var2, Object var3) + { + this(0, 0, 0, 0, 0, var1, var2, var3); + } + + public _tmi_MgButton(int var1, int var2, int var3, int var4, int var5, String var6, _tmi_MgButtonHandler var7, Object var8) + { + super(var1, var2, var3, var4, var5); + this.showState = false; + this.state = false; + this.agateType = false; + this.centerText = true; + this.label = var6; + this.controller = var7; + this.data = var8; + } + + public void setOwnWidth(_tmi_MgCanvas var1) + { + this.width = var1.getTextWidth(this.label, this.scaleFactor()) + this.graphicWidth(var1) + this.getMargin(); + } + + public int graphicWidth(_tmi_MgCanvas var1) + { + int var2 = 0; + + if (this.icon != null) + { + var2 += this.icon.width; + + if (this.label != null && this.label.length() > 0) + { + var2 += 2; + } + } + + if (this.showState) + { + var2 += TMIImages.buttonStateOff.width; + + if (this.label != null && this.label.length() > 0) + { + ++var2; + } + } + + return var2; + } + + public int getMargin() + { + return this.label != null && this.label.length() > 0 ? 6 : 2; + } + + protected float scaleFactor() + { + return this.agateType ? 0.5F : 1.0F; + } + + protected int neededWidth(_tmi_MgCanvas var1, String var2) + { + int var3 = var1.getTextWidth(var2, this.scaleFactor()); + var3 += this.graphicWidth(var1); + + if (!this.centerText) + { + var3 += this.getMargin() * 2; + } + + return var3; + } + + protected boolean drawGraphic(_tmi_MgCanvas var1, int var2) + { + if (this.icon != null) + { + int var3 = this.y + (this.height - this.icon.height) / 2; + var1.drawChrome(var2, var3, this.icon); + + if (this.showState) + { + _tmi_MgImage var4 = this.state ? TMIImages.buttonStateOn : TMIImages.buttonStateOff; + int var10000 = this.y + (this.height - var4.height) / 2; + var1.drawChrome(var2 + this.icon.width, var3, var4); + } + + return true; + } + else + { + return false; + } + } + + public void draw(_tmi_MgCanvas var1, int var2, int var3) + { + if (this.show) + { + var1.drawRect(this.x, this.y, this.width, this.height, this.contains(var2, var3) ? -297791480 : -301989888); + var1.drawText(this.x, this.y, "", -1); + String var4 = this.label; + int var5 = var1.getTextWidth(var4, this.scaleFactor()); + int var6; + + for (var6 = this.graphicWidth(var1); var5 + var6 > this.width && var4.length() > 0; var5 = var1.getTextWidth(var4, this.scaleFactor())) + { + var4 = var4.substring(0, var4.length() - 1); + } + + int var7 = var5 + var6; + int var8 = this.x + this.getMargin(); + + if (this.centerText) + { + var8 = this.x + (this.width - var7) / 2; + } + + int var9 = this.y + (this.height - 8) / 2; + boolean var10 = this.drawGraphic(var1, var8); + var8 += this.graphicWidth(var1); + + if (var10 && var5 > 0) + { + var8 += 2; + } + + var1.drawText(var8, var9, var4, -1, this.scaleFactor()); + } + } + + public boolean click(int var1, int var2, int var3) + { + return var3 == 0 ? this.controller.onButtonPress(this.data) : (var3 == 1 ? this.controller.onButtonRightClick(this.data) : true); + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgButtonHandler.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgButtonHandler.java new file mode 100644 index 0000000..0deabc5 --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgButtonHandler.java @@ -0,0 +1,8 @@ +package me.ayunami2000.ayuncraft.tmi; + +public interface _tmi_MgButtonHandler +{ + boolean onButtonPress(Object var1); + + boolean onButtonRightClick(Object var1); +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgCanvas.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgCanvas.java new file mode 100644 index 0000000..547aecb --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgCanvas.java @@ -0,0 +1,341 @@ +package me.ayunami2000.ayuncraft.tmi; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +import net.lax1dude.eaglercraft.EaglerAdapter; +import net.minecraft.client.Minecraft; +import net.minecraft.src.GuiScreen; +import net.minecraft.src.ItemStack; +import net.minecraft.src.RenderItem; + +public class _tmi_MgCanvas +{ + public static final String COPYRIGHT = "All of TooManyItems except for thesmall portion excerpted from the original Minecraft game is copyright 2011Marglyph. TooManyItems is free for personal use only. Do not redistributeTooManyItems, including in mod packs, and do not use TooManyItems\' sourcecode or graphics in your own mods."; + public int windowX = 0; + public int windowY = 0; + public GuiScreen window; + private RenderItem drawItems; + public List widgets = new ArrayList(); + public static final int ALIGN_TOP = 1001; + public static final int ALIGN_BOTTOM = 1002; + public static final int ALIGN_LEFT = 1003; + public static final int ALIGN_RIGHT = 1004; + public static final int ALIGN_MIDDLE = 1005; + public static final int WHITE = -1; + public static final int SHADE = -301989888; + public static final int RED_SHADE = -297791480; + public static final int LIGHT_SHADE = -296397483; + private boolean flatMode = false; + + public _tmi_MgCanvas(GuiScreen var1, RenderItem var2) + { + this.window = var1; + this.drawItems = var2; + } + + public void drawGradientRectDirect(int var1, int var2, int var3, int var4, int var5, int var6) + { + this.flatMode(true); + + try + { + TMIPrivateFields.drawGradientRect.invoke(this.window, new Object[] {Integer.valueOf(var1), Integer.valueOf(var2), Integer.valueOf(var3), Integer.valueOf(var4), Integer.valueOf(var5), Integer.valueOf(var6)}); + } + catch (Exception var8) + { + System.out.println("[TMI] Cannot draw gradient rect. So sad."); + var8.printStackTrace(); + } + } + + public void drawRect(int var1, int var2, int var3, int var4, int var5) + { + this.flatMode(true); + GuiScreen var10000 = this.window; + GuiScreen.drawRect(var1 - this.windowX, var2 - this.windowY, var1 + var3 - this.windowX, var2 + var4 - this.windowY, var5); + } + + public void drawText(int var1, int var2, String var3, int var4) + { + this.drawText(var1, var2, var3, var4, 1.0F); + } + + public void drawText(int var1, int var2, String var3, int var4, float var5) + { + this.hardSetFlatMode(true); + EaglerAdapter.glPushMatrix(); + EaglerAdapter.glScalef(var5, var5, 1.0F); + this.window.fontRenderer.drawStringWithShadow(var3, (int)((float)(var1 - this.windowX) / var5), (int)((float)(var2 - this.windowY) / var5), var4); + EaglerAdapter.glPopMatrix(); + } + + public void drawTextCentered(int var1, int var2, int var3, int var4, String var5, int var6, float var7) + { + this.drawText(var1 + (var3 - this.getTextWidth(var5, var7)) / 2, var2 + (var4 - 8) / 2, var5, var6, var7); + } + + public void drawTextCentered(int var1, int var2, int var3, int var4, String var5, int var6) + { + this.drawTextCentered(var1, var2, var3, var4, var5, var6, 1.0F); + } + + public void drawText(int var1, int var2, String var3) + { + this.drawText(var1, var2, var3, -1); + } + + public void drawTip(int var1, int var2, String var3) + { + ArrayList var4 = new ArrayList(); + var4.add(var3); + this.drawMultilineTip(var1, var2, var4, (ItemStack)null); + } + + public void drawMultilineTip(int var1, int var2, List var3) + { + this.drawMultilineTip(var1, var2, var3, (ItemStack)null); + } + + public void drawMultilineTip(int var1, int var2, List var3, ItemStack var4) + { + if (var3.size() > 0) + { + byte var5 = 0; + int var6 = 0; + Iterator var7 = var3.iterator(); + int var9; + + while (var7.hasNext()) + { + Object var8 = var7.next(); + var9 = this.getTextWidth((String)var8); + + if (var9 > var6) + { + var6 = var9; + } + } + + int var19 = 8; + + if (var3.size() > 1) + { + var19 += 2 + (var3.size() - 1) * 10; + } + + int var20 = var6 + var5 * 2; + var9 = var19 + var5 * 2; + int var10 = var1 + 12; + int var11 = var2 - 15; + + if (var11 - 2 < 0) + { + var11 = 0; + } + + if (var10 + var20 + 2 > this.window.width) + { + var10 = this.window.width - var20; + } + + if (var1 >= var10 && var1 <= var10 + var20 && var2 >= var11 && var2 <= var11 + var9) + { + var11 = var2 - var9 - 2; + + if (var11 < 0) + { + var11 = var2 + 2; + } + } + + int var12 = -267386864; + this.drawGradientRectDirect(var10 - 3, var11 - 4, var10 + var20 + 3, var11 - 3, var12, var12); + this.drawGradientRectDirect(var10 - 3, var11 + var9 + 3, var10 + var20 + 3, var11 + var9 + 4, var12, var12); + this.drawGradientRectDirect(var10 - 3, var11 - 3, var10 + var20 + 3, var11 + var9 + 3, var12, var12); + this.drawGradientRectDirect(var10 - 4, var11 - 3, var10 - 3, var11 + var9 + 3, var12, var12); + this.drawGradientRectDirect(var10 + var20 + 3, var11 - 3, var10 + var20 + 4, var11 + var9 + 3, var12, var12); + int var13 = 1347420415; + int var14 = (var13 & 16711422) >> 1 | var13 & -16777216; + this.drawGradientRectDirect(var10 - 3, var11 - 3 + 1, var10 - 3 + 1, var11 + var9 + 3 - 1, var13, var14); + this.drawGradientRectDirect(var10 + var20 + 2, var11 - 3 + 1, var10 + var20 + 3, var11 + var9 + 3 - 1, var13, var14); + this.drawGradientRectDirect(var10 - 3, var11 - 3, var10 + var20 + 3, var11 - 3 + 1, var13, var13); + this.drawGradientRectDirect(var10 - 3, var11 + var9 + 2, var10 + var20 + 3, var11 + var9 + 3, var14, var14); + var10 += var5; + var11 += var5; + boolean var15 = true; + + for (Iterator var16 = var3.iterator(); var16.hasNext(); var11 += 10) + { + String var17 = (String)var16.next(); + + if (var4 != null) + { + String var18 = "\u00a7" + (var15 ? Integer.toHexString(var4.getRarity().rarityColor) : "7"); + var17 = var18 + var17; + } + + this.drawText(var10, var11, var17, -1); + + if (var15) + { + var11 += 2; + var15 = false; + } + } + } + } + + public void drawItem(int var1, int var2, ItemStack var3) + { + this.hardSetFlatMode(false); + this.drawItems.zLevel = 200.0F; + + try + { + int var10004 = var1 - this.windowX; + int var10005 = var2 - this.windowY; + this.drawItems.renderItemAndEffectIntoGUI(this.window.fontRenderer, Minecraft.getMinecraft().renderEngine, var3, var10004, var10005); + } + catch (Exception var5) + { + this.drawItems.renderItemAndEffectIntoGUI(this.window.fontRenderer, Minecraft.getMinecraft().renderEngine, new ItemStack(51, 1, 0), var1 - this.windowX, var2 - this.windowY); + } + catch (LinkageError var6) + { + this.drawItems.renderItemAndEffectIntoGUI(this.window.fontRenderer, Minecraft.getMinecraft().renderEngine, new ItemStack(51, 1, 0), var1 - this.windowX, var2 - this.windowY); + } + + this.drawItems.zLevel = 0.0F; + } + + public void drawChrome(int var1, int var2, int var3, int var4, int var5, int var6) + { + this.hardSetFlatMode(true); + Minecraft.getMinecraft().renderEngine.bindTexture("/tmi.png"); + this.window.drawTexturedModalRect(var1 - this.windowX, var2 - this.windowY, var3, var4, var5, var6); + } + + public void drawChrome(int var1, int var2, _tmi_MgImage var3) + { + this.hardSetFlatMode(true); + Minecraft.getMinecraft().renderEngine.bindTexture(var3.filename); + this.window.drawTexturedModalRect(var1 - this.windowX, var2 - this.windowY, var3.x, var3.y, var3.width, var3.height); + } + + public void sortByZOrder() + { + Collections.sort(this.widgets, _tmi_MgWidget.getComparator()); + } + + public void drawWidgets(int var1, int var2) + { + boolean var3 = !EaglerAdapter.glBlendEnabled; + EaglerAdapter.glBlendFunc(EaglerAdapter.GL_SRC_ALPHA, EaglerAdapter.GL_ONE_MINUS_SRC_ALPHA); + this.sortByZOrder(); + Iterator var4 = this.widgets.iterator(); + + while (var4.hasNext()) + { + _tmi_MgWidget var5 = (_tmi_MgWidget)var4.next(); + EaglerAdapter.glEnable(EaglerAdapter.GL_BLEND); + var5.draw(this, var1, var2); + } + + if (var3) + { + EaglerAdapter.glDisable(EaglerAdapter.GL_BLEND); + } + } + + public int getTextWidth(String var1) + { + return this.getTextWidth(var1, 1.0F); + } + + public int getTextWidth(String var1, float var2) + { + return var1 != null && !var1.equals("") ? (int)((float)this.window.fontRenderer.getStringWidth(var1) * var2) : 0; + } + + public void flatMode(boolean var1) + { + if (var1 && !this.flatMode) + { + EaglerAdapter.glDisable(EaglerAdapter.GL_LIGHTING); + EaglerAdapter.glDisable(EaglerAdapter.GL_DEPTH_TEST); + } + else if (!var1 && this.flatMode) + { + EaglerAdapter.glEnable(EaglerAdapter.GL_LIGHTING); + EaglerAdapter.glEnable(EaglerAdapter.GL_DEPTH_TEST); + } + + this.flatMode = var1; + } + + public void hardSetFlatMode(boolean var1) + { + if (var1) + { + EaglerAdapter.glDisable(EaglerAdapter.GL_LIGHTING); + EaglerAdapter.glDisable(EaglerAdapter.GL_DEPTH_TEST); + } + else + { + EaglerAdapter.glEnable(EaglerAdapter.GL_LIGHTING); + EaglerAdapter.glEnable(EaglerAdapter.GL_DEPTH_TEST); + } + + this.flatMode = var1; + } + + public void arrangeHorizontally(int var1, int var2, _tmi_MgWidget ... var3) + { + if (var3.length > 1) + { + int var4 = var3[0].x; + int var5 = var3[0].y; + + if (var2 == 1002) + { + var5 += var3[0].height; + } + else if (var2 == 1005) + { + var5 += var3[0].height / 2; + } + + _tmi_MgWidget[] var6 = var3; + int var7 = var3.length; + + for (int var8 = 0; var8 < var7; ++var8) + { + _tmi_MgWidget var9 = var6[var8]; + var9.x = var4; + + switch (var2) + { + case 1001: + var9.y = var5; + break; + + case 1002: + var9.y = var5 - var9.height; + + case 1003: + case 1004: + default: + break; + + case 1005: + var9.y = var5 - var9.height / 2; + } + + var4 += var1 + var9.width; + } + } + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgFocusHandler.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgFocusHandler.java new file mode 100644 index 0000000..2bce0d9 --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgFocusHandler.java @@ -0,0 +1,8 @@ +package me.ayunami2000.ayuncraft.tmi; + +public interface _tmi_MgFocusHandler +{ + void focus(_tmi_MgWidget var1); + + void blur(_tmi_MgWidget var1); +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgImage.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgImage.java new file mode 100644 index 0000000..49c608b --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgImage.java @@ -0,0 +1,19 @@ +package me.ayunami2000.ayuncraft.tmi; + +public class _tmi_MgImage +{ + public static final String COPYRIGHT = "All of TooManyItems except for thesmall portion excerpted from the original Minecraft game is copyright 2011Marglyph. TooManyItems is free for personal use only. Do not redistributeTooManyItems, including in mod packs, and do not use TooManyItems\' sourcecode or graphics in your own mods."; + public String filename = "/tmi.png"; + public int x; + public int y; + public int width; + public int height; + + public _tmi_MgImage(int var1, int var2, int var3, int var4) + { + this.x = var1; + this.y = var2; + this.width = var3; + this.height = var4; + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgItemButton.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgItemButton.java new file mode 100644 index 0000000..431a05d --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgItemButton.java @@ -0,0 +1,41 @@ +package me.ayunami2000.ayuncraft.tmi; + +import net.minecraft.src.ItemStack; + +public class _tmi_MgItemButton extends _tmi_MgButton +{ + public ItemStack stack; + + public _tmi_MgItemButton(String var1, _tmi_MgButtonHandler var2, Object var3) + { + this(var1, (ItemStack)null, var2, var3); + } + + public _tmi_MgItemButton(String var1, ItemStack var2, _tmi_MgButtonHandler var3, Object var4) + { + super(var1, var3, var4); + this.stack = null; + this.stack = var2; + this.width = 18; + this.height = 18; + } + + public int graphicWidth(_tmi_MgCanvas var1) + { + return this.stack == null ? 0 : 16; + } + + protected boolean drawGraphic(_tmi_MgCanvas var1, int var2) + { + if (this.stack != null) + { + int var3 = this.y + (this.height - 16) / 2; + var1.drawItem(var2, var3, this.stack); + return true; + } + else + { + return false; + } + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgItemHandler.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgItemHandler.java new file mode 100644 index 0000000..2ef7fe9 --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgItemHandler.java @@ -0,0 +1,8 @@ +package me.ayunami2000.ayuncraft.tmi; + +import net.minecraft.src.ItemStack; + +public interface _tmi_MgItemHandler +{ + boolean onItemEvent(ItemStack var1, int var2); +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgTabView.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgTabView.java new file mode 100644 index 0000000..c8ec663 --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgTabView.java @@ -0,0 +1,139 @@ +package me.ayunami2000.ayuncraft.tmi; + +import java.util.HashMap; +import java.util.Iterator; +import java.util.LinkedHashMap; +import java.util.Map; + +public class _tmi_MgTabView extends _tmi_MgWidget +{ + public static final String COPYRIGHT = "All of TooManyItems except for thesmall portion excerpted from the original Minecraft game is copyright 2011Marglyph. TooManyItems is free for personal use only. Do not redistributeTooManyItems, including in mod packs, and do not use TooManyItems\' sourcecode or graphics in your own mods."; + private Map children = new LinkedHashMap(); + private Map icons = new HashMap(); + private Map iconsSelected = new HashMap(); + private String activeChildName = null; + public int tabsHeight = 18; + + public _tmi_MgTabView() + { + super(0, 0); + } + + public _tmi_MgTabView(int var1, int var2, int var3, int var4, int var5) + { + super(var1, var2, var3, var4, var5); + } + + public void addChild(String var1, _tmi_MgImage var2, _tmi_MgImage var3, _tmi_MgWidget var4) + { + this.children.put(var1, var4); + this.icons.put(var1, var2); + this.iconsSelected.put(var1, var3); + + if (this.activeChildName == null) + { + this.activeChildName = var1; + } + } + + public _tmi_MgWidget getChild(String var1) + { + return (_tmi_MgWidget)this.children.get(var1); + } + + public _tmi_MgWidget getActiveChild() + { + return this.getChild(this.getActiveChildName()); + } + + public String getActiveChildName() + { + return this.activeChildName; + } + + public void setActiveChild(String var1) + { + _tmi_MgWidget var3; + + for (Iterator var2 = this.children.values().iterator(); var2.hasNext(); var3.show = false) + { + var3 = (_tmi_MgWidget)var2.next(); + } + + ((_tmi_MgWidget)this.children.get(var1)).show = true; + this.activeChildName = var1; + } + + public void draw(_tmi_MgCanvas var1, int var2, int var3) + { + int var4 = this.x; + int var5 = this.y; + int var9; + + for (Iterator var6 = this.children.keySet().iterator(); var6.hasNext(); var4 += var9) + { + String var7 = (String)var6.next(); + _tmi_MgImage var8; + + if (var7 == this.activeChildName) + { + var8 = (_tmi_MgImage)this.iconsSelected.get(var7); + } + else + { + var8 = (_tmi_MgImage)this.icons.get(var7); + } + + var9 = var8.width + 6; + var1.drawChrome(var4 + 3, var5 + (this.tabsHeight - var8.height) / 2, var8); + } + + if (this.activeChildName != null) + { + this.getActiveChild().draw(var1, var2, var3); + } + } + + public void resize() + { + if (this.activeChildName != null) + { + _tmi_MgWidget var1 = this.getActiveChild(); + var1.x = this.x; + var1.y = this.y + this.tabsHeight; + var1.width = this.width; + var1.height = this.height - this.tabsHeight; + var1.resize(); + } + } + + public boolean click(int var1, int var2, int var3) + { + int var4 = var1 - this.x; + int var5 = var2 - this.y; + + if (var4 > 0 && var4 < this.width && var5 > 0 && var5 < this.tabsHeight) + { + int var6 = 0; + _tmi_MgImage var9; + + for (Iterator var7 = this.children.keySet().iterator(); var7.hasNext(); var6 += var9.width + 6) + { + String var8 = (String)var7.next(); + var9 = (_tmi_MgImage)this.icons.get(var8); + + if (var4 <= var6 + var9.width + 6) + { + this.setActiveChild(var8); + return false; + } + } + } + else if (this.activeChildName != null) + { + return this.getActiveChild().click(var1, var2, var3); + } + + return true; + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgTextField.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgTextField.java new file mode 100644 index 0000000..eca480a --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgTextField.java @@ -0,0 +1,101 @@ +package me.ayunami2000.ayuncraft.tmi; + +import net.minecraft.src.FontRenderer; +import net.minecraft.src.GuiTextField; + +public class _tmi_MgTextField extends _tmi_MgWidget +{ + public static final String COPYRIGHT = "All of TooManyItems except for thesmall portion excerpted from the original Minecraft game is copyright 2011Marglyph. TooManyItems is free for personal use only. Do not redistributeTooManyItems, including in mod packs, and do not use TooManyItems\' sourcecode or graphics in your own mods."; + public String placeholder; + private GuiTextField textField; + private _tmi_MgFocusHandler focusHandler; + private boolean focused; + + public _tmi_MgTextField(FontRenderer var1, String var2) + { + super(0, 0); + this.placeholder = ""; + this.focusHandler = null; + this.focused = false; + this.placeholder = var2; + this.textField = new GuiTextField(var1, 0, 0, 0, 0); + this.height = 14; + } + + public _tmi_MgTextField(FontRenderer var1, String var2, _tmi_MgFocusHandler var3) + { + this(var1, var2); + this.focusHandler = var3; + } + + public void draw(_tmi_MgCanvas var1, int var2, int var3) + { + if (this.show) + { + try + { + TMIPrivateFields.textFieldX.setInt(this.textField, this.x); + TMIPrivateFields.textFieldY.setInt(this.textField, this.y); + TMIPrivateFields.textFieldWidth.setInt(this.textField, this.width); + TMIPrivateFields.textFieldHeight.setInt(this.textField, this.height); + } + catch (IllegalAccessException var5) + { + System.out.println(var5); + } + + this.textField.drawTextBox(); + + if ((this.value() == null || this.value().equals("")) && !this.focused) + { + var1.drawText(this.x + 3, this.y + 3, this.placeholder, -7829368); + } + } + } + + public boolean click(int var1, int var2, int var3) + { + this.textField.setFocused(true); + this.textField.mouseClicked(var1, var2, var3); + + if (this.focusHandler != null) + { + this.focusHandler.focus(this); + } + + this.focused = true; + return true; + } + + public boolean keypress(char var1, int var2) + { + if (var2 == 1) + { + this.blur(); + } + + this.textField.textboxKeyTyped(var1, var2); + return true; + } + + public void blur() + { + this.textField.setFocused(false); + this.focused = false; + + if (this.focusHandler != null) + { + this.focusHandler.blur(this); + } + } + + public String value() + { + return this.textField.getText(); + } + + public void setValue(String var1) + { + this.textField.setText(var1); + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgTooltipHandler.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgTooltipHandler.java new file mode 100644 index 0000000..4d6b548 --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgTooltipHandler.java @@ -0,0 +1,6 @@ +package me.ayunami2000.ayuncraft.tmi; + +public interface _tmi_MgTooltipHandler +{ + void setTooltip(String var1); +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgWidget.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgWidget.java new file mode 100644 index 0000000..9c80546 --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgWidget.java @@ -0,0 +1,102 @@ +package me.ayunami2000.ayuncraft.tmi; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.Iterator; +import java.util.List; + +public class _tmi_MgWidget +{ + public static final String COPYRIGHT = "All of TooManyItems except for thesmall portion excerpted from the original Minecraft game is copyright 2011Marglyph. TooManyItems is free for personal use only. Do not redistributeTooManyItems, including in mod packs, and do not use TooManyItems\' sourcecode or graphics in your own mods."; + public int x; + public int y; + public int z; + public int width; + public int height; + public boolean show; + public boolean mouseOver; + public List children; + + public _tmi_MgWidget(int var1, int var2) + { + this(var1, var2, 0, 0, 0); + } + + public _tmi_MgWidget(int var1, int var2, int var3) + { + this(var1, var2, var3, 0, 0); + } + + public _tmi_MgWidget(int var1, int var2, int var3, int var4, int var5) + { + this.show = true; + this.mouseOver = false; + this.children = new ArrayList(); + this.x = var1; + this.y = var2; + this.z = var3; + this.width = var4; + this.height = var5; + } + + public static _tmi_MgZOrder getComparator() + { + return new _tmi_MgZOrder(); + } + + public void draw(_tmi_MgCanvas var1, int var2, int var3) {} + + public boolean click(int var1, int var2, int var3) + { + return true; + } + + public boolean contains(int var1, int var2) + { + return this.show && var1 >= this.x && var1 <= this.x + this.width && var2 >= this.y && var2 <= this.y + this.height; + } + + public void position(int var1, int var2, int var3, int var4, int var5) + { + this.x = var1; + this.y = var2; + this.z = var3; + this.width = var4; + this.height = var5; + this.resize(); + } + + public void resize() {} + + protected boolean delegateClickToChildren(int var1, int var2, int var3) + { + Collections.sort(this.children, getComparator()); + Iterator var4 = this.children.iterator(); + _tmi_MgWidget var5; + + do + { + if (!var4.hasNext()) + { + return true; + } + + var5 = (_tmi_MgWidget)var4.next(); + } + while (!var5.show || !var5.contains(var1, var2)); + + return var5.click(var1, var2, var3); + } + + protected void drawChildren(_tmi_MgCanvas var1, int var2, int var3) + { + Collections.sort(this.children, Collections.reverseOrder(getComparator())); + Iterator var4 = this.children.iterator(); + + while (var4.hasNext()) + { + _tmi_MgWidget var5 = (_tmi_MgWidget)var4.next(); + var5.draw(var1, var2, var3); + } + } +} diff --git a/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgZOrder.java b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgZOrder.java new file mode 100644 index 0000000..31e2911 --- /dev/null +++ b/src/main/java/me/ayunami2000/ayuncraft/tmi/_tmi_MgZOrder.java @@ -0,0 +1,18 @@ +package me.ayunami2000.ayuncraft.tmi; + +import java.util.Comparator; + +public class _tmi_MgZOrder implements Comparator +{ + public static final String COPYRIGHT = "All of TooManyItems except for thesmall portion excerpted from the original Minecraft game is copyright 2011Marglyph. TooManyItems is free for personal use only. Do not redistributeTooManyItems, including in mod packs, and do not use TooManyItems\' sourcecode or graphics in your own mods."; + + public int compare(_tmi_MgWidget var1, _tmi_MgWidget var2) + { + return var1.z > var2.z ? 1 : (var1.z < var2.z ? -1 : 0); + } + + public int compare(Object var1, Object var2) + { + return this.compare((_tmi_MgWidget)var1, (_tmi_MgWidget)var2); + } +} diff --git a/src/main/java/net/lax1dude/eaglercraft/glemu/EaglerAdapterGL30.java b/src/main/java/net/lax1dude/eaglercraft/glemu/EaglerAdapterGL30.java index 3a08d8f..8fc3ede 100644 --- a/src/main/java/net/lax1dude/eaglercraft/glemu/EaglerAdapterGL30.java +++ b/src/main/java/net/lax1dude/eaglercraft/glemu/EaglerAdapterGL30.java @@ -16,6 +16,7 @@ import net.lax1dude.eaglercraft.glemu.vector.Vector4f; import net.minecraft.src.RenderItem; public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { + public static boolean glBlendEnabled=false; public static final int GL_ZERO = 0; public static final int GL_ONE = 1; @@ -279,6 +280,7 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { break; case GL_BLEND: _wglEnable(_wGL_BLEND); + glBlendEnabled=true; break; case GL_RESCALE_NORMAL: break; @@ -413,6 +415,7 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { break; case GL_BLEND: _wglDisable(_wGL_BLEND); + glBlendEnabled=false; break; case GL_RESCALE_NORMAL: break; diff --git a/src/main/java/net/minecraft/src/GuiContainer.java b/src/main/java/net/minecraft/src/GuiContainer.java index cd1ba24..24ed3a9 100644 --- a/src/main/java/net/minecraft/src/GuiContainer.java +++ b/src/main/java/net/minecraft/src/GuiContainer.java @@ -648,7 +648,7 @@ public abstract class GuiContainer extends GuiScreen { return par5 >= par1 - 1 && par5 < par1 + par3 + 1 && par6 >= par2 - 1 && par6 < par2 + par4 + 1; } - protected void handleMouseClick(Slot par1Slot, int par2, int par3, int par4) { + public void handleMouseClick(Slot par1Slot, int par2, int par3, int par4) { if (par1Slot != null) { par2 = par1Slot.slotNumber; } diff --git a/src/main/java/net/minecraft/src/GuiScreen.java b/src/main/java/net/minecraft/src/GuiScreen.java index 61e7a7c..f24a454 100644 --- a/src/main/java/net/minecraft/src/GuiScreen.java +++ b/src/main/java/net/minecraft/src/GuiScreen.java @@ -24,7 +24,7 @@ public class GuiScreen extends Gui { public boolean allowUserInput = false; /** The FontRenderer used by GuiScreen */ - protected FontRenderer fontRenderer; + public FontRenderer fontRenderer; public GuiParticle guiParticles; /** The button that was just pressed. */ diff --git a/src/main/java/net/minecraft/src/SlotCreativeInventory.java b/src/main/java/net/minecraft/src/SlotCreativeInventory.java index e61c74e..005c965 100644 --- a/src/main/java/net/minecraft/src/SlotCreativeInventory.java +++ b/src/main/java/net/minecraft/src/SlotCreativeInventory.java @@ -1,6 +1,6 @@ package net.minecraft.src; -class SlotCreativeInventory extends Slot { +public class SlotCreativeInventory extends Slot { private final Slot theSlot; final GuiContainerCreative theCreativeInventory;