Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

Cool down not working afte4 changing


Mightydanp
 Share

Recommended Posts

  • Replies 55
  • Created
  • Last Reply

Top Posters In This Topic

This is merely an example - it is an efficient cooldown in which NBT is not being stressed every tick. The world total time does the counting for you. This WILL break if you use getWorldTime() instead of using getTotalWorldTime(). Reason for that - if you are using getWorldTime() and then set the world time to day / night / custom time, it WILL break and return a cooldown that is either extensively long, or no cooldown at all. Just something to remember.

 

if(itemstack.hasTagCompound()
{
    final Long time = itemstack.getTagCompound().getLong("Cooldown");
    if(time < THE TOTAL WORLD TIME)
    {
        DO WHAT YOU NEED HERE THEN SET THE COOLDOWN
        itemstack.setTagCompound("Cooldown", THE TOTAL WORLD TIME + YOUR COOLDOWN TIME IN TICKS);
    }
}
else
{
    itemstack.setTagCompound(new NBTTagCompound());
}

Development of Plugins [2012 - 2014] Development of Mods [2012 - Current]

Link to comment
Share on other sites

This is merely an example - it is an efficient cooldown in which NBT is not being stressed every tick. The world total time does the counting for you. This WILL break if you use getWorldTime() instead of using getTotalWorldTime(). Reason for that - if you are using getWorldTime() and then set the world time to day / night / custom time, it WILL break and return a cooldown that is either extensively long, or no cooldown at all. Just something to remember.

 

if(itemstack.hasTagCompound()
{
    final Long time = itemstack.getTagCompound().getLong("Cooldown");
    if(time < THE TOTAL WORLD TIME)
    {
        DO WHAT YOU NEED HERE THEN SET THE COOLDOWN
        itemstack.setTagCompound("Cooldown", THE TOTAL WORLD TIME + YOUR COOLDOWN TIME IN TICKS);
    }
}
else
{
    itemstack.setTagCompound(new NBTTagCompound());
}

 

While world timestamps are cool for most stuff and using them is often advertised on this forum with great praise, I must say that I am quite amazed how many people miss the fact or forget to mention that there can be more worlds than just one.

"If something can fail, it will." - Me. - And above (world timestamps) is among those things.

 

Solution is quite obvious (ServerTickEvent and global timestamp).

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share




×
×
  • Create New...

Important Information

By using this site, you agree to our Privacy Policy.