Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Add field to EntityPlayer or Item?


Goz3rr
 Share

Recommended Posts

So, i'm working on making a grappling hook. The actual hook itself is a EntityHook, like the fishing rod uses a EntityFishHook. The problem is, i need some way to store the EntityHook after i spawn it. Looking at the fishing rod, it uses the EntityPlayer.fishEntity field, which i can't since i'm using a EntityHook, not a EntityFishHook. Adding a field to the actual item won't work either, since that means it's shared across all instances of that item, and would probably glitch out. I looked into saving it to the player NBT thing, but i don't think you can write entities to it. Another possibility would be using ASM to add a new field to EntityPlayer, similar to fishEntity. What would be the best approach here?

Link to comment
Share on other sites

I had this issue with a few items in my mod.

 

The end solution?

 

Use a PlayerTracker, and a HashMap or similar to store the player instances and their corresponding Hook instances.  No need to edit base classes.  You would just query PlayerTracker.instance().getHookForPlayer() or similar, and set through PlayerTracker.instance().setHookForPlayer(EntityHook ent)

 

If persistence across saves is needed, you can save all of the data out to a custom NBT file.

 

Offtimes modding in MC is a game of compromise because of base-classes and inabilty to alter them.

Link to comment
Share on other sites

I had this issue with a few items in my mod.

 

The end solution?

 

Use a PlayerTracker, and a HashMap or similar to store the player instances and their corresponding Hook instances.  No need to edit base classes.  You would just query PlayerTracker.instance().getHookForPlayer() or similar, and set through PlayerTracker.instance().setHookForPlayer(EntityHook ent)

 

If persistence across saves is needed, you can save all of the data out to a custom NBT file.

 

Offtimes modding in MC is a game of compromise because of base-classes and inabilty to alter them.

 

Very interesting, hadn't thought of that. Will look into it!

Link to comment
Share on other sites

Did this ever work? I too am trying to make a strong version of the Fishing rod, however the Hook Entity does not like to function. I believe it due to entityplayer.fishEntity and the hardcoded

if (par1ItemStack.itemID == Item.fishingRod.shiftedIndex && this.fishEntity != null)

        {

            var3 = par1ItemStack.getIconIndex() + 16;

        }

 

=/

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

 Share



×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.