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

Simple question: Why has the isBadPotion() method the @SideOnly(Side.CLIENT) annotation (thus making it only accessible on the client only)? Since it only returns a (private final) field, which hasn't this annotation.

So I would like to either know if this is intended (and yes, why) or if this can be changed (since I intended to use this to easily filter the potions by their "badness" and I don't see a reason for making this accessible client-only).

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

  • Author

The @SideOnly annotations are generated automatically by FML during the client-server merge. In the vanilla code this method only exists on the client, so it gets this annotation.

Why that, you might ask. The obfuscator mojang uses strips out methods that aren't used. And since isBadPotion is never used in any server code, it gets stripped out there (not contained in the minecraft_server.jar). But the client code contains references to that method, so it stays in the minecraft.jar.

Thats what the annotation means. Removing the annotation would mean a base edit on the server (to add the method back in).

If you need access to the field use reflection or AccessTransformers (I am sure you are familiar with stuff like that ;)).

 

Oh, that's how the annotations get added :P

 

Well then, If I can't just remove the annotation with ASM, I'll add a dummy method to access that field. I don't want to use reflection for what I'm aiming at, because of performance.

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

  • Author

I don't want to use reflection for what I'm aiming at, because of performance.

It's not as bad as you might think, at least if you are not stupid :P

But if you are a coremod anyhow, a dynamically created setter is definitely cleaner and the way to go.

 

Reflection is not really an option, since I check something every tick (armor which removes bad potion effects), so a new getter (not a setter, I don't need one) would be fine, and yes, my Manager Pack (requirement for some time for my mods) will be a coremod in the next release.

An AccessTransformer would be an another option, but I don't like to have files in the root directory (/Minecraft/src/) :P

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

  • Author

Yup. Totally agree :)

If you want a tip for adding methods via ASM what I usually do is make a dummy interface that contains these methods, e.g. called EntityPlayerAccessor. Then via ASM I add the methods and the Interface to the EntityPlayer class. When I call the method i use something like ((EntityPlayerAccessor)player).someMethod(). That way you don't have to edit the base class files in eclipse.

 

Thanks, I'll make use of it when I need it :)

Don't ask for support per PM! They'll get ignored! | If a post helped you, click the "Thank You" button at the top right corner of said post! |

mah twitter

This thread makes me sad because people just post copy-paste-ready code when it's obvious that the OP has little to no programming experience. This is not how learning works.

protip everything is public at runtime.

I do Forge for free, however the servers to run it arn't free, so anything is appreciated.
Consider supporting the team on Patreon

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.