Jump to content

[1.7.10] Potion IDs


Recommended Posts

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.

Link to comment
Share on other sites

"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.

Link to comment
Share on other sites

public static void increaseArray(Class<?> clazz, int length, String... args){
	Object[] oldArray = null;
	for(Field field : clazz.getDeclaredFields()){
			for(String s : args){
						Field modfield = Field.class.getDeclaredField("modifiers");
						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){

And call in your main class:

increaseArray(Potion.class, 256, "potionTypes", "obfName");

Link to comment
Share on other sites

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.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use.