Posted December 14, 201212 yr 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?
December 14, 201212 yr 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.
December 14, 201212 yr Author 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!
December 16, 201212 yr 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; } =/ http://i715.photobucket.com/albums/ww155/JadeKnightblazer/AsgardShieldBannermain.png[/img]
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.