Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

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.

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

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.

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

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.