Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-11-19 14:30:16 +01:00
Prevent use of 2nd arm slot, items will get thrown on the ground when used.
Dieser Commit ist enthalten in:
Ursprung
135942c033
Commit
59b270beda
@ -3,16 +3,18 @@ package us.myles.ViaVersion.transformers;
|
|||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.channel.Channel;
|
import io.netty.channel.Channel;
|
||||||
|
import net.minecraft.server.v1_8_R3.ItemStack;
|
||||||
import net.minecraft.server.v1_8_R3.PacketDataSerializer;
|
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.CancelException;
|
||||||
import us.myles.ViaVersion.ConnectionInfo;
|
import us.myles.ViaVersion.ConnectionInfo;
|
||||||
import us.myles.ViaVersion.Core;
|
|
||||||
import us.myles.ViaVersion.PacketUtil;
|
import us.myles.ViaVersion.PacketUtil;
|
||||||
import us.myles.ViaVersion.handlers.ViaVersionInitializer;
|
import us.myles.ViaVersion.handlers.ViaVersionInitializer;
|
||||||
import us.myles.ViaVersion.packets.PacketType;
|
import us.myles.ViaVersion.packets.PacketType;
|
||||||
import us.myles.ViaVersion.packets.State;
|
import us.myles.ViaVersion.packets.State;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class IncomingTransformer {
|
public class IncomingTransformer {
|
||||||
private static Gson gson = new Gson();
|
private static Gson gson = new Gson();
|
||||||
private final Channel channel;
|
private final Channel channel;
|
||||||
@ -72,7 +74,7 @@ public class IncomingTransformer {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(packet == PacketType.PLAY_TAB_COMPLETE_REQUEST){
|
if (packet == PacketType.PLAY_TAB_COMPLETE_REQUEST) {
|
||||||
String text = PacketUtil.readString(input);
|
String text = PacketUtil.readString(input);
|
||||||
PacketUtil.writeString(text, output);
|
PacketUtil.writeString(text, output);
|
||||||
input.readBoolean(); // assume command
|
input.readBoolean(); // assume command
|
||||||
@ -92,6 +94,33 @@ public class IncomingTransformer {
|
|||||||
output.writeByte(face);
|
output.writeByte(face);
|
||||||
return;
|
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) {
|
if (packet == PacketType.PLAY_CLIENT_SETTINGS) {
|
||||||
String locale = PacketUtil.readString(input);
|
String locale = PacketUtil.readString(input);
|
||||||
PacketUtil.writeString(locale, output);
|
PacketUtil.writeString(locale, output);
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren