Posted June 7, 20169 yr I've realized a major flaw in my item: every 1200 ticks, it does something (this thing doesn't matter in this context). I check if 12000 ticks happened by using a NBT value that updates every tick using the method OnUpdate. It works nicely, but sadly the item will make the weird animation where it just goes up and down every tick. I believe this is due to the NBT being updated (or set if you want) I hope someone knows what I'm talking about When they say your code doesn't follow convention but ur edgy so u dont care d-d-d-dab on them haterz
June 7, 20169 yr Item#shouldCauseReequipAnimation 1.7.10 is no longer supported by forge, you are on your own.
June 7, 20169 yr Author I'm litteraly facepalming rn. When they say your code doesn't follow convention but ur edgy so u dont care d-d-d-dab on them haterz
June 7, 20169 yr When overriding that method, make sure to still return true for some cases, e.g. @Override public boolean shouldCauseReequipAnimation(ItemStack oldStack, ItemStack newStack, boolean slotChanged) { return !ItemStack.areItemsEqual(oldStack, newStack); // maybe also add || slotChanged } A better solution, however, is to avoid updating NBT every tick and instead store the world time at which the next event should happen, then simply compare the current time against the NBT each tick: // whenever time should be set: long next = world.getTotalWorldTime() + 12000; stack.getTagCompound().setLong('nextWhatever', next); // checking each tick: if (world.getTotalWorldTime() > stack.getTagCompound().getLong('nextWhatever')) { // do whatever you need to do, then set the next time again Not only will you not have to bother with shouldCauseReequipAnimation, but it is also more efficient as you only write to NBT once per cycle, rather than every single tick. http://i.imgur.com/NdrFdld.png[/img]
June 7, 20169 yr Well, if we are talking about BEST ways - the one is to use damn @Capability. Timestamps are not dimension-safe and still require NBT interactions. Caps don't (only once). 1.7.10 is no longer supported by forge, you are on your own.
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.