SkylordJoel Posted October 25, 2013 Posted October 25, 2013 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. Quote Check out SpaceAge: https://github.com/AwesCorp/SpaceAge http://i.imgur.com/J4rrGt6.png[/img]
TheGreyGhost Posted October 25, 2013 Posted October 25, 2013 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 Quote
SkylordJoel Posted October 25, 2013 Author Posted October 25, 2013 I meant an item. But thanks, very interesting. Quote Check out SpaceAge: https://github.com/AwesCorp/SpaceAge http://i.imgur.com/J4rrGt6.png[/img]
SkylordJoel Posted October 25, 2013 Author Posted October 25, 2013 I forgot to put that the item would be acting like a sword and taking damage. Quote Check out SpaceAge: https://github.com/AwesCorp/SpaceAge http://i.imgur.com/J4rrGt6.png[/img]
GotoLink Posted October 25, 2013 Posted October 25, 2013 You can use ItemStack nbt and the onItemRightClick method. Quote
SkylordJoel Posted October 25, 2013 Author Posted October 25, 2013 So how do you use that? (Isn't NBT like a string or something?) Quote Check out SpaceAge: https://github.com/AwesCorp/SpaceAge http://i.imgur.com/J4rrGt6.png[/img]
TheGreyGhost Posted October 25, 2013 Posted October 25, 2013 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 Quote
SkylordJoel Posted October 25, 2013 Author Posted October 25, 2013 Yeah, there is a picture of a package in the inventory, and it turns into a sword and back again. Quote Check out SpaceAge: https://github.com/AwesCorp/SpaceAge http://i.imgur.com/J4rrGt6.png[/img]
TheGreyGhost Posted October 26, 2013 Posted October 26, 2013 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 Quote
Recommended Posts
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.