Posted July 3, 201510 yr hello tis is little odd i been working in a fireguns mod and now im trying to improve the animations of mi guns when i take out the magazine or when put it in to, trying to reduce some graphical gliches i came whith this idea, if i could force the item to remain in use for at leats 20 tics(1sec) after i release rigth click i could improve the animation, but get stuck, i dont really know how to achive this this is the standar method in forge, you hold rigth click an this piece of code make the item enter to setItemInUse state and it remains that way until you release rigth click or something in the code execute playerIn.stopUsingItem(); // #########################################################################3 @Override public ItemStack onItemRightClick(ItemStack cargador, World worldIn, EntityPlayer playerIn) { playerIn.setItemInUse(cargador,this.getMaxItemUseDuration(cargador)); return cargador; } // #########################################################################3 i need the setItemInUse to keep working this other method for at least a second afther release the rigth click button // ####################################################################################3 @Override public ModelResourceLocation getModel(ItemStack gun, EntityPlayer playerIn, int useRemaining) { ModelResourceLocation modelresourcelocation = new ModelResourceLocation("modmercenario:cargador55645/cargador55645_CCe", "inventory"); } // ####################################################################################3 any idea ?? mod = http://www.curse.com/mc-mods/minecraft/228033-mercenarymod
July 3, 201510 yr Is it a reloading animation? What will you do if the player switches to a different item, or no item at all? If it is a reloading animation, I would tackle it a different way: store more information in the ItemStack's NBT tag about the current state of the gun, so that if it needs to be reloaded, any time the player switches to it it attempts to reload, which results in your 20 second animation, and if the player doesn't wait until the process finishes (i.e. switches to a different item), then the process must start again when the player switches back to the gun. http://i.imgur.com/NdrFdld.png[/img]
July 3, 201510 yr Author yap that s a trouble it will make the second item enter in onUse state actualy i been using an onupdate() to keep the animation going using an private int tick100; variable and like six nbttags to only afect the current gun/itme/magazine but has its troubles on update<tick> its not synced whith onreder<tick> causing the item to skip parts of the animation most of the time the whole animation and i fear if there is two player or more it will make the variable tick100 to count two or more times per onupdate<tick> setItemOnUse has not this troubles. but the other what else i could use to keep an animation goin ??
July 4, 201510 yr I'm having some trouble understanding you, but you can not use a private field in the Item class as a timer - there is only ONE instance of your item, so if you have more than one stack with that item, each of those will be changing that same timer, and that's no good. You need to store any type of unique-per-stack information (e.g. enchantments, timers, etc.) in the stack's NBT compound. That is the only way (usually). http://i.imgur.com/NdrFdld.png[/img]
July 4, 201510 yr Author sip thats one of the troubles done some changes , mi gui class is now a ticking class that only exist in local and send messages to server when finish all the ticks for animations come now from there. soo i have not to fear troubles in multiplayer anymore , but its still glichi some times its looks great other it just skip parts or all the animation the curious part is the ticks happen in mi gui/ticking class are taken from onRender(RenderGameOverlayEvent event) so it must be synced whith the method public ModelResourceLocation getModel(ItemStack pistola, EntityPlayer playerIn, int useRemaining) { } but its'n it
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.