Handle new Llama inventory

This commit is contained in:
Matsv 2017-06-08 15:31:34 +02:00
parent 7fda9dba0d
commit 67d3eef37a
No known key found for this signature in database
GPG Key ID: 97CEC2A2EA31350F
12 changed files with 365 additions and 21 deletions

View File

@ -12,8 +12,9 @@ package nl.matsv.viabackwards.api.entities.meta;
import lombok.AllArgsConstructor;
import lombok.Getter;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
import nl.matsv.viabackwards.api.entities.storage.MetaStorage;
import nl.matsv.viabackwards.api.entities.types.AbstractEntityType;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import java.util.Optional;
@ -21,7 +22,8 @@ import java.util.Optional;
@Getter
@AllArgsConstructor
public class MetaHandlerEvent {
private AbstractEntityType type;
private UserConnection user;
private EntityTracker.StoredEntity entity;
private int index = -1;
private Metadata data;
@Getter

View File

@ -0,0 +1,14 @@
/*
* Copyright (c) 2016 Matsv
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package nl.matsv.viabackwards.api.entities.storage;
public class EntityStorage {
}

View File

@ -10,6 +10,9 @@
package nl.matsv.viabackwards.api.entities.storage;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import lombok.ToString;
import nl.matsv.viabackwards.api.BackwardsProtocol;
import nl.matsv.viabackwards.api.entities.types.AbstractEntityType;
import us.myles.ViaVersion.api.data.StoredObject;
@ -34,12 +37,12 @@ public class EntityTracker extends StoredObject {
}
public class ProtocolEntityTracker {
private Map<Integer, AbstractEntityType> entityMap = new ConcurrentHashMap<>();
private Map<Integer, StoredEntity> entityMap = new ConcurrentHashMap<>();
public void trackEntityType(int id, AbstractEntityType type) {
if (entityMap.containsKey(id))
return;
entityMap.put(id, type);
entityMap.put(id, new StoredEntity(id, type));
}
public void removeEntity(int id) {
@ -47,6 +50,12 @@ public class EntityTracker extends StoredObject {
}
public AbstractEntityType getEntityType(int id) {
if (containsEntity(id))
return getEntity(id).getType();
return null;
}
public StoredEntity getEntity(int id) {
return entityMap.get(id);
}
@ -54,4 +63,43 @@ public class EntityTracker extends StoredObject {
return entityMap.containsKey(id);
}
}
@RequiredArgsConstructor
@Getter
@ToString
public class StoredEntity {
private final int entityId;
private final AbstractEntityType type;
Map<Class<? extends EntityStorage>, EntityStorage> storedObjects = new ConcurrentHashMap<>();
/**
* Get an object from the storage
*
* @param objectClass The class of the object to get
* @param <T> The type of the class you want to get.
* @return The requested object
*/
public <T extends EntityStorage> T get(Class<T> objectClass) {
return (T) storedObjects.get(objectClass);
}
/**
* Check if the storage has an object
*
* @param objectClass The object class to check
* @return True if the object is in the storage
*/
public boolean has(Class<? extends EntityStorage> objectClass) {
return storedObjects.containsKey(objectClass);
}
/**
* Put an object into the stored objects based on class
*
* @param object The object to store.
*/
public void put(EntityStorage object) {
storedObjects.put(object.getClass(), object);
}
}
}

View File

@ -85,7 +85,6 @@ public abstract class BlockItemRewriter<T extends BackwardsProtocol> extends Rew
// Remove data tag
tag.remove("ViaBackwards|" + getProtocolName());
}
System.out.println("TO_SERVER: " + item);
return item;
}

View File

