mirror of
https://github.com/PaperMC/Paper.git
synced 2025-01-03 23:07:40 +01:00
Do not allow negative count itemstacks (infinite itemstacks)
Should work around quite a few issues and this 'feature' is relatively worthless anyway
This commit is contained in:
parent
c683d9ad52
commit
73bc2489c0
@ -0,0 +1,154 @@
|
||||
From 0000000000000000000000000000000000000000 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/DispenseBehaviorItem.java
|
||||
+++ b/src/main/java/net/minecraft/server/DispenseBehaviorItem.java
|
||||
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityAgeable.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityAgeable.java
|
||||
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityHorse.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityHorse.java
|
||||
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
||||
@@ -0,0 +0,0 @@ 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();
|
||||
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/ItemStack.java
|
||||
+++ b/src/main/java/net/minecraft/server/ItemStack.java
|
||||
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerInteractManager.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerInteractManager.java
|
||||
@@ -0,0 +0,0 @@ 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();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerInventory.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerInventory.java
|
||||
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/Slot.java
|
||||
+++ b/src/main/java/net/minecraft/server/Slot.java
|
||||
@@ -0,0 +0,0 @@ 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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
|
||||
--- a/src/main/java/net/minecraft/server/TileEntityDispenser.java
|
||||
+++ b/src/main/java/net/minecraft/server/TileEntityDispenser.java
|
||||
@@ -0,0 +0,0 @@ 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
|
||||
|
@ -300,4 +300,89 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
|
||||
+
|
||||
+ }
|
||||
+}
|
||||
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 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/minecraft/server/Slot.java
|
||||
@@ -0,0 +0,0 @@
|
||||
+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;
|
||||
+ }
|
||||
+}
|
||||
--
|
Loading…
Reference in New Issue
Block a user