Posted April 14, 201411 yr 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 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
April 15, 201411 yr 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.
April 15, 201411 yr 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 You can find my github repo here
April 15, 201411 yr 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
April 15, 201411 yr Author Ok, thanks, I guess this makes sense now 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
April 15, 201411 yr 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
April 15, 201411 yr 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
April 15, 201411 yr 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 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
April 16, 201411 yr 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
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.