模块化方块捕获还原动作
This commit is contained in:
parent
559b9ad248
commit
bfe43ae465
@ -1,17 +1,22 @@
|
|||||||
--- ../src-base/minecraft/net/minecraft/block/BlockSapling.java
|
--- ../src-base/minecraft/net/minecraft/block/BlockSapling.java
|
||||||
+++ ../src-work/minecraft/net/minecraft/block/BlockSapling.java
|
+++ ../src-work/minecraft/net/minecraft/block/BlockSapling.java
|
||||||
@@ -22,10 +22,18 @@
|
@@ -1,9 +1,13 @@
|
||||||
import net.minecraft.world.gen.feature.WorldGenTrees;
|
package net.minecraft.block;
|
||||||
import net.minecraft.world.gen.feature.WorldGenerator;
|
|
||||||
|
|
||||||
+// CraftBukkit start
|
-import cpw.mods.fml.relauncher.Side;
|
||||||
+import org.bukkit.Location;
|
-import cpw.mods.fml.relauncher.SideOnly;
|
||||||
+import org.bukkit.TreeType;
|
import java.util.List;
|
||||||
+import org.bukkit.block.BlockState;
|
import java.util.Random;
|
||||||
+import org.bukkit.event.world.StructureGrowEvent;
|
|
||||||
+// CraftBukkit end
|
|
||||||
+
|
+
|
||||||
public class BlockSapling extends BlockBush implements IGrowable
|
+import org.bukkit.TreeType;
|
||||||
|
+
|
||||||
|
+import cc.capture.type.CaptureTree;
|
||||||
|
+import cpw.mods.fml.relauncher.Side;
|
||||||
|
+import cpw.mods.fml.relauncher.SideOnly;
|
||||||
|
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||||
|
import net.minecraft.creativetab.CreativeTabs;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
@@ -26,6 +30,7 @@
|
||||||
{
|
{
|
||||||
public static final String[] field_149882_a = new String[] {"oak", "spruce", "birch", "jungle", "acacia", "roofed_oak"};
|
public static final String[] field_149882_a = new String[] {"oak", "spruce", "birch", "jungle", "acacia", "roofed_oak"};
|
||||||
private static final IIcon[] field_149881_b = new IIcon[field_149882_a.length];
|
private static final IIcon[] field_149881_b = new IIcon[field_149882_a.length];
|
||||||
@ -19,7 +24,7 @@
|
|||||||
private static final String __OBFID = "CL_00000305";
|
private static final String __OBFID = "CL_00000305";
|
||||||
|
|
||||||
protected BlockSapling()
|
protected BlockSapling()
|
||||||
@@ -41,9 +49,39 @@
|
@@ -41,9 +46,13 @@
|
||||||
{
|
{
|
||||||
super.updateTick(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_5_);
|
super.updateTick(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_5_);
|
||||||
|
|
||||||
@ -27,40 +32,14 @@
|
|||||||
+ if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) >= 9 && (p_149674_5_.nextInt(Math.max(2, (int)((p_149674_1_.growthOdds / p_149674_1_.getSpigotConfig().saplingModifier * 7) + 0.5F))) == 0)) // Spigot // Cauldron
|
+ if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) >= 9 && (p_149674_5_.nextInt(Math.max(2, (int)((p_149674_1_.growthOdds / p_149674_1_.getSpigotConfig().saplingModifier * 7) + 0.5F))) == 0)) // Spigot // Cauldron
|
||||||
{
|
{
|
||||||
+ // Cauldron start
|
+ // Cauldron start
|
||||||
+ p_149674_1_.captureTreeGeneration = true;
|
+ CaptureTree tCapture=p_149674_1_.mCapture.startTreeGenCapture(null,p_149674_2_,p_149674_3_,p_149674_4_);
|
||||||
this.func_149879_c(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_5_);
|
this.func_149879_c(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_5_);
|
||||||
+ p_149674_1_.captureTreeGeneration = false;
|
+ tCapture.endCapture();
|
||||||
+ if (p_149674_1_.capturedBlockSnapshots.size() > 0)
|
|
||||||
+ {
|
|
||||||
+ TreeType treeType = BlockSapling.treeType;
|
|
||||||
+ BlockSapling.treeType = null;
|
|
||||||
+ Location location = new Location(p_149674_1_.getWorld(), p_149674_2_, p_149674_3_, p_149674_4_);
|
|
||||||
+ List<net.minecraftforge.common.util.BlockSnapshot> blocks = (List) p_149674_1_.capturedBlockSnapshots.clone();
|
|
||||||
+ List<BlockState> blockstates = new java.util.ArrayList();
|
|
||||||
+ for (net.minecraftforge.common.util.BlockSnapshot snapshot : blocks)
|
|
||||||
+ {
|
|
||||||
+ blockstates.add(new org.bukkit.craftbukkit.block.CraftBlockState(snapshot));
|
|
||||||
+ }
|
|
||||||
+ p_149674_1_.capturedBlockSnapshots.clear();
|
|
||||||
+ StructureGrowEvent event = null;
|
|
||||||
+ if (treeType != null)
|
|
||||||
+ {
|
|
||||||
+ event = new StructureGrowEvent(location, treeType, false, null, blockstates);
|
|
||||||
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
|
|
||||||
+ }
|
|
||||||
+ if (event == null || !event.isCancelled())
|
|
||||||
+ {
|
|
||||||
+ for (BlockState blockstate : blockstates)
|
|
||||||
+ {
|
|
||||||
+ blockstate.update(true);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ // Cauldron end
|
+ // Cauldron end
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,7 +111,20 @@
|
@@ -73,7 +82,20 @@
|
||||||
{
|
{
|
||||||
if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(p_149878_1_, p_149878_5_, p_149878_2_, p_149878_3_, p_149878_4_)) return;
|
if (!net.minecraftforge.event.terraingen.TerrainGen.saplingGrowTree(p_149878_1_, p_149878_5_, p_149878_2_, p_149878_3_, p_149878_4_)) return;
|
||||||
int l = p_149878_1_.getBlockMetadata(p_149878_2_, p_149878_3_, p_149878_4_) & 7;
|
int l = p_149878_1_.getBlockMetadata(p_149878_2_, p_149878_3_, p_149878_4_) & 7;
|
||||||
@ -82,7 +61,7 @@
|
|||||||
int i1 = 0;
|
int i1 = 0;
|
||||||
int j1 = 0;
|
int j1 = 0;
|
||||||
boolean flag = false;
|
boolean flag = false;
|
||||||
@@ -84,6 +135,7 @@
|
@@ -84,6 +106,7 @@
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
@ -90,7 +69,7 @@
|
|||||||
label78:
|
label78:
|
||||||
|
|
||||||
for (i1 = 0; i1 >= -1; --i1)
|
for (i1 = 0; i1 >= -1; --i1)
|
||||||
@@ -108,6 +160,7 @@
|
@@ -108,6 +131,7 @@
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
@ -98,7 +77,7 @@
|
|||||||
object = new WorldGenForest(true, false);
|
object = new WorldGenForest(true, false);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
@@ -119,6 +172,7 @@
|
@@ -119,6 +143,7 @@
|
||||||
{
|
{
|
||||||
if (this.func_149880_a(p_149878_1_, p_149878_2_ + i1, p_149878_3_, p_149878_4_ + j1, 3) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1 + 1, p_149878_3_, p_149878_4_ + j1, 3) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1, p_149878_3_, p_149878_4_ + j1 + 1, 3) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1 + 1, p_149878_3_, p_149878_4_ + j1 + 1, 3))
|
if (this.func_149880_a(p_149878_1_, p_149878_2_ + i1, p_149878_3_, p_149878_4_ + j1, 3) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1 + 1, p_149878_3_, p_149878_4_ + j1, 3) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1, p_149878_3_, p_149878_4_ + j1 + 1, 3) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1 + 1, p_149878_3_, p_149878_4_ + j1 + 1, 3))
|
||||||
{
|
{
|
||||||
@ -106,7 +85,7 @@
|
|||||||
object = new WorldGenMegaJungle(true, 10, 20, 3, 3);
|
object = new WorldGenMegaJungle(true, 10, 20, 3, 3);
|
||||||
flag = true;
|
flag = true;
|
||||||
break label93;
|
break label93;
|
||||||
@@ -130,11 +184,13 @@
|
@@ -130,11 +155,13 @@
|
||||||
{
|
{
|
||||||
j1 = 0;
|
j1 = 0;
|
||||||
i1 = 0;
|
i1 = 0;
|
||||||
@ -120,7 +99,7 @@
|
|||||||
object = new WorldGenSavannaTree(true);
|
object = new WorldGenSavannaTree(true);
|
||||||
break;
|
break;
|
||||||
case 5:
|
case 5:
|
||||||
@@ -147,6 +203,7 @@
|
@@ -147,6 +174,7 @@
|
||||||
if (this.func_149880_a(p_149878_1_, p_149878_2_ + i1, p_149878_3_, p_149878_4_ + j1, 5) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1 + 1, p_149878_3_, p_149878_4_ + j1, 5) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1, p_149878_3_, p_149878_4_ + j1 + 1, 5) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1 + 1, p_149878_3_, p_149878_4_ + j1 + 1, 5))
|
if (this.func_149880_a(p_149878_1_, p_149878_2_ + i1, p_149878_3_, p_149878_4_ + j1, 5) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1 + 1, p_149878_3_, p_149878_4_ + j1, 5) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1, p_149878_3_, p_149878_4_ + j1 + 1, 5) && this.func_149880_a(p_149878_1_, p_149878_2_ + i1 + 1, p_149878_3_, p_149878_4_ + j1 + 1, 5))
|
||||||
{
|
{
|
||||||
object = new WorldGenCanopyTree(true);
|
object = new WorldGenCanopyTree(true);
|
||||||
|
@ -1,37 +1,23 @@
|
|||||||
--- ../src-base/minecraft/net/minecraft/entity/player/InventoryPlayer.java
|
--- ../src-base/minecraft/net/minecraft/entity/player/InventoryPlayer.java
|
||||||
+++ ../src-work/minecraft/net/minecraft/entity/player/InventoryPlayer.java
|
+++ ../src-work/minecraft/net/minecraft/entity/player/InventoryPlayer.java
|
||||||
@@ -2,10 +2,13 @@
|
@@ -1,8 +1,15 @@
|
||||||
|
package net.minecraft.entity.player;
|
||||||
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;
|
|
||||||
+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
|
+// CraftBukkit start
|
||||||
+import java.util.List;
|
+import java.util.List;
|
||||||
|
+import java.util.concurrent.Callable;
|
||||||
+
|
+
|
||||||
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
|
||||||
+import org.bukkit.entity.HumanEntity;
|
+import org.bukkit.entity.HumanEntity;
|
||||||
+// CraftBukkit end
|
|
||||||
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
|
||||||
+
|
+
|
||||||
public class InventoryPlayer implements IInventory
|
+import cc.capture.type.CaptureBlock;
|
||||||
{
|
import cpw.mods.fml.relauncher.Side;
|
||||||
public ItemStack[] mainInventory = new ItemStack[36];
|
import cpw.mods.fml.relauncher.SideOnly;
|
||||||
@@ -25,7 +37,46 @@
|
-import java.util.concurrent.Callable;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.crash.CrashReport;
|
||||||
|
import net.minecraft.crash.CrashReportCategory;
|
||||||
|
@@ -25,7 +32,46 @@
|
||||||
private ItemStack itemStack;
|
private ItemStack itemStack;
|
||||||
public boolean inventoryChanged;
|
public boolean inventoryChanged;
|
||||||
private static final String __OBFID = "CL_00001709";
|
private static final String __OBFID = "CL_00001709";
|
||||||
@ -78,7 +64,7 @@
|
|||||||
public InventoryPlayer(EntityPlayer p_i1750_1_)
|
public InventoryPlayer(EntityPlayer p_i1750_1_)
|
||||||
{
|
{
|
||||||
this.player = p_i1750_1_;
|
this.player = p_i1750_1_;
|
||||||
@@ -81,6 +132,34 @@
|
@@ -81,6 +127,34 @@
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -113,18 +99,19 @@
|
|||||||
public int getFirstEmptyStack()
|
public int getFirstEmptyStack()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < this.mainInventory.length; ++i)
|
for (int i = 0; i < this.mainInventory.length; ++i)
|
||||||
@@ -350,6 +429,10 @@
|
@@ -350,6 +424,11 @@
|
||||||
{
|
{
|
||||||
if (p_70441_1_ != null && p_70441_1_.stackSize != 0 && p_70441_1_.getItem() != null)
|
if (p_70441_1_ != null && p_70441_1_.stackSize != 0 && p_70441_1_.getItem() != null)
|
||||||
{
|
{
|
||||||
+ if(player.worldObj.captureBlockSnapshots){
|
+ CaptureBlock tBlockCapture=player.worldObj.mCapture.getLastBlockCapture();
|
||||||
+ player.worldObj.capturedItems.add(ItemStack.copyItemStack(p_70441_1_));
|
+ if(tBlockCapture!=null&&tBlockCapture.mEnable){
|
||||||
|
+ tBlockCapture.addCaptureItem(player,ItemStack.copyItemStack(p_70441_1_));
|
||||||
+ return true;
|
+ return true;
|
||||||
+ }
|
+ }
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
@@ -430,25 +513,24 @@
|
@@ -430,25 +509,24 @@
|
||||||
|
|
||||||
if (aitemstack[p_70298_1_] != null)
|
if (aitemstack[p_70298_1_] != null)
|
||||||
{
|
{
|
||||||
@ -158,7 +145,7 @@
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -658,7 +740,7 @@
|
@@ -658,7 +736,7 @@
|
||||||
if (this.mainInventory[i] != null)
|
if (this.mainInventory[i] != null)
|
||||||
{
|
{
|
||||||
this.player.func_146097_a(this.mainInventory[i], true, false);
|
this.player.func_146097_a(this.mainInventory[i], true, false);
|
||||||
@ -167,7 +154,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -667,7 +749,7 @@
|
@@ -667,7 +745,7 @@
|
||||||
if (this.armorInventory[i] != null)
|
if (this.armorInventory[i] != null)
|
||||||
{
|
{
|
||||||
this.player.func_146097_a(this.armorInventory[i], true, false);
|
this.player.func_146097_a(this.armorInventory[i], true, false);
|
||||||
|
@ -1,99 +1,117 @@
|
|||||||
--- ../src-base/minecraft/net/minecraft/world/World.java
|
--- ../src-base/minecraft/net/minecraft/world/World.java
|
||||||
+++ ../src-work/minecraft/net/minecraft/world/World.java
|
+++ ../src-work/minecraft/net/minecraft/world/World.java
|
||||||
@@ -2,6 +2,7 @@
|
@@ -1,7 +1,5 @@
|
||||||
|
package net.minecraft.world;
|
||||||
|
|
||||||
import cpw.mods.fml.relauncher.Side;
|
-import cpw.mods.fml.relauncher.Side;
|
||||||
import cpw.mods.fml.relauncher.SideOnly;
|
-import cpw.mods.fml.relauncher.SideOnly;
|
||||||
+
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -12,6 +13,7 @@
|
@@ -12,19 +10,54 @@
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.concurrent.Callable;
|
import java.util.concurrent.Callable;
|
||||||
+
|
+
|
||||||
|
+import org.bukkit.Bukkit;
|
||||||
|
+import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
+import org.bukkit.craftbukkit.CraftWorld;
|
||||||
|
+import org.bukkit.craftbukkit.SpigotTimings;
|
||||||
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||||
|
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
||||||
|
+import org.bukkit.event.block.BlockCanBuildEvent;
|
||||||
|
+import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
|
+import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||||
|
+import org.bukkit.event.weather.ThunderChangeEvent;
|
||||||
|
+import org.bukkit.event.weather.WeatherChangeEvent;
|
||||||
|
+import org.bukkit.generator.ChunkGenerator;
|
||||||
|
+// Cauldron end
|
||||||
|
+import org.spigotmc.TickLimiter;
|
||||||
|
+
|
||||||
|
+import com.google.common.collect.ImmutableSetMultimap;
|
||||||
|
+
|
||||||
|
+import cc.capture.WorldCapture;
|
||||||
|
+import cc.capture.type.CaptureBlock;
|
||||||
|
+import cc.capture.type.CaptureTree;
|
||||||
|
+import cpw.mods.fml.common.FMLLog;
|
||||||
|
+import cpw.mods.fml.relauncher.Side;
|
||||||
|
+import cpw.mods.fml.relauncher.SideOnly;
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.block.BlockHopper;
|
-import net.minecraft.block.BlockHopper;
|
||||||
import net.minecraft.block.BlockLiquid;
|
import net.minecraft.block.BlockLiquid;
|
||||||
@@ -23,9 +25,11 @@
|
-import net.minecraft.block.BlockSlab;
|
||||||
|
-import net.minecraft.block.BlockSnow;
|
||||||
|
-import net.minecraft.block.BlockStairs;
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.command.IEntitySelector;
|
||||||
import net.minecraft.crash.CrashReport;
|
import net.minecraft.crash.CrashReport;
|
||||||
import net.minecraft.crash.CrashReportCategory;
|
import net.minecraft.crash.CrashReportCategory;
|
||||||
import net.minecraft.entity.Entity;
|
import net.minecraft.entity.Entity;
|
||||||
+import net.minecraft.entity.EntityList;
|
|
||||||
import net.minecraft.entity.EntityLiving;
|
import net.minecraft.entity.EntityLiving;
|
||||||
import net.minecraft.entity.player.EntityPlayer;
|
|
||||||
import net.minecraft.init.Blocks;
|
|
||||||
+import net.minecraft.item.ItemBlock;
|
|
||||||
import net.minecraft.item.ItemStack;
|
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
import net.minecraft.pathfinding.PathEntity;
|
|
||||||
@@ -51,7 +55,6 @@
|
|
||||||
import net.minecraft.world.storage.ISaveHandler;
|
|
||||||
import net.minecraft.world.storage.MapStorage;
|
|
||||||
import net.minecraft.world.storage.WorldInfo;
|
|
||||||
-
|
|
||||||
import cpw.mods.fml.common.FMLLog;
|
|
||||||
|
|
||||||
import com.google.common.collect.ImmutableSetMultimap;
|
|
||||||
@@ -70,6 +73,56 @@
|
|
||||||
import net.minecraftforge.event.entity.PlaySoundAtEntityEvent;
|
|
||||||
import net.minecraft.entity.EnumCreatureType;
|
|
||||||
|
|
||||||
+// CraftBukkit start
|
+// CraftBukkit start
|
||||||
+import net.minecraft.entity.EntityLivingBase;
|
+import net.minecraft.entity.EntityLivingBase;
|
||||||
|
+import net.minecraft.entity.EnumCreatureType;
|
||||||
+import net.minecraft.entity.item.EntityItem;
|
+import net.minecraft.entity.item.EntityItem;
|
||||||
|
+// CraftBukkit end
|
||||||
|
+// Spigot Start
|
||||||
|
+import net.minecraft.entity.item.EntityXPOrb;
|
||||||
+import net.minecraft.entity.monster.EntityGhast;
|
+import net.minecraft.entity.monster.EntityGhast;
|
||||||
+import net.minecraft.entity.monster.EntityGolem;
|
+import net.minecraft.entity.monster.EntityGolem;
|
||||||
+import net.minecraft.entity.monster.EntityMob;
|
+import net.minecraft.entity.monster.EntityMob;
|
||||||
+import net.minecraft.entity.monster.EntitySlime;
|
+import net.minecraft.entity.monster.EntitySlime;
|
||||||
+import net.minecraft.entity.passive.EntityAnimal;
|
+import net.minecraft.entity.passive.EntityAnimal;
|
||||||
+import net.minecraft.entity.passive.EntityWaterMob;
|
+import net.minecraft.entity.passive.EntityWaterMob;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
+import net.minecraft.entity.player.EntityPlayerMP;
|
+import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
@@ -36,7 +69,6 @@
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
import net.minecraft.util.ChunkCoordinates;
|
||||||
|
-import net.minecraft.util.Direction;
|
||||||
|
import net.minecraft.util.Facing;
|
||||||
|
import net.minecraft.util.MathHelper;
|
||||||
|
import net.minecraft.util.MovingObjectPosition;
|
||||||
|
@@ -48,27 +80,26 @@
|
||||||
|
import net.minecraft.world.biome.WorldChunkManager;
|
||||||
|
import net.minecraft.world.chunk.Chunk;
|
||||||
|
import net.minecraft.world.chunk.IChunkProvider;
|
||||||
+import net.minecraft.world.gen.ChunkProviderServer;
|
+import net.minecraft.world.gen.ChunkProviderServer;
|
||||||
+
|
import net.minecraft.world.storage.ISaveHandler;
|
||||||
+import org.bukkit.Bukkit;
|
import net.minecraft.world.storage.MapStorage;
|
||||||
+import org.bukkit.World.Environment;
|
import net.minecraft.world.storage.WorldInfo;
|
||||||
+import org.bukkit.block.BlockState;
|
-
|
||||||
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
-import cpw.mods.fml.common.FMLLog;
|
||||||
+import org.bukkit.craftbukkit.util.LongHashSet;
|
-
|
||||||
+import org.bukkit.craftbukkit.util.UnsafeList;
|
-import com.google.common.collect.ImmutableSetMultimap;
|
||||||
+import org.bukkit.generator.ChunkGenerator;
|
-
|
||||||
+import org.bukkit.craftbukkit.CraftServer;
|
|
||||||
+import org.bukkit.craftbukkit.CraftWorld;
|
|
||||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
|
||||||
+import org.bukkit.event.block.BlockCanBuildEvent;
|
|
||||||
+import org.bukkit.event.block.BlockPhysicsEvent;
|
|
||||||
+import org.bukkit.event.block.BlockPlaceEvent;
|
|
||||||
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
|
||||||
+import org.bukkit.event.weather.WeatherChangeEvent;
|
|
||||||
+import org.bukkit.event.weather.ThunderChangeEvent;
|
|
||||||
+
|
|
||||||
+// CraftBukkit end
|
|
||||||
+// Spigot Start
|
|
||||||
+import net.minecraft.entity.item.EntityXPOrb;
|
|
||||||
+
|
|
||||||
+import org.bukkit.craftbukkit.SpigotTimings;
|
|
||||||
+
|
|
||||||
+// Spigot end
|
|
||||||
+// Cauldron start
|
|
||||||
+import net.minecraft.nbt.NBTTagCompound;
|
|
||||||
+import net.minecraftforge.cauldron.CauldronHooks;
|
+import net.minecraftforge.cauldron.CauldronHooks;
|
||||||
+import net.minecraftforge.cauldron.configuration.CauldronConfig;
|
|
||||||
+import net.minecraftforge.cauldron.configuration.CauldronWorldConfig;
|
+import net.minecraftforge.cauldron.configuration.CauldronWorldConfig;
|
||||||
+import net.minecraftforge.cauldron.configuration.EntityWorldConfig;
|
+import net.minecraftforge.cauldron.configuration.EntityWorldConfig;
|
||||||
+import net.minecraftforge.cauldron.configuration.TileEntityConfig;
|
|
||||||
+import net.minecraftforge.cauldron.configuration.TileEntityWorldConfig;
|
+import net.minecraftforge.cauldron.configuration.TileEntityWorldConfig;
|
||||||
|
import net.minecraftforge.client.ForgeHooksClient;
|
||||||
+import net.minecraftforge.common.DimensionManager;
|
+import net.minecraftforge.common.DimensionManager;
|
||||||
+
|
import net.minecraftforge.common.ForgeChunkManager;
|
||||||
+import org.bukkit.block.BlockState;
|
import net.minecraftforge.common.ForgeChunkManager.Ticket;
|
||||||
+// Cauldron end
|
import net.minecraftforge.common.ForgeModContainer;
|
||||||
+import org.spigotmc.TickLimiter;
|
-import net.minecraftforge.common.ForgeHooks;
|
||||||
+
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
|
-import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import net.minecraftforge.common.WorldSpecificSaveHandler;
|
||||||
|
+import net.minecraftforge.common.util.BlockSnapshot;
|
||||||
|
+import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
import net.minecraftforge.event.entity.EntityEvent;
|
||||||
|
import net.minecraftforge.event.entity.EntityJoinWorldEvent;
|
||||||
|
-import net.minecraftforge.event.world.WorldEvent;
|
||||||
|
import net.minecraftforge.event.entity.PlaySoundAtEntityEvent;
|
||||||
|
-import net.minecraft.entity.EnumCreatureType;
|
||||||
|
|
||||||
public abstract class World implements IBlockAccess
|
public abstract class World implements IBlockAccess
|
||||||
{
|
{
|
||||||
/**
|
@@ -83,15 +114,14 @@
|
||||||
@@ -83,15 +136,14 @@
|
|
||||||
|
|
||||||
public boolean scheduledUpdatesAreImmediate;
|
public boolean scheduledUpdatesAreImmediate;
|
||||||
public List loadedEntityList = new ArrayList();
|
public List loadedEntityList = new ArrayList();
|
||||||
@ -111,7 +129,7 @@
|
|||||||
protected final int DIST_HASH_MAGIC = 1013904223;
|
protected final int DIST_HASH_MAGIC = 1013904223;
|
||||||
public float prevRainingStrength;
|
public float prevRainingStrength;
|
||||||
public float rainingStrength;
|
public float rainingStrength;
|
||||||
@@ -100,30 +152,94 @@
|
@@ -100,31 +130,92 @@
|
||||||
public int lastLightningBolt;
|
public int lastLightningBolt;
|
||||||
public EnumDifficulty difficultySetting;
|
public EnumDifficulty difficultySetting;
|
||||||
public Random rand = new Random();
|
public Random rand = new Random();
|
||||||
@ -151,7 +169,6 @@
|
|||||||
private boolean field_147481_N;
|
private boolean field_147481_N;
|
||||||
int[] lightUpdateBlockList;
|
int[] lightUpdateBlockList;
|
||||||
+ // Cauldron start
|
+ // Cauldron start
|
||||||
+ public boolean captureTreeGeneration = false;
|
|
||||||
+ public int entitiesTicked;
|
+ public int entitiesTicked;
|
||||||
+ public int tilesTicked;
|
+ public int tilesTicked;
|
||||||
+ public CauldronWorldConfig cauldronConfig;
|
+ public CauldronWorldConfig cauldronConfig;
|
||||||
@ -206,14 +223,15 @@
|
|||||||
+ // Spigot end
|
+ // Spigot end
|
||||||
private static final String __OBFID = "CL_00000140";
|
private static final String __OBFID = "CL_00000140";
|
||||||
public boolean restoringBlockSnapshots = false;
|
public boolean restoringBlockSnapshots = false;
|
||||||
public boolean captureBlockSnapshots = false;
|
- public boolean captureBlockSnapshots = false;
|
||||||
public ArrayList<net.minecraftforge.common.util.BlockSnapshot> capturedBlockSnapshots = new ArrayList<net.minecraftforge.common.util.BlockSnapshot>();
|
- public ArrayList<net.minecraftforge.common.util.BlockSnapshot> capturedBlockSnapshots = new ArrayList<net.minecraftforge.common.util.BlockSnapshot>();
|
||||||
+ public ArrayList<net.minecraftforge.common.util.EntitySnapshot> capturedEntitySnapshots=new ArrayList<net.minecraftforge.common.util.EntitySnapshot>();
|
|
||||||
+ public ArrayList<ItemStack> capturedItems=new ArrayList<ItemStack>();
|
|
||||||
|
|
||||||
|
+ public WorldCapture mCapture=new WorldCapture(this);
|
||||||
|
+
|
||||||
public BiomeGenBase getBiomeGenForCoords(final int p_72807_1_, final int p_72807_2_)
|
public BiomeGenBase getBiomeGenForCoords(final int p_72807_1_, final int p_72807_2_)
|
||||||
{
|
{
|
||||||
@@ -166,6 +282,27 @@
|
return provider.getBiomeGenForCoords(p_72807_1_, p_72807_2_);
|
||||||
|
@@ -166,6 +257,27 @@
|
||||||
return this.provider.worldChunkMgr;
|
return this.provider.worldChunkMgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -241,7 +259,7 @@
|
|||||||
@SideOnly(Side.CLIENT)
|
@SideOnly(Side.CLIENT)
|
||||||
public World(ISaveHandler p_i45368_1_, String p_i45368_2_, WorldProvider p_i45368_3_, WorldSettings p_i45368_4_, Profiler p_i45368_5_)
|
public World(ISaveHandler p_i45368_1_, String p_i45368_2_, WorldProvider p_i45368_3_, WorldSettings p_i45368_4_, Profiler p_i45368_5_)
|
||||||
{
|
{
|
||||||
@@ -179,6 +316,12 @@
|
@@ -179,6 +291,12 @@
|
||||||
this.worldInfo = new WorldInfo(p_i45368_4_, p_i45368_2_);
|
this.worldInfo = new WorldInfo(p_i45368_4_, p_i45368_2_);
|
||||||
this.provider = p_i45368_3_;
|
this.provider = p_i45368_3_;
|
||||||
perWorldStorage = new MapStorage((ISaveHandler)null);
|
perWorldStorage = new MapStorage((ISaveHandler)null);
|
||||||
@ -254,7 +272,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Broken up so that the WorldClient gets the chance to set the mapstorage object before the dimension initializes
|
// Broken up so that the WorldClient gets the chance to set the mapstorage object before the dimension initializes
|
||||||
@@ -207,8 +350,177 @@
|
@@ -207,8 +325,177 @@
|
||||||
this.calculateInitialWeather();
|
this.calculateInitialWeather();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -432,7 +450,7 @@
|
|||||||
this.ambientTickCountdown = this.rand.nextInt(12000);
|
this.ambientTickCountdown = this.rand.nextInt(12000);
|
||||||
this.spawnHostileMobs = true;
|
this.spawnHostileMobs = true;
|
||||||
this.spawnPeacefulMobs = true;
|
this.spawnPeacefulMobs = true;
|
||||||
@@ -216,7 +528,6 @@
|
@@ -216,7 +503,6 @@
|
||||||
this.lightUpdateBlockList = new int[32768];
|
this.lightUpdateBlockList = new int[32768];
|
||||||
this.saveHandler = p_i45369_1_;
|
this.saveHandler = p_i45369_1_;
|
||||||
this.theProfiler = p_i45369_5_;
|
this.theProfiler = p_i45369_5_;
|
||||||
@ -440,7 +458,7 @@
|
|||||||
this.worldInfo = p_i45369_1_.loadWorldInfo();
|
this.worldInfo = p_i45369_1_.loadWorldInfo();
|
||||||
|
|
||||||
if (p_i45369_4_ != null)
|
if (p_i45369_4_ != null)
|
||||||
@@ -235,13 +546,26 @@
|
@@ -235,13 +521,26 @@
|
||||||
if (this.worldInfo == null)
|
if (this.worldInfo == null)
|
||||||
{
|
{
|
||||||
this.worldInfo = new WorldInfo(p_i45369_3_, p_i45369_2_);
|
this.worldInfo = new WorldInfo(p_i45369_3_, p_i45369_2_);
|
||||||
@ -467,7 +485,7 @@
|
|||||||
this.chunkProvider = this.createChunkProvider();
|
this.chunkProvider = this.createChunkProvider();
|
||||||
|
|
||||||
if (this instanceof WorldServer)
|
if (this instanceof WorldServer)
|
||||||
@@ -294,6 +618,7 @@
|
@@ -294,6 +593,7 @@
|
||||||
this.calculateInitialSkylight();
|
this.calculateInitialSkylight();
|
||||||
this.calculateInitialWeather();
|
this.calculateInitialWeather();
|
||||||
}
|
}
|
||||||
@ -475,14 +493,15 @@
|
|||||||
|
|
||||||
private static MapStorage s_mapStorage;
|
private static MapStorage s_mapStorage;
|
||||||
private static ISaveHandler s_savehandler;
|
private static ISaveHandler s_savehandler;
|
||||||
@@ -336,6 +661,18 @@
|
@@ -336,6 +636,19 @@
|
||||||
|
|
||||||
public Block getBlock(int p_147439_1_, int p_147439_2_, int p_147439_3_)
|
public Block getBlock(int p_147439_1_, int p_147439_2_, int p_147439_3_)
|
||||||
{
|
{
|
||||||
+ // Cauldron start - tree generation
|
+ // Cauldron start - tree generation
|
||||||
+ if (captureTreeGeneration)
|
+ CaptureTree tTreeCapture=this.mCapture.getLastTreeGenCapture();
|
||||||
|
+ if (tTreeCapture!=null&&tTreeCapture.mEnable)
|
||||||
+ {
|
+ {
|
||||||
+ for (net.minecraftforge.common.util.BlockSnapshot blocksnapshot : capturedBlockSnapshots)
|
+ for (net.minecraftforge.common.util.BlockSnapshot blocksnapshot : tTreeCapture.mCapturedBlocks)
|
||||||
+ {
|
+ {
|
||||||
+ if (blocksnapshot.x == p_147439_1_ && blocksnapshot.y == p_147439_2_ && blocksnapshot.z == p_147439_3_)
|
+ if (blocksnapshot.x == p_147439_1_ && blocksnapshot.y == p_147439_2_ && blocksnapshot.z == p_147439_3_)
|
||||||
+ {
|
+ {
|
||||||
@ -494,7 +513,7 @@
|
|||||||
if (p_147439_1_ >= -30000000 && p_147439_3_ >= -30000000 && p_147439_1_ < 30000000 && p_147439_3_ < 30000000 && p_147439_2_ >= 0 && p_147439_2_ < 256)
|
if (p_147439_1_ >= -30000000 && p_147439_3_ >= -30000000 && p_147439_1_ < 30000000 && p_147439_3_ < 30000000 && p_147439_2_ >= 0 && p_147439_2_ < 256)
|
||||||
{
|
{
|
||||||
Chunk chunk = null;
|
Chunk chunk = null;
|
||||||
@@ -404,7 +741,7 @@
|
@@ -404,7 +717,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -503,16 +522,17 @@
|
|||||||
{
|
{
|
||||||
return this.chunkProvider.chunkExists(p_72916_1_, p_72916_2_);
|
return this.chunkProvider.chunkExists(p_72916_1_, p_72916_2_);
|
||||||
}
|
}
|
||||||
@@ -421,6 +758,27 @@
|
@@ -421,6 +734,28 @@
|
||||||
|
|
||||||
public boolean setBlock(int p_147465_1_, int p_147465_2_, int p_147465_3_, Block p_147465_4_, int p_147465_5_, int p_147465_6_)
|
public boolean setBlock(int p_147465_1_, int p_147465_2_, int p_147465_3_, Block p_147465_4_, int p_147465_5_, int p_147465_6_)
|
||||||
{
|
{
|
||||||
+ // Cauldron start - tree generation
|
+ // Cauldron start - tree generation
|
||||||
+ if (this.captureTreeGeneration)
|
+ CaptureTree tTreeCapture=this.mCapture.getLastTreeGenCapture();
|
||||||
|
+ if (tTreeCapture!=null&&tTreeCapture.mEnable)
|
||||||
+ {
|
+ {
|
||||||
+ net.minecraftforge.common.util.BlockSnapshot blocksnapshot = null;
|
+ net.minecraftforge.common.util.BlockSnapshot blocksnapshot = null;
|
||||||
+
|
+
|
||||||
+ for (net.minecraftforge.common.util.BlockSnapshot previous : capturedBlockSnapshots)
|
+ for (net.minecraftforge.common.util.BlockSnapshot previous : tTreeCapture.mCapturedBlocks)
|
||||||
+ {
|
+ {
|
||||||
+ if (previous.x == p_147465_1_ && previous.y == p_147465_2_ && previous.z == p_147465_3_)
|
+ if (previous.x == p_147465_1_ && previous.y == p_147465_2_ && previous.z == p_147465_3_)
|
||||||
+ {
|
+ {
|
||||||
@ -522,42 +542,65 @@
|
|||||||
+ }
|
+ }
|
||||||
+ if (blocksnapshot != null)
|
+ if (blocksnapshot != null)
|
||||||
+ {
|
+ {
|
||||||
+ capturedBlockSnapshots.remove(blocksnapshot);
|
+ tTreeCapture.mCapturedBlocks.remove(blocksnapshot);
|
||||||
+ }
|
+ }
|
||||||
+ this.capturedBlockSnapshots.add(new net.minecraftforge.common.util.BlockSnapshot(this, p_147465_1_, p_147465_2_, p_147465_3_, p_147465_4_, p_147465_5_, p_147465_6_));
|
+ tTreeCapture.mCapturedBlocks.add(new net.minecraftforge.common.util.BlockSnapshot(this, p_147465_1_, p_147465_2_, p_147465_3_, p_147465_4_, p_147465_5_, p_147465_6_));
|
||||||
+ return true;
|
+ return true;
|
||||||
+ }
|
+ }
|
||||||
+ // Cauldron end
|
+ // Cauldron end
|
||||||
if (p_147465_1_ >= -30000000 && p_147465_3_ >= -30000000 && p_147465_1_ < 30000000 && p_147465_3_ < 30000000)
|
if (p_147465_1_ >= -30000000 && p_147465_3_ >= -30000000 && p_147465_1_ < 30000000 && p_147465_3_ < 30000000)
|
||||||
{
|
{
|
||||||
if (p_147465_2_ < 0)
|
if (p_147465_2_ < 0)
|
||||||
@@ -450,7 +808,9 @@
|
@@ -435,32 +770,29 @@
|
||||||
|
{
|
||||||
|
Chunk chunk = this.getChunkFromChunkCoords(p_147465_1_ >> 4, p_147465_3_ >> 4);
|
||||||
|
Block block1 = null;
|
||||||
|
- net.minecraftforge.common.util.BlockSnapshot blockSnapshot = null;
|
||||||
|
|
||||||
|
if ((p_147465_6_ & 1) != 0)
|
||||||
|
{
|
||||||
|
block1 = chunk.getBlock(p_147465_1_ & 15, p_147465_2_, p_147465_3_ & 15);
|
||||||
|
}
|
||||||
|
|
||||||
|
- if (this.captureBlockSnapshots && !this.isRemote)
|
||||||
|
- {
|
||||||
|
- blockSnapshot = net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(this, p_147465_1_, p_147465_2_, p_147465_3_, p_147465_6_);
|
||||||
|
- this.capturedBlockSnapshots.add(blockSnapshot);
|
||||||
|
+ CaptureBlock tBlockCapture=this.mCapture.getLastBlockCapture();
|
||||||
|
+ BlockSnapshot tSnapshot=null;
|
||||||
|
+ if(tBlockCapture!=null&&tBlockCapture.mEnable){
|
||||||
|
+ tSnapshot=BlockSnapshot.getBlockSnapshot(this,p_147465_1_,p_147465_2_,p_147465_3_,p_147465_6_);
|
||||||
|
}
|
||||||
|
-
|
||||||
boolean flag = chunk.func_150807_a(p_147465_1_ & 15, p_147465_2_, p_147465_3_ & 15, p_147465_4_, p_147465_5_);
|
boolean flag = chunk.func_150807_a(p_147465_1_ & 15, p_147465_2_, p_147465_3_ & 15, p_147465_4_, p_147465_5_);
|
||||||
|
|
||||||
- if (!flag && blockSnapshot != null)
|
- if (!flag && blockSnapshot != null)
|
||||||
+ // Cauldron end
|
- {
|
||||||
+
|
- this.capturedBlockSnapshots.remove(blockSnapshot);
|
||||||
+ if (!flag && this.captureBlockSnapshots && blockSnapshot != null)
|
- blockSnapshot = null;
|
||||||
{
|
+ if(flag&&tSnapshot!=null){
|
||||||
this.capturedBlockSnapshots.remove(blockSnapshot);
|
+ tBlockCapture.addCapturedBlock(tSnapshot);
|
||||||
blockSnapshot = null;
|
}
|
||||||
@@ -460,6 +820,7 @@
|
|
||||||
|
this.theProfiler.startSection("checkLight");
|
||||||
this.func_147451_t(p_147465_1_, p_147465_2_, p_147465_3_);
|
this.func_147451_t(p_147465_1_, p_147465_2_, p_147465_3_);
|
||||||
this.theProfiler.endSection();
|
this.theProfiler.endSection();
|
||||||
|
|
||||||
|
- if (flag && blockSnapshot == null) // Don't notify clients or update physics while capturing blockstates
|
||||||
+ // Cauldron add !this.captureBlockStates
|
+ // Cauldron add !this.captureBlockStates
|
||||||
if (flag && blockSnapshot == null) // Don't notify clients or update physics while capturing blockstates
|
+ if (flag && tBlockCapture != null&&tBlockCapture.mEnable) // Don't notify clients or update physics while capturing blockstates
|
||||||
{
|
{
|
||||||
// Modularize client and physic updates
|
// Modularize client and physic updates
|
||||||
@@ -496,6 +857,19 @@
|
this.markAndNotifyBlock(p_147465_1_, p_147465_2_, p_147465_3_, chunk, block1, p_147465_4_, p_147465_6_);
|
||||||
|
@@ -496,6 +828,20 @@
|
||||||
|
|
||||||
public int getBlockMetadata(int p_72805_1_, int p_72805_2_, int p_72805_3_)
|
public int getBlockMetadata(int p_72805_1_, int p_72805_2_, int p_72805_3_)
|
||||||
{
|
{
|
||||||
+ // Cauldron start - tree generation
|
+ // Cauldron start - tree generation
|
||||||
+ if (captureTreeGeneration)
|
+ CaptureTree treeGenCapture=this.mCapture.getLastTreeGenCapture();
|
||||||
|
+ if (treeGenCapture!=null&&treeGenCapture.mEnable)
|
||||||
+ {
|
+ {
|
||||||
+ for (net.minecraftforge.common.util.BlockSnapshot blocksnapshot : capturedBlockSnapshots)
|
+ for (net.minecraftforge.common.util.BlockSnapshot blocksnapshot : treeGenCapture.mCapturedBlocks)
|
||||||
+ {
|
+ {
|
||||||
+ if (blocksnapshot.x == p_72805_1_ && blocksnapshot.y == p_72805_2_ && blocksnapshot.z == p_72805_3_)
|
+ if (blocksnapshot.x == p_72805_1_ && blocksnapshot.y == p_72805_2_ && blocksnapshot.z == p_72805_3_)
|
||||||
+ {
|
+ {
|
||||||
@ -570,7 +613,7 @@
|
|||||||
if (p_72805_1_ >= -30000000 && p_72805_3_ >= -30000000 && p_72805_1_ < 30000000 && p_72805_3_ < 30000000)
|
if (p_72805_1_ >= -30000000 && p_72805_3_ >= -30000000 && p_72805_1_ < 30000000 && p_72805_3_ < 30000000)
|
||||||
{
|
{
|
||||||
if (p_72805_2_ < 0)
|
if (p_72805_2_ < 0)
|
||||||
@@ -511,7 +885,7 @@
|
@@ -511,7 +857,7 @@
|
||||||
Chunk chunk = this.getChunkFromChunkCoords(p_72805_1_ >> 4, p_72805_3_ >> 4);
|
Chunk chunk = this.getChunkFromChunkCoords(p_72805_1_ >> 4, p_72805_3_ >> 4);
|
||||||
p_72805_1_ &= 15;
|
p_72805_1_ &= 15;
|
||||||
p_72805_3_ &= 15;
|
p_72805_3_ &= 15;
|
||||||
@ -579,7 +622,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -610,6 +984,12 @@
|
@@ -610,6 +956,12 @@
|
||||||
|
|
||||||
public void notifyBlockChange(int p_147444_1_, int p_147444_2_, int p_147444_3_, Block p_147444_4_)
|
public void notifyBlockChange(int p_147444_1_, int p_147444_2_, int p_147444_3_, Block p_147444_4_)
|
||||||
{
|
{
|
||||||
@ -592,7 +635,7 @@
|
|||||||
this.notifyBlocksOfNeighborChange(p_147444_1_, p_147444_2_, p_147444_3_, p_147444_4_);
|
this.notifyBlocksOfNeighborChange(p_147444_1_, p_147444_2_, p_147444_3_, p_147444_4_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -694,6 +1074,21 @@
|
@@ -694,6 +1046,21 @@
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -614,7 +657,7 @@
|
|||||||
block.onNeighborBlockChange(this, p_147460_1_, p_147460_2_, p_147460_3_, p_147460_4_);
|
block.onNeighborBlockChange(this, p_147460_1_, p_147460_2_, p_147460_3_, p_147460_4_);
|
||||||
}
|
}
|
||||||
catch (Throwable throwable1)
|
catch (Throwable throwable1)
|
||||||
@@ -1307,8 +1702,22 @@
|
@@ -1307,8 +1674,22 @@
|
||||||
|
|
||||||
public boolean spawnEntityInWorld(Entity p_72838_1_)
|
public boolean spawnEntityInWorld(Entity p_72838_1_)
|
||||||
{
|
{
|
||||||
@ -630,15 +673,15 @@
|
|||||||
+ if(!this.isRemote){
|
+ if(!this.isRemote){
|
||||||
+ if(p_72838_1_ instanceof net.minecraft.entity.item.EntityItem&&this.restoringBlockSnapshots)
|
+ if(p_72838_1_ instanceof net.minecraft.entity.item.EntityItem&&this.restoringBlockSnapshots)
|
||||||
+ return false;
|
+ return false;
|
||||||
+ if(this.captureBlockSnapshots&&!(p_72838_1_ instanceof EntityPlayerMP)){
|
+ if(this.mCapture.isCapture()&&!(p_72838_1_ instanceof EntityPlayerMP)){
|
||||||
+ this.capturedEntitySnapshots.add(new net.minecraftforge.common.util.EntitySnapshot(this,p_72838_1_,spawnReason));
|
+ this.mCapture.addCaptureEntity(this,p_72838_1_,spawnReason);
|
||||||
+ return true;
|
+ return true;
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
|
|
||||||
int i = MathHelper.floor_double(p_72838_1_.posX / 16.0D);
|
int i = MathHelper.floor_double(p_72838_1_.posX / 16.0D);
|
||||||
int j = MathHelper.floor_double(p_72838_1_.posZ / 16.0D);
|
int j = MathHelper.floor_double(p_72838_1_.posZ / 16.0D);
|
||||||
@@ -1319,23 +1728,99 @@
|
@@ -1319,23 +1700,99 @@
|
||||||
flag = true;
|
flag = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -740,7 +783,7 @@
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1346,6 +1831,8 @@
|
@@ -1346,6 +1803,8 @@
|
||||||
{
|
{
|
||||||
((IWorldAccess)this.worldAccesses.get(i)).onEntityCreate(p_72923_1_);
|
((IWorldAccess)this.worldAccesses.get(i)).onEntityCreate(p_72923_1_);
|
||||||
}
|
}
|
||||||
@ -749,7 +792,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void onEntityRemoved(Entity p_72847_1_)
|
public void onEntityRemoved(Entity p_72847_1_)
|
||||||
@@ -1354,6 +1841,8 @@
|
@@ -1354,6 +1813,8 @@
|
||||||
{
|
{
|
||||||
((IWorldAccess)this.worldAccesses.get(i)).onEntityDestroy(p_72847_1_);
|
((IWorldAccess)this.worldAccesses.get(i)).onEntityDestroy(p_72847_1_);
|
||||||
}
|
}
|
||||||
@ -758,7 +801,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void removeEntity(Entity p_72900_1_)
|
public void removeEntity(Entity p_72900_1_)
|
||||||
@@ -1397,6 +1886,19 @@
|
@@ -1397,6 +1858,19 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
this.loadedEntityList.remove(p_72973_1_);
|
this.loadedEntityList.remove(p_72973_1_);
|
||||||
@ -778,7 +821,7 @@
|
|||||||
this.onEntityRemoved(p_72973_1_);
|
this.onEntityRemoved(p_72973_1_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1408,40 +1910,58 @@
|
@@ -1408,40 +1882,58 @@
|
||||||
public List getCollidingBoundingBoxes(Entity p_72945_1_, AxisAlignedBB p_72945_2_)
|
public List getCollidingBoundingBoxes(Entity p_72945_1_, AxisAlignedBB p_72945_2_)
|
||||||
{
|
{
|
||||||
this.collidingBoundingBoxes.clear();
|
this.collidingBoundingBoxes.clear();
|
||||||
@ -851,7 +894,7 @@
|
|||||||
|
|
||||||
for (int j2 = 0; j2 < list.size(); ++j2)
|
for (int j2 = 0; j2 < list.size(); ++j2)
|
||||||
{
|
{
|
||||||
@@ -1797,11 +2317,22 @@
|
@@ -1797,11 +2289,22 @@
|
||||||
Entity entity;
|
Entity entity;
|
||||||
CrashReport crashreport;
|
CrashReport crashreport;
|
||||||
CrashReportCategory crashreportcategory;
|
CrashReportCategory crashreportcategory;
|
||||||
@ -874,7 +917,7 @@
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
++entity.ticksExisted;
|
++entity.ticksExisted;
|
||||||
@@ -1812,14 +2343,7 @@
|
@@ -1812,14 +2315,7 @@
|
||||||
crashreport = CrashReport.makeCrashReport(throwable2, "Ticking entity");
|
crashreport = CrashReport.makeCrashReport(throwable2, "Ticking entity");
|
||||||
crashreportcategory = crashreport.makeCategory("Entity being ticked");
|
crashreportcategory = crashreport.makeCategory("Entity being ticked");
|
||||||
|
|
||||||
@ -890,7 +933,7 @@
|
|||||||
|
|
||||||
if (ForgeModContainer.removeErroringEntities)
|
if (ForgeModContainer.removeErroringEntities)
|
||||||
{
|
{
|
||||||
@@ -1862,10 +2386,14 @@
|
@@ -1862,10 +2358,14 @@
|
||||||
|
|
||||||
this.unloadedEntityList.clear();
|
this.unloadedEntityList.clear();
|
||||||
this.theProfiler.endStartSection("regular");
|
this.theProfiler.endStartSection("regular");
|
||||||
@ -908,7 +951,7 @@
|
|||||||
|
|
||||||
if (entity.ridingEntity != null)
|
if (entity.ridingEntity != null)
|
||||||
{
|
{
|
||||||
@@ -1884,7 +2412,9 @@
|
@@ -1884,7 +2384,9 @@
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@ -918,7 +961,7 @@
|
|||||||
}
|
}
|
||||||
catch (Throwable throwable1)
|
catch (Throwable throwable1)
|
||||||
{
|
{
|
||||||
@@ -1916,30 +2446,84 @@
|
@@ -1916,30 +2418,84 @@
|
||||||
{
|
{
|
||||||
this.getChunkFromChunkCoords(j, l).removeEntity(entity);
|
this.getChunkFromChunkCoords(j, l).removeEntity(entity);
|
||||||
}
|
}
|
||||||
@ -1010,7 +1053,7 @@
|
|||||||
crashreport = CrashReport.makeCrashReport(throwable, "Ticking block entity");
|
crashreport = CrashReport.makeCrashReport(throwable, "Ticking block entity");
|
||||||
crashreportcategory = crashreport.makeCategory("Block entity being ticked");
|
crashreportcategory = crashreport.makeCategory("Block entity being ticked");
|
||||||
tileentity.func_145828_a(crashreportcategory);
|
tileentity.func_145828_a(crashreportcategory);
|
||||||
@@ -1955,23 +2539,13 @@
|
@@ -1955,23 +2511,13 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1039,7 +1082,7 @@
|
|||||||
if (!this.field_147483_b.isEmpty())
|
if (!this.field_147483_b.isEmpty())
|
||||||
{
|
{
|
||||||
for (Object tile : field_147483_b)
|
for (Object tile : field_147483_b)
|
||||||
@@ -1981,6 +2555,7 @@
|
@@ -1981,6 +2527,7 @@
|
||||||
this.loadedTileEntityList.removeAll(this.field_147483_b);
|
this.loadedTileEntityList.removeAll(this.field_147483_b);
|
||||||
this.field_147483_b.clear();
|
this.field_147483_b.clear();
|
||||||
}
|
}
|
||||||
@ -1047,7 +1090,7 @@
|
|||||||
|
|
||||||
this.field_147481_N = false;
|
this.field_147481_N = false;
|
||||||
|
|
||||||
@@ -2016,17 +2591,23 @@
|
@@ -2016,17 +2563,23 @@
|
||||||
this.addedTileEntityList.clear();
|
this.addedTileEntityList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1074,7 +1117,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void updateEntity(Entity p_72870_1_)
|
public void updateEntity(Entity p_72870_1_)
|
||||||
@@ -2036,21 +2617,41 @@
|
@@ -2036,21 +2589,41 @@
|
||||||
|
|
||||||
public void updateEntityWithOptionalForce(Entity p_72866_1_, boolean p_72866_2_)
|
public void updateEntityWithOptionalForce(Entity p_72866_1_, boolean p_72866_2_)
|
||||||
{
|
{
|
||||||
@ -1118,7 +1161,7 @@
|
|||||||
p_72866_1_.lastTickPosX = p_72866_1_.posX;
|
p_72866_1_.lastTickPosX = p_72866_1_.posX;
|
||||||
p_72866_1_.lastTickPosY = p_72866_1_.posY;
|
p_72866_1_.lastTickPosY = p_72866_1_.posY;
|
||||||
p_72866_1_.lastTickPosZ = p_72866_1_.posZ;
|
p_72866_1_.lastTickPosZ = p_72866_1_.posZ;
|
||||||
@@ -2134,6 +2735,7 @@
|
@@ -2134,6 +2707,7 @@
|
||||||
p_72866_1_.riddenByEntity = null;
|
p_72866_1_.riddenByEntity = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1126,7 +1169,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2570,7 +3172,7 @@
|
@@ -2570,7 +3144,7 @@
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1135,7 +1178,7 @@
|
|||||||
{
|
{
|
||||||
if (this.field_147481_N)
|
if (this.field_147481_N)
|
||||||
{
|
{
|
||||||
@@ -2612,6 +3214,9 @@
|
@@ -2612,6 +3186,9 @@
|
||||||
|
|
||||||
public void func_147457_a(TileEntity p_147457_1_)
|
public void func_147457_a(TileEntity p_147457_1_)
|
||||||
{
|
{
|
||||||
@ -1145,7 +1188,7 @@
|
|||||||
this.field_147483_b.add(p_147457_1_);
|
this.field_147483_b.add(p_147457_1_);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2718,7 +3323,15 @@
|
@@ -2718,7 +3295,15 @@
|
||||||
|
|
||||||
if (i <= 0)
|
if (i <= 0)
|
||||||
{
|
{
|
||||||
@ -1162,7 +1205,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2754,7 +3367,15 @@
|
@@ -2754,7 +3339,15 @@
|
||||||
|
|
||||||
if (j <= 0)
|
if (j <= 0)
|
||||||
{
|
{
|
||||||
@ -1179,7 +1222,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2777,8 +3398,41 @@
|
@@ -2777,8 +3370,41 @@
|
||||||
protected void setActivePlayerChunksAndCheckLight()
|
protected void setActivePlayerChunksAndCheckLight()
|
||||||
{
|
{
|
||||||
this.activeChunkSet.clear();
|
this.activeChunkSet.clear();
|
||||||
@ -1222,7 +1265,7 @@
|
|||||||
int i;
|
int i;
|
||||||
EntityPlayer entityplayer;
|
EntityPlayer entityplayer;
|
||||||
int j;
|
int j;
|
||||||
@@ -2788,17 +3442,28 @@
|
@@ -2788,17 +3414,28 @@
|
||||||
for (i = 0; i < this.playerEntities.size(); ++i)
|
for (i = 0; i < this.playerEntities.size(); ++i)
|
||||||
{
|
{
|
||||||
entityplayer = (EntityPlayer)this.playerEntities.get(i);
|
entityplayer = (EntityPlayer)this.playerEntities.get(i);
|
||||||
@ -1257,7 +1300,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.theProfiler.endSection();
|
this.theProfiler.endSection();
|
||||||
@@ -2810,7 +3475,7 @@
|
@@ -2810,7 +3447,7 @@
|
||||||
|
|
||||||
this.theProfiler.startSection("playerCheckLight");
|
this.theProfiler.startSection("playerCheckLight");
|
||||||
|
|
||||||
@ -1266,7 +1309,7 @@
|
|||||||
{
|
{
|
||||||
i = this.rand.nextInt(this.playerEntities.size());
|
i = this.rand.nextInt(this.playerEntities.size());
|
||||||
entityplayer = (EntityPlayer)this.playerEntities.get(i);
|
entityplayer = (EntityPlayer)this.playerEntities.get(i);
|
||||||
@@ -3034,9 +3699,9 @@
|
@@ -3034,9 +3671,9 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1278,7 +1321,7 @@
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -3166,6 +3831,16 @@
|
@@ -3166,6 +3803,16 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1295,7 +1338,7 @@
|
|||||||
this.theProfiler.endSection();
|
this.theProfiler.endSection();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -3284,8 +3959,21 @@
|
@@ -3284,8 +3931,21 @@
|
||||||
{
|
{
|
||||||
Entity entity = (Entity)this.loadedEntityList.get(j);
|
Entity entity = (Entity)this.loadedEntityList.get(j);
|
||||||
|
|
||||||
@ -1318,7 +1361,7 @@
|
|||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3298,6 +3986,7 @@
|
@@ -3298,6 +3958,7 @@
|
||||||
for (int i = 0; i < p_72868_1_.size(); ++i)
|
for (int i = 0; i < p_72868_1_.size(); ++i)
|
||||||
{
|
{
|
||||||
Entity entity = (Entity)p_72868_1_.get(i);
|
Entity entity = (Entity)p_72868_1_.get(i);
|
||||||
@ -1326,7 +1369,7 @@
|
|||||||
if (!MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(entity, this)))
|
if (!MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(entity, this)))
|
||||||
{
|
{
|
||||||
loadedEntityList.add(entity);
|
loadedEntityList.add(entity);
|
||||||
@@ -3314,8 +4003,17 @@
|
@@ -3314,8 +3975,17 @@
|
||||||
public boolean canPlaceEntityOnSide(Block p_147472_1_, int p_147472_2_, int p_147472_3_, int p_147472_4_, boolean p_147472_5_, int p_147472_6_, Entity p_147472_7_, ItemStack p_147472_8_)
|
public boolean canPlaceEntityOnSide(Block p_147472_1_, int p_147472_2_, int p_147472_3_, int p_147472_4_, boolean p_147472_5_, int p_147472_6_, Entity p_147472_7_, ItemStack p_147472_8_)
|
||||||
{
|
{
|
||||||
Block block1 = this.getBlock(p_147472_2_, p_147472_3_, p_147472_4_);
|
Block block1 = this.getBlock(p_147472_2_, p_147472_3_, p_147472_4_);
|
||||||
@ -1345,7 +1388,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public PathEntity getPathEntityToEntity(Entity p_72865_1_, Entity p_72865_2_, float p_72865_3_, boolean p_72865_4_, boolean p_72865_5_, boolean p_72865_6_, boolean p_72865_7_)
|
public PathEntity getPathEntityToEntity(Entity p_72865_1_, Entity p_72865_2_, float p_72865_3_, boolean p_72865_4_, boolean p_72865_5_, boolean p_72865_6_, boolean p_72865_7_)
|
||||||
@@ -3464,6 +4162,12 @@
|
@@ -3464,6 +4134,12 @@
|
||||||
for (int i = 0; i < this.playerEntities.size(); ++i)
|
for (int i = 0; i < this.playerEntities.size(); ++i)
|
||||||
{
|
{
|
||||||
EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i);
|
EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i);
|
||||||
@ -1358,7 +1401,7 @@
|
|||||||
double d5 = entityplayer1.getDistanceSq(p_72977_1_, p_72977_3_, p_72977_5_);
|
double d5 = entityplayer1.getDistanceSq(p_72977_1_, p_72977_3_, p_72977_5_);
|
||||||
|
|
||||||
if ((p_72977_7_ < 0.0D || d5 < p_72977_7_ * p_72977_7_) && (d4 == -1.0D || d5 < d4))
|
if ((p_72977_7_ < 0.0D || d5 < p_72977_7_ * p_72977_7_) && (d4 == -1.0D || d5 < d4))
|
||||||
@@ -3489,7 +4193,12 @@
|
@@ -3489,7 +4165,12 @@
|
||||||
for (int i = 0; i < this.playerEntities.size(); ++i)
|
for (int i = 0; i < this.playerEntities.size(); ++i)
|
||||||
{
|
{
|
||||||
EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i);
|
EntityPlayer entityplayer1 = (EntityPlayer)this.playerEntities.get(i);
|
||||||
@ -1372,7 +1415,7 @@
|
|||||||
if (!entityplayer1.capabilities.disableDamage && entityplayer1.isEntityAlive())
|
if (!entityplayer1.capabilities.disableDamage && entityplayer1.isEntityAlive())
|
||||||
{
|
{
|
||||||
double d5 = entityplayer1.getDistanceSq(p_72846_1_, p_72846_3_, p_72846_5_);
|
double d5 = entityplayer1.getDistanceSq(p_72846_1_, p_72846_3_, p_72846_5_);
|
||||||
@@ -3660,6 +4369,18 @@
|
@@ -3660,6 +4341,18 @@
|
||||||
|
|
||||||
public void updateAllPlayersSleepingFlag() {}
|
public void updateAllPlayersSleepingFlag() {}
|
||||||
|
|
||||||
@ -1391,7 +1434,7 @@
|
|||||||
public float getWeightedThunderStrength(float p_72819_1_)
|
public float getWeightedThunderStrength(float p_72819_1_)
|
||||||
{
|
{
|
||||||
return (this.prevThunderingStrength + (this.thunderingStrength - this.prevThunderingStrength) * p_72819_1_) * this.getRainStrength(p_72819_1_);
|
return (this.prevThunderingStrength + (this.thunderingStrength - this.prevThunderingStrength) * p_72819_1_) * this.getRainStrength(p_72819_1_);
|
||||||
@@ -3932,8 +4653,8 @@
|
@@ -3932,8 +4625,8 @@
|
||||||
*/
|
*/
|
||||||
public void addTileEntity(TileEntity entity)
|
public void addTileEntity(TileEntity entity)
|
||||||
{
|
{
|
||||||
@ -1402,7 +1445,7 @@
|
|||||||
{
|
{
|
||||||
dest.add(entity);
|
dest.add(entity);
|
||||||
}
|
}
|
||||||
@@ -4029,4 +4750,122 @@
|
@@ -4029,4 +4722,122 @@
|
||||||
}
|
}
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,74 @@
|
|||||||
--- ../src-base/minecraft/net/minecraftforge/common/ForgeHooks.java
|
--- ../src-base/minecraft/net/minecraftforge/common/ForgeHooks.java
|
||||||
+++ ../src-work/minecraft/net/minecraftforge/common/ForgeHooks.java
|
+++ ../src-work/minecraft/net/minecraftforge/common/ForgeHooks.java
|
||||||
@@ -63,6 +63,16 @@
|
@@ -1,5 +1,14 @@
|
||||||
import net.minecraftforge.event.world.BlockEvent;
|
package net.minecraftforge.common;
|
||||||
import net.minecraftforge.event.world.NoteBlockEvent;
|
|
||||||
import static net.minecraft.init.Blocks.*;
|
+import static net.minecraft.init.Blocks.diamond_block;
|
||||||
|
+import static net.minecraft.init.Blocks.diamond_ore;
|
||||||
|
+import static net.minecraft.init.Blocks.emerald_block;
|
||||||
|
+import static net.minecraft.init.Blocks.emerald_ore;
|
||||||
|
+import static net.minecraft.init.Blocks.gold_block;
|
||||||
|
+import static net.minecraft.init.Blocks.gold_ore;
|
||||||
|
+import static net.minecraft.init.Blocks.lit_redstone_ore;
|
||||||
|
+import static net.minecraft.init.Blocks.redstone_ore;
|
||||||
|
+
|
||||||
|
import java.net.URI;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
@@ -7,6 +16,8 @@
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
+import cc.capture.type.CaptureBlock;
|
||||||
|
+import cc.capture.type.CaptureTree;
|
||||||
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
|
import cpw.mods.fml.relauncher.ReflectionHelper;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
@@ -20,19 +31,15 @@
|
||||||
|
import net.minecraft.inventory.Container;
|
||||||
|
import net.minecraft.inventory.ContainerRepair;
|
||||||
|
import net.minecraft.inventory.IInventory;
|
||||||
|
-import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemArmor;
|
||||||
|
import net.minecraft.item.ItemAxe;
|
||||||
|
import net.minecraft.item.ItemBucket;
|
||||||
|
import net.minecraft.item.ItemPickaxe;
|
||||||
|
import net.minecraft.item.ItemSpade;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
-import net.minecraft.item.ItemSword;
|
||||||
|
-import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.network.NetHandlerPlayServer;
|
||||||
|
import net.minecraft.network.Packet;
|
||||||
|
import net.minecraft.network.play.server.S23PacketBlockChange;
|
||||||
|
-import net.minecraft.stats.StatList;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.tileentity.TileEntityNote;
|
||||||
|
import net.minecraft.util.AxisAlignedBB;
|
||||||
|
@@ -46,8 +53,9 @@
|
||||||
|
import net.minecraft.util.WeightedRandom;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraft.world.WorldSettings.GameType;
|
||||||
+// Cauldron start
|
+// Cauldron start
|
||||||
+import net.minecraftforge.common.util.FakePlayer;
|
+import net.minecraftforge.common.util.FakePlayer;
|
||||||
+import org.bukkit.Bukkit;
|
import net.minecraftforge.event.AnvilUpdateEvent;
|
||||||
+import org.bukkit.Location;
|
-import net.minecraftforge.event.ForgeEventFactory;
|
||||||
+import org.bukkit.TreeType;
|
import net.minecraftforge.event.ServerChatEvent;
|
||||||
+import org.bukkit.block.BlockState;
|
import net.minecraftforge.event.entity.item.ItemTossEvent;
|
||||||
+import org.bukkit.craftbukkit.block.CraftBlockState;
|
import net.minecraftforge.event.entity.living.LivingAttackEvent;
|
||||||
+import org.bukkit.entity.Player;
|
@@ -58,11 +66,10 @@
|
||||||
+import org.bukkit.event.world.StructureGrowEvent;
|
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||||
+//Cauldron end
|
import net.minecraftforge.event.entity.living.LivingHurtEvent;
|
||||||
|
import net.minecraftforge.event.entity.living.LivingSetAttackTargetEvent;
|
||||||
|
-import net.minecraftforge.event.entity.player.PlayerOpenContainerEvent;
|
||||||
|
import net.minecraftforge.event.entity.player.AnvilRepairEvent;
|
||||||
|
+import net.minecraftforge.event.entity.player.PlayerOpenContainerEvent;
|
||||||
|
import net.minecraftforge.event.world.BlockEvent;
|
||||||
|
import net.minecraftforge.event.world.NoteBlockEvent;
|
||||||
|
-import static net.minecraft.init.Blocks.*;
|
||||||
|
|
||||||
public class ForgeHooks
|
public class ForgeHooks
|
||||||
{
|
{
|
||||||
@@ -379,10 +389,12 @@
|
@@ -379,10 +386,12 @@
|
||||||
public static ChatComponentTranslation onServerChatEvent(NetHandlerPlayServer net, String raw, ChatComponentTranslation comp)
|
public static ChatComponentTranslation onServerChatEvent(NetHandlerPlayServer net, String raw, ChatComponentTranslation comp)
|
||||||
{
|
{
|
||||||
ServerChatEvent event = new ServerChatEvent(net.playerEntity, raw, comp);
|
ServerChatEvent event = new ServerChatEvent(net.playerEntity, raw, comp);
|
||||||
@ -30,7 +81,7 @@
|
|||||||
return event.component;
|
return event.component;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -439,6 +451,8 @@
|
@@ -439,6 +448,8 @@
|
||||||
|
|
||||||
public static BlockEvent.BreakEvent onBlockBreakEvent(World world, GameType gameType, EntityPlayerMP entityPlayer, int x, int y, int z)
|
public static BlockEvent.BreakEvent onBlockBreakEvent(World world, GameType gameType, EntityPlayerMP entityPlayer, int x, int y, int z)
|
||||||
{
|
{
|
||||||
@ -39,7 +90,7 @@
|
|||||||
// Logic from tryHarvestBlock for pre-canceling the event
|
// Logic from tryHarvestBlock for pre-canceling the event
|
||||||
boolean preCancelEvent = false;
|
boolean preCancelEvent = false;
|
||||||
if (gameType.isAdventure() && !entityPlayer.isCurrentToolAdventureModeExempt(x, y, z))
|
if (gameType.isAdventure() && !entityPlayer.isCurrentToolAdventureModeExempt(x, y, z))
|
||||||
@@ -449,9 +463,9 @@
|
@@ -449,9 +460,9 @@
|
||||||
{
|
{
|
||||||
preCancelEvent = true;
|
preCancelEvent = true;
|
||||||
}
|
}
|
||||||
@ -51,7 +102,7 @@
|
|||||||
{
|
{
|
||||||
S23PacketBlockChange packet = new S23PacketBlockChange(x, y, z, world);
|
S23PacketBlockChange packet = new S23PacketBlockChange(x, y, z, world);
|
||||||
packet.field_148883_d = Blocks.air;
|
packet.field_148883_d = Blocks.air;
|
||||||
@@ -463,11 +477,11 @@
|
@@ -463,11 +474,11 @@
|
||||||
Block block = world.getBlock(x, y, z);
|
Block block = world.getBlock(x, y, z);
|
||||||
int blockMetadata = world.getBlockMetadata(x, y, z);
|
int blockMetadata = world.getBlockMetadata(x, y, z);
|
||||||
BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(x, y, z, world, block, blockMetadata, entityPlayer);
|
BlockEvent.BreakEvent event = new BlockEvent.BreakEvent(x, y, z, world, block, blockMetadata, entityPlayer);
|
||||||
@ -65,62 +116,73 @@
|
|||||||
{
|
{
|
||||||
// Let the client know the block still exists
|
// Let the client know the block still exists
|
||||||
entityPlayer.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
|
entityPlayer.playerNetServerHandler.sendPacket(new S23PacketBlockChange(x, y, z, world));
|
||||||
@@ -500,81 +514,157 @@
|
@@ -488,95 +499,43 @@
|
||||||
if (!(itemstack.getItem() instanceof ItemBucket)) // if not bucket
|
|
||||||
|
public static boolean onPlaceItemIntoWorld(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ)
|
||||||
{
|
{
|
||||||
world.captureBlockSnapshots = true;
|
- // handle all placement events here
|
||||||
|
- int meta = itemstack.getItemDamage();
|
||||||
|
- int size = itemstack.stackSize;
|
||||||
|
- NBTTagCompound nbt = null;
|
||||||
|
- if (itemstack.getTagCompound() != null)
|
||||||
|
- {
|
||||||
|
- nbt = (NBTTagCompound)itemstack.getTagCompound().copy();
|
||||||
|
- }
|
||||||
|
+ // handle all placement events here
|
||||||
|
+ CaptureBlock tCapture=null;
|
||||||
|
+ CaptureTree tTreeGenCapture=null;
|
||||||
|
|
||||||
|
- if (!(itemstack.getItem() instanceof ItemBucket)) // if not bucket
|
||||||
|
- {
|
||||||
|
- world.captureBlockSnapshots = true;
|
||||||
|
+ if(!(itemstack.getItem() instanceof ItemBucket)){ // if not bucket
|
||||||
|
+ tCapture=world.mCapture.startCapture(player,itemstack);
|
||||||
|
+ tCapture.setAgaistPostionAndSide(side,x,y,z);
|
||||||
+ // Cauldron start
|
+ // Cauldron start
|
||||||
+ if (itemstack.getItem() instanceof net.minecraft.item.ItemDye && itemstack.getItemDamage() == 15)
|
+ if(itemstack.getItem() instanceof net.minecraft.item.ItemDye&&itemstack.getItemDamage()==15){
|
||||||
+ {
|
+ Block block=world.getBlock(x,y,z);
|
||||||
+ Block block = world.getBlock(x, y, z);
|
+ if(block!=null&&(block instanceof net.minecraft.block.BlockSapling||block instanceof net.minecraft.block.BlockMushroom)){
|
||||||
+ if (block != null && (block instanceof net.minecraft.block.BlockSapling || block instanceof net.minecraft.block.BlockMushroom))
|
+ tTreeGenCapture=world.mCapture.startTreeGenCapture(player,x,y,z);
|
||||||
+ {
|
+ tTreeGenCapture.setAgaistPostionAndSide(x,y,z,side);
|
||||||
+ world.captureTreeGeneration = true;
|
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ // Cauldron end
|
+ // Cauldron end
|
||||||
}
|
}
|
||||||
|
|
||||||
+ ItemStack.currentPlayer = player; // Cauldron
|
- boolean flag = itemstack.getItem().onItemUse(itemstack, player, world, x, y, z, side, hitX, hitY, hitZ);
|
||||||
boolean flag = itemstack.getItem().onItemUse(itemstack, player, world, x, y, z, side, hitX, hitY, hitZ);
|
- world.captureBlockSnapshots = false;
|
||||||
+ ItemStack.currentPlayer = null; // Cauldron
|
+ ItemStack.currentPlayer=player; // Cauldron
|
||||||
world.captureBlockSnapshots = false;
|
+ boolean flag=itemstack.getItem().onItemUse(itemstack,player,world,x,y,z,side,hitX,hitY,hitZ);
|
||||||
|
+ ItemStack.currentPlayer=null; // Cauldron
|
||||||
|
|
||||||
- if (flag)
|
- if (flag)
|
||||||
+ // Cauldron start
|
- {
|
||||||
+ if (flag && world.captureTreeGeneration && world.capturedBlockSnapshots.size() > 0)
|
|
||||||
{
|
|
||||||
- // save new item data
|
- // save new item data
|
||||||
- int newMeta = itemstack.getItemDamage();
|
- int newMeta = itemstack.getItemDamage();
|
||||||
- int newSize = itemstack.stackSize;
|
- int newSize = itemstack.stackSize;
|
||||||
- NBTTagCompound newNBT = null;
|
- NBTTagCompound newNBT = null;
|
||||||
- if (itemstack.getTagCompound() != null)
|
- if (itemstack.getTagCompound() != null)
|
||||||
+ world.captureTreeGeneration = false;
|
- {
|
||||||
+ Location loc = new Location(world.getWorld(), (double) x, (double) y, (double) z);
|
|
||||||
+ TreeType type = net.minecraft.block.BlockSapling.treeType;
|
|
||||||
+ net.minecraft.block.BlockSapling.treeType = null;
|
|
||||||
+ List<BlockState> states = new ArrayList();
|
|
||||||
+
|
|
||||||
+ for (net.minecraftforge.common.util.BlockSnapshot snapshot : (List<net.minecraftforge.common.util.BlockSnapshot>) world.capturedBlockSnapshots.clone())
|
|
||||||
{
|
|
||||||
- newNBT = (NBTTagCompound)itemstack.getTagCompound().copy();
|
- newNBT = (NBTTagCompound)itemstack.getTagCompound().copy();
|
||||||
+ states.add(new CraftBlockState(snapshot));
|
- }
|
||||||
}
|
|
||||||
- net.minecraftforge.event.world.BlockEvent.PlaceEvent placeEvent = null;
|
- net.minecraftforge.event.world.BlockEvent.PlaceEvent placeEvent = null;
|
||||||
- List<net.minecraftforge.common.util.BlockSnapshot> blockSnapshots = (List<net.minecraftforge.common.util.BlockSnapshot>) world.capturedBlockSnapshots.clone();
|
- List<net.minecraftforge.common.util.BlockSnapshot> blockSnapshots = (List<net.minecraftforge.common.util.BlockSnapshot>) world.capturedBlockSnapshots.clone();
|
||||||
- world.capturedBlockSnapshots.clear();
|
- world.capturedBlockSnapshots.clear();
|
||||||
|
+ if(tCapture!=null) tCapture.disableCapture();
|
||||||
|
+ if(tTreeGenCapture!=null) tTreeGenCapture.disableCapture();
|
||||||
|
|
||||||
- // make sure to set pre-placement item data for event
|
- // make sure to set pre-placement item data for event
|
||||||
- itemstack.setItemDamage(meta);
|
- itemstack.setItemDamage(meta);
|
||||||
- itemstack.stackSize = size;
|
- itemstack.stackSize = size;
|
||||||
- if (nbt != null)
|
- if (nbt != null)
|
||||||
+ world.capturedBlockSnapshots.clear();
|
- {
|
||||||
+ StructureGrowEvent event = null;
|
|
||||||
+ if (type != null)
|
|
||||||
{
|
|
||||||
- itemstack.setTagCompound(nbt);
|
- itemstack.setTagCompound(nbt);
|
||||||
+ event = new StructureGrowEvent(loc, type, false, (Player) player.getBukkitEntity(), states);
|
+ // Cauldron start
|
||||||
+ Bukkit.getPluginManager().callEvent(event);
|
+ if(flag){
|
||||||
|
+ if(tTreeGenCapture!=null&&tTreeGenCapture.mCapturedBlocks.size()>0){
|
||||||
|
+ tTreeGenCapture.endCapture();
|
||||||
|
+ }else if(tCapture!=null){
|
||||||
|
+ tCapture.endCapture();
|
||||||
}
|
}
|
||||||
- if (blockSnapshots.size() > 1)
|
- if (blockSnapshots.size() > 1)
|
||||||
- {
|
- {
|
||||||
@ -130,72 +192,30 @@
|
|||||||
- {
|
- {
|
||||||
- placeEvent = ForgeEventFactory.onPlayerBlockPlace(player, blockSnapshots.get(0), net.minecraftforge.common.util.ForgeDirection.getOrientation(side));
|
- placeEvent = ForgeEventFactory.onPlayerBlockPlace(player, blockSnapshots.get(0), net.minecraftforge.common.util.ForgeDirection.getOrientation(side));
|
||||||
- }
|
- }
|
||||||
|
-
|
||||||
- if (placeEvent != null && (placeEvent.isCanceled()))
|
- if (placeEvent != null && (placeEvent.isCanceled()))
|
||||||
+ if (event == null || !event.isCancelled())
|
- {
|
||||||
{
|
|
||||||
- flag = false; // cancel placement
|
- flag = false; // cancel placement
|
||||||
- // revert back all captured blocks
|
- // revert back all captured blocks
|
||||||
- for (net.minecraftforge.common.util.BlockSnapshot blocksnapshot : blockSnapshots)
|
- for (net.minecraftforge.common.util.BlockSnapshot blocksnapshot : blockSnapshots)
|
||||||
+ for (BlockState state : states)
|
- {
|
||||||
{
|
|
||||||
- world.restoringBlockSnapshots = true;
|
- world.restoringBlockSnapshots = true;
|
||||||
- blocksnapshot.restore(true, false);
|
- blocksnapshot.restore(true, false);
|
||||||
- world.restoringBlockSnapshots = false;
|
- world.restoringBlockSnapshots = false;
|
||||||
+ state.update(true);
|
- }
|
||||||
}
|
- }
|
||||||
}
|
|
||||||
- else
|
- else
|
||||||
+
|
- {
|
||||||
+ return flag;
|
|
||||||
+ }
|
|
||||||
+ else
|
|
||||||
+ {
|
|
||||||
+ world.captureTreeGeneration = false; // Cauldron end
|
|
||||||
+ if (flag)
|
|
||||||
{
|
|
||||||
- // Change the stack to its new content
|
- // Change the stack to its new content
|
||||||
- itemstack.setItemDamage(newMeta);
|
- itemstack.setItemDamage(newMeta);
|
||||||
- itemstack.stackSize = newSize;
|
- itemstack.stackSize = newSize;
|
||||||
+ // save new item data
|
- if (nbt != null)
|
||||||
+ int newMeta = itemstack.getItemDamage();
|
- {
|
||||||
+ int newSize = itemstack.stackSize;
|
|
||||||
+ NBTTagCompound newNBT = null;
|
|
||||||
+ if (itemstack.getTagCompound() != null)
|
|
||||||
+ {
|
|
||||||
+ newNBT = (NBTTagCompound) itemstack.getTagCompound().copy();
|
|
||||||
+ }
|
|
||||||
+ net.minecraftforge.event.world.BlockEvent.PlaceEvent placeEvent = null;
|
|
||||||
+ List<net.minecraftforge.common.util.BlockSnapshot> blockSnapshots = (List<net.minecraftforge.common.util.BlockSnapshot>) world.capturedBlockSnapshots
|
|
||||||
+ .clone();
|
|
||||||
+ world.capturedBlockSnapshots.clear();
|
|
||||||
+ List<net.minecraftforge.common.util.EntitySnapshot> tDropItemSnapshots=(List<net.minecraftforge.common.util.EntitySnapshot>)world.capturedEntitySnapshots.clone();
|
|
||||||
+ world.capturedEntitySnapshots.clear();
|
|
||||||
+ List<ItemStack> tCaptureItems=(List<ItemStack>)world.capturedItems.clone();
|
|
||||||
+ world.capturedItems.clear();
|
|
||||||
+
|
|
||||||
+ // make sure to set pre-placement item data for event
|
|
||||||
+ itemstack.setItemDamage(meta);
|
|
||||||
+ itemstack.stackSize = size;
|
|
||||||
if (nbt != null)
|
|
||||||
{
|
|
||||||
- itemstack.setTagCompound(newNBT);
|
- itemstack.setTagCompound(newNBT);
|
||||||
+ itemstack.setTagCompound(nbt);
|
- }
|
||||||
}
|
-
|
||||||
+ if (blockSnapshots.size() > 1)
|
|
||||||
+ {
|
|
||||||
+ placeEvent = ForgeEventFactory.onPlayerMultiBlockPlace(player, blockSnapshots,
|
|
||||||
+ net.minecraftforge.common.util.ForgeDirection.getOrientation(side));
|
|
||||||
+ }
|
|
||||||
+ else if (blockSnapshots.size() == 1)
|
|
||||||
+ {
|
|
||||||
+ placeEvent = ForgeEventFactory.onPlayerBlockPlace(player, blockSnapshots.get(0),
|
|
||||||
+ net.minecraftforge.common.util.ForgeDirection.getOrientation(side));
|
|
||||||
+ }
|
|
||||||
|
|
||||||
- for (net.minecraftforge.common.util.BlockSnapshot blocksnapshot : blockSnapshots)
|
- for (net.minecraftforge.common.util.BlockSnapshot blocksnapshot : blockSnapshots)
|
||||||
+ if (placeEvent != null && (placeEvent.isCanceled()))
|
- {
|
||||||
{
|
|
||||||
- int blockX = blocksnapshot.x;
|
- int blockX = blocksnapshot.x;
|
||||||
- int blockY = blocksnapshot.y;
|
- int blockY = blocksnapshot.y;
|
||||||
- int blockZ = blocksnapshot.z;
|
- int blockZ = blocksnapshot.z;
|
||||||
@ -204,69 +224,20 @@
|
|||||||
- Block oldBlock = blocksnapshot.replacedBlock;
|
- Block oldBlock = blocksnapshot.replacedBlock;
|
||||||
- Block newBlock = world.getBlock(blockX, blockY, blockZ);
|
- Block newBlock = world.getBlock(blockX, blockY, blockZ);
|
||||||
- if (newBlock != null && !(newBlock.hasTileEntity(metadata))) // Containers get placed automatically
|
- if (newBlock != null && !(newBlock.hasTileEntity(metadata))) // Containers get placed automatically
|
||||||
+ flag = false; // cancel placement
|
- {
|
||||||
+ // revert back all captured blocks
|
|
||||||
+ for(int i=blockSnapshots.size();i>0;){
|
|
||||||
+ world.restoringBlockSnapshots=true;
|
|
||||||
+ blockSnapshots.get(--i).restore(true,false);
|
|
||||||
+ world.restoringBlockSnapshots=false;
|
|
||||||
+ }
|
|
||||||
+ for(net.minecraftforge.common.util.EntitySnapshot sEntityItem : tDropItemSnapshots){
|
|
||||||
+ sEntityItem.cancel();
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ else
|
|
||||||
+ {
|
|
||||||
+ // Change the stack to its new content
|
|
||||||
+ itemstack.setItemDamage(newMeta);
|
|
||||||
+ itemstack.stackSize = newSize;
|
|
||||||
+ if (nbt != null)
|
|
||||||
{
|
|
||||||
- newBlock.onBlockAdded(world, blockX, blockY, blockZ);
|
- newBlock.onBlockAdded(world, blockX, blockY, blockZ);
|
||||||
+ itemstack.setTagCompound(newNBT);
|
- }
|
||||||
}
|
-
|
||||||
|
|
||||||
- world.markAndNotifyBlock(blockX, blockY, blockZ, null, oldBlock, newBlock, updateFlag);
|
- world.markAndNotifyBlock(blockX, blockY, blockZ, null, oldBlock, newBlock, updateFlag);
|
||||||
+ for (net.minecraftforge.common.util.BlockSnapshot blocksnapshot : blockSnapshots)
|
- }
|
||||||
+ {
|
|
||||||
+ int blockX = blocksnapshot.x;
|
|
||||||
+ int blockY = blocksnapshot.y;
|
|
||||||
+ int blockZ = blocksnapshot.z;
|
|
||||||
+ int metadata = world.getBlockMetadata(blockX, blockY, blockZ);
|
|
||||||
+ int updateFlag = blocksnapshot.flag;
|
|
||||||
+ Block oldBlock = blocksnapshot.replacedBlock;
|
|
||||||
+ Block newBlock = world.getBlock(blockX, blockY, blockZ);
|
|
||||||
+ if (newBlock != null && !(newBlock.hasTileEntity(metadata))) // Containers
|
|
||||||
+ // get
|
|
||||||
+ // placed
|
|
||||||
+ // automatically
|
|
||||||
+ {
|
|
||||||
+ newBlock.onBlockAdded(world, blockX, blockY, blockZ);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ world.markAndNotifyBlock(blockX, blockY, blockZ, null, oldBlock, newBlock, updateFlag);
|
|
||||||
+ }
|
|
||||||
+ 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);
|
- player.addStat(StatList.objectUseStats[Item.getIdFromItem(itemstack.getItem())], 1);
|
||||||
+
|
- }
|
||||||
}
|
}
|
||||||
}
|
- world.capturedBlockSnapshots.clear();
|
||||||
+
|
|
||||||
world.capturedBlockSnapshots.clear();
|
|
||||||
|
|
||||||
|
+ if(tCapture!=null) tCapture.markHandled();
|
||||||
|
+ if(tTreeGenCapture!=null) tTreeGenCapture.markHandled();
|
||||||
|
+
|
||||||
return flag;
|
return flag;
|
||||||
|
}
|
||||||
|
|
||||||
|
@ -1,23 +1,33 @@
|
|||||||
--- ../src-base/minecraft/net/minecraftforge/event/world/BlockEvent.java
|
--- ../src-base/minecraft/net/minecraftforge/event/world/BlockEvent.java
|
||||||
+++ ../src-work/minecraft/net/minecraftforge/event/world/BlockEvent.java
|
+++ ../src-work/minecraft/net/minecraftforge/event/world/BlockEvent.java
|
||||||
@@ -16,6 +16,16 @@
|
@@ -3,17 +3,23 @@
|
||||||
import net.minecraftforge.common.ForgeHooks;
|
import java.util.ArrayList;
|
||||||
import net.minecraftforge.common.util.BlockSnapshot;
|
import java.util.List;
|
||||||
|
|
||||||
+import org.bukkit.block.BlockState;
|
+import org.bukkit.block.BlockState;
|
||||||
+import org.bukkit.craftbukkit.block.CraftBlockState;
|
+import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||||
+// Cauldron start
|
+// Cauldron start
|
||||||
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
+import org.bukkit.craftbukkit.event.CraftEventFactory;
|
||||||
+import org.bukkit.event.block.BlockBreakEvent;
|
|
||||||
+import org.bukkit.event.block.BlockMultiPlaceEvent;
|
+import org.bukkit.event.block.BlockMultiPlaceEvent;
|
||||||
+
|
+
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
|
||||||
|
+import cc.capture.type.CaptureBlock;
|
||||||
|
import cpw.mods.fml.common.eventhandler.Cancelable;
|
||||||
|
import cpw.mods.fml.common.eventhandler.Event;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
-import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
-import net.minecraft.init.Blocks;
|
||||||
+import net.minecraft.entity.player.EntityPlayerMP;
|
+import net.minecraft.entity.player.EntityPlayerMP;
|
||||||
+// Cauldron end
|
+// Cauldron end
|
||||||
+
|
import net.minecraft.item.ItemStack;
|
||||||
public class BlockEvent extends Event {
|
import net.minecraft.world.World;
|
||||||
private static final boolean DEBUG = Boolean.parseBoolean(System.getProperty("forge.debugBlockEvent", "false"));
|
-import net.minecraftforge.common.ForgeHooks;
|
||||||
|
import net.minecraftforge.common.util.BlockSnapshot;
|
||||||
|
|
||||||
@@ -80,17 +90,18 @@
|
public class BlockEvent extends Event {
|
||||||
|
@@ -80,17 +86,18 @@
|
||||||
super(x, y, z, world, block, blockMetadata);
|
super(x, y, z, world, block, blockMetadata);
|
||||||
this.player = player;
|
this.player = player;
|
||||||
|
|
||||||
@ -42,7 +52,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
public EntityPlayer getPlayer()
|
public EntityPlayer getPlayer()
|
||||||
@@ -140,6 +151,16 @@
|
@@ -140,6 +147,21 @@
|
||||||
this.blockSnapshot = blockSnapshot;
|
this.blockSnapshot = blockSnapshot;
|
||||||
this.placedBlock = blockSnapshot.getCurrentBlock();
|
this.placedBlock = blockSnapshot.getCurrentBlock();
|
||||||
this.placedAgainst = placedAgainst;
|
this.placedAgainst = placedAgainst;
|
||||||
@ -54,12 +64,17 @@
|
|||||||
+ if(bukkitEvent.isCancelled()||!bukkitEvent.canBuild()){
|
+ if(bukkitEvent.isCancelled()||!bukkitEvent.canBuild()){
|
||||||
+ this.setCanceled(true);
|
+ this.setCanceled(true);
|
||||||
+ }
|
+ }
|
||||||
|
+
|
||||||
|
+ CaptureBlock tCapture=world.mCapture.getLastBlockCapture();
|
||||||
|
+ if(tCapture!=null&&tCapture.mEnable){
|
||||||
|
+ tCapture.addCheckedBlock(world,x,y,z);
|
||||||
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+ // Cauldron end
|
+ // Cauldron end
|
||||||
if (DEBUG)
|
if (DEBUG)
|
||||||
{
|
{
|
||||||
System.out.printf("Created PlaceEvent - [PlacedBlock: %s ][PlacedAgainst: %s ][ItemStack: %s ][Player: %s ]\n", placedBlock, placedAgainst, player.getCurrentEquippedItem(), player);
|
System.out.printf("Created PlaceEvent - [PlacedBlock: %s ][PlacedAgainst: %s ][ItemStack: %s ][Player: %s ]\n", placedBlock, placedAgainst, player.getCurrentEquippedItem(), player);
|
||||||
@@ -160,7 +181,17 @@
|
@@ -160,7 +182,17 @@
|
||||||
|
|
||||||
public MultiPlaceEvent(List<BlockSnapshot> blockSnapshots, Block placedAgainst, EntityPlayer player) {
|
public MultiPlaceEvent(List<BlockSnapshot> blockSnapshots, Block placedAgainst, EntityPlayer player) {
|
||||||
super(blockSnapshots.get(0), placedAgainst, player);
|
super(blockSnapshots.get(0), placedAgainst, player);
|
||||||
|
40
src/main/java/cc/Location.java
Normal file
40
src/main/java/cc/Location.java
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
package cc;
|
||||||
|
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class Location{
|
||||||
|
|
||||||
|
public World mWorld;
|
||||||
|
|
||||||
|
public int mPosX=0;
|
||||||
|
public int mPosY=0;
|
||||||
|
public int mPosZ=0;
|
||||||
|
|
||||||
|
private String mToString=null;
|
||||||
|
|
||||||
|
public Location(World pWorld,int pPosX,int pPosY,int pPosZ){
|
||||||
|
this.mWorld=pWorld;
|
||||||
|
this.mPosX=pPosX;
|
||||||
|
this.mPosY=pPosY;
|
||||||
|
this.mPosZ=pPosZ;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(){
|
||||||
|
if(this.mToString==null){
|
||||||
|
this.mToString=this.mWorld.worldInfo.getWorldName()+"("+this.mPosX+","+this.mPosY+","+this.mPosZ+")";
|
||||||
|
}
|
||||||
|
return this.mToString;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode(){
|
||||||
|
return this.toString().hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object pObj){
|
||||||
|
return pObj instanceof Location&&((Location)pObj).hashCode()==this.hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
38
src/main/java/cc/capture/ItemSnapshot.java
Normal file
38
src/main/java/cc/capture/ItemSnapshot.java
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
package cc.capture;
|
||||||
|
|
||||||
|
import net.minecraft.entity.item.EntityItem;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
|
||||||
|
public class ItemSnapshot{
|
||||||
|
|
||||||
|
public final EntityPlayer mPlayer;
|
||||||
|
public final ItemStack mItem;
|
||||||
|
|
||||||
|
private boolean mApply=false;
|
||||||
|
|
||||||
|
public ItemSnapshot(EntityPlayer pPlayer,ItemStack pItem){
|
||||||
|
this.mPlayer=pPlayer;
|
||||||
|
this.mItem=pItem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将物品放到玩家身上
|
||||||
|
*
|
||||||
|
* @return 如果背包满,将生成物品在地上并返回false
|
||||||
|
*/
|
||||||
|
public boolean apply(){
|
||||||
|
if(!this.mApply){
|
||||||
|
this.mApply=true;
|
||||||
|
this.mPlayer.inventory.addItemStackToInventory(this.mItem);
|
||||||
|
|
||||||
|
if(!this.mPlayer.inventory.addItemStackToInventory(this.mItem)){
|
||||||
|
this.mPlayer.worldObj.spawnEntityInWorld(
|
||||||
|
new EntityItem(this.mPlayer.worldObj,this.mPlayer.posX,this.mPlayer.posY,this.mPlayer.posZ,this.mItem));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
171
src/main/java/cc/capture/WorldCapture.java
Normal file
171
src/main/java/cc/capture/WorldCapture.java
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
package cc.capture;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Stack;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
|
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||||
|
|
||||||
|
import cc.capture.type.ACapture;
|
||||||
|
import cc.capture.type.CaptureBlock;
|
||||||
|
import cc.capture.type.CaptureTree;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
|
||||||
|
public class WorldCapture{
|
||||||
|
|
||||||
|
public final World mWorld;
|
||||||
|
/** Capture任务Id生成器 */
|
||||||
|
private AtomicInteger mIdCreate=new AtomicInteger();
|
||||||
|
/** 方块捕获任务 */
|
||||||
|
public Stack<CaptureBlock> mBlockCaptures=new Stack<CaptureBlock>();
|
||||||
|
/** 树捕获任务 */
|
||||||
|
public Stack<CaptureTree> mTreeCaptures=new Stack<CaptureTree>();
|
||||||
|
|
||||||
|
public WorldCapture(World pWorld){
|
||||||
|
this.mWorld=pWorld;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CaptureBlock getLastBlockCapture(){
|
||||||
|
return getEleOrLast(this.mBlockCaptures,-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CaptureTree getLastTreeGenCapture(){
|
||||||
|
return getEleOrLast(this.mTreeCaptures,-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T extends ACapture> T getEleOrLast(Stack<T> pStack,int pId){
|
||||||
|
if(pId!=-1){
|
||||||
|
Iterator<T> tIt=pStack.iterator();
|
||||||
|
while(tIt.hasNext()){
|
||||||
|
T tCapture=tIt.next();
|
||||||
|
if(tCapture.mHandled){
|
||||||
|
tIt.remove();
|
||||||
|
}else if(tCapture.mId==pId){
|
||||||
|
return tCapture;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
while(!pStack.isEmpty()){
|
||||||
|
T tCapture=pStack.lastElement();
|
||||||
|
if(tCapture.mHandled){
|
||||||
|
pStack.pop();
|
||||||
|
}
|
||||||
|
return tCapture;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCaptureEntity(World pWorld,Entity pEntity,SpawnReason pReason){
|
||||||
|
CaptureBlock tCapture=this.getLastBlockCapture();
|
||||||
|
if(tCapture==null||!tCapture.mEnable) return;
|
||||||
|
|
||||||
|
tCapture.addCaptureEntity(pWorld,pEntity,pReason);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCaptureItem(EntityPlayer pPlayer,ItemStack pItem){
|
||||||
|
CaptureBlock tCapture=this.getLastBlockCapture();
|
||||||
|
if(tCapture==null||!tCapture.mEnable) return;
|
||||||
|
|
||||||
|
tCapture.addCaptureItem(pPlayer,pItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCheckedBlock(World pWorld,int pPosX,int pPosY,int pPosZ){
|
||||||
|
CaptureBlock tCapture=this.getLastBlockCapture();
|
||||||
|
if(tCapture==null||!tCapture.mEnable) return;
|
||||||
|
|
||||||
|
tCapture.addCheckedBlock(pWorld,pPosX,pPosY,pPosZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCapture(){
|
||||||
|
CaptureBlock tCapture=this.getLastBlockCapture();
|
||||||
|
return tCapture!=null&&tCapture.mEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTreeGenCapture(){
|
||||||
|
CaptureTree tCapture=this.getLastTreeGenCapture();
|
||||||
|
return tCapture!=null&&tCapture.mEnable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CaptureBlock startCapture(EntityPlayer pPlayer){
|
||||||
|
ItemStack tItem=null;
|
||||||
|
int tSlot=-1;
|
||||||
|
if(pPlayer!=null){
|
||||||
|
tSlot=pPlayer.inventory.currentItem;
|
||||||
|
tItem=pPlayer.getCurrentEquippedItem();
|
||||||
|
}
|
||||||
|
return this.startCapture(pPlayer,tItem,tSlot);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public CaptureBlock startCapture(EntityPlayer pPlayer,ItemStack pCurrent){
|
||||||
|
return this.startCapture(pPlayer,pCurrent,-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CaptureBlock startCapture(EntityPlayer pPlayer,ItemStack pCurrent,int pSlot){
|
||||||
|
CaptureBlock tCapture=this.mBlockCaptures.push(new CaptureBlock(this,this.mIdCreate.incrementAndGet(),pPlayer));
|
||||||
|
tCapture.mUseItem=pCurrent;
|
||||||
|
if(pCurrent!=null){
|
||||||
|
tCapture.mOldItemMeta=pCurrent.getItemDamage();
|
||||||
|
tCapture.mOldItemSize=pCurrent.stackSize;
|
||||||
|
tCapture.mOldItemNBT=pCurrent.stackTagCompound;
|
||||||
|
tCapture.mSlot=pSlot;
|
||||||
|
}
|
||||||
|
return tCapture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disableCapture(){
|
||||||
|
CaptureBlock tCapture=this.getLastBlockCapture();
|
||||||
|
if(tCapture==null) return;
|
||||||
|
|
||||||
|
tCapture.mEnable=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean endCapture(int pId){
|
||||||
|
CaptureBlock tCapture=getEleOrLast(this.mBlockCaptures,pId);
|
||||||
|
if(tCapture==null) return true;
|
||||||
|
|
||||||
|
this.mBlockCaptures.remove(tCapture);
|
||||||
|
return tCapture.endCapture();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public CaptureTree startTreeGenCapture(EntityPlayer pPlayer,int pPosX,int pPosY,int pPosZ){
|
||||||
|
CaptureTree tCapture=this.mTreeCaptures.push(new CaptureTree(this,this.mIdCreate.incrementAndGet(),pPlayer));
|
||||||
|
tCapture.setAgaistPostionAndSide(-1,pPosX,pPosY,pPosZ);
|
||||||
|
return tCapture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CaptureTree startTreeGenCapture(EntityPlayer pPlayer,org.bukkit.Location pTreeLoc){
|
||||||
|
return this.startTreeGenCapture(pPlayer,pTreeLoc.getBlockX(),pTreeLoc.getBlockY(),pTreeLoc.getBlockZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
public CaptureTree disableTreeGenCapture(int pId){
|
||||||
|
CaptureTree tCapture=getEleOrLast(this.mTreeCaptures,pId);
|
||||||
|
if(tCapture==null) return null;
|
||||||
|
|
||||||
|
tCapture.mEnable=false;
|
||||||
|
return tCapture;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean endTreeGenCapture(int pId){
|
||||||
|
CaptureTree tCapture=getEleOrLast(this.mTreeCaptures,pId);
|
||||||
|
if(tCapture==null) return true;
|
||||||
|
|
||||||
|
this.mTreeCaptures.remove(tCapture);
|
||||||
|
return tCapture.endCapture();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 清理捕获的数据
|
||||||
|
*/
|
||||||
|
public void clearAllData(){
|
||||||
|
this.mBlockCaptures.clear();
|
||||||
|
this.mTreeCaptures.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
68
src/main/java/cc/capture/type/ACapture.java
Normal file
68
src/main/java/cc/capture/type/ACapture.java
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
package cc.capture.type;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import cc.capture.WorldCapture;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.init.Blocks;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.util.BlockSnapshot;
|
||||||
|
import net.minecraftforge.common.util.ForgeDirection;
|
||||||
|
|
||||||
|
public abstract class ACapture{
|
||||||
|
|
||||||
|
public final WorldCapture mWorldCapture;
|
||||||
|
public final World mWorld;
|
||||||
|
public final int mId;
|
||||||
|
/** 是否启用捕获 */
|
||||||
|
public boolean mEnable=true;
|
||||||
|
/** 是否已经处理完毕 */
|
||||||
|
public boolean mHandled=false;
|
||||||
|
/** 当前捕获作用的玩家,可能为null,用作普通捕获 */
|
||||||
|
public final EntityPlayer mCapturePlayer;
|
||||||
|
/** 方块放置时顶着的面 */
|
||||||
|
protected ForgeDirection mSide=ForgeDirection.UNKNOWN;
|
||||||
|
protected Block mAgaistBlock=Blocks.air;
|
||||||
|
/** 捕获的数据 */
|
||||||
|
public ArrayList<BlockSnapshot> mCapturedBlocks=new ArrayList<BlockSnapshot>();
|
||||||
|
|
||||||
|
public ACapture(WorldCapture pWorldCapture,int pId,EntityPlayer pPlayer){
|
||||||
|
this.mWorldCapture=pWorldCapture;
|
||||||
|
this.mWorld=pWorldCapture.mWorld;
|
||||||
|
this.mId=pId;
|
||||||
|
this.mCapturePlayer=pPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAgaistPostionAndSide(int pSide,int pPosX,int pPosY,int pPosZ){
|
||||||
|
this.mSide=ForgeDirection.getOrientation(pSide);
|
||||||
|
this.mAgaistBlock=this.mWorldCapture.mWorld.getBlock(pPosX,pPosY,pPosZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCapturedBlock(World pWorld,int pPosX,int pPosY,int pPosZ){
|
||||||
|
this.addCapturedBlock(pWorld,pPosX,pPosY,pPosZ,3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCapturedBlock(World pWorld,int pPosX,int pPosY,int pPosZ,int pFlag){
|
||||||
|
if(!this.mEnable) return;
|
||||||
|
|
||||||
|
BlockSnapshot tSnapshot=BlockSnapshot.getBlockSnapshot(pWorld,pPosX,pPosY,pPosZ,pFlag);
|
||||||
|
this.mCapturedBlocks.add(tSnapshot);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void disableCapture(){
|
||||||
|
this.mEnable=false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 标记此捕获为已经处理
|
||||||
|
* <p>
|
||||||
|
* 只设置捕获中的数据,并从世界捕获中移除,不会清理捕获数据
|
||||||
|
* </p>
|
||||||
|
*/
|
||||||
|
public void markHandled(){
|
||||||
|
this.mEnable=false;
|
||||||
|
this.mHandled=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
154
src/main/java/cc/capture/type/CaptureBlock.java
Normal file
154
src/main/java/cc/capture/type/CaptureBlock.java
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
package cc.capture.type;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
|
||||||
|
import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
|
||||||
|
|
||||||
|
import cc.Location;
|
||||||
|
import cc.capture.EntitySnapshot;
|
||||||
|
import cc.capture.ItemSnapshot;
|
||||||
|
import cc.capture.WorldCapture;
|
||||||
|
import net.minecraft.entity.Entity;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.item.ItemStack;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.stats.StatList;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.common.util.BlockSnapshot;
|
||||||
|
import net.minecraftforge.event.ForgeEventFactory;
|
||||||
|
import net.minecraftforge.event.world.BlockEvent.PlaceEvent;
|
||||||
|
|
||||||
|
public class CaptureBlock extends ACapture{
|
||||||
|
|
||||||
|
/** 是否为还原模式 */
|
||||||
|
public boolean mRestoring=false;
|
||||||
|
/** 当前物品 */
|
||||||
|
public ItemStack mUseItem=null;
|
||||||
|
/** 当前物品所在的快捷栏位置,如果为-1表示不存在,或者不是从背包取出的物品 */
|
||||||
|
public int mSlot=-1;
|
||||||
|
public int mOldItemSize=0;
|
||||||
|
public int mOldItemMeta=0;
|
||||||
|
public NBTTagCompound mOldItemNBT=null;
|
||||||
|
/** 捕获的数据 */
|
||||||
|
public ArrayList<EntitySnapshot> mCapturedEntitys=new ArrayList<EntitySnapshot>();
|
||||||
|
public ArrayList<ItemSnapshot> mCapturedItems=new ArrayList<ItemSnapshot>();
|
||||||
|
public ArrayList<Location> mCheckedBlocks=new ArrayList<Location>();
|
||||||
|
|
||||||
|
public CaptureBlock(WorldCapture pWorldCapture,int pId,EntityPlayer pPlayer){
|
||||||
|
super(pWorldCapture,pId,pPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void markHandled(){
|
||||||
|
super.markHandled();
|
||||||
|
this.mWorldCapture.mBlockCaptures.remove(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addCapturedBlock(World pWorld,int pPosX,int pPosY,int pPosZ,int pFlag){
|
||||||
|
if(!this.mEnable||this.isChecked(pWorld,pPosX,pPosY,pPosZ,false))
|
||||||
|
return;
|
||||||
|
|
||||||
|
super.addCapturedBlock(pWorld,pPosX,pPosY,pPosZ,pFlag);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCapturedBlock(BlockSnapshot pSnapshot){
|
||||||
|
if(!this.mEnable||this.isChecked(pSnapshot.world,pSnapshot.x,pSnapshot.y,pSnapshot.z,false))
|
||||||
|
return;
|
||||||
|
|
||||||
|
this.mCapturedBlocks.add(pSnapshot);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isChecked(World pWorld,int pPosX,int pPosY,int pPosZ,boolean pSimula){
|
||||||
|
if(!this.mCheckedBlocks.isEmpty()){
|
||||||
|
Iterator<Location> tIt=this.mCheckedBlocks.iterator();
|
||||||
|
while(tIt.hasNext()){
|
||||||
|
Location tLoc=tIt.next();
|
||||||
|
if(tLoc.mWorld==pWorld&&tLoc.mPosX==pPosX&&tLoc.mPosY==pPosY&&tLoc.mPosZ==pPosZ){
|
||||||
|
if(!pSimula) tIt.remove();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCaptureEntity(World pWorld,Entity pEntity,SpawnReason pReason){
|
||||||
|
if(!this.mEnable) return;
|
||||||
|
|
||||||
|
this.mCapturedEntitys.add(new EntitySnapshot(pWorld,pEntity,pReason));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCaptureItem(EntityPlayer pPlayer,ItemStack pItem){
|
||||||
|
if(!this.mEnable) return;
|
||||||
|
|
||||||
|
this.mCapturedItems.add(new ItemSnapshot(pPlayer,pItem));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addCheckedBlock(World pWorld,int pPosX,int pPosY,int pPosZ){
|
||||||
|
this.mCheckedBlocks.add(new Location(pWorld,pPosX,pPosY,pPosZ));
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean endCapture(){
|
||||||
|
if(this.mHandled) return true;
|
||||||
|
this.markHandled();
|
||||||
|
|
||||||
|
boolean tResult;
|
||||||
|
PlaceEvent tPlaceEvent=null;
|
||||||
|
if(this.mCapturedBlocks.size()>1){
|
||||||
|
tPlaceEvent=ForgeEventFactory.onPlayerMultiBlockPlace(this.mCapturePlayer,this.mCapturedBlocks,this.mSide);
|
||||||
|
}else if(this.mCapturedBlocks.size()==1){
|
||||||
|
tPlaceEvent=ForgeEventFactory.onPlayerBlockPlace(this.mCapturePlayer,this.mCapturedBlocks.get(0),this.mSide);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tPlaceEvent!=null&&(tPlaceEvent.isCanceled())){
|
||||||
|
if(this.mUseItem!=null){
|
||||||
|
if(this.mSlot==-1){
|
||||||
|
this.mUseItem.setItemDamage(this.mOldItemMeta);
|
||||||
|
this.mUseItem.stackSize=this.mOldItemSize;
|
||||||
|
this.mUseItem.setTagCompound(this.mOldItemNBT);
|
||||||
|
}else{
|
||||||
|
this.mCapturePlayer.inventory.setInventorySlotContents(this.mSlot,this.mUseItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(!this.mCapturedBlocks.isEmpty()){
|
||||||
|
for(int i=this.mCapturedBlocks.size();i>0;){
|
||||||
|
this.mRestoring=true;
|
||||||
|
BlockSnapshot tSnapshot=this.mCapturedBlocks.get(--i);
|
||||||
|
tSnapshot.restore(true,false);
|
||||||
|
this.mRestoring=false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(EntitySnapshot sSnapshot : this.mCapturedEntitys){
|
||||||
|
sSnapshot.cancel();
|
||||||
|
}
|
||||||
|
tResult=false;
|
||||||
|
}else{
|
||||||
|
for(EntitySnapshot sSnapshot : this.mCapturedEntitys){
|
||||||
|
sSnapshot.apply();
|
||||||
|
}
|
||||||
|
if(!this.mCapturedItems.isEmpty()){
|
||||||
|
HashSet<EntityPlayer> tNotifyPlayers=new HashSet<EntityPlayer>();
|
||||||
|
for(ItemSnapshot sSnapshot : this.mCapturedItems){
|
||||||
|
if(sSnapshot.apply()){
|
||||||
|
tNotifyPlayers.add(sSnapshot.mPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for(EntityPlayer sPlayer : tNotifyPlayers){
|
||||||
|
sPlayer.openContainer.detectAndSendChanges();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(this.mUseItem!=null&&this.mCapturePlayer!=null){
|
||||||
|
this.mCapturePlayer.addStat(StatList.objectUseStats[Item.getIdFromItem(this.mUseItem.getItem())],1);
|
||||||
|
}
|
||||||
|
tResult=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tResult;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
72
src/main/java/cc/capture/type/CaptureTree.java
Normal file
72
src/main/java/cc/capture/type/CaptureTree.java
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
package cc.capture.type;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.TreeType;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.craftbukkit.block.CraftBlockState;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.world.StructureGrowEvent;
|
||||||
|
|
||||||
|
import cc.capture.WorldCapture;
|
||||||
|
import net.minecraft.block.BlockSapling;
|
||||||
|
import net.minecraft.entity.player.EntityPlayer;
|
||||||
|
import net.minecraftforge.common.util.BlockSnapshot;
|
||||||
|
|
||||||
|
public class CaptureTree extends ACapture{
|
||||||
|
|
||||||
|
/** 捕获数模式下的位置 */
|
||||||
|
public org.bukkit.Location mTreeLoc=null;
|
||||||
|
|
||||||
|
public CaptureTree(WorldCapture pWorldCapture,int pId,EntityPlayer pPlayer){
|
||||||
|
super(pWorldCapture,pId,pPlayer);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setAgaistPostionAndSide(int pSide,int pPosX,int pPosY,int pPosZ){
|
||||||
|
super.setAgaistPostionAndSide(pSide,pPosX,pPosY,pPosZ);
|
||||||
|
this.mTreeLoc=new org.bukkit.Location(this.mWorld.getWorld(),(double)pPosX,(double)pPosY,(double)pPosZ);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void markHandled(){
|
||||||
|
super.markHandled();
|
||||||
|
this.mWorldCapture.mTreeCaptures.remove(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean endCapture(){
|
||||||
|
if(this.mHandled) return true;
|
||||||
|
this.markHandled();
|
||||||
|
|
||||||
|
boolean tResult=true;
|
||||||
|
if(this.mCapturedBlocks.size()>0)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
TreeType tType=BlockSapling.treeType;
|
||||||
|
BlockSapling.treeType=null;
|
||||||
|
List<BlockState> tStates=new ArrayList();
|
||||||
|
|
||||||
|
for(BlockSnapshot sSnapshot : (List<BlockSnapshot>)this.mCapturedBlocks.clone()){
|
||||||
|
tStates.add(new CraftBlockState(sSnapshot));
|
||||||
|
}
|
||||||
|
|
||||||
|
StructureGrowEvent tEvent=null;
|
||||||
|
if(tType!=null){
|
||||||
|
tEvent=new StructureGrowEvent(this.mTreeLoc,tType,false,
|
||||||
|
this.mCapturePlayer==null?null:(Player)this.mCapturePlayer.getBukkitEntity(),tStates);
|
||||||
|
Bukkit.getPluginManager().callEvent(tEvent);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(tEvent==null||!tEvent.isCancelled()){
|
||||||
|
for(BlockState sState : tStates){
|
||||||
|
sState.update(true);
|
||||||
|
}
|
||||||
|
tResult=true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return tResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,7 +1,5 @@
|
|||||||
package org.bukkit.craftbukkit;
|
package org.bukkit.craftbukkit;
|
||||||
|
|
||||||
import gnu.trove.procedure.TObjectProcedure;
|
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -11,11 +9,6 @@ import java.util.Random;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import net.minecraft.entity.EntityLiving;
|
|
||||||
import net.minecraft.entity.IEntityLivingData;
|
|
||||||
import net.minecraft.world.ChunkCoordIntPair;
|
|
||||||
import net.minecraftforge.common.util.BlockSnapshot;
|
|
||||||
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.BlockChangeDelegate;
|
import org.bukkit.BlockChangeDelegate;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -30,15 +23,74 @@ import org.bukkit.World;
|
|||||||
import org.bukkit.block.Biome;
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.BlockFace;
|
import org.bukkit.block.BlockFace;
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
import org.bukkit.craftbukkit.block.CraftBlock;
|
import org.bukkit.craftbukkit.block.CraftBlock;
|
||||||
import org.bukkit.craftbukkit.block.CraftBlockState;
|
import org.bukkit.craftbukkit.entity.CraftItem;
|
||||||
import org.bukkit.craftbukkit.entity.*;
|
import org.bukkit.craftbukkit.entity.CraftLightningStrike;
|
||||||
|
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||||
import org.bukkit.craftbukkit.metadata.BlockMetadataStore;
|
import org.bukkit.craftbukkit.metadata.BlockMetadataStore;
|
||||||
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
|
import org.bukkit.entity.Ambient;
|
||||||
import org.bukkit.craftbukkit.util.LongHash;
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.Bat;
|
||||||
|
import org.bukkit.entity.Blaze;
|
||||||
|
import org.bukkit.entity.Boat;
|
||||||
|
import org.bukkit.entity.CaveSpider;
|
||||||
|
import org.bukkit.entity.Chicken;
|
||||||
|
import org.bukkit.entity.ComplexLivingEntity;
|
||||||
|
import org.bukkit.entity.Cow;
|
||||||
|
import org.bukkit.entity.CreatureType;
|
||||||
|
import org.bukkit.entity.Creeper;
|
||||||
|
import org.bukkit.entity.Egg;
|
||||||
|
import org.bukkit.entity.EnderCrystal;
|
||||||
|
import org.bukkit.entity.EnderDragon;
|
||||||
|
import org.bukkit.entity.EnderPearl;
|
||||||
|
import org.bukkit.entity.EnderSignal;
|
||||||
|
import org.bukkit.entity.Enderman;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.ExperienceOrb;
|
||||||
|
import org.bukkit.entity.FallingBlock;
|
||||||
|
import org.bukkit.entity.Fireball;
|
||||||
|
import org.bukkit.entity.Firework;
|
||||||
|
import org.bukkit.entity.Ghast;
|
||||||
|
import org.bukkit.entity.Giant;
|
||||||
|
import org.bukkit.entity.Golem;
|
||||||
|
import org.bukkit.entity.Hanging;
|
||||||
|
import org.bukkit.entity.Horse;
|
||||||
|
import org.bukkit.entity.IronGolem;
|
||||||
|
import org.bukkit.entity.ItemFrame;
|
||||||
|
import org.bukkit.entity.LeashHitch;
|
||||||
|
import org.bukkit.entity.LightningStrike;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
|
import org.bukkit.entity.MagmaCube;
|
||||||
|
import org.bukkit.entity.Minecart;
|
||||||
|
import org.bukkit.entity.MushroomCow;
|
||||||
|
import org.bukkit.entity.Ocelot;
|
||||||
|
import org.bukkit.entity.Painting;
|
||||||
|
import org.bukkit.entity.Pig;
|
||||||
|
import org.bukkit.entity.PigZombie;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Projectile;
|
||||||
|
import org.bukkit.entity.Sheep;
|
||||||
|
import org.bukkit.entity.Silverfish;
|
||||||
|
import org.bukkit.entity.Skeleton;
|
||||||
|
import org.bukkit.entity.Slime;
|
||||||
|
import org.bukkit.entity.SmallFireball;
|
||||||
|
import org.bukkit.entity.Snowball;
|
||||||
|
import org.bukkit.entity.Snowman;
|
||||||
|
import org.bukkit.entity.Spider;
|
||||||
|
import org.bukkit.entity.Squid;
|
||||||
|
import org.bukkit.entity.TNTPrimed;
|
||||||
|
import org.bukkit.entity.Tameable;
|
||||||
|
import org.bukkit.entity.ThrownExpBottle;
|
||||||
|
import org.bukkit.entity.ThrownPotion;
|
||||||
|
import org.bukkit.entity.Villager;
|
||||||
|
import org.bukkit.entity.Weather;
|
||||||
|
import org.bukkit.entity.Witch;
|
||||||
|
import org.bukkit.entity.Wither;
|
||||||
|
import org.bukkit.entity.WitherSkull;
|
||||||
|
import org.bukkit.entity.Wolf;
|
||||||
|
import org.bukkit.entity.Zombie;
|
||||||
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
import org.bukkit.entity.minecart.ExplosiveMinecart;
|
||||||
import org.bukkit.entity.minecart.HopperMinecart;
|
import org.bukkit.entity.minecart.HopperMinecart;
|
||||||
import org.bukkit.entity.minecart.PoweredMinecart;
|
import org.bukkit.entity.minecart.PoweredMinecart;
|
||||||
@ -56,7 +108,11 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import org.bukkit.plugin.messaging.StandardMessenger;
|
import org.bukkit.plugin.messaging.StandardMessenger;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import cc.capture.type.CaptureTree;
|
||||||
import cpw.mods.fml.common.registry.EntityRegistry; // Cauldron
|
import cpw.mods.fml.common.registry.EntityRegistry; // Cauldron
|
||||||
|
import net.minecraft.entity.EntityLiving;
|
||||||
|
import net.minecraft.entity.IEntityLivingData;
|
||||||
|
import net.minecraftforge.common.util.BlockSnapshot;
|
||||||
|
|
||||||
public class CraftWorld implements World {
|
public class CraftWorld implements World {
|
||||||
//public static final int CUSTOM_DIMENSION_OFFSET = 10; // Cauldron - disabled
|
//public static final int CUSTOM_DIMENSION_OFFSET = 10; // Cauldron - disabled
|
||||||
@ -512,13 +568,11 @@ public class CraftWorld implements World {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
world.captureTreeGeneration = true;
|
CaptureTree tCapture=world.mCapture.startTreeGenCapture(null,loc);
|
||||||
world.captureBlockSnapshots = true;
|
|
||||||
boolean grownTree = gen.generate(world, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
boolean grownTree = gen.generate(world, rand, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||||
world.captureBlockSnapshots = false;
|
tCapture.markHandled();
|
||||||
world.captureTreeGeneration = false;
|
|
||||||
if (grownTree) { // Copy block data to delegate
|
if (grownTree) { // Copy block data to delegate
|
||||||
for (BlockSnapshot blocksnapshot : world.capturedBlockSnapshots) {
|
for (BlockSnapshot blocksnapshot : tCapture.mCapturedBlocks) {
|
||||||
int x = blocksnapshot.x;
|
int x = blocksnapshot.x;
|
||||||
int y = blocksnapshot.y;
|
int y = blocksnapshot.y;
|
||||||
int z = blocksnapshot.z;
|
int z = blocksnapshot.z;
|
||||||
@ -530,11 +584,9 @@ public class CraftWorld implements World {
|
|||||||
net.minecraft.block.Block newBlock = world.getBlock(x, y, z);
|
net.minecraft.block.Block newBlock = world.getBlock(x, y, z);
|
||||||
world.markAndNotifyBlock(x, y, z, null, oldBlock, newBlock, flag);
|
world.markAndNotifyBlock(x, y, z, null, oldBlock, newBlock, flag);
|
||||||
}
|
}
|
||||||
world.capturedBlockSnapshots.clear();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
world.capturedBlockSnapshots.clear();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user