* Removed clearItemUse() from refreshHeldSlot() because offhand
* Use 0 itemUseTime if the player is already using their mainHand and tries to use their offHand as you can only use one hand at a time
* Call clearItemUse() only when not using offhand, also refreshActiveHand
* Removed duplicate check
* fix: painting variants are now ordered and sent to the client correctly
* fix: use equals() to compare Strings
Co-authored-by: mudkip <mudkip@mudkip.dev>
* chore: add comment explaining painting variant check
* chore: improve explanation for painting variant exception
Proper support for "holder" types like this one should be added later.
---------
Co-authored-by: mudkip <mudkip@mudkip.dev>
Mojang is somewhat inconsistent here. It is written over the wire as a var int, but the NBT type is a byte. DFU will coerce an int to a byte when reading so it is compatible to treat it as an int everywhere on our side.
* Duplicate property check
* increased bits per index
* fixed MAX_STATES error
* Block properties are now long, and new test for block state ID conversion
* Block properties are now long, and new test for block state ID conversion
* Block properties are now long, and new test for block state ID conversion
* excessive bits, and assertion fix
---------
Co-authored-by: Matt Worzala <35708499+mworzala@users.noreply.github.com>
fixes an ArrayOutOfBounds packet exploit abusing ClientClickWindowPacket that spams console and could lead to a crash due to excess cpu usage.
java.lang.ArrayIndexOutOfBoundsException: Index -1 out of bounds for length 46 at java.base/jdk.internal.util.Preconditions$2.apply(Preconditions.java:63) at java.base/jdk.internal.util.Preconditions$2.apply(Preconditions.java:60) at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:213) at java.base/jdk.internal.util.Preconditions$4.apply(Preconditions.java:210) at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:98) at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:106) at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:302) at java.base/java.lang.invoke.VarHandleReferences$Array.getVolatile(VarHandleReferences.java:604) at net.minestom.server.inventory.AbstractInventory.getItemStack(AbstractInventory.java:185) at net.minestom.server.inventory.PlayerInventory.changeHeld(PlayerInventory.java:250) at net.minestom.server.listener.WindowListener.clickWindowListener(WindowListener.java:54) at net.minestom.server.listener.manager.PacketListenerManager.lambda$setPlayListener$2(PacketListenerManager.java:163) at net.minestom.server.listener.manager.PacketListenerManager.processClientPacket(PacketListenerManager.java:132) at net.minestom.server.entity.Player.lambda$interpretPacketQueue$12(Player.java:2131) at org.jctools.queues.MpscArrayQueue.drain(MpscArrayQueue.java:512) at net.minestom.server.entity.Player.interpretPacketQueue(Player.java:2131) at java.base/java.util.concurrent.CopyOnWriteArrayList.forEach(CopyOnWriteArrayList.java:891) at java.base/java.util.concurrent.CopyOnWriteArraySet.forEach(CopyOnWriteArraySet.java:425) at net.minestom.server.network.ConnectionManager.tick(ConnectionManager.java:369) at net.minestom.server.ServerProcessImpl$TickerImpl.tick(ServerProcessImpl.java:37