3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-11-09 17:50:23 +01:00

Merge fix for duplicated events for placement

Dieser Commit ist enthalten in:
Myles 2016-03-23 13:41:11 +00:00
Commit 95ceabb495

Datei anzeigen

@ -1,5 +1,6 @@
package us.myles.ViaVersion.protocols.protocol1_9to1_8.packets; package us.myles.ViaVersion.protocols.protocol1_9to1_8.packets;
import org.bukkit.Material;
import org.spacehq.opennbt.tag.builtin.CompoundTag; import org.spacehq.opennbt.tag.builtin.CompoundTag;
import org.spacehq.opennbt.tag.builtin.StringTag; import org.spacehq.opennbt.tag.builtin.StringTag;
import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.PacketWrapper;
@ -226,13 +227,29 @@ public class WorldPackets {
@Override @Override
public void write(PacketWrapper wrapper) throws Exception { public void write(PacketWrapper wrapper) throws Exception {
Item item = Item.getItem(Protocol1_9TO1_8.getHandItem(wrapper.user())); Item item = Item.getItem(Protocol1_9TO1_8.getHandItem(wrapper.user()));
wrapper.write(Type.ITEM, item); wrapper.write(Type.ITEM, item); // 3 - Item
} }
}); });
map(Type.UNSIGNED_BYTE); // 4 - X map(Type.UNSIGNED_BYTE); // 4 - X
map(Type.UNSIGNED_BYTE); // 5 - Y map(Type.UNSIGNED_BYTE); // 5 - Y
map(Type.UNSIGNED_BYTE); // 6 - Z map(Type.UNSIGNED_BYTE); // 6 - Z
// Cancel if item as 1.9 uses Use_Item packet
handler(new PacketHandler() {
@Override
public void handle(PacketWrapper wrapper) throws Exception {
Item item = wrapper.get(Type.ITEM, 0);
if (item != null) {
Material m = Material.getMaterial(item.getId());
if (m != null) {
if (!m.isBlock()) {
wrapper.cancel();
}
}
}
}
});
} }
}); });
} }