Replace the village window patch with one that effects all windows (Closes #143)

This commit is contained in:
Thinkofdeath 2014-03-30 17:00:57 +01:00
parent b8bbdcfacb
commit b4686b49be
3 changed files with 86 additions and 22 deletions

View File

@ -1,4 +1,4 @@
From 796630458aee1aab9b870fece5ead790d7f0274b Mon Sep 17 00:00:00 2001 From d1cf8a682f9fe9a4a32f7590869243c259db4461 Mon Sep 17 00:00:00 2001
From: md_5 <md_5@live.com.au> From: md_5 <md_5@live.com.au>
Date: Sun, 1 Dec 2013 15:10:48 +1100 Date: Sun, 1 Dec 2013 15:10:48 +1100
Subject: [PATCH] mc-dev imports Subject: [PATCH] mc-dev imports
@ -1888,6 +1888,70 @@ index 0000000..c7b799a
+ this.a((PacketPlayOutListener) packetlistener); + this.a((PacketPlayOutListener) packetlistener);
+ } + }
+} +}
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutOpenWindow.java b/src/main/java/net/minecraft/server/PacketPlayOutOpenWindow.java
new file mode 100644
index 0000000..f6d7b2b
--- /dev/null
+++ b/src/main/java/net/minecraft/server/PacketPlayOutOpenWindow.java
@@ -0,0 +1,58 @@
+package net.minecraft.server;
+
+import java.io.IOException;
+
+public class PacketPlayOutOpenWindow extends Packet {
+
+ private int a;
+ private int b;
+ private String c;
+ private int d;
+ private boolean e;
+ private int f;
+
+ public PacketPlayOutOpenWindow() {}
+
+ public PacketPlayOutOpenWindow(int i, int j, String s, int k, boolean flag) {
+ this.a = i;
+ this.b = j;
+ this.c = s;
+ this.d = k;
+ this.e = flag;
+ }
+
+ public PacketPlayOutOpenWindow(int i, int j, String s, int k, boolean flag, int l) {
+ this(i, j, s, k, flag);
+ this.f = l;
+ }
+
+ public void a(PacketPlayOutListener packetplayoutlistener) {
+ packetplayoutlistener.a(this);
+ }
+
+ public void a(PacketDataSerializer packetdataserializer) throws IOException {
+ this.a = packetdataserializer.readUnsignedByte();
+ this.b = packetdataserializer.readUnsignedByte();
+ this.c = packetdataserializer.c(32);
+ this.d = packetdataserializer.readUnsignedByte();
+ this.e = packetdataserializer.readBoolean();
+ if (this.b == 11) {
+ this.f = packetdataserializer.readInt();
+ }
+ }
+
+ public void b(PacketDataSerializer packetdataserializer) throws IOException {
+ packetdataserializer.writeByte(this.a);
+ packetdataserializer.writeByte(this.b);
+ packetdataserializer.a(this.c);
+ packetdataserializer.writeByte(this.d);
+ packetdataserializer.writeBoolean(this.e);
+ if (this.b == 11) {
+ packetdataserializer.writeInt(this.f);
+ }
+ }
+
+ public void handle(PacketListener packetlistener) {
+ this.a((PacketPlayOutListener) packetlistener);
+ }
+}
diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java diff --git a/src/main/java/net/minecraft/server/RegionFileCache.java b/src/main/java/net/minecraft/server/RegionFileCache.java
new file mode 100644 new file mode 100644
index 0000000..900ed68 index 0000000..900ed68

View File

@ -1,21 +0,0 @@
From bbc9173afbca5aba3c761b7c724618105c63f7cf Mon Sep 17 00:00:00 2001
From: Thinkofdeath <thethinkofdeath@gmail.com>
Date: Sun, 23 Mar 2014 10:53:48 +0000
Subject: [PATCH] Cap villagers' window name to prevent client disconnects
diff --git a/src/main/java/net/minecraft/server/EntityPlayer.java b/src/main/java/net/minecraft/server/EntityPlayer.java
index ca06f60..27f9dc9 100644
--- a/src/main/java/net/minecraft/server/EntityPlayer.java
+++ b/src/main/java/net/minecraft/server/EntityPlayer.java
@@ -755,6 +755,7 @@ public class EntityPlayer extends EntityHuman implements ICrafting {
this.activeContainer.addSlotListener(this);
InventoryMerchant inventorymerchant = ((ContainerMerchant) this.activeContainer).getMerchantInventory();
+ if (s.length() > 32) s = s.substring( 0, 32 ); // Spigot - Cap window name to prevent client disconnects
this.playerConnection.sendPacket(new PacketPlayOutOpenWindow(this.containerCounter, 6, s == null ? "" : s, inventorymerchant.getSize(), s != null));
MerchantRecipeList merchantrecipelist = imerchant.getOffers(this);
--
1.8.5.2.msysgit.0

View File

@ -0,0 +1,21 @@
From d9f3f7223ac926e3c89521a74bec232d41ffd5d6 Mon Sep 17 00:00:00 2001
From: Thinkofdeath <thethinkofdeath@gmail.com>
Date: Sun, 23 Mar 2014 10:53:48 +0000
Subject: [PATCH] Cap window names to prevent client disconnects
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutOpenWindow.java b/src/main/java/net/minecraft/server/PacketPlayOutOpenWindow.java
index f6d7b2b..860592d 100644
--- a/src/main/java/net/minecraft/server/PacketPlayOutOpenWindow.java
+++ b/src/main/java/net/minecraft/server/PacketPlayOutOpenWindow.java
@@ -14,6 +14,7 @@ public class PacketPlayOutOpenWindow extends Packet {
public PacketPlayOutOpenWindow() {}
public PacketPlayOutOpenWindow(int i, int j, String s, int k, boolean flag) {
+ if (s.length() > 32) s = s.substring( 0, 32 ); // Spigot - Cap window name to prevent client disconnects
this.a = i;
this.b = j;
this.c = s;
--
1.8.5.2.msysgit.0