Posted September 8, 201312 yr 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?? http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
September 9, 201312 yr Author anybody any ideas? http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
September 9, 201312 yr I'm not sure what you mean by click it. Do you mean having it in the hand and then clicking? If you guys dont get it.. then well ya.. try harder...
September 9, 201312 yr Author 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) http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
September 9, 201312 yr 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 If you guys dont get it.. then well ya.. try harder...
September 9, 201312 yr Author 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... http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
September 10, 201312 yr Author I don't know how, but it must be possible, because they do it in the PortalGun Mod. http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
September 10, 201312 yr @ForgeSubscribe public void playerInteractEvent(PlayerInteractEvent evt) it might help to you.
September 18, 201312 yr Author 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. http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
September 18, 201312 yr 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
September 20, 201311 yr Author Thank You! This finally worked! http://i.imgur.com/wNvtGZw.png[/img] MODS and MODDING TUTORIALS
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.