Jump to content

[1.9] Getting the amount of ticks passed between two triggers.


_loco_

Recommended Posts

How would I get the amount of ticks passed between two triggers? (e.g. a onItemRightClick trigger)

 

Example:

 

@Override
public ActionResult<ItemStack> onItemRightClick(ItemStack stack, World worldIn, EntityPlayer playerIn, EnumHand hand) {
int ticks = getTicks(); // gets ticks since the last time getTicks() was called
System.out.println(ticks);
        return new ActionResult(EnumActionResult.PASS, stack);
    }

 

How would I make the getTicks() method?

Link to comment
Share on other sites

World#getTotalWorldTime

gives you the age of the world in ticks, it increments every tick. So remember that value and return the difference between the remembered value and the current value.

 

Thanks, but I found a better way to do this for my situation. I use the

Item#onUpdate

method and just store the ticks passed as damage values.

Link to comment
Share on other sites

World#getTotalWorldTime

gives you the age of the world in ticks, it increments every tick. So remember that value and return the difference between the remembered value and the current value.

 

Thanks, but I found a better way to do this for my situation. I use the

Item#onUpdate

method and just store the ticks passed as damage values.

 

That's not better, that's worse.  Now the itemstack needs to update every tick and will cause a jiggle as if the player is switching items.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

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.



  • Recently Browsing

    • No registered users viewing this page.
  • Posts

    • Issue with giacomos_foundry, check you have the latest version then contact the mod author.
    • Heya, so i was running atm8 through curseforge end of last year and connecting to servers fine, i have recently returned to it and now i cant login into the authentication servers no matter what i try. everything is updated and running fine i just cant login to authenticate.  i can run normal vanilla minecraft and go into servers fine with no issues it just seems to be the atm8 auth issue.  here is my latest log file im hoping someone can help me figure out what is causing this issue or give me some things to try as ive tried multiple things on several sites but nothing has fixed the issue. my internet connect is fine i have no issues with anything apart from this game, my friend who lives 15mins drive from me in the same state of Australia can get it working on his pc but i cant seem to. any advice would be great this has frustrated me greatly. i can provide more of the logs if required 19:42:23.342 [19:42:23] [Render thread/INFO] [mojang/YggdrasilAuthenticationService]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD' 19:42:28.554 [19:42:28] [Render thread/ERROR] [minecraft/Minecraft]: Failed to verify authentication 19:42:28.554 com.mojang.authlib.exceptions.AuthenticationException: com.mojang.authlib.exceptions.MinecraftClientException: Failed to read from https://api.minecraftservices.com/player/attributes due to Connect timed out 19:42:28.554 at com.mojang.authlib.exceptions.MinecraftClientException.toAuthenticationException(MinecraftClientException.java:28) ~[authlib-3.11.49.jar%23122!/:?] {} 19:42:28.554 at com.mojang.authlib.yggdrasil.YggdrasilUserApiService.fetchProperties(YggdrasilUserApiService.java:159) ~[authlib-3.11.49.jar%23122!/:?] {} 19:42:28.554 at com.mojang.authlib.yggdrasil.YggdrasilUserApiService.<init>(YggdrasilUserApiService.java:55) ~[authlib-3.11.49.jar%23122!/:?] {} 19:42:28.554 at com.mojang.authlib.yggdrasil.YggdrasilAuthenticationService.createUserApiService(YggdrasilAuthenticationService.java:161) ~[authlib-3.11.49.jar%23122!/:?] {} 19:42:28.555 Caused by: com.mojang.authlib.exceptions.MinecraftClientException: Failed to read from https://api.minecraftservices.com/player/attributes due to Connect timed out 19:42:28.555 at com.mojang.authlib.minecraft.client.MinecraftClient.readInputStream(MinecraftClient.java:93) ~[authlib-3.11.49.jar%23122!/:?] {} 19:42:28.555 at com.mojang.authlib.minecraft.client.MinecraftClient.get(MinecraftClient.java:48) ~[authlib-3.11.49.jar%23122!/:?] {} 19:42:28.555 at com.mojang.authlib.yggdrasil.YggdrasilUserApiService.fetchProperties(YggdrasilUserApiService.java:129) ~[authlib-3.11.49.jar%23122!/:?] {}
    • i dont really know what happened pls help the report is in the spoiler
    • Quick update on this. I tried to setup Forge locally to made the change myself, but ran into some issues described here (which I hope to fix, so any help would be much appreciated). So I did something different: I cloned the MutableHashedLinkedMap inside my project and then "clone" the vanilla map entries to my object. Inside my object I removed the null assignments and that seems to fix the issue. If I remove all paintings and then iterate over the leftover entries the breakpoint inside the check for a painting is never hit, which is what I expect. If I apply a filter to exclude only the modded variants, the breakpoint is hit only for the vanilla ones. So it seems that is just that null assignments on both previous and next that breaks the iterator. This is how I debugged using my own local class   if(tab.equals(CreativeModeTabs.FUNCTIONAL_BLOCKS)) { org.blazers.MutableHashedLinkedMap<ItemStack, CreativeModeTab.TabVisibility> test = new org.blazers.MutableHashedLinkedMap<ItemStack, CreativeModeTab.TabVisibility>(ItemStackLinkedSet.TYPE_AND_TAG); event.getEntries().forEach(entry -> test.put(entry.getKey(), entry.getValue())); var iterator = test.iterator(); ArrayList<ItemStack> itemsToRemove = new ArrayList<>(); while (iterator.hasNext()) { ItemStack stack = iterator.next().getKey(); if(stack.is(Items.PAINTING)) { itemsToRemove.add(stack); } } itemsToRemove.forEach(test::remove); var iterator2 = test.iterator(); while (iterator2.hasNext()) { ItemStack stack = iterator2.next().getKey(); if(stack.is(Items.PAINTING)) { LOG.info(stack + " " + stack.getOrCreateTag()); } } } I'm submitting a PR now that I know that removing those null assignments fixes this, hopefully that's really what it needs to solve it
  • Topics

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.