Hi everyone !
First of all I'd like to apologize about my English, I'm French and I don't speak English fluently yet.
Also, I'd like to add that I began coding with Minecraft Forge 4 days ago, although I have a good experience with Java.
My problem lies in the onUsage() method of a custom item I made, a simple dosimeter that mesure the irradiation dose that the player get by being exposed to radiation sources.
In that method, I use the item NBTTagCompound to store the radiation measure made by another item (a geiger counter) and the irradiation related. I perform (successfuly) the following calculation : irradiation += radiationMeasure. In the code, it looks like this :
Even if the calculation is correctly executed and the mathematical behavior matches my expectations, I have a sort of "bug" or strange behavior in the item. Indeed, my item moves continuously as if it was right-clicked on a block every tick. To show you, I recorded a short video that I posted on my Youtube Channel :
https://www.youtube.com/watch?v=CsxCDbUtz7U
To identify the problem, I tried to store each NBTTagCompound double value in an independant standard Java double variable, and then performed the calculation as follows :
I also tried to perform the operation in a third double value, and to set the "irradiation" value from that variable. As you can guess, I didn't change anything. Concerned by this very weird problem, I tried to perform a simple c = a + b operation in the method without assigning any NBTTagCompound with the result, just as I would do in a simple Java console program, and then of course the movement stopped (as the item NBTTagCompound values weren't modified).
Here is my full ItemDosimeter.java file :
Does anyone of you have an idea why that happens ? And possibly a solution ?
Thank you for reading, and sorry if I missed a post in the past that talked about this problem already. As I said my English isn't perfect yet and maybe I didn't search for the right thing before to post.
SteriCraft