Posted October 25, 201311 yr Hi, I am creating a mod where you click a package and it turns into a sword. How would I do this? I would prefer it to not do damage as a package but just changing sprites would be good enough. Thanks. Check out SpaceAge: https://github.com/AwesCorp/SpaceAge http://i.imgur.com/J4rrGt6.png[/img]
October 25, 201311 yr Hi I'd suggest: Override Block.onBlockClicked or Block.onBlockActivated to change the block metadata. You'll also need to call World.markBlockForUpdate to make sure that the new texture is drawn. Override BLock.getBlockTexture to return a different texture based on the metadata. If you're not familiar with metadata, this might help http://greyminecraftcoder.blogspot.com.au/2013/07/blocks.html and -TGG
October 25, 201311 yr Author I meant an item. But thanks, very interesting. Check out SpaceAge: https://github.com/AwesCorp/SpaceAge http://i.imgur.com/J4rrGt6.png[/img]
October 25, 201311 yr Author I forgot to put that the item would be acting like a sword and taking damage. Check out SpaceAge: https://github.com/AwesCorp/SpaceAge http://i.imgur.com/J4rrGt6.png[/img]
October 25, 201311 yr Author So how do you use that? (Isn't NBT like a string or something?) Check out SpaceAge: https://github.com/AwesCorp/SpaceAge http://i.imgur.com/J4rrGt6.png[/img]
October 25, 201311 yr Hi What do you mean "click on a package" exactly? In the inventory screen? The method GotoLink has suggested (if I've understood his/her suggestion correctly) is called when you're holding the item and you press the right mouse button. -TGG
October 25, 201311 yr Author Yeah, there is a picture of a package in the inventory, and it turns into a sword and back again. Check out SpaceAge: https://github.com/AwesCorp/SpaceAge http://i.imgur.com/J4rrGt6.png[/img]
October 26, 201311 yr Hi Hmmm that sounds like it will be tricky. The code that handles clicks on items in the inventory is GuiContainer.mouseClicked I don't see an easy way to intercept it without changing one of the base classes or (eg) writing a class that overrides PlayerControllerMP.windowClick to intercept the click, and replacing Minecraft.playerController with your new class. That's getting a bit hard to do robustly and I'm not confident it would work. -TGG
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.