Jump to content

Custom method listener


Tslat

Recommended Posts

I was wondering what the best way is to listen for when a method is fired.

 

This method isn't in the events register, and is a base Minecraft class.

 

I'm assuming to use reflection, obviously.. but I'm not entirely sure how I would go about tracking that specific method.

Link to comment
Share on other sites

Actually, I think you could possibly figure out when one is created, and you could also search for one in tick event if you're conscious not try to search the whole world in one tick and instead break it down.

 

For example, you could possibly keep track of all obsidian placed (and even generated by checking each chunk when loaded).  There are events for the generation and also events for placement, and you could copy the vanilla code that detects that a portal has been completed.

 

I'm not sure if you meant you wanted to detect when one was activated, but if you kept track of which ones are created block-wise you could poll them in tick event to see if they've lit.

 

Probably a bit of work, and intermediate coding level required, but not impossible I think.

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Link to comment
Share on other sites

Certainly, but then how do you keep track of ones that are made by coming through from the other side (The game creates it)

 

And also those lit by ghast/dispenser/etc..

 

We're on the right track, just gotta figure out the other cases

Link to comment
Share on other sites

Certainly, but then how do you keep track of ones that are made by coming through from the other side (The game creates it)

 

And also those lit by ghast/dispenser/etc..

 

We're on the right track, just gotta figure out the other cases

 

Yes.  But like I said you to catch those you can search the world if you're careful about perf (meaning perhaps searching a bit each tick).  But yeah if you're coming through from the other side then you know there is one you need to record.

 

You need to separate the detection of location of portals with whether they are lit.  I think you can have some sort of array or list field in your main class that can track portals "discovered" and then you can further occasionally check whether they have been lit (or also if they've been destroyed or otherwise changed state).

 

Certainly not easy, but I think with some thought and effort it just might be possible.

 

What exactly are you trying to achieve?  Depending on what you want to do, maybe you should make it more like actual discovering the portals -- like if it is within range of the player then you record it.  That approach would greatly help performance because you only have to search smaller area (and also check previously discovered portals for changes in state).

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

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.