From 62ebe6c4e95dbd2ca2d267314903ec6aef94908a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=81=AA=E8=81=AA?= <178666380@qq.com> Date: Fri, 30 Jun 2017 16:37:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=9C=A8=E6=94=BE=E7=BD=AE=E4=BA=8B=E4=BB=B6?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E6=97=B6,=E5=AF=B9=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E5=88=B0=E7=8E=A9=E5=AE=B6=E8=83=8C=E5=8C=85=E7=9A=84=E7=89=A9?= =?UTF-8?q?=E5=93=81=E8=BF=9B=E8=A1=8C=E8=BF=98=E5=8E=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../entity/player/InventoryPlayer.java.patch | 34 ++++++++++++++----- patches/net/minecraft/world/World.java.patch | 6 ++-- .../common/ForgeHooks.java.patch | 19 +++++++++-- 3 files changed, 45 insertions(+), 14 deletions(-) diff --git a/patches/net/minecraft/entity/player/InventoryPlayer.java.patch b/patches/net/minecraft/entity/player/InventoryPlayer.java.patch index 11ad63a..8be8a33 100644 --- a/patches/net/minecraft/entity/player/InventoryPlayer.java.patch +++ b/patches/net/minecraft/entity/player/InventoryPlayer.java.patch @@ -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); diff --git a/patches/net/minecraft/world/World.java.patch b/patches/net/minecraft/world/World.java.patch index 46c70a5..53e08c9 100644 --- a/patches/net/minecraft/world/World.java.patch +++ b/patches/net/minecraft/world/World.java.patch @@ -152,7 +152,6 @@ int[] lightUpdateBlockList; + // Cauldron start + public boolean captureTreeGeneration = false; -+ public ArrayList capturedItems = new ArrayList(); + public int entitiesTicked; + public int tilesTicked; + public CauldronWorldConfig cauldronConfig; @@ -209,7 +208,8 @@ public boolean restoringBlockSnapshots = false; public boolean captureBlockSnapshots = false; public ArrayList capturedBlockSnapshots = new ArrayList(); -+ public ArrayList capturedEntityItemSnapshots=new ArrayList(); ++ public ArrayList capturedEntitySnapshots=new ArrayList(); ++ public ArrayList capturedItems=new ArrayList(); public BiomeGenBase getBiomeGenForCoords(final int p_72807_1_, final int p_72807_2_) { @@ -631,7 +631,7 @@ + if(p_72838_1_ instanceof net.minecraft.entity.item.EntityItem&&this.restoringBlockSnapshots) + return false; + if(this.captureBlockSnapshots&&!(p_72838_1_ instanceof EntityPlayerMP)){ -+ this.capturedEntityItemSnapshots.add(new net.minecraftforge.common.util.EntitySnapshot(this,p_72838_1_,spawnReason)); ++ this.capturedEntitySnapshots.add(new net.minecraftforge.common.util.EntitySnapshot(this,p_72838_1_,spawnReason)); + return true; + } + } diff --git a/patches/net/minecraftforge/common/ForgeHooks.java.patch b/patches/net/minecraftforge/common/ForgeHooks.java.patch index 24af66c..434fd5e 100644 --- a/patches/net/minecraftforge/common/ForgeHooks.java.patch +++ b/patches/net/minecraftforge/common/ForgeHooks.java.patch @@ -65,7 +65,7 @@ { // Let the client know the block still exists entityPlayer.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world)); -@@ -500,81 +514,144 @@ +@@ -500,81 +514,157 @@ if (!(itemstack.getItem() instanceof ItemBucket)) // if not bucket { world.captureBlockSnapshots = true; @@ -169,8 +169,10 @@ + List blockSnapshots = (List) world.capturedBlockSnapshots + .clone(); + world.capturedBlockSnapshots.clear(); -+ List tDropItemSnapshots=(List)world.capturedEntityItemSnapshots.clone(); -+ world.capturedEntityItemSnapshots.clear(); ++ List tDropItemSnapshots=(List)world.capturedEntitySnapshots.clone(); ++ world.capturedEntitySnapshots.clear(); ++ List tCaptureItems=(List)world.capturedItems.clone(); ++ world.capturedItems.clear(); + + // make sure to set pre-placement item data for event + itemstack.setItemDamage(meta); @@ -247,6 +249,17 @@ + for(net.minecraftforge.common.util.EntitySnapshot sEntityItem : tDropItemSnapshots){ + sEntityItem.apply(); + } ++ if(!tCaptureItems.isEmpty()){ ++ boolean tAdded=false; ++ for(ItemStack sItem : tCaptureItems){ ++ if(!player.inventory.addItemStackToInventory(sItem)){ ++ world.spawnEntityInWorld(new EntityItem(world,player.posX,player.posY,player.posZ,sItem)); ++ }else{ ++ tAdded=true; ++ } ++ } ++ if(tAdded) player.openContainer.detectAndSendChanges(); ++ } + player.addStat(StatList.objectUseStats[Item.getIdFromItem(itemstack.getItem())], 1); } - player.addStat(StatList.objectUseStats[Item.getIdFromItem(itemstack.getItem())], 1);