Prevent use of 2nd arm slot, items will get thrown on the ground when used.

This commit is contained in:
Myles 2016-02-29 13:15:38 +00:00
parent 135942c033
commit 59b270beda

View File

@ -3,16 +3,18 @@ package us.myles.ViaVersion.transformers;
import com.google.gson.Gson;
import io.netty.buffer.ByteBuf;
import io.netty.channel.Channel;
import net.minecraft.server.v1_8_R3.ItemStack;
import net.minecraft.server.v1_8_R3.PacketDataSerializer;
import org.bukkit.craftbukkit.v1_8_R3.inventory.CraftItemStack;
import net.minecraft.server.v1_8_R3.PacketPlayOutSetSlot;
import us.myles.ViaVersion.CancelException;
import us.myles.ViaVersion.ConnectionInfo;
import us.myles.ViaVersion.Core;
import us.myles.ViaVersion.PacketUtil;
import us.myles.ViaVersion.handlers.ViaVersionInitializer;
import us.myles.ViaVersion.packets.PacketType;
import us.myles.ViaVersion.packets.State;
import java.io.IOException;
public class IncomingTransformer {
private static Gson gson = new Gson();
private final Channel channel;
@ -92,6 +94,33 @@ public class IncomingTransformer {
output.writeByte(face);
return;
}
if (packet == PacketType.PLAY_CLICK_WINDOW) {
// if placed in new slot, reject :)
int windowID = input.readUnsignedByte();
short slot = input.readShort();
byte button = input.readByte();
short action = input.readShort();
byte mode = input.readByte();
PacketDataSerializer pds = new PacketDataSerializer(input);
ItemStack slotItem = null;
try {
slotItem = pds.i();
} catch (IOException e) {
}
if (slot == 45 && windowID == 0) {
channel.writeAndFlush(new PacketPlayOutSetSlot(windowID, slot, null)); // slot is empty
slot = -999; // we're evil, they'll throw item on the ground
}
output.writeByte(windowID);
output.writeShort(slot);
output.writeByte(button);
output.writeShort(action);
output.writeByte(mode);
PacketDataSerializer pdss = new PacketDataSerializer(output);
pdss.a(slotItem);
return;
}
if (packet == PacketType.PLAY_CLIENT_SETTINGS) {
String locale = PacketUtil.readString(input);
PacketUtil.writeString(locale, output);