Better container checks (#564)

This commit is contained in:
prplz 2017-01-03 09:16:57 +11:00 committed by Daniel Ennis
parent 13ac2d8ff8
commit 9b9a43e472

View file

@ -0,0 +1,41 @@
From 45fbd09f4c64d743fcd64a514bc60e1fa4214be5 Mon Sep 17 00:00:00 2001
From: Michael Himing <mhiming@gmail.com>
Date: Tue, 3 Jan 2017 08:54:00 +1100
Subject: [PATCH] Better container checks
diff --git a/src/main/java/net/minecraft/server/Container.java b/src/main/java/net/minecraft/server/Container.java
index b826089..704da18 100644
--- a/src/main/java/net/minecraft/server/Container.java
+++ b/src/main/java/net/minecraft/server/Container.java
@@ -461,6 +461,7 @@ public abstract class Container {
}
+ public boolean canPlayerUse(EntityHuman entityhuman) { return a(entityhuman); } // Paper - OBFHELPER
public abstract boolean a(EntityHuman entityhuman);
protected boolean a(ItemStack itemstack, int i, int j, boolean flag) {
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
index e9a8428..a9857d3 100644
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
@@ -1674,6 +1674,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
PlayerConnectionUtils.ensureMainThread(packetplayinwindowclick, this, this.player.x());
if (this.player.isFrozen()) return; // CraftBukkit
this.player.resetIdleTimer();
+ if (!this.player.activeContainer.canPlayerUse(this.player)) return; // Paper - check if player is able to use this container
if (this.player.activeContainer.windowId == packetplayinwindowclick.a() && this.player.activeContainer.c(this.player)) {
boolean cancelled = this.player.isSpectator(); // CraftBukkit - see below if
if (false/*this.player.isSpectator()*/) { // CraftBukkit
@@ -2079,6 +2080,7 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
public void a(PacketPlayInTransaction packetplayintransaction) {
PlayerConnectionUtils.ensureMainThread(packetplayintransaction, this, this.player.x());
if (this.player.isFrozen()) return; // CraftBukkit
+ if (!this.player.activeContainer.canPlayerUse(this.player)) return; // Paper - check if player is able to use this container
Short oshort = (Short) this.k.get(this.player.activeContainer.windowId);
if (oshort != null && packetplayintransaction.b() == oshort.shortValue() && this.player.activeContainer.windowId == packetplayintransaction.a() && !this.player.activeContainer.c(this.player) && !this.player.isSpectator()) {
--
2.9.2.windows.1