January 17, 201510 yr PotionIDs can be extended to max. 127. You can dynamically modify the array Potion.potionTypes (you'll have to set it via reflection). First check if the array is smaller than 127 (other mods might already expand it!) if so, expand it using Arrays.copyOf. I actually found a way to safely extend it to 255 (and theoretically higher), but it required ASM into the PotionEffect packet and NBT methods to remove the byte casts. Follow my mod(s) here: http://www.minecraftforum.net/topic/1969694-
January 19, 201510 yr "safely" and "ASM into vanilla classes" are pretty much mutually exclusive. Not really. Barring a MC version change or another mod's conflicting ASM edit, there is no way for this to error out. Also, you seem to be implying, based on your wording of "ASM into vanilla classes" that using ASM is not necessarily dangerous, but using it on vanilla classes is. What else would you normally use it on? You could of course theoretically ASM Forge or other mods, but that is far more dangerous and will generate a huge amount of drama. Follow my mod(s) here: http://www.minecraftforum.net/topic/1969694-
January 19, 201510 yr public static void increaseArray(Class<?> clazz, int length, String... args){ Object[] oldArray = null; for(Field field : clazz.getDeclaredFields()){ try{ for(String s : args){ if(field.getName().equals(s)){ field.setAccessible(true); if(Modifier.isFinal(field.getModifiers())){ Field modfield = Field.class.getDeclaredField("modifiers"); modfield.setAccessible(true); modfield.setInt(field, field.getModifiers() & ~Modifier.FINAL); } oldArray = (Object[])field.get(null); Object newArray = Array.newInstance(field.get(null).getClass().getComponentType(), length); System.arraycopy(oldArray, 0, newArray, 0, oldArray.length); field.set(null, newArray); } } }catch(ReflectiveOperationException e){ e.printStackTrace(); } } } And call in your main class: increaseArray(Potion.class, 256, "potionTypes", "obfName");
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.