Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

First up, I'd like to apologise as this question likely has an extremely simple and stupid answer, but I've been stuck with this for hours.

 

I am currently developing a mod which uses a Timer in order to remove one durability per second. After a few teething problems, I've got this to work perfectly, and it damages the item of one use per second whilst certain conditions are met. The class which I use for the TimerTask can be seen here.

 

The references "rge.shouldRepair" are from here.

 

The problem I seem to be having is whenever I click on the gem in my inventory whilst debugging, it's state resets to before any damage was taken and also any damage was repaired. I've narrowed this down to the server's version of my inventory overriding my (the client's) version, however I am clueless about how to counter this.

 

I'd assume it has something to do with packets, but I'm not very experienced with packets so I can't say I've tried much there. This is because the server's version of my inventory does not contain the changed damage values.

 

Any and all help appreciated :P And apologies for the terrible coding layout, it's just my style ;)

 

PS. I've tried inv.markDirty();, but it had no effect because this is for tile entities such as chests.

You can find my github repo here :D

You can remove Client-Server sync problem by damaging item only on the Server-side.

Do not use Minecraft.getMinecraft(), since that is for Client-side.

Instead, Just use EntityJoinWorldEvent to start the timer, and store the player in the timer.

I. Stellarium for Minecraft: Configurable Universe for Minecraft! (WIP)

II. Stellar Sky, Better Star Rendering&Sky Utility mod, had separated from Stellarium.

  • Author

You can remove Client-Server sync problem by damaging item only on the Server-side.

Do not use Minecraft.getMinecraft(), since that is for Client-side.

Instead, Just use EntityJoinWorldEvent to start the timer, and store the player in the timer.

 

Ok, thanks, I probably should've realised getMinecraft() would be client side only :P

You can find my github repo here :D

  • Author

You can remove Client-Server sync problem by damaging item only on the Server-side.

Do not use Minecraft.getMinecraft(), since that is for Client-side.

Instead, Just use EntityJoinWorldEvent to start the timer, and store the player in the timer.

 

Same problem occurring. It's still only changing the inventory client side, with the same symptoms. New Event, Task, and RepairGemEvents.

You can find my github repo here :D

  • Author

Ok, thanks, I guess this makes sense now :P

 

So in general, I must stick to the default thread when modding with forge, and I shouldn't use or create new ones?

You can find my github repo here :D

  • Author

Timer creates a new thread. That doesn't work. You need to count ticks with a TickHandler if you want to schedule something.

 

Despite fixing this, the same problem STILL occurs :(

 

I'm pretty sure the problem is something I do here...

 

At this point I've changed so much in the code just ask me for extracts as you see fit. Instead of using a timer I now count ticks, so it's nothing to do with this.

 

You can find my github repo here :D

Just out of curiousity, why are you damaging the item while in invenotry?  What is your mod doing? 

 

Sounds like it could be intetesting.

Long time Bukkit & Forge Programmer

Happy to try and help

  • Author

Well it started as a proof of concept, but specifically the reason I am damaging the item whilst in the inventory is to try and simulate the effect of transferring it to another item. Hence the name RepairGemTask.java :D

 

It transfers one of it's durability points to another damaged item's once a second (or so), and has the same amount of uses as roughly one and a half diamond pickaxes

You can find my github repo here :D

  • Author

If you mean the "mg.p" reference - It's currently part of my debugging on another exception I was getting, and it does only support one player. I think I'll make a List and iterate through.

 

I'll change the world tick now, thanks for notifying me. I'll mess around with it and then push it to github once I'm happy with the changes.

You can find my github repo here :D

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...

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.