|
18 | 18 | */
|
19 | 19 | package com.comphenix.packetwrapper;
|
20 | 20 |
|
| 21 | +import com.comphenix.packetwrapper.util.BackwardsCompatible; |
21 | 22 | import org.bukkit.inventory.ItemStack;
|
22 | 23 |
|
23 | 24 | import com.comphenix.protocol.PacketType;
|
24 | 25 | import com.comphenix.protocol.events.PacketContainer;
|
25 | 26 |
|
| 27 | +@BackwardsCompatible |
26 | 28 | public class WrapperPlayClientWindowClick extends AbstractPacket {
|
27 | 29 | public static final PacketType TYPE = PacketType.Play.Client.WINDOW_CLICK;
|
28 | 30 |
|
@@ -135,14 +137,23 @@ public void setClickedItem(ItemStack value) {
|
135 | 137 | }
|
136 | 138 |
|
137 | 139 | public InventoryClickType getShift() {
|
138 |
| - return handle.getEnumModifier(InventoryClickType.class, 5).read(0); |
| 140 | + return MINOR_VERSION >= 9 |
| 141 | + ? handle.getEnumModifier(InventoryClickType.class, 5).read(0) |
| 142 | + : InventoryClickType.fromId(handle.getIntegers().read(3)); |
139 | 143 | }
|
140 | 144 |
|
141 | 145 | public void setShift(InventoryClickType value) {
|
142 |
| - handle.getEnumModifier(InventoryClickType.class, 5).write(0, value); |
| 146 | + if (MINOR_VERSION >= 9) handle.getEnumModifier(InventoryClickType.class, 5).write(0, value); |
| 147 | + else handle.getIntegers().write(3, value.ordinal()); |
143 | 148 | }
|
144 | 149 |
|
145 | 150 | public enum InventoryClickType {
|
146 | 151 | PICKUP, QUICK_MOVE, SWAP, CLONE, THROW, QUICK_CRAFT, PICKUP_ALL;
|
| 152 | + |
| 153 | + private static final InventoryClickType[] VALUES = values(); |
| 154 | + |
| 155 | + public static InventoryClickType fromId(final int id) { |
| 156 | + return VALUES[id]; |
| 157 | + } |
147 | 158 | }
|
148 | 159 | }
|
0 commit comments