Hi!
Currently I'm trying to make a Jetpack. But I ran into a quite tricky problem when I decided to make the Jetpack store Energy.
Problem:
If you want to detect if the player who wears the Jetpack is jumping, you need to do all of the velocity and energy reducing stuff on the client because there's no way the server can access the client's gamesettings.
Now, I store the data used to determinate how much energy the Jetpack has left by writing a float with the key "storageValue" to the ItemStacks tagCompound.
if (stack.getTagCompound() != null) {
if (stack.getTagCompound().hasKey("storageVoltage") && stack.getTagCompound().hasKey("storageValue")) {
stack.getTagCompound().setFloat("storageVoltage", storage.getVoltage());
stack.getTagCompound().setFloat("storageValue", storage.getCurrentlyStored().getAmount());
}
}
But because the NBT stuff is done by the Client, the Server does not know if the damage of the item, which is the indicator for how much energy is stored, or if the tagcompound has changed.
So, after I click on the Item, the energy jumps back to full, what is completely logical.
I do have a few guesses how I could fix this. If I set myself to gamemode creative, the serverside storage-value somehow gets updated after the inventory is opened.
So, if I adjust the player's capabilities to match creative (excluding flying), but leave the client's gamemode at survival, there should be a way of controlling your inventory fully even though you're in survival... But how? The values don't get updated even with the adjusted capabilities!
I just wan't to know if there's any way of sending the server the inventory-changes.
Thanks for your help,
Michael