Bedrock_Miner Posted September 8, 2013 Posted September 8, 2013 Hello Guys! I'm creating a special Item, which should have a shooting function if you right klick it and a healing function if you left klick it. Right Klick short: Shoot Right Klick long: Aim and shoot Left klick: Heal The function should be created in a way that you don't have to select a Block or an Entity before klicking, just klick anywhere. Any Ideas?? Quote http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
Bedrock_Miner Posted September 9, 2013 Author Posted September 9, 2013 anybody any ideas? Quote http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
Mazetar Posted September 9, 2013 Posted September 9, 2013 I'm not sure what you mean by click it. Do you mean having it in the hand and then clicking? Quote If you guys dont get it.. then well ya.. try harder...
Bedrock_Miner Posted September 9, 2013 Author Posted September 9, 2013 I'm not sure what you mean by click it. Do you mean having it in the hand and then clicking? Yes, exactly. You hold the Item and perform a klick, either with the left mouse-button or with the right one. And both clicks should lead to a single method. But I could only find methods for the event of klicking at a Block... You should be able to klick right into the air, like wit a bow, but also with the left mouse button. (Hope, everybody understands) Quote http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
Mazetar Posted September 9, 2013 Posted September 9, 2013 There are many functions of the Item which you can look into. If you look into the Item.java class of the minecraft project you will see many methods, look into them and you will find several interesting ones like onItemUse and so on. If you press Ctrl+Shift+T inside eclipse and type Item you should be able to find the main Item class rather quickly Quote If you guys dont get it.. then well ya.. try harder...
Bedrock_Miner Posted September 9, 2013 Author Posted September 9, 2013 I looked it up and found only onItemRightKlick(...), but nothing for Left Klick except onLeftKlickEntity, and this is only for entities and not active if you click right into the air... Quote http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
Bedrock_Miner Posted September 10, 2013 Author Posted September 10, 2013 I don't know how, but it must be possible, because they do it in the PortalGun Mod. Quote http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
fhntv24 Posted September 10, 2013 Posted September 10, 2013 @ForgeSubscribe public void playerInteractEvent(PlayerInteractEvent evt) it might help to you. Quote
Bedrock_Miner Posted September 18, 2013 Author Posted September 18, 2013 But ther's also no property for clicking right into the air. There are only RIGHT_KLICK_BLOCK, RIGHT_KLICK_AIR and LEFT_KLICK_BLOCK; I need LEFT_KLICK_AIR. Quote http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
TheGreyGhost Posted September 18, 2013 Posted September 18, 2013 Hi The code for handling left & right mouse clicks is in Minecraft.tick() --> Minecraft.clickMouse(int button) A left click goes to EntityLivingBase.swingItem --> item.onEntitySwing(), so you can probably intercept it here, however the code continues on to do all sorts of other left-click things and you might have trouble stopping it - perhaps overwriting Minecraft.objectMouseOver might do the trick. Depends what you want to do exactly. -TGG Quote
Bedrock_Miner Posted September 20, 2013 Author Posted September 20, 2013 Thank You! This finally worked! Quote http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
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.