@ -86,9 +86,8 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
}
protected MetaStorage handleMeta(UserConnection user, int entityId, MetaStorage storage) throws Exception {
EntityTracker tracker = user.get(EntityTracker.class);
AbstractEntityType type = tracker.get(getProtocol()).getEntityType(entityId);
EntityTracker.StoredEntity entity = getEntityTracker(user).getEntity(entityId);
AbstractEntityType type = entity.getType();
List<Metadata> newList = new CopyOnWriteArrayList<>();
@ -97,7 +96,7 @@ public abstract class EntityRewriter<T extends BackwardsProtocol> extends Rewrit
Metadata nmd = md;
try {
if (settings.isGucci(type, nmd))
nmd = settings.getHandler().handle(new MetaHandlerEvent(type, nmd.getId(), nmd, storage));
nmd = settings.getHandler().handle(new MetaHandlerEvent(user, entity, nmd.getId(), nmd, storage));
if (nmd == null)
throw new RemovedValueException();

View File

@ -17,6 +17,7 @@ import nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets.BlockItemPacket
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets.EntityPackets;
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets.PlayerPackets;
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets.SoundPackets;
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage.WindowTracker;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
@ -42,6 +43,9 @@ public class Protocol1_10To1_11 extends BackwardsProtocol {
if (!user.has(EntityTracker.class))
user.put(new EntityTracker(user));
if (!user.has(WindowTracker.class))
user.put(new WindowTracker(user));
// Init protocol in EntityTracker
user.get(EntityTracker.class).initProtocol(this);
}

View File

@ -10,11 +10,16 @@
package nl.matsv.viabackwards.protocol.protocol1_10to1_11.packets;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
import nl.matsv.viabackwards.api.entities.types.EntityType1_11;
import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter;
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.EntityTypeNames;
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage.ChestedHorseStorage;
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage.WindowTracker;
import nl.matsv.viabackwards.utils.Block;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_9;
@ -28,6 +33,9 @@ import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
import us.myles.viaversion.libs.opennbt.tag.builtin.CompoundTag;
import us.myles.viaversion.libs.opennbt.tag.builtin.StringTag;
import java.util.Arrays;
import java.util.Optional;
public class BlockItemPackets extends BlockItemRewriter<Protocol1_10To1_11> {
@Override
protected void registerPackets(Protocol1_10To1_11 protocol) {
@ -48,6 +56,22 @@ public class BlockItemPackets extends BlockItemRewriter<Protocol1_10To1_11> {
wrapper.set(Type.ITEM, 0, handleItemToClient(stack));
}
});
// Handle Llama
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
if (isLlama(wrapper.user())) {
Optional<ChestedHorseStorage> horse = getChestedHorse(wrapper.user());
if (!horse.isPresent())
return;
ChestedHorseStorage storage = horse.get();
int currentSlot = wrapper.get(Type.SHORT, 0);
wrapper.set(Type.SHORT, 0, ((Integer) (currentSlot = getNewSlotId(storage, currentSlot))).shortValue());
wrapper.set(Type.ITEM, 0, getNewItem(storage, currentSlot, wrapper.get(Type.ITEM, 0)));
}
}
});
}
});
@ -64,6 +88,20 @@ public class BlockItemPackets extends BlockItemRewriter<Protocol1_10To1_11> {
Item[] stacks = wrapper.get(Type.ITEM_ARRAY, 0);
for (int i = 0; i < stacks.length; i++)
stacks[i] = handleItemToClient(stacks[i]);
if (isLlama(wrapper.user())) {
Optional<ChestedHorseStorage> horse = getChestedHorse(wrapper.user());
if (!horse.isPresent())
return;
ChestedHorseStorage storage = horse.get();
stacks = Arrays.copyOf(stacks, !storage.isChested() ? 38 : 53);
for (int i = stacks.length - 1; i >= 0; i--) {
stacks[getNewSlotId(storage, i)] = stacks[i];
stacks[i] = getNewItem(storage, i, stacks[i]);
}
wrapper.set(Type.ITEM_ARRAY, 0, stacks);
}
}
});
}
@ -136,6 +174,23 @@ public class BlockItemPackets extends BlockItemRewriter<Protocol1_10To1_11> {
handleItemToServer(item);
}
});
// Llama slot
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
if (isLlama(wrapper.user())) {
Optional<ChestedHorseStorage> horse = getChestedHorse(wrapper.user());
if (!horse.isPresent())
return;
ChestedHorseStorage storage = horse.get();
int clickSlot = wrapper.get(Type.SHORT, 0);
int correctSlot = getOldSlotId(storage, clickSlot);
wrapper.set(Type.SHORT, 0, ((Integer) correctSlot).shortValue());
}
}
});
}
}
);
@ -247,6 +302,70 @@ public class BlockItemPackets extends BlockItemRewriter<Protocol1_10To1_11> {
}
});
// Open window packet
protocol.registerOutgoing(State.PLAY, 0x13, 0x13, new PacketRemapper() {
@Override
public void registerMap() {
map(Type.UNSIGNED_BYTE); // 0 - Window ID
map(Type.STRING); // 1 - Window Type
map(Type.STRING); // 2 - Title
map(Type.UNSIGNED_BYTE); // 3 - Slots
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
int entityId = -1;
// Passthrough Entity ID
if (wrapper.get(Type.STRING, 0).equals("EntityHorse"))
entityId = wrapper.passthrough(Type.INT);
// Track Inventory
String inventory = wrapper.get(Type.STRING, 0);
WindowTracker windowTracker = wrapper.user().get(WindowTracker.class);
windowTracker.setInventory(inventory);
windowTracker.setEntityId(entityId);
// Change llama slotcount to the donkey one
if (isLlama(wrapper.user()))
wrapper.set(Type.UNSIGNED_BYTE, 1, (short) 17);
}
});
}
});
// Close Window Packet
protocol.registerOutgoing(State.PLAY, 0x12, 0x12, new PacketRemapper() {
@Override
public void registerMap() {
// Inventory tracking
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
WindowTracker windowTracker = wrapper.user().get(WindowTracker.class);
windowTracker.setInventory(null);
windowTracker.setEntityId(-1);
}
});
}
});
// Close Window Incoming Packet
protocol.registerIncoming(State.PLAY, 0x08, 0x08, new PacketRemapper() {
@Override
public void registerMap() {
// Inventory tracking
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
WindowTracker windowTracker = wrapper.user().get(WindowTracker.class);
windowTracker.setInventory(null);
windowTracker.setEntityId(-1);
}
});
}
});
protocol.getEntityPackets().registerMetaHandler().handle(e -> {
Metadata data = e.getData();
@ -292,4 +411,66 @@ public class BlockItemPackets extends BlockItemRewriter<Protocol1_10To1_11> {
rewrite(450).repItem(new Item((short) 433, (byte) 1, (short) 0, getNamedTag("1.11 Shulker Shell")));
}
private boolean isLlama(UserConnection user) {
WindowTracker tracker = user.get(WindowTracker.class);
if (tracker.getInventory() != null && tracker.getInventory().equals("EntityHorse")) {
System.out.println(tracker + " tracker");
EntityTracker.ProtocolEntityTracker entTracker = user.get(EntityTracker.class).get(getProtocol());
if (tracker.getEntityId() != -1 && entTracker.getEntity(tracker.getEntityId()).getType().is(EntityType1_11.EntityType.LIAMA))
return true;
}
return false;
}
private Optional<ChestedHorseStorage> getChestedHorse(UserConnection user) {
WindowTracker tracker = user.get(WindowTracker.class);
if (tracker.getInventory() != null && tracker.getInventory().equals("EntityHorse")) {
EntityTracker.ProtocolEntityTracker entTracker = user.get(EntityTracker.class).get(getProtocol());
if (tracker.getEntityId() != -1)
return Optional.of(entTracker.getEntity(tracker.getEntityId()).get(ChestedHorseStorage.class));
}
return Optional.empty();
}
// TODO improve the llama inventory part
public int getNewSlotId(ChestedHorseStorage storage, int slotId) {
int totalSlots = !storage.isChested() ? 38 : 53;
int strength = storage.isChested() ? storage.getLiamaStrength() : 0;
int startNonExistingFormula = 2 + 3 * strength;
int offsetForm = 15 - (3 * strength);
if (slotId >= startNonExistingFormula && totalSlots > (slotId + offsetForm))
return offsetForm + slotId;
if (slotId == 1)
return 0;
return slotId;
}
public int getOldSlotId(ChestedHorseStorage storage, int slotId) {
int strength = storage.isChested() ? storage.getLiamaStrength() : 0;
int startNonExistingFormula = 2 + 3 * strength;
int endNonExistingFormula = 2 + 3 * (storage.isChested() ? 5 : 0);
int offsetForm = 15 - (3 * strength);
if (slotId == 1 || slotId >= startNonExistingFormula && slotId < endNonExistingFormula)
return 0;
if (slotId >= endNonExistingFormula)
return slotId - offsetForm;
if (slotId == 0)
return 1;
return slotId;
}
public Item getNewItem(ChestedHorseStorage storage, int slotId, Item current) {
int strength = storage.isChested() ? storage.getLiamaStrength() : 0;
int startNonExistingFormula = 2 + 3 * strength;
int endNonExistingFormula = 2 + 3 * (storage.isChested() ? 5 : 0);
if (slotId >= startNonExistingFormula && slotId < endNonExistingFormula)
return new Item((short) 166, (byte) 1, (short) 0, getNamedTag("NOT IN USE"));
if (slotId == 1)
return null;
return current;
}
}

View File

@ -17,6 +17,7 @@ import nl.matsv.viabackwards.api.entities.types.AbstractEntityType;
import nl.matsv.viabackwards.api.exceptions.RemovedValueException;
import nl.matsv.viabackwards.api.rewriters.EntityRewriter;
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.Protocol1_10To1_11;
import nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage.ChestedHorseStorage;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
@ -399,7 +400,7 @@ public class EntityPackets extends EntityRewriter<Protocol1_10To1_11> {
boolean b = (boolean) data.getValue();
int bitmask = b ? 0x02 : 0;
if (e.getType().is(EntityType.ELDER_GUARDIAN))
if (e.getEntity().getType().is(EntityType.ELDER_GUARDIAN))
bitmask |= 0x04;
data.setMetaType(MetaType1_9.Byte);
@ -472,17 +473,21 @@ public class EntityPackets extends EntityRewriter<Protocol1_10To1_11> {
registerMetaHandler().filter(EntityType.ABSTRACT_HORSE, true, 13).handle(e -> {
Metadata data = e.getData();
byte b = (byte) data.getValue();
Optional<Metadata> chest = e.getMetaByIndex(15);
if (chest.isPresent()) {
boolean hasChest = (boolean) chest.get().getValue();
if (hasChest)
b |= 0x08; // Chested
if (e.getEntity().has(ChestedHorseStorage.class) &&
e.getEntity().get(ChestedHorseStorage.class).isChested()) {
b |= 0x08; // Chested
data.setValue(b);
}
return data;
});
// Create chested horse storage TODO create on mob spawn?
registerMetaHandler().filter(EntityType.CHESTED_HORSE, true).handle(e -> {
if (!e.getEntity().has(ChestedHorseStorage.class))
e.getEntity().put(new ChestedHorseStorage());
return e.getData();
});
// Handle Horse (Correct owner)
registerMetaHandler().filter(EntityType.ABSTRACT_HORSE, true, 14).handleIndexChange(16);
@ -490,13 +495,32 @@ public class EntityPackets extends EntityRewriter<Protocol1_10To1_11> {
registerMetaHandler().filter(EntityType.HORSE, 16).handleIndexChange(17);
// Handle chested horse
registerMetaHandler().filter(EntityType.CHESTED_HORSE, true, 15).removed();
registerMetaHandler().filter(EntityType.CHESTED_HORSE, true, 15).handle(e -> {
ChestedHorseStorage storage = e.getEntity().get(ChestedHorseStorage.class);
boolean b = (boolean) e.getData().getValue();
storage.setChested(b);
// Get rid of Liama metadata TODO maybe for some special magic in the future?
throw new RemovedValueException();
});
// Get rid of Liama metadata
registerMetaHandler().filter(EntityType.LIAMA).handle(e -> {
Metadata data = e.getData();
ChestedHorseStorage storage = e.getEntity().get(ChestedHorseStorage.class);
int index = e.getIndex();
if (index == 16 || index == 17 || index == 18)
throw new RemovedValueException();
// Store them for later (:
switch (index) {
case 16:
storage.setLiamaStrength((int) data.getValue());
throw new RemovedValueException();
case 17:
storage.setLiamaCarpetColor((int) data.getValue());
throw new RemovedValueException();
case 18:
storage.setLiamaVariant((int) data.getValue());
throw new RemovedValueException();
}
return e.getData();
});

View File

@ -0,0 +1,27 @@
/*
* Copyright (c) 2016 Matsv
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import nl.matsv.viabackwards.api.entities.storage.EntityStorage;
@Getter
@Setter
@ToString
public class ChestedHorseStorage extends EntityStorage {
private boolean chested = false;
private int liamaStrength = 0;
private int liamaCarpetColor = -1;
private int liamaVariant = 0;
}

View File

@ -0,0 +1,30 @@
/*
* Copyright (c) 2016 Matsv
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
package nl.matsv.viabackwards.protocol.protocol1_10to1_11.storage;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion.api.data.UserConnection;
@Getter
@ToString
@Setter
public class WindowTracker extends StoredObject {
private String inventory;
private int entityId = -1;
public WindowTracker(UserConnection user) {
super(user);
}
}

View File

@ -10,6 +10,7 @@
package nl.matsv.viabackwards.protocol.protocol1_11to1_11_1;
import lombok.Getter;
import nl.matsv.viabackwards.api.BackwardsProtocol;
import nl.matsv.viabackwards.api.entities.storage.EntityTracker;
import nl.matsv.viabackwards.protocol.protocol1_11to1_11_1.packets.EntityPackets;
@ -17,10 +18,13 @@ import nl.matsv.viabackwards.protocol.protocol1_11to1_11_1.packets.ItemPackets;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
@Getter
public class Protocol1_11To1_11_1 extends BackwardsProtocol {
private EntityPackets entityPackets;
@Override
protected void registerPackets() {
new EntityPackets().register(this);
(entityPackets = new EntityPackets()).register(this);
new ItemPackets().register(this);
}

View File

@ -14,6 +14,8 @@ import nl.matsv.viabackwards.api.rewriters.BlockItemRewriter;
import nl.matsv.viabackwards.protocol.protocol1_11to1_11_1.Protocol1_11To1_11_1;
import us.myles.ViaVersion.api.PacketWrapper;
import us.myles.ViaVersion.api.minecraft.item.Item;
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_9;
import us.myles.ViaVersion.api.remapper.PacketHandler;
import us.myles.ViaVersion.api.remapper.PacketRemapper;
import us.myles.ViaVersion.api.type.Type;
@ -147,6 +149,16 @@ public class ItemPackets extends BlockItemRewriter<Protocol1_11To1_11_1> {
}
}
);
// Handle item metadata
protocol.getEntityPackets().registerMetaHandler().handle(e -> {
Metadata data = e.getData();
if (data.getMetaType().equals(MetaType1_9.Slot)) // Is Item
data.setValue(handleItemToClient((Item) data.getValue()));
return data;
});
}
@Override