1
0
forked from xjboss/KCauldronX

在放置事件取消时,对添加到玩家背包的物品进行还原

This commit is contained in:
2017-06-30 16:37:49 +08:00
parent 1811737e6a
commit 62ebe6c4e9
3 changed files with 45 additions and 14 deletions

View File

@ -1,6 +1,6 @@
--- ../src-base/minecraft/net/minecraft/entity/player/InventoryPlayer.java
+++ ../src-work/minecraft/net/minecraft/entity/player/InventoryPlayer.java
@@ -2,7 +2,9 @@
@@ -2,10 +2,13 @@
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@ -10,21 +10,28 @@
import net.minecraft.block.Block;
import net.minecraft.crash.CrashReport;
import net.minecraft.crash.CrashReportCategory;
@@ -13,7 +15,13 @@
+import net.minecraft.entity.item.EntityItem;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.Item;
import net.minecraft.item.ItemArmor;
@@ -13,7 +16,16 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ReportedException;
+import net.minecraftforge.common.util.EntitySnapshot;
+// CraftBukkit start
+import java.util.List;
+
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
+
public class InventoryPlayer implements IInventory
{
public ItemStack[] mainInventory = new ItemStack[36];
@@ -25,7 +33,46 @@
@@ -25,7 +37,46 @@
private ItemStack itemStack;
public boolean inventoryChanged;
private static final String __OBFID = "CL_00001709";
@ -71,7 +78,7 @@
public InventoryPlayer(EntityPlayer p_i1750_1_)
{
this.player = p_i1750_1_;
@@ -81,6 +128,34 @@
@@ -81,6 +132,34 @@
return -1;
}
@ -106,7 +113,18 @@
public int getFirstEmptyStack()
{
for (int i = 0; i < this.mainInventory.length; ++i)
@@ -430,25 +505,24 @@
@@ -350,6 +429,10 @@
{
if (p_70441_1_ != null && p_70441_1_.stackSize != 0 && p_70441_1_.getItem() != null)
{
+ if(player.worldObj.captureBlockSnapshots){
+ player.worldObj.capturedItems.add(ItemStack.copyItemStack(p_70441_1_));
+ return true;
+ }
try
{
int i;
@@ -430,25 +513,24 @@
if (aitemstack[p_70298_1_] != null)
{
@ -140,7 +158,7 @@
}
else
{
@@ -658,7 +732,7 @@
@@ -658,7 +740,7 @@
if (this.mainInventory[i] != null)
{
this.player.func_146097_a(this.mainInventory[i], true, false);
@ -149,7 +167,7 @@
}
}
@@ -667,7 +741,7 @@
@@ -667,7 +749,7 @@
if (this.armorInventory[i] != null)
{
this.player.func_146097_a(this.armorInventory[i], true, false);