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

Posted

Do I need my Potion to be registered? My potion ID must really be within the range of the Potion.potionTypes array or does Forge comes to the rescue somehow to avoid mods overwriting each other's potions? How the method setIconIndex works?

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

  • Author

thanks! but why do I need SRG name? the mod won't work after release if I use the deobfuscated name?

 

also,

 

Field modField = Field.class.getDeclaredField("modifiers");
modField.setAccessible(true);

 

the need of those lines seems to me like a flaw in the reflection framework. I'm reflecting on a class of the java.lang.reflect package itself. this shouldn't be necessary IMO. the framework should allow something like this:

 

Field potionTypesField = Potion.class.getDeclaredField("potionTypes");
int modifiers = potionTypesField.getModifiers();
potionTypesField.setModifiers(modifiers & ~Modifier.FINAL);

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

  • Author

I see. Well if it's for the sake of optimization then I agree with java dev team. I thought it was just, you know, lack of imagination.

 

one last thing: is there away to find out whether im running my mod in a deobfuscated environment, maybe some forge or fml method. This way I could set that string to the SRG name or the deobfuscated name depending on that, instead of manually changing it before release.

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

  • Author

thanks again, diesieben07. you're a living wiki!

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

  • Author

Is there an event I can subscribe to handle when a potion effect is added and when it's ended? If there isn't, maybe Forge devs could give Potions some attention if I may ask. There should be a way to register them into the GameRegistry instead of having to hack the potionTypes array and all that. and there should also be events related to them. performEffect is executed too often and doesn't fit certain cases very well, the most clear example of that being a potion of flight.

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

  • Author

I can't understand Attribute modifiers at all. What I'm trying to do is a potion of flight. This is what I do:

 

@Override
public void performEffect(EntityLivingBase target, int amplifier)
{
if(target instanceof EntityPlayer)
{
	EntityPlayer player = (EntityPlayer)target;
	if(!player.capabilities.isCreativeMode)
	{
		PotionEffect effect = player.getActivePotionEffect(ModPotions.flight);
		if(effect != null)
		{
			if(effect.getDuration() <= 20)//strangely, it doesn't work with 1
			{
				player.capabilities.allowFlying = false;
				player.capabilities.isFlying = false;
			}
			else
			{
				player.capabilities.allowFlying = true;
		        }
		}
		else
		{
			player.capabilities.allowFlying = false;
		}
	}
}
}

@Override
public boolean isReady(int duration, int amplifier)
{
return duration == 1 || duration % 20 == 0; //returns true every 20 ticks, then performEffect is invoked
}

 

it works but I can't help but feel this is an ugly hack. I was wondering if there was a better way of doing that.

 

I tryed overloading applyAttributesModifiersToEntity and removeAttributesModifiersFromEntity (I would just invoke the super class version of the method and then set the player.capabilities to allow or disallow flight depending on the method) but setting the player's capabilities from inside those methods has no effect, probably something to do with the Side from which those methods are invoked (Server/Client).

 

Is there a better way of doing that?

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

  • Author

So my way (doing that thing inside performEffect) is the only way? I thought something invoked from server side only would end up updating the client.

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

  • Author

Everything works great now.

WIP mods: easyautomation, easyenergy, easyelectronics, easymoney, easytrasportation, easysecurity, easymultiverse, easyfactions, easymagick, easyalchemy, easyseasons

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.