Jump to content

[1.12.2] onUsingTick getting constantly called on server after client stops using Item


Recommended Posts

Posted (edited)

I've got the same problem as Daniel336Cobra in this thread 

 

I've got an Item (a gun) with a capability storing a list of ItemStacks (attachments - scopes, circuits, etc.). My circuit in that capability is an ItemStack that has another (different) capability that controls how often the gun should fire. Every time the gun is shot (in onUsingTick) a counter in my circuit's capability is incremented. This counter is reset in onPlayerStoppedUsing. Both capabilities are stored in the Gun's NBT and it seems that because of this when I'm using the gun the item stack is constantly updating and animations don't get applied successfully. ALSO when I stop using the gun on the client usually the server isn't made aware of this and keeps shooting.

 

My problem is that the server keeps shooting when the client has stopped. I believe it's the capability because when I comment out line 149 the animations & server/client shooting work fine (except obviously without the control provided by the capability). This makes it seem like the solution is not to sync (write NBT to the item stack) the capability & just hope they remain the same client/server.

My code - https://github.com/Cadiboo/WIPTechAlpha/blob/9304a1745aec48891841a0d9d8703a01cda72ca3/src/main/java/cadiboo/wiptech/item/ItemHandheldGun.java#L74-L192 

and a couple videos to illustrate

https://streamable.com/rv9c0

https://streamable.com/o4dq6

The relevant part of my debug log - https://gist.github.com/Cadiboo/1db00e79ccd6e6a644b9670990e93cec

Edited by Cadiboo
added debug log

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted

I haven't yet looked at your code to see if there is a problem as I currently dont have time, but I dont know a reason to sync this data to your client in the first place. Unless you plan to use it for an animation. If that is the plan dont sync it every time is changes only every so often.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
Just now, Animefan8888 said:

I haven't yet looked at your code to see if there is a problem as I currently dont have time, but I dont know a reason to sync this data to your client in the first place. Unless you plan to use it for an animation. If that is the plan dont sync it every time is changes only every so often.

The first capability (list of attachments) is used for animation, control and pretty much everything. The second capability (Circuit control) is only used to control when the gun can fire (burst mode, auto mode, semi-auto mode) and _should_ remain the same on the server & client without syncing. I've removed syncing for the Circuit control capability and everything works perfectly, but if I plan to do stuff with capability based ammo (which I do), I'm going to need to solve this.

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted (edited)
46 minutes ago, Cadiboo said:

capability based ammo

Explain this a bit more, why would this cause an "error"?

Edited by Animefan8888

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
1 minute ago, Animefan8888 said:

Explain this a bit more, why would this cause an "error"?

 

2 hours ago, Cadiboo said:

Both capabilities are stored in the Gun's NBT and it seems that because of this when I'm using the gun the item stack is constantly updating and animations don't get applied successfully. ALSO when I stop using the gun on the client usually the server isn't made aware of this and keeps shooting.

Basically, I don't know why its causing an error, but it is. As I said, if I stop the capability's NBT being written to the ItemStack I stop getting any problems. This works fine for the circuit control capability as it doesn't really need to be synced, but an Ammo capability will definitely need to be synced. Forgetting ammo entirely, my gun uses energy so that will need to be synced.

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
15 minutes ago, Cadiboo said:

 

Basically, I don't know why its causing an error, but it is. As I said, if I stop the capability's NBT being written to the ItemStack I stop getting any problems. This works fine for the circuit control capability as it doesn't really need to be synced, but an Ammo capability will definitely need to be synced. Forgetting ammo entirely, my gun uses energy so that will need to be synced.

Ok, so we are just dealing with the animation and updating part of the problem. There is a method in the Item class called shouldCauseReequipAnimation. You will have to handle this in an appropriate way to fix your problem.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
1 minute ago, Animefan8888 said:

Ok, so we are just dealing with the animation and updating part of the problem. There is a method in the Item class called shouldCauseReequipAnimation. You will have to handle this in an appropriate way to fix your problem.

I have, I even tried always returning false, it didn't help. I still didn't get the pulling animation & the server continued to shoot after the client stopped.

https://github.com/Cadiboo/WIPTechAlpha/blob/9304a1745aec48891841a0d9d8703a01cda72ca3/src/main/java/cadiboo/wiptech/item/ItemHandheldGun.java#L309-L333 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
9 minutes ago, Cadiboo said:

I have, I even tried always returning false, it didn't help. I still didn't get the pulling animation & the server continued to shoot after the client stopped.

https://github.com/Cadiboo/WIPTechAlpha/blob/9304a1745aec48891841a0d9d8703a01cda72ca3/src/main/java/cadiboo/wiptech/item/ItemHandheldGun.java#L309-L333 

You did not override the equals method so this will not work.

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

Posted
14 minutes ago, Cadiboo said:

I even tried always returning false, it didn't help. I still didn't get the pulling animation & the server continued to shoot after the client stopped.

I'll go override it now though. 

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
Just now, Animefan8888 said:

Did you check in the debugger about this particular part?

what do you mean?

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

Posted
9 minutes ago, Cadiboo said:

what do you mean?

Is the method being called? when it is call what are the parameters? What is it returning for said parameters?

VANILLA MINECRAFT CLASSES ARE THE BEST RESOURCES WHEN MODDING

I will be posting 1.15.2 modding tutorials on this channel. If you want to be notified of it do the normal YouTube stuff like subscribing, ect.

Forge and vanilla BlockState generator.

  • 5 weeks later...
Posted

Yeah I did go through it with the debugger, but apparently forgot to post the results.

This problem still isn't solved, so I'll go back to this project soon and get you a proper answer.

About Me

Spoiler

My Discord - Cadiboo#8887

My WebsiteCadiboo.github.io

My ModsCadiboo.github.io/projects

My TutorialsCadiboo.github.io/tutorials

Versions below 1.14.4 are no longer supported on this forum. Use the latest version to receive support.

When asking support remember to include all relevant log files (logs are found in .minecraft/logs/), code if applicable and screenshots if possible.

Only download mods from trusted sites like CurseForge (minecraft.curseforge.com). A list of bad sites can be found here, with more information available at stopmodreposts.org

Edit your own signature at www.minecraftforge.net/forum/settings/signature/ (Make sure to check its compatibility with the Dark Theme)

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

Announcements



×
×
  • Create New...

Important Information

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