Jump to content

[1.10.2] Alter beacon behavior when base is certain material


IceMetalPunk

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

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.

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

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

Announcements



×
×
  • Create New...

Important Information

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