Do not allow negative count itemstacks (infinite itemstacks)
Should work around quite a few issues and this 'feature' is relatively worthless anyway
Dieser Commit ist enthalten in:
Ursprung
ed8119ad4d
Commit
5460c17f8a
@ -300,6 +300,91 @@ index 0000000..7b6f8ae
|
|||||||
+
|
+
|
||||||
+ }
|
+ }
|
||||||
+}
|
+}
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/Slot.java b/src/main/java/net/minecraft/server/Slot.java
|
||||||
|
new file mode 100644
|
||||||
|
index 0000000..375989f
|
||||||
|
--- /dev/null
|
||||||
|
+++ b/src/main/java/net/minecraft/server/Slot.java
|
||||||
|
@@ -0,0 +1,79 @@
|
||||||
|
+package net.minecraft.server;
|
||||||
|
+
|
||||||
|
+public class Slot {
|
||||||
|
+
|
||||||
|
+ public final int index;
|
||||||
|
+ public final IInventory inventory;
|
||||||
|
+ public int rawSlotIndex;
|
||||||
|
+ public int f;
|
||||||
|
+ public int g;
|
||||||
|
+
|
||||||
|
+ public Slot(IInventory iinventory, int i, int j, int k) {
|
||||||
|
+ this.inventory = iinventory;
|
||||||
|
+ this.index = i;
|
||||||
|
+ this.f = j;
|
||||||
|
+ this.g = k;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void a(ItemStack itemstack, ItemStack itemstack1) {
|
||||||
|
+ if (itemstack != null && itemstack1 != null) {
|
||||||
|
+ if (itemstack.getItem() == itemstack1.getItem()) {
|
||||||
|
+ int i = itemstack1.count - itemstack.count;
|
||||||
|
+
|
||||||
|
+ if (i > 0) {
|
||||||
|
+ this.a(itemstack, i);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ protected void a(ItemStack itemstack, int i) {}
|
||||||
|
+
|
||||||
|
+ protected void c(ItemStack itemstack) {}
|
||||||
|
+
|
||||||
|
+ public void a(EntityHuman entityhuman, ItemStack itemstack) {
|
||||||
|
+ this.f();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public boolean isAllowed(ItemStack itemstack) {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public ItemStack getItem() {
|
||||||
|
+ return this.inventory.getItem(this.index);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public boolean hasItem() {
|
||||||
|
+ return this.getItem() != null;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void set(ItemStack itemstack) {
|
||||||
|
+ this.inventory.setItem(this.index, itemstack);
|
||||||
|
+ this.f();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public void f() {
|
||||||
|
+ this.inventory.update();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public int getMaxStackSize() {
|
||||||
|
+ return this.inventory.getMaxStackSize();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public int getMaxStackSize(ItemStack itemstack) {
|
||||||
|
+ return this.getMaxStackSize();
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public ItemStack a(int i) {
|
||||||
|
+ return this.inventory.splitStack(this.index, i);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public boolean a(IInventory iinventory, int i) {
|
||||||
|
+ return iinventory == this.inventory && i == this.index;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ public boolean isAllowed(EntityHuman entityhuman) {
|
||||||
|
+ return true;
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
--
|
--
|
||||||
1.9.1
|
1.9.1
|
||||||
|
|
||||||
|
@ -0,0 +1,154 @@
|
|||||||
|
From c6d478b50d868bef21254e0d81e0600171510315 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Aikar <aikar@aikar.co>
|
||||||
|
Date: Fri, 19 Dec 2014 16:28:22 -0600
|
||||||
|
Subject: [PATCH] Remove CraftBukkit "Feature" of ItemStack's having infinite
|
||||||
|
use if less than 0 stack size
|
||||||
|
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/DispenseBehaviorItem.java b/src/main/java/net/minecraft/server/DispenseBehaviorItem.java
|
||||||
|
index 2450265..ea9b20c 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/DispenseBehaviorItem.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/DispenseBehaviorItem.java
|
||||||
|
@@ -10,6 +10,7 @@ public class DispenseBehaviorItem implements IDispenseBehavior {
|
||||||
|
public DispenseBehaviorItem() {}
|
||||||
|
|
||||||
|
public final ItemStack a(ISourceBlock isourceblock, ItemStack itemstack) {
|
||||||
|
+ if (itemstack != null && itemstack.count < 0) itemstack.count = 0; // PaperSpigot - Remove CB 'feature' of infinite items
|
||||||
|
ItemStack itemstack1 = this.b(isourceblock, itemstack);
|
||||||
|
|
||||||
|
this.a(isourceblock);
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/EntityAgeable.java b/src/main/java/net/minecraft/server/EntityAgeable.java
|
||||||
|
index 23091bd..930682a 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/EntityAgeable.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/EntityAgeable.java
|
||||||
|
@@ -60,7 +60,7 @@ public abstract class EntityAgeable extends EntityCreature {
|
||||||
|
|
||||||
|
if (!entityhuman.abilities.canInstantlyBuild) {
|
||||||
|
--itemstack.count;
|
||||||
|
- if (itemstack.count == 0) { // CraftBukkit - allow less than 0 stacks as "infinite"
|
||||||
|
+ if (itemstack.count <= 0) { // PaperSpigot - Remove CB 'feature' of infinite items
|
||||||
|
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/EntityHorse.java b/src/main/java/net/minecraft/server/EntityHorse.java
|
||||||
|
index 326c043..f93a291 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/EntityHorse.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/EntityHorse.java
|
||||||
|
@@ -635,7 +635,7 @@ public class EntityHorse extends EntityAnimal implements IInventoryListener {
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flag) {
|
||||||
|
- if (!entityhuman.abilities.canInstantlyBuild && --itemstack.count == 0) {
|
||||||
|
+ if (!entityhuman.abilities.canInstantlyBuild && --itemstack.count <= 0) { // PaperSpigot - Remove CB 'feature' of infinite items
|
||||||
|
entityhuman.inventory.setItem(entityhuman.inventory.itemInHandIndex, (ItemStack) null);
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
|
||||||
|
index 0199856..4f3bc3c 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
||||||
|
@@ -563,7 +563,7 @@ public abstract class EntityHuman extends EntityLiving {
|
||||||
|
public EntityItem a(ItemStack itemstack, boolean flag, boolean flag1) {
|
||||||
|
if (itemstack == null) {
|
||||||
|
return null;
|
||||||
|
- } else if (itemstack.count == 0) {
|
||||||
|
+ } else if (itemstack.count <= 0) { // PaperSpigot - Remove CB 'feature' of infinite items
|
||||||
|
return null;
|
||||||
|
} else {
|
||||||
|
double d0 = this.locY - 0.30000001192092896D + (double) this.getHeadHeight();
|
||||||
|
@@ -920,7 +920,7 @@ public abstract class EntityHuman extends EntityLiving {
|
||||||
|
|
||||||
|
if (itemstack.a(this, (EntityLiving) entity)) {
|
||||||
|
// CraftBukkit - bypass infinite items; <= 0 -> == 0
|
||||||
|
- if (itemstack.count == 0 && !this.abilities.canInstantlyBuild) {
|
||||||
|
+ if (itemstack.count <= 0 && !this.abilities.canInstantlyBuild) { // PaperSpigot - Remove CB 'feature' of infinite items
|
||||||
|
this.bZ();
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
|
||||||
|
index e5af375..4084dd3 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/ItemStack.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/ItemStack.java
|
||||||
|
@@ -73,6 +73,7 @@ public final class ItemStack {
|
||||||
|
ItemStack itemstack = new ItemStack();
|
||||||
|
|
||||||
|
itemstack.c(nbttagcompound);
|
||||||
|
+ if (itemstack.count < 0) itemstack.count = 0; // PaperSpigot - Remove CB 'feature' of infinite items
|
||||||
|
return itemstack.getItem() != null ? itemstack : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||||
|
index 3b4bb3f..8d97824 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||||
|
@@ -735,7 +735,7 @@ public class PlayerConnection implements PacketListenerPlayIn, IUpdatePlayerList
|
||||||
|
}
|
||||||
|
|
||||||
|
itemstack = this.player.inventory.getItemInHand();
|
||||||
|
- if (itemstack != null && itemstack.count == 0) {
|
||||||
|
+ if (itemstack != null && itemstack.count <= 0) { // PaperSpigot - Remove CB 'feature' of infinite items
|
||||||
|
this.player.inventory.items[this.player.inventory.itemInHandIndex] = null;
|
||||||
|
itemstack = null;
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/PlayerInteractManager.java b/src/main/java/net/minecraft/server/PlayerInteractManager.java
|
||||||
|
index a13610e..2012ebd 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/PlayerInteractManager.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/PlayerInteractManager.java
|
||||||
|
@@ -342,7 +342,7 @@ public class PlayerInteractManager {
|
||||||
|
|
||||||
|
if (itemstack1 != null) {
|
||||||
|
itemstack1.a(this.world, iblockdata.getBlock(), blockposition, this.player);
|
||||||
|
- if (itemstack1.count == 0) {
|
||||||
|
+ if (itemstack1.count <= 0) { // PaperSpigot - Remove CB 'feature' of infinite items
|
||||||
|
this.player.bZ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -381,7 +381,7 @@ public class PlayerInteractManager {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (itemstack1.count == 0) {
|
||||||
|
+ if (itemstack1.count <= 0) { // PaperSpigot - Remove CB 'feature' of infinite items
|
||||||
|
entityhuman.inventory.items[entityhuman.inventory.itemInHandIndex] = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/PlayerInventory.java b/src/main/java/net/minecraft/server/PlayerInventory.java
|
||||||
|
index 1c27843..ea593e5 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/PlayerInventory.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/PlayerInventory.java
|
||||||
|
@@ -515,7 +515,7 @@ public class PlayerInventory implements IInventory {
|
||||||
|
|
||||||
|
public ItemStack getCarried() {
|
||||||
|
// CraftBukkit start
|
||||||
|
- if (this.f != null && this.f.count == 0) {
|
||||||
|
+ if (this.f != null && this.f.count <= 0) { // PaperSpigot - Remove CB 'feature' of infinite items
|
||||||
|
this.setCarried(null);
|
||||||
|
}
|
||||||
|
// CraftBukkit end
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/Slot.java b/src/main/java/net/minecraft/server/Slot.java
|
||||||
|
index 375989f..42d6dcf 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/Slot.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/Slot.java
|
||||||
|
@@ -49,6 +49,7 @@ public class Slot {
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(ItemStack itemstack) {
|
||||||
|
+ if (itemstack != null && itemstack.count < 0) itemstack.count = 0; // PaperSpigot - Remove CB 'feature' of infinite items
|
||||||
|
this.inventory.setItem(this.index, itemstack);
|
||||||
|
this.f();
|
||||||
|
}
|
||||||
|
diff --git a/src/main/java/net/minecraft/server/TileEntityDispenser.java b/src/main/java/net/minecraft/server/TileEntityDispenser.java
|
||||||
|
index 040a69f..3269d39 100644
|
||||||
|
--- a/src/main/java/net/minecraft/server/TileEntityDispenser.java
|
||||||
|
+++ b/src/main/java/net/minecraft/server/TileEntityDispenser.java
|
||||||
|
@@ -100,6 +100,7 @@ public class TileEntityDispenser extends TileEntityContainer implements IInvento
|
||||||
|
|
||||||
|
public void setItem(int i, ItemStack itemstack) {
|
||||||
|
this.items[i] = itemstack;
|
||||||
|
+ if (itemstack != null && itemstack.count < 0) itemstack.count = 0; // PaperSpigot - Remove CB 'feature' of infinite items
|
||||||
|
if (itemstack != null && itemstack.count > this.getMaxStackSize()) {
|
||||||
|
itemstack.count = this.getMaxStackSize();
|
||||||
|
}
|
||||||
|
--
|
||||||
|
1.9.5.msysgit.0
|
||||||
|
|
In neuem Issue referenzieren
Einen Benutzer sperren