deApollo Posted November 30, 2012 Share Posted November 30, 2012 Hello everyone! I am designing a plugin that sells the item you are holding based on it's EMC value from the Equivalent Exchange Mod. I have everything working but, I would rather not have to define every item and it's emc value in the config, so I was wondering if there was a way to import and store the values directly from EE itself. I have seen plugins that are able to modify the EMC value of an item such as TekkitRestrict or CustomEMC, so I assume that it is possible to accomplish what I am attempting. I am developing this using Bukkit Version 1.2.5 R5 since this is for a tekkit server. Any help would be great! I posted on the Dev Bukkit forums but they redirected me here. Link to comment Share on other sites More sharing options...
phoenix987 Posted December 1, 2012 Share Posted December 1, 2012 Try decompiling TekkitRestrict. I found this in /a/a/a/a/a/a.class. Looks like you'll need to import ee.EEMaps, which is most likely a file in the bukkit port on mcportcentral. if ((localHashMap2 = (HashMap)EEMaps.alchemicalValues.get(Integer.valueOf(localj.a))) != null) { localHashMap2.put(Integer.valueOf(i1),Integer.valueOf(Integer.parseInt(paramArrayOfString[4]))); paramCommandSender.add("Temporary EMC set successful!"); EEMaps.alchemicalValues.put(Integer.valueOf(localj.a), localHashMap2); } else { (localHashMap2 = new HashMap()).put(Integer.valueOf(i1),Integer.valueOf(Integer.parseInt(paramArrayOfString[4]))); paramCommandSender.add("Temporary EMC set successful!"); EEMaps.alchemicalValues.put(Integer.valueOf(localj.a), localHashMap2); } Link to comment Share on other sites More sharing options...
deApollo Posted December 1, 2012 Author Share Posted December 1, 2012 Try decompiling TekkitRestrict. I found this in /a/a/a/a/a/a.class. Looks like you'll need to import ee.EEMaps, which is most likely a file in the bukkit port on mcportcentral. if ((localHashMap2 = (HashMap)EEMaps.alchemicalValues.get(Integer.valueOf(localj.a))) != null) { localHashMap2.put(Integer.valueOf(i1),Integer.valueOf(Integer.parseInt(paramArrayOfString[4]))); paramCommandSender.add("Temporary EMC set successful!"); EEMaps.alchemicalValues.put(Integer.valueOf(localj.a), localHashMap2); } else { (localHashMap2 = new HashMap()).put(Integer.valueOf(i1),Integer.valueOf(Integer.parseInt(paramArrayOfString[4]))); paramCommandSender.add("Temporary EMC set successful!"); EEMaps.alchemicalValues.put(Integer.valueOf(localj.a), localHashMap2); } Hmm, I've found and imported the EEmaps file, is there a decompiler your recommend? Link to comment Share on other sites More sharing options...
phoenix987 Posted December 1, 2012 Share Posted December 1, 2012 I use jd-gui. Other options are JAD and fernflower (both command line programs). Link to comment Share on other sites More sharing options...
deApollo Posted December 1, 2012 Author Share Posted December 1, 2012 Okay, so I currently have: public static void testID(Player player, Integer sellAMT) { ItemStack stack = player.getInventory().getItemInHand(); int itemID = stack.getTypeId(); int emc; try { Class<?> equivexmaps = Class.forName("ee.EEMaps"); Method getEMC = equivexmaps.getMethod("getEMC", int.class); emc = getEMC(itemID); } catch (Exception ex) { } if(emc > 0){ sellStack(player, emc, sellAMT); }else{ player.sendMessage("The item you are trying to sell has not been added to the EMC database"); } } However, at this point: emc = getEMC(itemID); I get the error: "The method getEMC(int) is undefined for the type emcshopMain" I thought I defined the method in the line above. What's up with that? EDIT: The method I'm getting is in EEMaps.class: public static int getEMC(int var0) { return getEMC(var0, 0); } EDIT2: There are actually 3 methods I could choose from, which would be best? I want to input the Item ID and get the EMC value public static int getEMC(ItemStack var0) { return getEMC(var0.id, var0.getData()) == 0 ? 0 : getEMC(var0.id) > 0 ? getEMC(var0.id) : var0.d() ? (int)(getEMC(var0.id) * ((var0.i() - var0.getData()) / var0.i())) : var0 == null ? 0 : getEMC(var0.id, var0.getData()); } public static int getEMC(int var0) { return getEMC(var0, 0); } public static int getEMC(int var0, int var1) { return ((HashMap)alchemicalValues.get(Integer.valueOf(var0))).get(Integer.valueOf(var1)) == null ? 0 : alchemicalValues.get(Integer.valueOf(var0)) == null ? 0 : ((Integer)((HashMap)alchemicalValues.get(Integer.valueOf(var0))).get(Integer.valueOf(var1))).intValue(); } EDIT3: I got it working, thanks for the help! Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now