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

I have a custom block (BlockAmethyst) which is a beacon base material. I would like the UI of the beacon to change if its entire base is made of BlockAmethyst, to allow different effects to be chosen.

 

Changing the UI is a simple container replacement in the GuiOpen event. Detecting the material of the beacon base would be easy as well. The hard part is that there's a HashSet of valid beacon effects in TileEntityBeacon, and without reflection, it's private. The primary and secondary effects are also private members with no setters. In fact, it seems the only way to change the beacon effects is to use readFromNBT, but that inherently verifies the beacon effects against that HashSet.

 

So I'm thinking the best approach would be to replace the default Minecraft TileEntityBeacon with a custom one...but I have no idea how to do that. Is there even a way to replace a vanilla tile entity with my own? Or should I just be hooking into the beacon block placement, removing the instance of the tile entity naturally created, and then creating an instance of my own that extends it?

Whatever Minecraft needs, it is most likely not yet another tool tier.

  • Author

Perhaps I'm mistaken, but isn't reflection generally frowned upon? As in, a last-ditch effort if nothing else works?

Whatever Minecraft needs, it is most likely not yet another tool tier.

Perhaps I'm mistaken, but isn't reflection generally frowned upon? As in, a last-ditch effort if nothing else works?

 

No that's--

 

 

User was banned for coremodding

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

  • Author

Sure, but it is a valid use-case here.

 

Fair enough; I'll go that route and see what I can manage. Thanks.

Whatever Minecraft needs, it is most likely not yet another tool tier.

Perhaps I'm mistaken, but isn't reflection generally frowned upon? As in, a last-ditch effort if nothing else works?

That's correct for developers on the inside (if we were Mojang employees), but we're not. Being on the outside looking in, our mods are stuck using reflection rather more often than nicely integrated projects would.

 

If used only to init data rather than in tight loops running many times per second, we don't care about the performance hit. Even if some reflected element needs to be used frequently, you can usually arrange to pay the cost during initialization so your data access is reasonably fast.

 

However, reflection can defeat some of our IDE tools (because classes and fields become text strings that the IDE doesn't trace -- never assume that "unused" elements are really unused). Therefore, you're right that we're better off using reflection only when  needed.

The debugger is a powerful and necessary tool in any IDE, so learn how to use it. You'll be able to tell us more and get better help here if you investigate your runtime problems in the debugger before posting.

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.