Hello, I am trying to remove 1 Durability from the Current Durability of an Item but I fail... Im using: Code (Java): itemInHand.setDurability((short) (itemInHand.getDurability() -1)); Any idea how i can fix this ? Im using 1.12.2
i think durability should count upwards, iE the more durability you have the closer the item is to breaking.
Why don't you read the Javadoc and see why the method is deprecated. Use the alternatives. Don't know about the durability (deprecated), but with damage (not deprecated) it's correct.
This interface was already present a long time ago. So this works. Edit: Wow was the API shitty before flattening. Forgot that since it is multiple years ago.
I think it should work. If it doesn't, the method was probably not deprecated at the time and @Blutkrone's point is what you're looking for. (Or you have an issue with the code)
When im doing: Code (Java): final Damageable dmg = (Damageable) itemInHand.getItemMeta() ((EntityDamageEvent) dmg).setDamage(((EntityDamageEvent) dmg).getDamage() - 1); im getting this error: Code (Text): [12:27:17 ERROR]: Could not pass event PlayerInteractEvent to Airsoft v1.0 org.bukkit.event.EventException: null at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) ~[spigot.jar:git-Spigot-dcd1643-e60fc34] at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[spigot.jar:git-Spigot-dcd1643-e60fc34] at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:500) [spigot.jar:git-Spigot-dcd1643-e60fc34] at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:485) [spigot.jar:git-Spigot-dcd1643-e60fc34] at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:235) [spigot.jar:git-Spigot-dcd1643-e60fc34] at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:202) [spigot.jar:git-Spigot-dcd1643-e60fc34] at org.bukkit.craftbukkit.v1_12_R1.event.CraftEventFactory.callPlayerInteractEvent(CraftEventFactory.java:198) [spigot.jar:git-Spigot-dcd1643-e60fc34] at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:991) [spigot.jar:git-Spigot-dcd1643-e60fc34] at net.minecraft.server.v1_12_R1.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:26) [spigot.jar:git-Spigot-dcd1643-e60fc34] at net.minecraft.server.v1_12_R1.PacketPlayInBlockPlace.a(PacketPlayInBlockPlace.java:1) [spigot.jar:git-Spigot-dcd1643-e60fc34] at net.minecraft.server.v1_12_R1.PlayerConnectionUtils$1.run(SourceFile:13) [spigot.jar:git-Spigot-dcd1643-e60fc34] at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_231] at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_231] at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [spigot.jar:git-Spigot-dcd1643-e60fc34] at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:748) [spigot.jar:git-Spigot-dcd1643-e60fc34] at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:406) [spigot.jar:git-Spigot-dcd1643-e60fc34] at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:679) [spigot.jar:git-Spigot-dcd1643-e60fc34] at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:577) [spigot.jar:git-Spigot-dcd1643-e60fc34] at java.lang.Thread.run(Unknown Source) [?:1.8.0_231] Caused by: java.lang.ClassCastException: org.bukkit.craftbukkit.v1_12_R1.inventory.CraftMetaItem cannot be cast to org.bukkit.entity.Damageable at de.th3wh1teg0d.guns.Weapon.onInteract(Weapon.java:49) ~[?:?] at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_231] at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_231] at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_231] at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_231] at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:302) ~[spigot.jar:git-Spigot-dcd1643-e60fc34] ... 18 more
This is the class you need. 1.12 is not supported by spigot, and no one here is going to dig for old methods to do it in 1.12. If you want to use a long outdated version, you will have to do the research on your own. There are some websites that hold outdated javadocs.
The fact that people are using even older versions doesn't mean 1.12 isn't outdated, it's from 2+ years now and much has changed.