3
0
KCauldronX/patches/net/minecraft/entity/player/InventoryPlayer.java.patch

166 lines
5.4 KiB
Diff
Raw Normal View History

2015-03-22 17:38:04 +00:00
--- ../src-base/minecraft/net/minecraft/entity/player/InventoryPlayer.java
+++ ../src-work/minecraft/net/minecraft/entity/player/InventoryPlayer.java
2017-07-04 06:29:35 +00:00
@@ -1,8 +1,15 @@
package net.minecraft.entity.player;
2015-03-22 17:38:04 +00:00
+// CraftBukkit start
+import java.util.List;
2017-07-04 06:29:35 +00:00
+import java.util.concurrent.Callable;
+
2015-03-22 17:38:04 +00:00
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+
2017-07-04 06:29:35 +00:00
+import cc.capture.type.CaptureBlock;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
-import java.util.concurrent.Callable;
import net.minecraft.block.Block;
import net.minecraft.crash.CrashReport;
import net.minecraft.crash.CrashReportCategory;
@@ -25,7 +32,46 @@
2015-03-22 17:38:04 +00:00
private ItemStack itemStack;
public boolean inventoryChanged;
private static final String __OBFID = "CL_00001709";
+ // CraftBukkit start
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ private int maxStack = MAX_STACK;
+ public ItemStack[] getContents()
+ {
+ return this.mainInventory;
+ }
+
+ public ItemStack[] getArmorContents()
+ {
+ return this.armorInventory;
+ }
+
+ public void onOpen(CraftHumanEntity who)
+ {
+ transaction.add(who);
+ }
+
+ public void onClose(CraftHumanEntity who)
+ {
+ transaction.remove(who);
+ }
+
+ public List<HumanEntity> getViewers()
+ {
+ return transaction;
+ }
+
+ public org.bukkit.inventory.InventoryHolder getOwner()
+ {
+ return this.player.getBukkitEntity();
+ }
+
+ public void setMaxStackSize(int size)
+ {
+ maxStack = size;
+ }
+ // CraftBukkit end
+
public InventoryPlayer(EntityPlayer p_i1750_1_)
{
this.player = p_i1750_1_;
2017-07-04 06:29:35 +00:00
@@ -81,6 +127,34 @@
2015-03-22 17:38:04 +00:00
return -1;
}
+ // CraftBukkit start - Watch method above! :D
+ public int canHold(ItemStack itemstack)
+ {
+ int remains = itemstack.stackSize;
+
+ for (int i = 0; i < this.mainInventory.length; ++i)
+ {
+ if (this.mainInventory[i] == null)
+ {
+ return itemstack.stackSize;
+ }
+
+ // Taken from firstPartial(ItemStack)
+ if (this.mainInventory[i] != null && this.mainInventory[i].getItem() == itemstack.getItem() && this.mainInventory[i].isStackable() && this.mainInventory[i].stackSize < this.mainInventory[i].getMaxStackSize() && this.mainInventory[i].stackSize < this.getInventoryStackLimit() && (!this.mainInventory[i].getHasSubtypes() || this.mainInventory[i].getItemDamage() == itemstack.getItemDamage()) && ItemStack.areItemStackTagsEqual(this.mainInventory[i], itemstack))
+ {
+ remains -= (this.mainInventory[i].getMaxStackSize() < this.getInventoryStackLimit() ? this.mainInventory[i].getMaxStackSize() : this.getInventoryStackLimit()) - this.mainInventory[i].stackSize;
+ }
+
+ if (remains <= 0)
+ {
+ return itemstack.stackSize;
+ }
+ }
+
+ return itemstack.stackSize - remains;
+ }
+ // CraftBukkit end
+
public int getFirstEmptyStack()
{
for (int i = 0; i < this.mainInventory.length; ++i)
2017-07-04 06:29:35 +00:00
@@ -350,6 +424,11 @@
{
if (p_70441_1_ != null && p_70441_1_.stackSize != 0 && p_70441_1_.getItem() != null)
{
2017-07-04 06:29:35 +00:00
+ CaptureBlock tBlockCapture=player.worldObj.mCapture.getLastBlockCapture();
+ if(tBlockCapture!=null&&tBlockCapture.mEnable){
+ tBlockCapture.addCaptureItem(player,ItemStack.copyItemStack(p_70441_1_));
+ return true;
+ }
try
{
int i;
2017-07-04 06:29:35 +00:00
@@ -430,25 +509,24 @@
2015-06-26 15:42:30 +00:00
if (aitemstack[p_70298_1_] != null)
{
- ItemStack itemstack;
2015-06-26 16:47:31 +00:00
+ ItemStack itemstack = aitemstack[p_70298_1_], result;
2015-06-26 15:42:30 +00:00
- if (aitemstack[p_70298_1_].stackSize <= p_70298_2_)
+ if (itemstack.stackSize <= p_70298_2_)
{
- itemstack = aitemstack[p_70298_1_];
2015-06-26 16:47:31 +00:00
+ result = itemstack.copy();
+ itemstack.stackSize = 0;
2015-06-26 15:42:30 +00:00
aitemstack[p_70298_1_] = null;
2015-06-26 16:47:31 +00:00
- return itemstack;
2015-06-26 15:42:30 +00:00
}
else
{
- itemstack = aitemstack[p_70298_1_].splitStack(p_70298_2_);
2015-06-26 16:47:31 +00:00
+ result = itemstack.splitStack(p_70298_2_);
2015-06-26 15:42:30 +00:00
2015-06-26 16:47:31 +00:00
- if (aitemstack[p_70298_1_].stackSize == 0)
+ if (itemstack.stackSize == 0)
2015-06-26 15:42:30 +00:00
{
2015-06-26 16:47:31 +00:00
- aitemstack[p_70298_1_] = null;
+ itemstack = null;
}
-
- return itemstack;
}
+ return result;
}
else
{
2017-07-04 06:29:35 +00:00
@@ -658,7 +736,7 @@
2015-03-22 17:38:04 +00:00
if (this.mainInventory[i] != null)
{
this.player.func_146097_a(this.mainInventory[i], true, false);
- this.mainInventory[i] = null;
+ //this.mainInventory[i] = null; // Cauldron - we clear this in EntityPlayerMP.onDeath after PlayerDeathEvent
}
}
2017-07-04 06:29:35 +00:00
@@ -667,7 +745,7 @@
2015-03-22 17:38:04 +00:00
if (this.armorInventory[i] != null)
{
this.player.func_146097_a(this.armorInventory[i], true, false);
- this.armorInventory[i] = null;
+ //this.armorInventory[i] = null; // Cauldron - we clear this in EntityPlayerMP.onDeath after PlayerDeathEvent
}
}
}