1
0
forked from xjboss/KCauldronX

Apply fixes from binary patches.

This commit is contained in:
gamerforEA 2015-03-25 08:24:42 +03:00
parent 16773ead6a
commit 099d1a7732
23 changed files with 604 additions and 431 deletions

View File

@ -8,24 +8,6 @@
private static final String __OBFID = "CL_00000199"; private static final String __OBFID = "CL_00000199";
public final cpw.mods.fml.common.registry.RegistryDelegate<Block> delegate = public final cpw.mods.fml.common.registry.RegistryDelegate<Block> delegate =
@@ -650,7 +651,7 @@
public void dropBlockAsItemWithChance(World p_149690_1_, int p_149690_2_, int p_149690_3_, int p_149690_4_, int p_149690_5_, float p_149690_6_, int p_149690_7_)
{
- if (!p_149690_1_.isRemote && !p_149690_1_.restoringBlockSnapshots) // do not drop items while restoring blockstates, prevents item dupe
+ if (!p_149690_1_.isRemote && (!p_149690_1_.restoringBlockSnapshots || !p_149690_1_.restoringBlockStates)) // do not drop items while restoring blockstates, prevents item dupe
{
ArrayList<ItemStack> items = getDrops(p_149690_1_, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_7_);
p_149690_6_ = ForgeEventFactory.fireBlockHarvesting(items, p_149690_1_, this, p_149690_2_, p_149690_3_, p_149690_4_, p_149690_5_, p_149690_7_, p_149690_6_, false, harvesters.get());
@@ -667,7 +668,7 @@
protected void dropBlockAsItem(World p_149642_1_, int p_149642_2_, int p_149642_3_, int p_149642_4_, ItemStack p_149642_5_)
{
- if (!p_149642_1_.isRemote && p_149642_1_.getGameRules().getGameRuleBooleanValue("doTileDrops") && !p_149642_1_.restoringBlockSnapshots) // do not drop items while restoring blockstates, prevents item dupe
+ if (!p_149642_1_.isRemote && p_149642_1_.getGameRules().getGameRuleBooleanValue("doTileDrops") && (!p_149642_1_.restoringBlockSnapshots || !p_149642_1_.restoringBlockStates)) // do not drop items while restoring blockstates, prevents item dupe
{
if (captureDrops.get())
{
@@ -1131,6 +1132,23 @@ @@ -1131,6 +1132,23 @@
return this; return this;
} }

View File

@ -19,7 +19,7 @@
private static final String __OBFID = "CL_00000305"; private static final String __OBFID = "CL_00000305";
protected BlockSapling() protected BlockSapling()
@@ -41,9 +49,31 @@ @@ -41,9 +49,39 @@
{ {
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_);
@ -30,29 +30,37 @@
+ p_149674_1_.captureTreeGeneration = true; + p_149674_1_.captureTreeGeneration = true;
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; + p_149674_1_.captureTreeGeneration = false;
+ if (p_149674_1_.capturedBlockStates.size() > 0) + if (p_149674_1_.capturedBlockSnapshots.size() > 0)
+ { + {
+ TreeType treeType = BlockSapling.treeType; + TreeType treeType = BlockSapling.treeType;
+ BlockSapling.treeType = null; + BlockSapling.treeType = null;
+ Location location = new Location(p_149674_1_.getWorld(), p_149674_2_, p_149674_3_, p_149674_4_); + Location location = new Location(p_149674_1_.getWorld(), p_149674_2_, p_149674_3_, p_149674_4_);
+ List<BlockState> blocks = (List<BlockState>) p_149674_1_.capturedBlockStates.clone(); + List<net.minecraftforge.common.util.BlockSnapshot> blocks = (List) p_149674_1_.capturedBlockSnapshots.clone();
+ p_149674_1_.capturedBlockStates.clear(); + 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; + StructureGrowEvent event = null;
+ if (treeType != null) { + if (treeType != null)
+ event = new StructureGrowEvent(location, treeType, false, null, blocks); + {
+ event = new StructureGrowEvent(location, treeType, false, null, blockstates);
+ org.bukkit.Bukkit.getPluginManager().callEvent(event); + org.bukkit.Bukkit.getPluginManager().callEvent(event);
+ } + }
+ if (event == null || !event.isCancelled()) { + if (event == null || !event.isCancelled())
+ for (BlockState blockstate : blocks) { + {
+ for (BlockState blockstate : blockstates)
+ {
+ blockstate.update(true); + blockstate.update(true);
+ } + }
+ } + }
+ } + }
+ //Cauldron end + // Cauldron end
} }
} }
} }
@@ -73,7 +103,20 @@ @@ -73,7 +111,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;
@ -74,7 +82,7 @@
int i1 = 0; int i1 = 0;
int j1 = 0; int j1 = 0;
boolean flag = false; boolean flag = false;
@@ -84,6 +127,7 @@ @@ -84,6 +135,7 @@
default: default:
break; break;
case 1: case 1:
@ -82,7 +90,7 @@
label78: label78:
for (i1 = 0; i1 >= -1; --i1) for (i1 = 0; i1 >= -1; --i1)
@@ -108,6 +152,7 @@ @@ -108,6 +160,7 @@
break; break;
case 2: case 2:
@ -90,7 +98,7 @@
object = new WorldGenForest(true, false); object = new WorldGenForest(true, false);
break; break;
case 3: case 3:
@@ -119,6 +164,7 @@ @@ -119,6 +172,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))
{ {
@ -98,7 +106,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 +176,13 @@ @@ -130,11 +184,13 @@
{ {
j1 = 0; j1 = 0;
i1 = 0; i1 = 0;
@ -112,7 +120,7 @@
object = new WorldGenSavannaTree(true); object = new WorldGenSavannaTree(true);
break; break;
case 5: case 5:
@@ -147,6 +195,7 @@ @@ -147,6 +203,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);

View File

@ -241,12 +241,12 @@
if (this.noClip) if (this.noClip)
{ {
this.boundingBox.offset(p_70091_1_, p_70091_3_, p_70091_5_); this.boundingBox.offset(p_70091_1_, p_70091_3_, p_70091_5_);
@@ -756,6 +899,35 @@ @@ -756,6 +899,34 @@
d10 = this.posY - d4; d10 = this.posY - d4;
d11 = this.posZ - d5; d11 = this.posZ - d5;
+ // CraftBukkit start + // CraftBukkit start
+ if ((this.isCollidedHorizontally) && (this.getBukkitEntity() instanceof Vehicle)) + if (this.isCollidedHorizontally && this.getBukkitEntity() instanceof Vehicle && this.worldObj.getWorld() != null)
+ { + {
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity(); + Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ org.bukkit.block.Block block = this.worldObj.getWorld().getBlockAt(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY - (double) this.yOffset), MathHelper.floor_double(this.posZ)); + org.bukkit.block.Block block = this.worldObj.getWorld().getBlockAt(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY - (double) this.yOffset), MathHelper.floor_double(this.posZ));
@ -271,13 +271,12 @@
+ VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, block); + VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, block);
+ this.worldObj.getServer().getPluginManager().callEvent(event); + this.worldObj.getServer().getPluginManager().callEvent(event);
+ } + }
+
+ // CraftBukkit end + // CraftBukkit end
+ +
if (this.canTriggerWalking() && !flag && this.ridingEntity == null) if (this.canTriggerWalking() && !flag && this.ridingEntity == null)
{ {
int j1 = MathHelper.floor_double(this.posX); int j1 = MathHelper.floor_double(this.posX);
@@ -798,6 +970,8 @@ @@ -798,6 +969,8 @@
} }
} }
@ -286,7 +285,7 @@
try try
{ {
this.func_145775_I(); this.func_145775_I();
@@ -809,7 +983,8 @@ @@ -809,7 +982,8 @@
this.addEntityCrashInfo(crashreportcategory); this.addEntityCrashInfo(crashreportcategory);
throw new ReportedException(crashreport); throw new ReportedException(crashreport);
} }
@ -296,7 +295,7 @@
boolean flag2 = this.isWet(); boolean flag2 = this.isWet();
if (this.worldObj.func_147470_e(this.boundingBox.contract(0.001D, 0.001D, 0.001D))) if (this.worldObj.func_147470_e(this.boundingBox.contract(0.001D, 0.001D, 0.001D)))
@@ -820,8 +995,20 @@ @@ -820,8 +994,20 @@
{ {
++this.fire; ++this.fire;
@ -318,7 +317,7 @@
this.setFire(8); this.setFire(8);
} }
} }
@@ -839,6 +1026,8 @@ @@ -839,6 +1025,8 @@
this.worldObj.theProfiler.endSection(); this.worldObj.theProfiler.endSection();
} }
@ -327,19 +326,27 @@
} }
protected String getSwimSound() protected String getSwimSound()
@@ -867,7 +1056,11 @@ @@ -867,7 +1055,18 @@
try try
{ {
- block.onEntityCollidedWithBlock(this.worldObj, k1, l1, i2, this);
+ // Cauldron start - damage hook for custom blocks + // Cauldron start - damage hook for custom blocks
+ CraftEventFactory.blockDamage = this.worldObj.getWorld().getBlockAt(k1, l1, i2); + if (this.worldObj.getWorld() != null)
block.onEntityCollidedWithBlock(this.worldObj, k1, l1, i2, this); + {
+ CraftEventFactory.blockDamage = null; + CraftEventFactory.blockDamage = this.worldObj.getWorld().getBlockAt(k1, l1, i2);
+ block.onEntityCollidedWithBlock(this.worldObj, k1, l1, i2, this);
+ CraftEventFactory.blockDamage = null;
+ }
+ else
+ {
+ block.onEntityCollidedWithBlock(this.worldObj, k1, l1, i2, this);
+ }
+ // Cauldron end + // Cauldron end
} }
catch (Throwable throwable) catch (Throwable throwable)
{ {
@@ -928,6 +1121,7 @@ @@ -928,6 +1127,7 @@
return null; return null;
} }
@ -347,7 +354,7 @@
protected void dealFireDamage(int p_70081_1_) protected void dealFireDamage(int p_70081_1_)
{ {
if (!this.isImmuneToFire) if (!this.isImmuneToFire)
@@ -935,7 +1129,16 @@ @@ -935,7 +1135,16 @@
this.attackEntityFrom(DamageSource.inFire, (float)p_70081_1_); this.attackEntityFrom(DamageSource.inFire, (float)p_70081_1_);
} }
} }
@ -364,7 +371,7 @@
public final boolean isImmuneToFire() public final boolean isImmuneToFire()
{ {
return this.isImmuneToFire; return this.isImmuneToFire;
@@ -1184,6 +1387,8 @@ @@ -1184,6 +1393,8 @@
public void onCollideWithPlayer(EntityPlayer p_70100_1_) {} public void onCollideWithPlayer(EntityPlayer p_70100_1_) {}
@ -373,7 +380,7 @@
public void applyEntityCollision(Entity p_70108_1_) public void applyEntityCollision(Entity p_70108_1_)
{ {
if (p_70108_1_.riddenByEntity != this && p_70108_1_.ridingEntity != this) if (p_70108_1_.riddenByEntity != this && p_70108_1_.ridingEntity != this)
@@ -1310,6 +1515,20 @@ @@ -1310,6 +1521,20 @@
{ {
p_70109_1_.setTag("Pos", this.newDoubleNBTList(new double[] {this.posX, this.posY + (double)this.ySize, this.posZ})); p_70109_1_.setTag("Pos", this.newDoubleNBTList(new double[] {this.posX, this.posY + (double)this.ySize, this.posZ}));
p_70109_1_.setTag("Motion", this.newDoubleNBTList(new double[] {this.motionX, this.motionY, this.motionZ})); p_70109_1_.setTag("Motion", this.newDoubleNBTList(new double[] {this.motionX, this.motionY, this.motionZ}));
@ -394,7 +401,7 @@
p_70109_1_.setTag("Rotation", this.newFloatNBTList(new float[] {this.rotationYaw, this.rotationPitch})); p_70109_1_.setTag("Rotation", this.newFloatNBTList(new float[] {this.rotationYaw, this.rotationPitch}));
p_70109_1_.setFloat("FallDistance", this.fallDistance); p_70109_1_.setFloat("FallDistance", this.fallDistance);
p_70109_1_.setShort("Fire", (short)this.fire); p_70109_1_.setShort("Fire", (short)this.fire);
@@ -1320,6 +1539,12 @@ @@ -1320,6 +1545,12 @@
p_70109_1_.setInteger("PortalCooldown", this.timeUntilPortal); p_70109_1_.setInteger("PortalCooldown", this.timeUntilPortal);
p_70109_1_.setLong("UUIDMost", this.getUniqueID().getMostSignificantBits()); p_70109_1_.setLong("UUIDMost", this.getUniqueID().getMostSignificantBits());
p_70109_1_.setLong("UUIDLeast", this.getUniqueID().getLeastSignificantBits()); p_70109_1_.setLong("UUIDLeast", this.getUniqueID().getLeastSignificantBits());
@ -407,7 +414,7 @@
if (customEntityData != null) if (customEntityData != null)
{ {
p_70109_1_.setTag("ForgeData", customEntityData); p_70109_1_.setTag("ForgeData", customEntityData);
@@ -1370,7 +1595,7 @@ @@ -1370,7 +1601,7 @@
this.motionX = nbttaglist1.func_150309_d(0); this.motionX = nbttaglist1.func_150309_d(0);
this.motionY = nbttaglist1.func_150309_d(1); this.motionY = nbttaglist1.func_150309_d(1);
this.motionZ = nbttaglist1.func_150309_d(2); this.motionZ = nbttaglist1.func_150309_d(2);
@ -416,7 +423,7 @@
if (Math.abs(this.motionX) > 10.0D) if (Math.abs(this.motionX) > 10.0D)
{ {
this.motionX = 0.0D; this.motionX = 0.0D;
@@ -1385,7 +1610,7 @@ @@ -1385,7 +1616,7 @@
{ {
this.motionZ = 0.0D; this.motionZ = 0.0D;
} }
@ -425,7 +432,7 @@
this.prevPosX = this.lastTickPosX = this.posX = nbttaglist.func_150309_d(0); this.prevPosX = this.lastTickPosX = this.posX = nbttaglist.func_150309_d(0);
this.prevPosY = this.lastTickPosY = this.posY = nbttaglist.func_150309_d(1); this.prevPosY = this.lastTickPosY = this.posY = nbttaglist.func_150309_d(1);
this.prevPosZ = this.lastTickPosZ = this.posZ = nbttaglist.func_150309_d(2); this.prevPosZ = this.lastTickPosZ = this.posZ = nbttaglist.func_150309_d(2);
@@ -1436,6 +1661,76 @@ @@ -1436,6 +1667,76 @@
{ {
this.setPosition(this.posX, this.posY, this.posZ); this.setPosition(this.posX, this.posY, this.posZ);
} }
@ -502,7 +509,7 @@
} }
catch (Throwable throwable) catch (Throwable throwable)
{ {
@@ -1653,6 +1948,31 @@ @@ -1653,6 +1954,31 @@
public void mountEntity(Entity p_70078_1_) public void mountEntity(Entity p_70078_1_)
{ {
@ -534,7 +541,7 @@
this.entityRiderPitchDelta = 0.0D; this.entityRiderPitchDelta = 0.0D;
this.entityRiderYawDelta = 0.0D; this.entityRiderYawDelta = 0.0D;
@@ -1660,6 +1980,20 @@ @@ -1660,6 +1986,20 @@
{ {
if (this.ridingEntity != null) if (this.ridingEntity != null)
{ {
@ -555,7 +562,7 @@
this.setLocationAndAngles(this.ridingEntity.posX, this.ridingEntity.boundingBox.minY + (double)this.ridingEntity.height, this.ridingEntity.posZ, this.rotationYaw, this.rotationPitch); this.setLocationAndAngles(this.ridingEntity.posX, this.ridingEntity.boundingBox.minY + (double)this.ridingEntity.height, this.ridingEntity.posZ, this.rotationYaw, this.rotationPitch);
this.ridingEntity.riddenByEntity = null; this.ridingEntity.riddenByEntity = null;
} }
@@ -1668,22 +2002,61 @@ @@ -1668,22 +2008,61 @@
} }
else else
{ {
@ -624,7 +631,7 @@
this.ridingEntity = p_70078_1_; this.ridingEntity = p_70078_1_;
p_70078_1_.riddenByEntity = this; p_70078_1_.riddenByEntity = this;
} }
@@ -1860,12 +2233,59 @@ @@ -1860,12 +2239,59 @@
public void onStruckByLightning(EntityLightningBolt p_70077_1_) public void onStruckByLightning(EntityLightningBolt p_70077_1_)
{ {
@ -686,7 +693,7 @@
} }
} }
@@ -2038,36 +2458,62 @@ @@ -2038,36 +2464,62 @@
{ {
this.worldObj.theProfiler.startSection("changeDimension"); this.worldObj.theProfiler.startSection("changeDimension");
MinecraftServer minecraftserver = MinecraftServer.getServer(); MinecraftServer minecraftserver = MinecraftServer.getServer();
@ -765,7 +772,7 @@
} }
this.isDead = true; this.isDead = true;
@@ -2077,7 +2523,6 @@ @@ -2077,7 +2529,6 @@
this.worldObj.theProfiler.endSection(); this.worldObj.theProfiler.endSection();
} }
} }

View File

@ -406,7 +406,7 @@
+ float originalDamage = f; + float originalDamage = f;
+ // Cauldron start - apply forge damage hook + // Cauldron start - apply forge damage hook
+ f = ForgeHooks.onLivingHurt(this, damagesource, f); + f = ForgeHooks.onLivingHurt(this, damagesource, f);
+ if (f <= 0) return false; + if (f <= 0) return true;
+ // Cauldron end + // Cauldron end
+ Function<Double, Double> hardHat = new Function<Double, Double>() { + Function<Double, Double> hardHat = new Function<Double, Double>() {
+ @Override + @Override

View File

@ -124,17 +124,3 @@
} }
} }
} }
@@ -684,6 +759,13 @@
public ItemStack getItemStack()
{
+ // CraftBukkit start
+ if (this.itemStack != null && this.itemStack.stackSize == 0)
+ {
+ this.setItemStack(null);
+ }
+
+ // CraftBukkit end
return this.itemStack;
}

View File

@ -35,129 +35,23 @@
private static final String __OBFID = "CL_00000043"; private static final String __OBFID = "CL_00000043";
private cpw.mods.fml.common.registry.RegistryDelegate<Item> delegate; private cpw.mods.fml.common.registry.RegistryDelegate<Item> delegate;
@@ -126,12 +145,120 @@ @@ -126,12 +145,14 @@
public boolean tryPlaceItemIntoWorld(EntityPlayer p_77943_1_, World p_77943_2_, int p_77943_3_, int p_77943_4_, int p_77943_5_, int p_77943_6_, float p_77943_7_, float p_77943_8_, float p_77943_9_) public boolean tryPlaceItemIntoWorld(EntityPlayer p_77943_1_, World p_77943_2_, int p_77943_3_, int p_77943_4_, int p_77943_5_, int p_77943_6_, float p_77943_7_, float p_77943_8_, float p_77943_9_)
{ {
if (!p_77943_2_.isRemote) return net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(this, p_77943_1_, p_77943_2_, p_77943_3_, p_77943_4_, p_77943_5_, p_77943_6_, p_77943_7_, p_77943_8_, p_77943_9_); if (!p_77943_2_.isRemote) return net.minecraftforge.common.ForgeHooks.onPlaceItemIntoWorld(this, p_77943_1_, p_77943_2_, p_77943_3_, p_77943_4_, p_77943_5_, p_77943_6_, p_77943_7_, p_77943_8_, p_77943_9_);
+ // Cauldron start - handle all placement events here - boolean flag = this.getItem().onItemUse(this, p_77943_1_, p_77943_2_, p_77943_3_, p_77943_4_, p_77943_5_, p_77943_6_, p_77943_7_, p_77943_8_, p_77943_9_);
+ int meta = this.getItemDamage();
+ int size = this.stackSize;
+ NBTTagCompound nbt = null;
+ if (this.getTagCompound() != null)
+ {
+ nbt = (NBTTagCompound) this.getTagCompound().copy();
+ }
+
+ if (!(this.getItem() instanceof ItemBucket)) // if not bucket
+ {
+ p_77943_2_.captureBlockStates = true;
+ if (this.getItem() instanceof ItemDye && this.getItemDamage() == 15)
+ {
+ Block block = p_77943_2_.getBlock(p_77943_3_, p_77943_4_, p_77943_5_);
+ if (block != null && (block instanceof BlockSapling || block instanceof BlockMushroom))
+ {
+ p_77943_2_.captureTreeGeneration = true;
+ }
+ }
+ }
+ currentPlayer = p_77943_1_;
boolean flag = this.getItem().onItemUse(this, p_77943_1_, p_77943_2_, p_77943_3_, p_77943_4_, p_77943_5_, p_77943_6_, p_77943_7_, p_77943_8_, p_77943_9_);
+ p_77943_2_.captureBlockStates = false;
+ currentPlayer = null;
+ if (flag && p_77943_2_.captureTreeGeneration && p_77943_2_.capturedBlockStates.size() > 0)
+ {
+ p_77943_2_.captureTreeGeneration = false;
+ Location location = new Location(p_77943_2_.getWorld(), p_77943_3_, p_77943_4_, p_77943_5_);
+ TreeType treeType = BlockSapling.treeType;
+ BlockSapling.treeType = null;
+ List<BlockState> blocks = (List<BlockState>) p_77943_2_.capturedBlockStates.clone();
+ p_77943_2_.capturedBlockStates.clear();
+ StructureGrowEvent event = null;
+ if (treeType != null)
+ {
+ event = new StructureGrowEvent(location, treeType, false, (Player) p_77943_1_.getBukkitEntity(), blocks);
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+ }
+ if (event == null || !event.isCancelled())
+ {
+ for (BlockState blockstate : blocks)
+ {
+ blockstate.update(true);
+ }
+ }
+ return flag; + // Cauldron start - handle all placement events here
+ } + boolean flag = this.getItem().onItemUse(this, p_77943_1_, p_77943_2_, p_77943_3_, p_77943_4_, p_77943_5_, p_77943_6_, p_77943_7_, p_77943_8_, p_77943_9_);
+ p_77943_2_.captureTreeGeneration = false;
+
if (flag) if (flag)
{ {
- p_77943_1_.addStat(StatList.objectUseStats[Item.getIdFromItem(this.field_151002_e)], 1); p_77943_1_.addStat(StatList.objectUseStats[Item.getIdFromItem(this.field_151002_e)], 1);
+ org.bukkit.event.block.BlockPlaceEvent placeEvent = null;
+ List<BlockState> blockstates = (List<BlockState>) p_77943_2_.capturedBlockStates.clone();
+ p_77943_2_.capturedBlockStates.clear();
+ if (blockstates.size() > 1)
+ {
+ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockMultiPlaceEvent(p_77943_2_, p_77943_1_, blockstates, p_77943_3_,
+ p_77943_4_, p_77943_5_);
+ }
+ else if (blockstates.size() == 1)
+ {
+ placeEvent = org.bukkit.craftbukkit.event.CraftEventFactory.callBlockPlaceEvent(p_77943_2_, p_77943_1_, blockstates.get(0), p_77943_3_,
+ p_77943_4_, p_77943_5_);
+ }
+ if (placeEvent != null && (placeEvent.isCancelled() || !placeEvent.canBuild()))
+ {
+ flag = false; // cancel placement
+ // revert back all captured blocks
+ for (BlockState blockstate : blockstates)
+ {
+ p_77943_2_.restoringBlockStates = true;
+ blockstate.update(true, false); // restore blockstate
+ p_77943_2_.restoringBlockStates = false;
+ }
+ // make sure to restore stack after cancel
+ this.setItemDamage(meta);
+ this.stackSize = size;
+ if (nbt != null)
+ {
+ this.setTagCompound(nbt);
+ }
+ }
+ else
+ {
+ // drop items
+ for (int i = 0; i < p_77943_2_.capturedItems.size(); i++)
+ {
+ p_77943_2_.spawnEntityInWorld(p_77943_2_.capturedItems.get(i));
+ }
+
+ for (BlockState blockstate : blockstates)
+ {
+ int x = blockstate.getX();
+ int y = blockstate.getY();
+ int z = blockstate.getZ();
+ int metadata = p_77943_2_.getBlockMetadata(x, y, z);
+ int updateFlag = ((CraftBlockState) blockstate).getFlag();
+ Block oldBlock = CraftMagicNumbers.getBlock(blockstate.getTypeId());
+ Block newBlock = p_77943_2_.getBlock(x, y, z);
+ if (newBlock != null && !(newBlock.hasTileEntity(metadata)))
+ { // Containers get placed automatically
+ newBlock.onBlockAdded(p_77943_2_, x, y, z);
+ }
+
+ p_77943_2_.markAndNotifyBlock(x, y, z, null, oldBlock, newBlock, updateFlag);
+ }
+ p_77943_1_.addStat(StatList.objectUseStats[Item.getIdFromItem(this.field_151002_e)], 1);
+ }
} }
+ p_77943_2_.capturedBlockStates.clear();
+ p_77943_2_.capturedItems.clear();
+ // Cauldron end + // Cauldron end
return flag; return flag;
} }
@@ -227,8 +354,22 @@ @@ -227,8 +248,22 @@
return getItem().getMaxDamage(this); return getItem().getMaxDamage(this);
} }
@ -180,7 +74,7 @@
if (!this.isItemStackDamageable()) if (!this.isItemStackDamageable())
{ {
return false; return false;
@@ -250,6 +391,23 @@ @@ -250,6 +285,23 @@
p_96631_1_ -= k; p_96631_1_ -= k;
@ -204,7 +98,7 @@
if (p_96631_1_ <= 0) if (p_96631_1_ <= 0)
{ {
return false; return false;
@@ -288,6 +446,12 @@ @@ -288,6 +340,12 @@
this.stackSize = 0; this.stackSize = 0;
} }
@ -217,7 +111,7 @@
this.itemDamage = 0; this.itemDamage = 0;
} }
} }
@@ -419,6 +583,7 @@ @@ -419,6 +477,7 @@
public void setTagCompound(NBTTagCompound p_77982_1_) public void setTagCompound(NBTTagCompound p_77982_1_)
{ {

View File

@ -311,7 +311,21 @@
double d1; double d1;
double d2; double d2;
double d3; double d3;
@@ -318,7 +512,7 @@ @@ -280,13 +474,6 @@
d3 = p_147347_1_.func_149472_e();
d4 = p_147347_1_.func_149471_f() - p_147347_1_.func_149467_d();
- if (!this.playerEntity.isPlayerSleeping() && (d4 > 1.65D || d4 < 0.1D))
- {
- this.kickPlayerFromServer("Illegal stance");
- logger.warn(this.playerEntity.getCommandSenderName() + " had an illegal stance: " + d4);
- return;
- }
-
if (Math.abs(p_147347_1_.func_149464_c()) > 3.2E7D || Math.abs(p_147347_1_.func_149472_e()) > 3.2E7D)
{
this.kickPlayerFromServer("Illegal position");
@@ -318,7 +505,7 @@
double d9 = Math.max(Math.abs(d6), Math.abs(this.playerEntity.motionZ)); double d9 = Math.max(Math.abs(d6), Math.abs(this.playerEntity.motionZ));
double d10 = d7 * d7 + d8 * d8 + d9 * d9; double d10 = d7 * d7 + d8 * d8 + d9 * d9;
@ -320,7 +334,7 @@
{ {
logger.warn(this.playerEntity.getCommandSenderName() + " moved too quickly! " + d4 + "," + d5 + "," + d6 + " (" + d7 + ", " + d8 + ", " + d9 + ")"); logger.warn(this.playerEntity.getCommandSenderName() + " moved too quickly! " + d4 + "," + d5 + "," + d6 + " (" + d7 + ", " + d8 + ", " + d9 + ")");
this.setPlayerLocation(this.lastPosX, this.lastPosY, this.lastPosZ, this.playerEntity.rotationYaw, this.playerEntity.rotationPitch); this.setPlayerLocation(this.lastPosX, this.lastPosY, this.lastPosZ, this.playerEntity.rotationYaw, this.playerEntity.rotationPitch);
@@ -413,21 +607,85 @@ @@ -413,21 +600,85 @@
public void setPlayerLocation(double p_147364_1_, double p_147364_3_, double p_147364_5_, float p_147364_7_, float p_147364_8_) public void setPlayerLocation(double p_147364_1_, double p_147364_3_, double p_147364_5_, float p_147364_7_, float p_147364_8_)
{ {
@ -411,7 +425,7 @@
this.playerEntity.dropOneItem(false); this.playerEntity.dropOneItem(false);
} }
else if (p_147345_1_.func_149506_g() == 3) else if (p_147345_1_.func_149506_g() == 3)
@@ -490,7 +748,17 @@ @@ -490,7 +741,17 @@
} }
else else
{ {
@ -429,7 +443,7 @@
} }
} }
else if (p_147345_1_.func_149506_g() == 2) else if (p_147345_1_.func_149506_g() == 2)
@@ -517,6 +785,39 @@ @@ -517,6 +778,34 @@
public void processPlayerBlockPlacement(C08PacketPlayerBlockPlacement p_147346_1_) public void processPlayerBlockPlacement(C08PacketPlayerBlockPlacement p_147346_1_)
{ {
WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension); WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension);
@ -461,15 +475,10 @@
+ this.lastPacket = p_147346_1_.timestamp; + this.lastPacket = p_147346_1_.timestamp;
+ } + }
+ +
+ // CraftBukkit - if rightclick decremented the item, always send the update packet. */
+ // this is not here for CraftBukkit's own functionality; rather it is to fix
+ // a notch bug where the item doesn't update correctly.
+ boolean always = false;
+ // CraftBukkit end
ItemStack itemstack = this.playerEntity.inventory.getCurrentItem(); ItemStack itemstack = this.playerEntity.inventory.getCurrentItem();
boolean flag = false; boolean flag = false;
boolean placeResult = true; boolean placeResult = true;
@@ -533,11 +834,21 @@ @@ -533,11 +822,21 @@
return; return;
} }
@ -488,12 +497,12 @@
+ // CraftBukkit - notch decrements the counter by 1 in the above method with food, + // CraftBukkit - notch decrements the counter by 1 in the above method with food,
+ // snowballs and so forth, but he does it in a place that doesn't cause the + // snowballs and so forth, but he does it in a place that doesn't cause the
+ // inventory update packet to get sent + // inventory update packet to get sent
+ always = (itemstack.stackSize != itemstackAmount); + placeResult = itemstack.stackSize != itemstackAmount;
+ // CraftBukkit end + // CraftBukkit end
} }
else if (p_147346_1_.func_149571_d() >= this.serverController.getBuildLimit() - 1 && (p_147346_1_.func_149568_f() == 1 || p_147346_1_.func_149571_d() >= this.serverController.getBuildLimit())) else if (p_147346_1_.func_149571_d() >= this.serverController.getBuildLimit() - 1 && (p_147346_1_.func_149568_f() == 1 || p_147346_1_.func_149571_d() >= this.serverController.getBuildLimit()))
{ {
@@ -548,17 +859,24 @@ @@ -548,17 +847,24 @@
} }
else else
{ {
@ -519,33 +528,23 @@
+ if (!this.playerEntity.theItemInWorldManager.activateBlockOrUseItem(this.playerEntity, worldserver, itemstack, i, j, k, l, + if (!this.playerEntity.theItemInWorldManager.activateBlockOrUseItem(this.playerEntity, worldserver, itemstack, i, j, k, l,
+ p_147346_1_.func_149573_h(), p_147346_1_.func_149569_i(), p_147346_1_.func_149575_j())) + p_147346_1_.func_149573_h(), p_147346_1_.func_149569_i(), p_147346_1_.func_149575_j()))
+ { + {
+ always = true; + placeResult = true;
+ } + }
+ // Cauldron end + // Cauldron end
+ // CraftBukkit end + // CraftBukkit end
flag = true; flag = true;
} }
@@ -612,10 +930,17 @@ @@ -615,7 +921,7 @@
this.playerEntity.isChangingQuantityOnly = true;
this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem] = ItemStack.copyItemStack(this.playerEntity.inventory.mainInventory[this.playerEntity.inventory.currentItem]);
Slot slot = this.playerEntity.openContainer.getSlotFromInventory(this.playerEntity.inventory, this.playerEntity.inventory.currentItem);
+ // Cauldron start - abort if no slot, fixes RP2 timer crash block place - see #181
+ if (slot == null)
+ {
+ this.playerEntity.isChangingQuantityOnly = false; // set flag to false or it will cause inventory to glitch on death
+ return;
+ }
+ // Cauldron end
this.playerEntity.openContainer.detectAndSendChanges(); this.playerEntity.openContainer.detectAndSendChanges();
this.playerEntity.isChangingQuantityOnly = false; this.playerEntity.isChangingQuantityOnly = false;
- if (!ItemStack.areItemStacksEqual(this.playerEntity.inventory.getCurrentItem(), p_147346_1_.func_149574_g()) || !placeResult) // force client itemstack update if place event was cancelled - if (!ItemStack.areItemStacksEqual(this.playerEntity.inventory.getCurrentItem(), p_147346_1_.func_149574_g()) || !placeResult) // force client itemstack update if place event was cancelled
+ if (!ItemStack.areItemStacksEqual(this.playerEntity.inventory.getCurrentItem(), p_147346_1_.func_149574_g()) || always) // Cauldron - always is needed to update client itemstack if placement is cancelled + if (!ItemStack.areItemStacksEqual(this.playerEntity.inventory.getCurrentItem(), p_147346_1_.func_149574_g()) || !placeResult) // Cauldron - always is needed to update client itemstack if placement is cancelled
{ {
this.sendPacket(new S2FPacketSetSlot(this.playerEntity.openContainer.windowId, slot.slotNumber, this.playerEntity.inventory.getCurrentItem())); this.sendPacket(new S2FPacketSetSlot(this.playerEntity.openContainer.windowId, slot.slotNumber, this.playerEntity.inventory.getCurrentItem()));
} }
@@ -624,14 +949,34 @@ @@ -624,14 +930,34 @@
public void onDisconnect(IChatComponent p_147231_1_) public void onDisconnect(IChatComponent p_147231_1_)
{ {
@ -585,7 +584,7 @@
if (this.serverController.isSinglePlayer() && this.playerEntity.getCommandSenderName().equals(this.serverController.getServerOwner())) if (this.serverController.isSinglePlayer() && this.playerEntity.getCommandSenderName().equals(this.serverController.getServerOwner()))
{ {
logger.info("Stopping singleplayer server as player logged out"); logger.info("Stopping singleplayer server as player logged out");
@@ -657,6 +1002,18 @@ @@ -657,6 +983,18 @@
} }
} }
@ -604,7 +603,7 @@
try try
{ {
this.netManager.scheduleOutboundPacket(p_147359_1_, new GenericFutureListener[0]); this.netManager.scheduleOutboundPacket(p_147359_1_, new GenericFutureListener[0]);
@@ -679,20 +1036,37 @@ @@ -679,20 +1017,37 @@
public void processHeldItemChange(C09PacketHeldItemChange p_147355_1_) public void processHeldItemChange(C09PacketHeldItemChange p_147355_1_)
{ {
@ -643,7 +642,7 @@
{ {
ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("chat.cannotSend", new Object[0]); ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("chat.cannotSend", new Object[0]);
chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED); chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.RED);
@@ -708,51 +1082,385 @@ @@ -708,51 +1063,385 @@
{ {
if (!ChatAllowedCharacters.isAllowedCharacter(s.charAt(i))) if (!ChatAllowedCharacters.isAllowedCharacter(s.charAt(i)))
{ {
@ -1041,7 +1040,7 @@
if (p_147357_1_.func_149513_d() == 1) if (p_147357_1_.func_149513_d() == 1)
{ {
this.playerEntity.setSneaking(true); this.playerEntity.setSneaking(true);
@@ -772,7 +1480,7 @@ @@ -772,7 +1461,7 @@
else if (p_147357_1_.func_149513_d() == 3) else if (p_147357_1_.func_149513_d() == 3)
{ {
this.playerEntity.wakeUpPlayer(false, true, true); this.playerEntity.wakeUpPlayer(false, true, true);
@ -1050,7 +1049,7 @@
} }
else if (p_147357_1_.func_149513_d() == 6) else if (p_147357_1_.func_149513_d() == 6)
{ {
@@ -789,8 +1497,20 @@ @@ -789,8 +1478,20 @@
public void processUseEntity(C02PacketUseEntity p_147340_1_) public void processUseEntity(C02PacketUseEntity p_147340_1_)
{ {
@ -1072,7 +1071,7 @@
this.playerEntity.func_143004_u(); this.playerEntity.func_143004_u();
if (entity != null) if (entity != null)
@@ -805,9 +1525,53 @@ @@ -805,9 +1506,53 @@
if (this.playerEntity.getDistanceSqToEntity(entity) < d0) if (this.playerEntity.getDistanceSqToEntity(entity) < d0)
{ {
@ -1126,7 +1125,7 @@
} }
else if (p_147340_1_.func_149565_c() == C02PacketUseEntity.Action.ATTACK) else if (p_147340_1_.func_149565_c() == C02PacketUseEntity.Action.ATTACK)
{ {
@@ -819,6 +1583,13 @@ @@ -819,6 +1564,13 @@
} }
this.playerEntity.attackTargetEntityWithCurrentItem(entity); this.playerEntity.attackTargetEntityWithCurrentItem(entity);
@ -1140,13 +1139,13 @@
} }
} }
} }
@@ -834,8 +1605,19 @@ @@ -834,8 +1586,19 @@
case 1: case 1:
if (this.playerEntity.playerConqueredTheEnd) if (this.playerEntity.playerConqueredTheEnd)
{ {
- this.playerEntity = this.serverController.getConfigurationManager().respawnPlayer(this.playerEntity, 0, true); - this.playerEntity = this.serverController.getConfigurationManager().respawnPlayer(this.playerEntity, 0, true);
+ // Cauldron start + // Cauldron start
+ if (this.playerEntity.dimension == -1) // coming from end + if (this.playerEntity.dimension == 1) // coming from end
+ { + {
+ // We really should be calling transferPlayerToDimension since the player is coming in contact with a portal. + // We really should be calling transferPlayerToDimension since the player is coming in contact with a portal.
+ this.serverController.getConfigurationManager().respawnPlayer(this.playerEntity, 0, true); // set flag to indicate player is leaving end. + this.serverController.getConfigurationManager().respawnPlayer(this.playerEntity, 0, true); // set flag to indicate player is leaving end.
@ -1161,7 +1160,7 @@
else if (this.playerEntity.getServerForPlayer().getWorldInfo().isHardcoreModeEnabled()) else if (this.playerEntity.getServerForPlayer().getWorldInfo().isHardcoreModeEnabled())
{ {
if (this.serverController.isSinglePlayer() && this.playerEntity.getCommandSenderName().equals(this.serverController.getServerOwner())) if (this.serverController.isSinglePlayer() && this.playerEntity.getCommandSenderName().equals(this.serverController.getServerOwner()))
@@ -871,17 +1653,461 @@ @@ -871,17 +1634,461 @@
public void processCloseWindow(C0DPacketCloseWindow p_147356_1_) public void processCloseWindow(C0DPacketCloseWindow p_147356_1_)
{ {
@ -1624,7 +1623,7 @@
if (ItemStack.areItemStacksEqual(p_147351_1_.func_149546_g(), itemstack)) if (ItemStack.areItemStacksEqual(p_147351_1_.func_149546_g(), itemstack))
{ {
this.playerEntity.playerNetServerHandler.sendPacket(new S32PacketConfirmTransaction(p_147351_1_.func_149548_c(), p_147351_1_.func_149547_f(), true)); this.playerEntity.playerNetServerHandler.sendPacket(new S32PacketConfirmTransaction(p_147351_1_.func_149548_c(), p_147351_1_.func_149547_f(), true));
@@ -903,6 +2129,12 @@ @@ -903,6 +2110,12 @@
} }
this.playerEntity.sendContainerAndContentsToPlayer(this.playerEntity.openContainer, arraylist); this.playerEntity.sendContainerAndContentsToPlayer(this.playerEntity.openContainer, arraylist);
@ -1637,7 +1636,7 @@
} }
} }
} }
@@ -925,9 +2157,61 @@ @@ -925,9 +2138,61 @@
boolean flag = p_147344_1_.func_149627_c() < 0; boolean flag = p_147344_1_.func_149627_c() < 0;
ItemStack itemstack = p_147344_1_.func_149625_d(); ItemStack itemstack = p_147344_1_.func_149625_d();
boolean flag1 = p_147344_1_.func_149627_c() >= 1 && p_147344_1_.func_149627_c() < 36 + InventoryPlayer.getHotbarSize(); boolean flag1 = p_147344_1_.func_149627_c() >= 1 && p_147344_1_.func_149627_c() < 36 + InventoryPlayer.getHotbarSize();
@ -1700,7 +1699,7 @@
if (flag1 && flag2 && flag3) if (flag1 && flag2 && flag3)
{ {
if (itemstack == null) if (itemstack == null)
@@ -956,6 +2240,11 @@ @@ -956,6 +2221,11 @@
public void processConfirmTransaction(C0FPacketConfirmTransaction p_147339_1_) public void processConfirmTransaction(C0FPacketConfirmTransaction p_147339_1_)
{ {
@ -1712,7 +1711,7 @@
Short oshort = (Short)this.field_147372_n.lookup(this.playerEntity.openContainer.windowId); Short oshort = (Short)this.field_147372_n.lookup(this.playerEntity.openContainer.windowId);
if (oshort != null && p_147339_1_.func_149533_d() == oshort.shortValue() && this.playerEntity.openContainer.windowId == p_147339_1_.func_149532_c() && !this.playerEntity.openContainer.isPlayerNotUsingContainer(this.playerEntity)) if (oshort != null && p_147339_1_.func_149533_d() == oshort.shortValue() && this.playerEntity.openContainer.windowId == p_147339_1_.func_149532_c() && !this.playerEntity.openContainer.isPlayerNotUsingContainer(this.playerEntity))
@@ -966,6 +2255,11 @@ @@ -966,6 +2236,11 @@
public void processUpdateSign(C12PacketUpdateSign p_147343_1_) public void processUpdateSign(C12PacketUpdateSign p_147343_1_)
{ {
@ -1724,7 +1723,7 @@
this.playerEntity.func_143004_u(); this.playerEntity.func_143004_u();
WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension); WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension);
@@ -980,6 +2274,7 @@ @@ -980,6 +2255,7 @@
if (!tileentitysign.func_145914_a() || tileentitysign.func_145911_b() != this.playerEntity) if (!tileentitysign.func_145914_a() || tileentitysign.func_145911_b() != this.playerEntity)
{ {
this.serverController.logWarning("Player " + this.playerEntity.getCommandSenderName() + " just tried to change non-editable sign"); this.serverController.logWarning("Player " + this.playerEntity.getCommandSenderName() + " just tried to change non-editable sign");
@ -1732,7 +1731,7 @@
return; return;
} }
} }
@@ -990,6 +2285,7 @@ @@ -990,6 +2266,7 @@
for (j = 0; j < 4; ++j) for (j = 0; j < 4; ++j)
{ {
boolean flag = true; boolean flag = true;
@ -1740,7 +1739,7 @@
if (p_147343_1_.func_149589_f()[j].length() > 15) if (p_147343_1_.func_149589_f()[j].length() > 15)
{ {
@@ -1018,7 +2314,29 @@ @@ -1018,7 +2295,29 @@
int k = p_147343_1_.func_149586_d(); int k = p_147343_1_.func_149586_d();
i = p_147343_1_.func_149585_e(); i = p_147343_1_.func_149585_e();
TileEntitySign tileentitysign1 = (TileEntitySign)tileentity; TileEntitySign tileentitysign1 = (TileEntitySign)tileentity;
@ -1771,7 +1770,7 @@
tileentitysign1.markDirty(); tileentitysign1.markDirty();
worldserver.markBlockForUpdate(j, k, i); worldserver.markBlockForUpdate(j, k, i);
} }
@@ -1041,7 +2359,22 @@ @@ -1041,7 +2340,22 @@
public void processPlayerAbilities(C13PacketPlayerAbilities p_147348_1_) public void processPlayerAbilities(C13PacketPlayerAbilities p_147348_1_)
{ {
@ -1795,21 +1794,15 @@
} }
public void processTabComplete(C14PacketTabComplete p_147341_1_) public void processTabComplete(C14PacketTabComplete p_147341_1_)
@@ -1068,7 +2401,12 @@ @@ -1068,7 +2382,6 @@
PacketBuffer packetbuffer; PacketBuffer packetbuffer;
ItemStack itemstack; ItemStack itemstack;
ItemStack itemstack1; ItemStack itemstack1;
- -
+ // CraftBukkit start - Ignore empty payloads
+ if (p_147349_1_.field_149560_b <= 0)
+ {
+ return;
+ }
+ // CraftBukkit end
if ("MC|BEdit".equals(p_147349_1_.func_149559_c())) if ("MC|BEdit".equals(p_147349_1_.func_149559_c()))
{ {
packetbuffer = new PacketBuffer(Unpooled.wrappedBuffer(p_147349_1_.func_149558_e())); packetbuffer = new PacketBuffer(Unpooled.wrappedBuffer(p_147349_1_.func_149558_e()));
@@ -1093,16 +2431,18 @@ @@ -1093,16 +2406,18 @@
if (itemstack.getItem() == Items.writable_book && itemstack.getItem() == itemstack1.getItem()) if (itemstack.getItem() == Items.writable_book && itemstack.getItem() == itemstack1.getItem())
{ {
@ -1832,7 +1825,7 @@
} }
finally finally
{ {
@@ -1135,19 +2475,18 @@ @@ -1135,19 +2450,18 @@
{ {
if (itemstack.getItem() == Items.written_book && itemstack1.getItem() == Items.writable_book) if (itemstack.getItem() == Items.written_book && itemstack1.getItem() == Items.writable_book)
{ {
@ -1858,7 +1851,7 @@
} }
finally finally
{ {
@@ -1174,9 +2513,12 @@ @@ -1174,9 +2488,12 @@
((ContainerMerchant)container).setCurrentRecipeIndex(i); ((ContainerMerchant)container).setCurrentRecipeIndex(i);
} }
} }
@ -1872,7 +1865,7 @@
} }
} }
else if ("MC|AdvCdm".equals(p_147349_1_.func_149559_c())) else if ("MC|AdvCdm".equals(p_147349_1_.func_149559_c()))
@@ -1222,9 +2564,12 @@ @@ -1222,9 +2539,12 @@
this.playerEntity.addChatMessage(new ChatComponentTranslation("advMode.setCommand.success", new Object[] {s1})); this.playerEntity.addChatMessage(new ChatComponentTranslation("advMode.setCommand.success", new Object[] {s1}));
} }
} }
@ -1887,7 +1880,7 @@
} }
finally finally
{ {
@@ -1257,9 +2602,12 @@ @@ -1257,9 +2577,12 @@
tileentitybeacon.markDirty(); tileentitybeacon.markDirty();
} }
} }
@ -1902,7 +1895,7 @@
} }
} }
} }
@@ -1281,6 +2629,13 @@ @@ -1281,6 +2604,13 @@
containerrepair.updateItemName(""); containerrepair.updateItemName("");
} }
} }
@ -1916,7 +1909,7 @@
} }
} }
@@ -1292,6 +2647,21 @@ @@ -1292,6 +2622,21 @@
} }
} }

View File

@ -0,0 +1,11 @@
--- ../src-base/minecraft/net/minecraft/network/rcon/RConThreadClient.java
+++ ../src-work/minecraft/net/minecraft/network/rcon/RConThreadClient.java
@@ -53,6 +53,8 @@
BufferedInputStream bufferedinputstream = new BufferedInputStream(this.clientSocket.getInputStream());
int i = bufferedinputstream.read(this.buffer, 0, 1460);
+ if (i == -1) this.running = false; // Cauldron
+
if (10 <= i)
{
byte b0 = 0;

View File

@ -1,6 +1,6 @@
--- ../src-base/minecraft/net/minecraft/server/management/PlayerManager.java --- ../src-base/minecraft/net/minecraft/server/management/PlayerManager.java
+++ ../src-work/minecraft/net/minecraft/server/management/PlayerManager.java +++ ../src-work/minecraft/net/minecraft/server/management/PlayerManager.java
@@ -18,17 +18,23 @@ @@ -18,14 +18,19 @@
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -22,11 +22,7 @@
private int playerViewRadius; private int playerViewRadius;
private long previousTotalWorldTime; private long previousTotalWorldTime;
private final int[][] xzDirectionsConst = new int[][] {{1, 0}, {0, 1}, { -1, 0}, {0, -1}}; private final int[][] xzDirectionsConst = new int[][] {{1, 0}, {0, 1}, { -1, 0}, {0, -1}};
+ private boolean wasNotEmpty; // CraftBukkit @@ -37,6 +42,14 @@
private static final String __OBFID = "CL_00001434";
public PlayerManager(WorldServer p_i1176_1_)
@@ -37,6 +43,14 @@
this.func_152622_a(p_i1176_1_.func_73046_m().getConfigurationManager().getViewDistance()); this.func_152622_a(p_i1176_1_.func_73046_m().getConfigurationManager().getViewDistance());
} }
@ -41,7 +37,7 @@
public WorldServer getWorldServer() public WorldServer getWorldServer()
{ {
return this.theWorldServer; return this.theWorldServer;
@@ -51,34 +65,53 @@ @@ -51,27 +64,38 @@
if (i - this.previousTotalWorldTime > 8000L) if (i - this.previousTotalWorldTime > 8000L)
{ {
this.previousTotalWorldTime = i; this.previousTotalWorldTime = i;
@ -77,7 +73,7 @@
if (this.players.isEmpty()) if (this.players.isEmpty())
{ {
+ if (!wasNotEmpty) + if (this.theWorldServer.loadedEntityList.size() == 0 || this.theWorldServer.theChunkProviderServer.loadedChunkHashMap.size() == 0)
+ { + {
+ return; // CraftBukkit - Only do unload when we go from non-empty to empty + return; // CraftBukkit - Only do unload when we go from non-empty to empty
+ } + }
@ -85,22 +81,7 @@
WorldProvider worldprovider = this.theWorldServer.provider; WorldProvider worldprovider = this.theWorldServer.provider;
if (!worldprovider.canRespawnHere()) if (!worldprovider.canRespawnHere())
{ @@ -102,6 +126,20 @@
this.theWorldServer.theChunkProviderServer.unloadAllChunks();
}
+
+ // CraftBukkit start
+ wasNotEmpty = false;
}
+ else
+ {
+ wasNotEmpty = true;
+ }
+ // CraftBukkit end
}
public boolean func_152621_a(int p_152621_1_, int p_152621_2_)
@@ -102,6 +135,20 @@
return playerinstance; return playerinstance;
} }
@ -121,7 +102,7 @@
public void markBlockForUpdate(int p_151250_1_, int p_151250_2_, int p_151250_3_) public void markBlockForUpdate(int p_151250_1_, int p_151250_2_, int p_151250_3_)
{ {
int l = p_151250_1_ >> 4; int l = p_151250_1_ >> 4;
@@ -541,7 +588,7 @@ @@ -541,7 +579,7 @@
{ {
i = this.chunkLocation.chunkXPos * 16; i = this.chunkLocation.chunkXPos * 16;
j = this.chunkLocation.chunkZPos * 16; j = this.chunkLocation.chunkZPos * 16;

View File

@ -58,7 +58,7 @@
protected int maxPlayers; protected int maxPlayers;
private int viewDistance; private int viewDistance;
private WorldSettings.GameType gameType; private WorldSettings.GameType gameType;
@@ -91,8 +115,16 @@ @@ -91,8 +115,17 @@
private int playerPingIndex; private int playerPingIndex;
private static final String __OBFID = "CL_00001423"; private static final String __OBFID = "CL_00001423";
@ -69,13 +69,14 @@
{ {
+ p_i1500_1_.server = new CraftServer(p_i1500_1_, this); + p_i1500_1_.server = new CraftServer(p_i1500_1_, this);
+ p_i1500_1_.console = org.bukkit.craftbukkit.command.ColouredConsoleSender.getInstance(); + p_i1500_1_.console = org.bukkit.craftbukkit.command.ColouredConsoleSender.getInstance();
+ p_i1500_1_.remoteConsole = new org.bukkit.craftbukkit.command.CraftRemoteConsoleCommandSender();
+ p_i1500_1_.reader.addCompleter(new org.bukkit.craftbukkit.command.ConsoleCommandCompleter(p_i1500_1_.server)); + p_i1500_1_.reader.addCompleter(new org.bukkit.craftbukkit.command.ConsoleCommandCompleter(p_i1500_1_.server));
+ this.cserver = p_i1500_1_.server; + this.cserver = p_i1500_1_.server;
+ // CraftBukkit end + // CraftBukkit end
this.bannedPlayers = new UserListBans(field_152613_a); this.bannedPlayers = new UserListBans(field_152613_a);
this.bannedIPs = new BanList(field_152614_b); this.bannedIPs = new BanList(field_152614_b);
this.ops = new UserListOps(field_152615_c); this.ops = new UserListOps(field_152615_c);
@@ -131,12 +163,32 @@ @@ -131,12 +164,32 @@
s1 = p_72355_1_.getSocketAddress().toString(); s1 = p_72355_1_.getSocketAddress().toString();
} }
@ -109,7 +110,7 @@
nethandlerplayserver.sendPacket(new S3FPacketCustomPayload("MC|Brand", this.getServerInstance().getServerModName().getBytes(Charsets.UTF_8))); nethandlerplayserver.sendPacket(new S3FPacketCustomPayload("MC|Brand", this.getServerInstance().getServerModName().getBytes(Charsets.UTF_8)));
nethandlerplayserver.sendPacket(new S05PacketSpawnPosition(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ)); nethandlerplayserver.sendPacket(new S05PacketSpawnPosition(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ));
nethandlerplayserver.sendPacket(new S39PacketPlayerAbilities(p_72355_2_.capabilities)); nethandlerplayserver.sendPacket(new S39PacketPlayerAbilities(p_72355_2_.capabilities));
@@ -145,6 +197,7 @@ @@ -145,6 +198,7 @@
p_72355_2_.func_147099_x().func_150884_b(p_72355_2_); p_72355_2_.func_147099_x().func_150884_b(p_72355_2_);
this.func_96456_a((ServerScoreboard)worldserver.getScoreboard(), p_72355_2_); this.func_96456_a((ServerScoreboard)worldserver.getScoreboard(), p_72355_2_);
this.mcServer.func_147132_au(); this.mcServer.func_147132_au();
@ -117,7 +118,7 @@
ChatComponentTranslation chatcomponenttranslation; ChatComponentTranslation chatcomponenttranslation;
if (!p_72355_2_.getCommandSenderName().equalsIgnoreCase(s)) if (!p_72355_2_.getCommandSenderName().equalsIgnoreCase(s))
@@ -158,6 +211,7 @@ @@ -158,6 +212,7 @@
chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.YELLOW); chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.YELLOW);
this.sendChatMsg(chatcomponenttranslation); this.sendChatMsg(chatcomponenttranslation);
@ -125,7 +126,7 @@
this.playerLoggedIn(p_72355_2_); this.playerLoggedIn(p_72355_2_);
nethandlerplayserver.setPlayerLocation(p_72355_2_.posX, p_72355_2_.posY, p_72355_2_.posZ, p_72355_2_.rotationYaw, p_72355_2_.rotationPitch); nethandlerplayserver.setPlayerLocation(p_72355_2_.posX, p_72355_2_.posY, p_72355_2_.posZ, p_72355_2_.rotationYaw, p_72355_2_.rotationPitch);
this.updateTimeAndWeatherForPlayer(p_72355_2_, worldserver); this.updateTimeAndWeatherForPlayer(p_72355_2_, worldserver);
@@ -192,7 +246,7 @@ @@ -192,7 +247,7 @@
} }
} }
@ -134,7 +135,7 @@
{ {
HashSet hashset = new HashSet(); HashSet hashset = new HashSet();
Iterator iterator = p_96456_1_.getTeams().iterator(); Iterator iterator = p_96456_1_.getTeams().iterator();
@@ -225,6 +279,11 @@ @@ -225,6 +280,11 @@
public void setPlayerManager(WorldServer[] p_72364_1_) public void setPlayerManager(WorldServer[] p_72364_1_)
{ {
@ -146,7 +147,7 @@
this.playerNBTManagerObj = p_72364_1_[0].getSaveHandler().getSaveHandler(); this.playerNBTManagerObj = p_72364_1_[0].getSaveHandler().getSaveHandler();
} }
@@ -248,7 +307,7 @@ @@ -248,7 +308,7 @@
public NBTTagCompound readPlayerDataFromFile(EntityPlayerMP p_72380_1_) public NBTTagCompound readPlayerDataFromFile(EntityPlayerMP p_72380_1_)
{ {
@ -155,7 +156,7 @@
NBTTagCompound nbttagcompound1; NBTTagCompound nbttagcompound1;
if (p_72380_1_.getCommandSenderName().equals(this.mcServer.getServerOwner()) && nbttagcompound != null) if (p_72380_1_.getCommandSenderName().equals(this.mcServer.getServerOwner()) && nbttagcompound != null)
@@ -281,18 +340,61 @@ @@ -281,18 +341,61 @@
public void playerLoggedIn(EntityPlayerMP p_72377_1_) public void playerLoggedIn(EntityPlayerMP p_72377_1_)
{ {
@ -222,7 +223,7 @@
} }
public void updatePlayerPertinentChunks(EntityPlayerMP p_72358_1_) public void updatePlayerPertinentChunks(EntityPlayerMP p_72358_1_)
@@ -300,14 +402,33 @@ @@ -300,14 +403,33 @@
p_72358_1_.getServerForPlayer().getPlayerManager().updatePlayerPertinentChunks(p_72358_1_); p_72358_1_.getServerForPlayer().getPlayerManager().updatePlayerPertinentChunks(p_72358_1_);
} }
@ -258,7 +259,7 @@
{ {
worldserver.removePlayerEntityDangerously(p_72367_1_.ridingEntity); worldserver.removePlayerEntityDangerously(p_72367_1_.ridingEntity);
logger.debug("removing player mount"); logger.debug("removing player mount");
@@ -316,9 +437,35 @@ @@ -316,9 +438,35 @@
worldserver.removeEntity(p_72367_1_); worldserver.removeEntity(p_72367_1_);
worldserver.getPlayerManager().removePlayer(p_72367_1_); worldserver.getPlayerManager().removePlayer(p_72367_1_);
this.playerEntityList.remove(p_72367_1_); this.playerEntityList.remove(p_72367_1_);
@ -297,7 +298,7 @@
} }
public String allowUserToConnect(SocketAddress p_148542_1_, GameProfile p_148542_2_) public String allowUserToConnect(SocketAddress p_148542_1_, GameProfile p_148542_2_)
@@ -359,6 +506,71 @@ @@ -359,6 +507,71 @@
} }
} }
@ -369,7 +370,7 @@
public EntityPlayerMP createPlayerForUser(GameProfile p_148545_1_) public EntityPlayerMP createPlayerForUser(GameProfile p_148545_1_)
{ {
UUID uuid = EntityPlayer.func_146094_a(p_148545_1_); UUID uuid = EntityPlayer.func_146094_a(p_148545_1_);
@@ -397,116 +609,316 @@ @@ -397,116 +610,316 @@
return new EntityPlayerMP(this.mcServer, this.mcServer.worldServerForDimension(0), p_148545_1_, (ItemInWorldManager)object); return new EntityPlayerMP(this.mcServer, this.mcServer.worldServerForDimension(0), p_148545_1_, (ItemInWorldManager)object);
} }
@ -606,7 +607,7 @@
+ if (fromWorld != location.getWorld()) + if (fromWorld != location.getWorld())
+ { + {
+ FMLCommonHandler.instance().firePlayerChangedDimensionEvent(entityplayermp1, ((CraftWorld) fromWorld).getHandle().provider.dimensionId, + FMLCommonHandler.instance().firePlayerChangedDimensionEvent(entityplayermp1, ((CraftWorld) fromWorld).getHandle().provider.dimensionId,
+ ((CraftWorld) location.getWorld()).getHandle().provider.dimensionId); // Cauldron - fire forge changed dimension event + ((CraftWorld) location.getWorld()).getHandle().provider.dimensionId, (CraftWorld) fromWorld); // Cauldron - fire forge changed dimension event
+ } + }
+ else + else
+ FMLCommonHandler.instance().firePlayerRespawnEvent(entityplayermp1); + FMLCommonHandler.instance().firePlayerRespawnEvent(entityplayermp1);
@ -745,7 +746,7 @@
} }
public void transferEntityToWorld(Entity p_82448_1_, int p_82448_2_, WorldServer p_82448_3_, WorldServer p_82448_4_, Teleporter teleporter) public void transferEntityToWorld(Entity p_82448_1_, int p_82448_2_, WorldServer p_82448_3_, WorldServer p_82448_4_, Teleporter teleporter)
@@ -592,6 +1004,197 @@ @@ -592,6 +1005,197 @@
p_82448_1_.setWorld(p_82448_4_); p_82448_1_.setWorld(p_82448_4_);
} }
@ -943,7 +944,7 @@
public void sendPlayerInfoToAllPlayers() public void sendPlayerInfoToAllPlayers()
{ {
if (++this.playerPingIndex > 600) if (++this.playerPingIndex > 600)
@@ -599,11 +1202,13 @@ @@ -599,11 +1203,13 @@
this.playerPingIndex = 0; this.playerPingIndex = 0;
} }
@ -957,7 +958,7 @@
} }
public void sendPacketToAllPlayers(Packet p_148540_1_) public void sendPacketToAllPlayers(Packet p_148540_1_)
@@ -864,13 +1469,24 @@ @@ -864,13 +1470,24 @@
for (int j = 0; j < this.playerEntityList.size(); ++j) for (int j = 0; j < this.playerEntityList.size(); ++j)
{ {
EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(j); EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(j);
@ -984,7 +985,7 @@
if (d4 * d4 + d5 * d5 + d6 * d6 < p_148543_8_ * p_148543_8_) if (d4 * d4 + d5 * d5 + d6 * d6 < p_148543_8_ * p_148543_8_)
{ {
entityplayermp.playerNetServerHandler.sendPacket(p_148543_11_); entityplayermp.playerNetServerHandler.sendPacket(p_148543_11_);
@@ -925,16 +1541,19 @@ @@ -925,16 +1542,19 @@
if (p_72354_2_.isRaining()) if (p_72354_2_.isRaining())
{ {
@ -1005,7 +1006,7 @@
p_72385_1_.playerNetServerHandler.sendPacket(new S09PacketHeldItemChange(p_72385_1_.inventory.currentItem)); p_72385_1_.playerNetServerHandler.sendPacket(new S09PacketHeldItemChange(p_72385_1_.inventory.currentItem));
} }
@@ -950,7 +1569,10 @@ @@ -950,7 +1570,10 @@
public String[] getAvailablePlayerDat() public String[] getAvailablePlayerDat()
{ {
@ -1017,7 +1018,7 @@
} }
public void setWhiteListEnabled(boolean p_72371_1_) public void setWhiteListEnabled(boolean p_72371_1_)
@@ -1019,12 +1641,30 @@ @@ -1019,12 +1642,30 @@
public void removeAllPlayers() public void removeAllPlayers()
{ {

View File

@ -75,7 +75,7 @@
public List playerEntities = new ArrayList(); public List playerEntities = new ArrayList();
public List weatherEffects = new ArrayList(); public List weatherEffects = new ArrayList();
private long cloudColour = 16777215L; private long cloudColour = 16777215L;
@@ -100,26 +145,90 @@ @@ -100,26 +145,87 @@
public int lastLightningBolt; public int lastLightningBolt;
public EnumDifficulty difficultySetting; public EnumDifficulty difficultySetting;
public Random rand = new Random(); public Random rand = new Random();
@ -114,10 +114,7 @@
private boolean field_147481_N; private boolean field_147481_N;
int[] lightUpdateBlockList; int[] lightUpdateBlockList;
+ // Cauldron start + // Cauldron start
+ public boolean restoringBlockStates = false;
+ public boolean captureBlockStates = false;
+ public boolean captureTreeGeneration = false; + public boolean captureTreeGeneration = false;
+ public ArrayList<BlockState> capturedBlockStates = new ArrayList<BlockState>();
+ public ArrayList<EntityItem> capturedItems = new ArrayList<EntityItem>(); + public ArrayList<EntityItem> capturedItems = new ArrayList<EntityItem>();
+ public int entitiesTicked; + public int entitiesTicked;
+ public int tilesTicked; + public int tilesTicked;
@ -173,7 +170,7 @@
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;
@@ -166,6 +275,24 @@ @@ -166,6 +272,24 @@
return this.provider.worldChunkMgr; return this.provider.worldChunkMgr;
} }
@ -198,7 +195,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 +306,12 @@ @@ -179,6 +303,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);
@ -211,7 +208,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 +340,173 @@ @@ -207,8 +337,173 @@
this.calculateInitialWeather(); this.calculateInitialWeather();
} }
@ -385,7 +382,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 +514,6 @@ @@ -216,7 +511,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_;
@ -393,7 +390,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 +532,26 @@ @@ -235,13 +529,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_);
@ -420,7 +417,7 @@
this.chunkProvider = this.createChunkProvider(); this.chunkProvider = this.createChunkProvider();
if (this instanceof WorldServer) if (this instanceof WorldServer)
@@ -294,6 +604,7 @@ @@ -294,6 +601,7 @@
this.calculateInitialSkylight(); this.calculateInitialSkylight();
this.calculateInitialWeather(); this.calculateInitialWeather();
} }
@ -428,18 +425,18 @@
private static MapStorage s_mapStorage; private static MapStorage s_mapStorage;
private static ISaveHandler s_savehandler; private static ISaveHandler s_savehandler;
@@ -336,6 +647,18 @@ @@ -336,6 +644,18 @@
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) + if (captureTreeGeneration)
+ { + {
+ for (BlockState blockstate : capturedBlockStates) + for (net.minecraftforge.common.util.BlockSnapshot blocksnapshot : capturedBlockSnapshots)
+ { + {
+ if (blockstate.getX() == p_147439_1_ && blockstate.getY() == p_147439_2_ && blockstate.getZ() == p_147439_3_) + if (blocksnapshot.x == p_147439_1_ && blocksnapshot.y == p_147439_2_ && blocksnapshot.z == p_147439_3_)
+ { + {
+ return CraftMagicNumbers.getBlock(blockstate.getTypeId()); + return blocksnapshot.replacedBlock;
+ } + }
+ } + }
+ } + }
@ -447,7 +444,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 +727,7 @@ @@ -404,7 +724,7 @@
} }
} }
@ -456,85 +453,77 @@
{ {
return this.chunkProvider.chunkExists(p_72916_1_, p_72916_2_); return this.chunkProvider.chunkExists(p_72916_1_, p_72916_2_);
} }
@@ -421,6 +744,33 @@ @@ -421,6 +741,27 @@
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) + if (this.captureTreeGeneration)
+ { + {
+ BlockState blockstate = null; + net.minecraftforge.common.util.BlockSnapshot blocksnapshot = null;
+ +
+ for (BlockState previous : capturedBlockStates) + for (net.minecraftforge.common.util.BlockSnapshot previous : capturedBlockSnapshots)
+ { + {
+ if (previous.getX() == p_147465_1_ && previous.getY() == p_147465_2_ && previous.getZ() == p_147465_3_) + if (previous.x == p_147465_1_ && previous.y == p_147465_2_ && previous.z == p_147465_3_)
+ { + {
+ blockstate = previous; + blocksnapshot = previous;
+ break; + break;
+ } + }
+ } + }
+ if (blockstate != null) + if (blocksnapshot != null)
+ { + {
+ capturedBlockStates.remove(blockstate); + capturedBlockSnapshots.remove(blocksnapshot);
+ } + }
+ else + 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_));
+ {
+ blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(this, p_147465_1_, p_147465_2_, p_147465_3_, p_147465_6_);
+ }
+ blockstate.setTypeId(CraftMagicNumbers.getId(p_147465_4_));
+ blockstate.setRawData((byte) p_147465_5_);
+ this.capturedBlockStates.add(blockstate);
+ 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)
@@ -448,8 +798,22 @@ @@ -448,8 +789,22 @@
this.capturedBlockSnapshots.add(blockSnapshot); this.capturedBlockSnapshots.add(blockSnapshot);
} }
+ // Cauldron start - capture blockstates + // Cauldron start - capture blockstates
+ org.bukkit.block.BlockState blockstate = null; + net.minecraftforge.common.util.BlockSnapshot blocksnapshot = null;
+ if (this.captureBlockStates) + if (this.captureBlockSnapshots)
+ { + {
+ blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(this, p_147465_1_, p_147465_2_, p_147465_3_, p_147465_6_); + blocksnapshot = net.minecraftforge.common.util.BlockSnapshot.getBlockSnapshot(this, p_147465_1_, p_147465_2_, p_147465_3_, p_147465_6_);
+ this.capturedBlockStates.add(blockstate); + this.capturedBlockSnapshots.add(blocksnapshot);
+ } + }
+ +
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 && this.captureBlockStates) + if (!flag && this.captureBlockSnapshots)
+ { + {
+ this.capturedBlockStates.remove(blockstate); + this.capturedBlockSnapshots.remove(blocksnapshot);
+ } + }
+ // Cauldron end + // Cauldron end
+ +
if (!flag && blockSnapshot != null) if (!flag && blockSnapshot != null)
{ {
this.capturedBlockSnapshots.remove(blockSnapshot); this.capturedBlockSnapshots.remove(blockSnapshot);
@@ -460,7 +824,8 @@ @@ -460,6 +815,7 @@
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 || !this.captureBlockStates)) // Don't notify clients or update physics while capturing blockstates if (flag && blockSnapshot == null) // Don't notify clients or update physics while capturing blockstates
{ {
// Modularize client and physic updates // Modularize client and physic updates
this.markAndNotifyBlock(p_147465_1_, p_147465_2_, p_147465_3_, chunk, block1, p_147465_4_, p_147465_6_); @@ -496,6 +852,19 @@
@@ -496,6 +861,19 @@
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) + if (captureTreeGeneration)
+ { + {
+ for (BlockState blockstate : capturedBlockStates) + for (net.minecraftforge.common.util.BlockSnapshot blocksnapshot : capturedBlockSnapshots)
+ { + {
+ if (blockstate.getX() == p_72805_1_ && blockstate.getY() == p_72805_2_ && blockstate.getZ() == p_72805_3_) + if (blocksnapshot.x == p_72805_1_ && blocksnapshot.y == p_72805_2_ && blocksnapshot.z == p_72805_3_)
+ { + {
+ return blockstate.getRawData(); + return blocksnapshot.meta;
+ } + }
+ } + }
+ } + }
@ -543,7 +532,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)
@@ -610,6 +988,12 @@ @@ -610,6 +979,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_)
{ {
@ -556,7 +545,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 +1078,21 @@ @@ -694,6 +1069,21 @@
try try
{ {
@ -578,7 +567,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 +1706,14 @@ @@ -1307,6 +1697,12 @@
public boolean spawnEntityInWorld(Entity p_72838_1_) public boolean spawnEntityInWorld(Entity p_72838_1_)
{ {
@ -589,12 +578,9 @@
+ public boolean addEntity(Entity p_72838_1_, SpawnReason spawnReason) // Changed signature, added SpawnReason + public boolean addEntity(Entity p_72838_1_, SpawnReason spawnReason) // Changed signature, added SpawnReason
+ { + {
// do not drop any items while restoring blocksnapshots. Prevents dupes // do not drop any items while restoring blocksnapshots. Prevents dupes
- if (!this.isRemote && (p_72838_1_ == null || (p_72838_1_ instanceof net.minecraft.entity.item.EntityItem && this.restoringBlockSnapshots))) return false; if (!this.isRemote && (p_72838_1_ == null || (p_72838_1_ instanceof net.minecraft.entity.item.EntityItem && this.restoringBlockSnapshots))) return false;
+ if (!this.isRemote && (p_72838_1_ == null || (p_72838_1_ instanceof net.minecraft.entity.item.EntityItem && (this.restoringBlockSnapshots || this.restoringBlockStates)))) return false;
int i = MathHelper.floor_double(p_72838_1_.posX / 16.0D); @@ -1319,8 +1715,84 @@
int j = MathHelper.floor_double(p_72838_1_.posZ / 16.0D);
@@ -1319,8 +1724,84 @@
flag = true; flag = true;
} }
@ -679,7 +665,11 @@
return false; return false;
} }
else else
@@ -1336,6 +1817,7 @@ @@ -1332,10 +1804,10 @@
this.updateAllPlayersSleepingFlag();
}
if (MinecraftForge.EVENT_BUS.post(new EntityJoinWorldEvent(p_72838_1_, this)) && !flag) return false;
-
this.getChunkFromChunkCoords(i, j).addEntity(p_72838_1_); this.getChunkFromChunkCoords(i, j).addEntity(p_72838_1_);
this.loadedEntityList.add(p_72838_1_); this.loadedEntityList.add(p_72838_1_);
this.onEntityAdded(p_72838_1_); this.onEntityAdded(p_72838_1_);
@ -687,7 +677,7 @@
return true; return true;
} }
} }
@@ -1346,6 +1828,8 @@ @@ -1346,6 +1818,8 @@
{ {
((IWorldAccess)this.worldAccesses.get(i)).onEntityCreate(p_72923_1_); ((IWorldAccess)this.worldAccesses.get(i)).onEntityCreate(p_72923_1_);
} }
@ -696,7 +686,7 @@
} }
public void onEntityRemoved(Entity p_72847_1_) public void onEntityRemoved(Entity p_72847_1_)
@@ -1354,6 +1838,8 @@ @@ -1354,6 +1828,8 @@
{ {
((IWorldAccess)this.worldAccesses.get(i)).onEntityDestroy(p_72847_1_); ((IWorldAccess)this.worldAccesses.get(i)).onEntityDestroy(p_72847_1_);
} }
@ -705,7 +695,7 @@
} }
public void removeEntity(Entity p_72900_1_) public void removeEntity(Entity p_72900_1_)
@@ -1397,6 +1883,19 @@ @@ -1397,6 +1873,19 @@
} }
this.loadedEntityList.remove(p_72973_1_); this.loadedEntityList.remove(p_72973_1_);
@ -725,7 +715,7 @@
this.onEntityRemoved(p_72973_1_); this.onEntityRemoved(p_72973_1_);
} }
@@ -1408,40 +1907,58 @@ @@ -1408,40 +1897,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();
@ -798,7 +788,7 @@
for (int j2 = 0; j2 < list.size(); ++j2) for (int j2 = 0; j2 < list.size(); ++j2)
{ {
@@ -1797,11 +2314,22 @@ @@ -1797,11 +2304,22 @@
Entity entity; Entity entity;
CrashReport crashreport; CrashReport crashreport;
CrashReportCategory crashreportcategory; CrashReportCategory crashreportcategory;
@ -821,7 +811,7 @@
try try
{ {
++entity.ticksExisted; ++entity.ticksExisted;
@@ -1862,10 +2390,13 @@ @@ -1862,10 +2380,13 @@
this.unloadedEntityList.clear(); this.unloadedEntityList.clear();
this.theProfiler.endStartSection("regular"); this.theProfiler.endStartSection("regular");
@ -837,7 +827,7 @@
if (entity.ridingEntity != null) if (entity.ridingEntity != null)
{ {
@@ -1884,7 +2415,9 @@ @@ -1884,7 +2405,9 @@
{ {
try try
{ {
@ -847,7 +837,7 @@
} }
catch (Throwable throwable1) catch (Throwable throwable1)
{ {
@@ -1917,29 +2450,56 @@ @@ -1917,29 +2440,56 @@
this.getChunkFromChunkCoords(j, l).removeEntity(entity); this.getChunkFromChunkCoords(j, l).removeEntity(entity);
} }
@ -906,7 +896,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);
@@ -1972,6 +2532,11 @@ @@ -1972,6 +2522,11 @@
} }
} }
@ -918,7 +908,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 +2546,7 @@ @@ -1981,6 +2536,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();
} }
@ -926,7 +916,7 @@
this.field_147481_N = false; this.field_147481_N = false;
@@ -2016,17 +2582,23 @@ @@ -2016,17 +2572,23 @@
this.addedTileEntityList.clear(); this.addedTileEntityList.clear();
} }
@ -953,7 +943,7 @@
} }
public void updateEntity(Entity p_72870_1_) public void updateEntity(Entity p_72870_1_)
@@ -2041,16 +2613,27 @@ @@ -2041,16 +2603,27 @@
boolean isForced = getPersistentChunks().containsKey(new ChunkCoordIntPair(i >> 4, j >> 4)); boolean isForced = getPersistentChunks().containsKey(new ChunkCoordIntPair(i >> 4, j >> 4));
byte b0 = isForced ? (byte)0 : 32; byte b0 = isForced ? (byte)0 : 32;
boolean canUpdate = !p_72866_2_ || this.checkChunksExist(i - b0, 0, j - b0, i + b0, 0, j + b0); boolean canUpdate = !p_72866_2_ || this.checkChunksExist(i - b0, 0, j - b0, i + b0, 0, j + b0);
@ -982,7 +972,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 +2717,7 @@ @@ -2134,6 +2707,7 @@
p_72866_1_.riddenByEntity = null; p_72866_1_.riddenByEntity = null;
} }
} }
@ -990,7 +980,7 @@
} }
} }
@@ -2570,7 +3154,7 @@ @@ -2570,7 +3144,7 @@
return; return;
} }
@ -999,7 +989,7 @@
{ {
if (this.field_147481_N) if (this.field_147481_N)
{ {
@@ -2718,7 +3302,15 @@ @@ -2718,7 +3292,15 @@
if (i <= 0) if (i <= 0)
{ {
@ -1016,7 +1006,7 @@
} }
} }
@@ -2754,7 +3346,15 @@ @@ -2754,7 +3336,15 @@
if (j <= 0) if (j <= 0)
{ {
@ -1033,7 +1023,7 @@
} }
} }
@@ -2777,8 +3377,41 @@ @@ -2777,8 +3367,41 @@
protected void setActivePlayerChunksAndCheckLight() protected void setActivePlayerChunksAndCheckLight()
{ {
this.activeChunkSet.clear(); this.activeChunkSet.clear();
@ -1067,7 +1057,7 @@
+ int randRange = this.func_152379_p(); + int randRange = this.func_152379_p();
+ if (randRange < 1) + if (randRange < 1)
+ { + {
+ throw new IllegalArgumentException("Too small view radius! edit spigot.yml and change view-distance to a value > 0."); + throw new IllegalArgumentException("Too small view radius! edit server.properties and change view-distance to a value > 0.");
+ } + }
+ // Cauldron end + // Cauldron end
+ // odds of growth happening vs growth happening in vanilla + // odds of growth happening vs growth happening in vanilla
@ -1076,7 +1066,7 @@
int i; int i;
EntityPlayer entityplayer; EntityPlayer entityplayer;
int j; int j;
@@ -2788,17 +3421,28 @@ @@ -2788,17 +3411,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);
@ -1111,7 +1101,7 @@
} }
this.theProfiler.endSection(); this.theProfiler.endSection();
@@ -2810,7 +3454,7 @@ @@ -2810,7 +3444,7 @@
this.theProfiler.startSection("playerCheckLight"); this.theProfiler.startSection("playerCheckLight");
@ -1120,7 +1110,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);
@@ -3284,8 +3928,21 @@ @@ -3284,8 +3918,21 @@
{ {
Entity entity = (Entity)this.loadedEntityList.get(j); Entity entity = (Entity)this.loadedEntityList.get(j);
@ -1143,7 +1133,7 @@
++i; ++i;
} }
} }
@@ -3314,8 +3971,17 @@ @@ -3314,8 +3961,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_);
@ -1162,7 +1152,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 +4130,12 @@ @@ -3464,6 +4120,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);
@ -1175,7 +1165,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 +4161,12 @@ @@ -3489,7 +4151,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);
@ -1189,7 +1179,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 +4337,18 @@ @@ -3660,6 +4327,18 @@
public void updateAllPlayersSleepingFlag() {} public void updateAllPlayersSleepingFlag() {}
@ -1208,7 +1198,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 +4621,8 @@ @@ -3932,8 +4611,8 @@
*/ */
public void addTileEntity(TileEntity entity) public void addTileEntity(TileEntity entity)
{ {
@ -1219,7 +1209,7 @@
{ {
dest.add(entity); dest.add(entity);
} }
@@ -4029,4 +4718,60 @@ @@ -4029,4 +4708,60 @@
} }
return count; return count;
} }

View File

@ -552,13 +552,27 @@
if (flag != this.isRaining()) if (flag != this.isRaining())
{ {
if (flag) if (flag)
@@ -1006,6 +1263,20 @@ @@ -1006,6 +1263,33 @@
this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(7, this.rainingStrength), this.provider.dimensionId); this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(7, this.rainingStrength), this.provider.dimensionId);
this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(8, this.thunderingStrength), this.provider.dimensionId); this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(8, this.thunderingStrength), this.provider.dimensionId);
} }
+ // */ + // */
+ if (flag != this.isRaining()) + if (flag != this.isRaining())
+ { + {
+ if (flag)
+ {
+ this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(2, 0.0F), super.provider.dimensionId);
+ }
+ else
+ {
+ this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(1, 0.0F), super.provider.dimensionId);
+ }
+
+ this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(7, super.rainingStrength),
+ super.provider.dimensionId);
+ this.mcServer.getConfigurationManager().sendPacketToAllPlayersInDimension(new S2BPacketChangeGameState(8, super.thunderingStrength),
+ super.provider.dimensionId);
+
+ // Only send weather packets to those affected + // Only send weather packets to those affected
+ for (int i = 0; i < this.playerEntities.size(); ++i) + for (int i = 0; i < this.playerEntities.size(); ++i)
+ { + {
@ -567,13 +581,12 @@
+ ((EntityPlayerMP) this.playerEntities.get(i)).setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false); + ((EntityPlayerMP) this.playerEntities.get(i)).setPlayerWeather((!flag ? WeatherType.DOWNFALL : WeatherType.CLEAR), false);
+ } + }
+ } + }
+
+ // CraftBukkit end + // CraftBukkit end
+ } + }
} }
protected int func_152379_p() protected int func_152379_p()
@@ -1069,4 +1340,31 @@ @@ -1069,4 +1353,51 @@
this(); this();
} }
} }
@ -603,5 +616,25 @@
+ { + {
+ return Block.getIdFromBlock(getBlock(x, y, z)); + return Block.getIdFromBlock(getBlock(x, y, z));
+ } + }
+
+ public boolean setTypeAndData(int x, int y, int z, Block block, int data, int flag)
+ {
+ return this.setBlock(x, y, z, block, data, flag);
+ }
+
+ public boolean setData(int x, int y, int z, int data, int flag)
+ {
+ return this.setBlockMetadataWithNotify(x, y, z, data, flag);
+ }
+
+ public int getData(int x, int y, int z)
+ {
+ return this.getBlockMetadata(x, y, z);
+ }
+
+ public Block getType(int x, int y, int z)
+ {
+ return this.getBlock(x, y, z);
+ }
+ // CraftBukkit end + // CraftBukkit end
} }

View File

@ -63,7 +63,7 @@
extendedblockstorage.func_150818_a(p_150807_1_, p_150807_2_ & 15, p_150807_3_, p_150807_4_); extendedblockstorage.func_150818_a(p_150807_1_, p_150807_2_ & 15, p_150807_3_, p_150807_4_);
extendedblockstorage.setExtBlockMetadata(p_150807_1_, p_150807_2_ & 15, p_150807_3_, p_150807_5_); // This line duplicates the one below, so breakBlock fires with valid worldstate extendedblockstorage.setExtBlockMetadata(p_150807_1_, p_150807_2_ & 15, p_150807_3_, p_150807_5_); // This line duplicates the one below, so breakBlock fires with valid worldstate
@@ -777,8 +800,14 @@ @@ -777,8 +800,20 @@
if (i != this.xPosition || j != this.zPosition) if (i != this.xPosition || j != this.zPosition)
{ {
@ -76,11 +76,17 @@
+ Bukkit.getLogger().warning( + Bukkit.getLogger().warning(
+ "Entity is at " + p_76612_1_.posX + "," + p_76612_1_.posZ + " (chunk " + i + "," + j + ") but was stored in chunk " + this.xPosition + "," + "Entity is at " + p_76612_1_.posX + "," + p_76612_1_.posZ + " (chunk " + i + "," + j + ") but was stored in chunk " + this.xPosition + ","
+ + this.zPosition); + + this.zPosition);
+ if (!(p_76612_1_ instanceof EntityPlayerMP))
+ {
+ Bukkit.getLogger().warning("Cauldron has removed " + p_76612_1_ + " to prevent a server crash.");
+ p_76612_1_.setDead();
+ return;
+ }
+ // CraftBukkit end + // CraftBukkit end
} }
int k = MathHelper.floor_double(p_76612_1_.posY / 16.0D); int k = MathHelper.floor_double(p_76612_1_.posY / 16.0D);
@@ -799,6 +828,26 @@ @@ -799,6 +834,26 @@
p_76612_1_.chunkCoordY = k; p_76612_1_.chunkCoordY = k;
p_76612_1_.chunkCoordZ = this.zPosition; p_76612_1_.chunkCoordZ = this.zPosition;
this.entityLists[k].add(p_76612_1_); this.entityLists[k].add(p_76612_1_);
@ -107,7 +113,7 @@
} }
public void removeEntity(Entity p_76622_1_) public void removeEntity(Entity p_76622_1_)
@@ -819,6 +868,26 @@ @@ -819,6 +874,26 @@
} }
this.entityLists[p_76608_2_].remove(p_76608_1_); this.entityLists[p_76608_2_].remove(p_76608_1_);
@ -134,7 +140,7 @@
} }
public boolean canBlockSeeTheSky(int p_76619_1_, int p_76619_2_, int p_76619_3_) public boolean canBlockSeeTheSky(int p_76619_1_, int p_76619_2_, int p_76619_3_)
@@ -874,9 +943,23 @@ @@ -874,9 +949,23 @@
p_150812_4_.xCoord = this.xPosition * 16 + p_150812_1_; p_150812_4_.xCoord = this.xPosition * 16 + p_150812_1_;
p_150812_4_.yCoord = p_150812_2_; p_150812_4_.yCoord = p_150812_2_;
p_150812_4_.zCoord = this.zPosition * 16 + p_150812_3_; p_150812_4_.zCoord = this.zPosition * 16 + p_150812_3_;
@ -159,7 +165,7 @@
{ {
if (this.chunkTileEntityMap.containsKey(chunkposition)) if (this.chunkTileEntityMap.containsKey(chunkposition))
{ {
@@ -886,6 +969,16 @@ @@ -886,6 +975,16 @@
p_150812_4_.validate(); p_150812_4_.validate();
this.chunkTileEntityMap.put(chunkposition, p_150812_4_); this.chunkTileEntityMap.put(chunkposition, p_150812_4_);
} }
@ -176,7 +182,7 @@
} }
public void removeTileEntity(int p_150805_1_, int p_150805_2_, int p_150805_3_) public void removeTileEntity(int p_150805_1_, int p_150805_2_, int p_150805_3_)
@@ -936,6 +1029,21 @@ @@ -936,6 +1035,21 @@
for (int i = 0; i < this.entityLists.length; ++i) for (int i = 0; i < this.entityLists.length; ++i)
{ {
@ -198,7 +204,7 @@
this.worldObj.unloadEntities(this.entityLists[i]); this.worldObj.unloadEntities(this.entityLists[i]);
} }
MinecraftForge.EVENT_BUS.post(new ChunkEvent.Unload(this)); MinecraftForge.EVENT_BUS.post(new ChunkEvent.Unload(this));
@@ -1035,6 +1143,7 @@ @@ -1035,6 +1149,7 @@
public void populateChunk(IChunkProvider p_76624_1_, IChunkProvider p_76624_2_, int p_76624_3_, int p_76624_4_) public void populateChunk(IChunkProvider p_76624_1_, IChunkProvider p_76624_2_, int p_76624_3_, int p_76624_4_)
{ {
@ -206,7 +212,7 @@
if (!this.isTerrainPopulated && p_76624_1_.chunkExists(p_76624_3_ + 1, p_76624_4_ + 1) && p_76624_1_.chunkExists(p_76624_3_, p_76624_4_ + 1) && p_76624_1_.chunkExists(p_76624_3_ + 1, p_76624_4_)) if (!this.isTerrainPopulated && p_76624_1_.chunkExists(p_76624_3_ + 1, p_76624_4_ + 1) && p_76624_1_.chunkExists(p_76624_3_, p_76624_4_ + 1) && p_76624_1_.chunkExists(p_76624_3_ + 1, p_76624_4_))
{ {
p_76624_1_.populate(p_76624_2_, p_76624_3_, p_76624_4_); p_76624_1_.populate(p_76624_2_, p_76624_3_, p_76624_4_);
@@ -1054,6 +1163,7 @@ @@ -1054,6 +1169,7 @@
{ {
p_76624_1_.populate(p_76624_2_, p_76624_3_ - 1, p_76624_4_ - 1); p_76624_1_.populate(p_76624_2_, p_76624_3_ - 1, p_76624_4_ - 1);
} }
@ -214,7 +220,7 @@
} }
public int getPrecipitationHeight(int p_76626_1_, int p_76626_2_) public int getPrecipitationHeight(int p_76626_1_, int p_76626_2_)
@@ -1184,8 +1294,10 @@ @@ -1184,8 +1300,10 @@
if ((p_76607_2_ & 1 << l) != 0 && this.storageArrays[l] != null) if ((p_76607_2_ & 1 << l) != 0 && this.storageArrays[l] != null)
{ {
nibblearray = this.storageArrays[l].getMetadataArray(); nibblearray = this.storageArrays[l].getMetadataArray();
@ -227,7 +233,7 @@
} }
} }
@@ -1194,8 +1306,10 @@ @@ -1194,8 +1312,10 @@
if ((p_76607_2_ & 1 << l) != 0 && this.storageArrays[l] != null) if ((p_76607_2_ & 1 << l) != 0 && this.storageArrays[l] != null)
{ {
nibblearray = this.storageArrays[l].getBlocklightArray(); nibblearray = this.storageArrays[l].getBlocklightArray();
@ -240,7 +246,7 @@
} }
} }
@@ -1206,8 +1320,10 @@ @@ -1206,8 +1326,10 @@
if ((p_76607_2_ & 1 << l) != 0 && this.storageArrays[l] != null) if ((p_76607_2_ & 1 << l) != 0 && this.storageArrays[l] != null)
{ {
nibblearray = this.storageArrays[l].getSkylightArray(); nibblearray = this.storageArrays[l].getSkylightArray();
@ -253,7 +259,7 @@
} }
} }
} }
@@ -1229,8 +1345,8 @@ @@ -1229,8 +1351,8 @@
nibblearray = this.storageArrays[l].createBlockMSBArray(); nibblearray = this.storageArrays[l].createBlockMSBArray();
} }

View File

@ -1,14 +1,23 @@
--- ../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,7 @@ @@ -63,6 +63,16 @@
import net.minecraftforge.event.world.BlockEvent; import net.minecraftforge.event.world.BlockEvent;
import net.minecraftforge.event.world.NoteBlockEvent; import net.minecraftforge.event.world.NoteBlockEvent;
import static net.minecraft.init.Blocks.*; import static net.minecraft.init.Blocks.*;
+import net.minecraftforge.common.util.FakePlayer; // Cauldron +// Cauldron start
+import net.minecraftforge.common.util.FakePlayer;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+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;
+//Cauldron end
public class ForgeHooks public class ForgeHooks
{ {
@@ -439,6 +440,8 @@ @@ -439,6 +449,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)
{ {
@ -17,7 +26,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 +452,9 @@ @@ -449,9 +461,9 @@
{ {
preCancelEvent = true; preCancelEvent = true;
} }
@ -29,7 +38,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 +466,11 @@ @@ -463,11 +475,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);
@ -43,3 +52,188 @@
{ {
// 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 +512,137 @@
if (!(itemstack.getItem() instanceof ItemBucket)) // if not bucket
{
world.captureBlockSnapshots = true;
+ // Cauldron start
+ if (itemstack.getItem() instanceof net.minecraft.item.ItemDye && itemstack.getItemDamage() == 15)
+ {
+ Block block = world.getBlock(x, y, z);
+ if (block != null && (block instanceof net.minecraft.block.BlockSapling || block instanceof net.minecraft.block.BlockMushroom))
+ {
+ world.captureTreeGeneration = true;
+ }
+ }
+ // Cauldron end
}
+ ItemStack.currentPlayer = player; // Cauldron
boolean flag = itemstack.getItem().onItemUse(itemstack, player, world, x, y, z, side, hitX, hitY, hitZ);
+ ItemStack.currentPlayer = null; // Cauldron
world.captureBlockSnapshots = false;
- if (flag)
+ // Cauldron start
+ if (flag && world.captureTreeGeneration && world.capturedBlockSnapshots.size() > 0)
{
- // save new item data
- int newMeta = itemstack.getItemDamage();
- int newSize = itemstack.stackSize;
- NBTTagCompound newNBT = 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();
+ states.add(new CraftBlockState(snapshot));
}
- 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();
- // make sure to set pre-placement item data for event
- itemstack.setItemDamage(meta);
- itemstack.stackSize = size;
- if (nbt != null)
+ world.capturedBlockSnapshots.clear();
+ StructureGrowEvent event = null;
+ if (type != null)
{
- itemstack.setTagCompound(nbt);
+ event = new StructureGrowEvent(loc, type, false, (Player) player.getBukkitEntity(), states);
+ Bukkit.getPluginManager().callEvent(event);
}
- 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));
- }
- if (placeEvent != null && (placeEvent.isCanceled()))
+ if (event == null || !event.isCancelled())
{
- flag = false; // cancel placement
- // revert back all captured blocks
- for (net.minecraftforge.common.util.BlockSnapshot blocksnapshot : blockSnapshots)
+ for (BlockState state : states)
{
- world.restoringBlockSnapshots = true;
- blocksnapshot.restore(true, false);
- world.restoringBlockSnapshots = false;
+ state.update(true);
}
}
- else
+
+ return flag;
+ }
+ else
+ {
+ world.captureTreeGeneration = false; // Cauldron end
+ if (flag)
{
- // Change the stack to its new content
- itemstack.setItemDamage(newMeta);
- itemstack.stackSize = newSize;
+ // save new item data
+ 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();
+
+ // make sure to set pre-placement item data for event
+ itemstack.setItemDamage(meta);
+ itemstack.stackSize = size;
if (nbt != null)
{
- 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)
+ if (placeEvent != null && (placeEvent.isCanceled()))
{
- 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
+ flag = false; // cancel placement
+ // revert back all captured blocks
+ for (net.minecraftforge.common.util.BlockSnapshot blocksnapshot : blockSnapshots)
{
- newBlock.onBlockAdded(world, blockX, blockY, blockZ);
+ world.restoringBlockSnapshots = true;
+ blocksnapshot.restore(true, false);
+ world.restoringBlockSnapshots = false;
}
+ }
+ else
+ {
+ // Change the stack to its new content
+ itemstack.setItemDamage(newMeta);
+ itemstack.stackSize = newSize;
+ if (nbt != null)
+ {
+ itemstack.setTagCompound(newNBT);
+ }
- 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);
+ }
+ player.addStat(StatList.objectUseStats[Item.getIdFromItem(itemstack.getItem())], 1);
}
- player.addStat(StatList.objectUseStats[Item.getIdFromItem(itemstack.getItem())], 1);
+
}
}
+
world.capturedBlockSnapshots.clear();
return flag;

View File

@ -0,0 +1,29 @@
--- ../src-base/minecraft/net/minecraftforge/common/ISpecialArmor.java
+++ ../src-work/minecraft/net/minecraftforge/common/ISpecialArmor.java
@@ -92,6 +92,11 @@
*/
public static float ApplyArmor(EntityLivingBase entity, ItemStack[] inventory, DamageSource source, double damage)
{
+ return ApplyArmor(entity, inventory, source, damage, true);
+ }
+
+ public static float ApplyArmor(EntityLivingBase entity, ItemStack[] inventory, DamageSource source, double damage, boolean applyDamage)
+ {
if (DEBUG)
{
System.out.println("Start: " + damage + " " + (damage * 25));
@@ -145,9 +150,12 @@
int itemDamage = (int)(absorb / 25D < 1 ? 1 : absorb / 25D);
if (stack.getItem() instanceof ISpecialArmor)
{
- ((ISpecialArmor)stack.getItem()).damageArmor(entity, stack, source, itemDamage, prop.Slot);
+ if (applyDamage)
+ {
+ ((ISpecialArmor) stack.getItem()).damageArmor(entity, stack, source, itemDamage, prop.Slot);
+ }
}
- else
+ else if(applyDamage)
{
if (DEBUG)
{

View File

@ -37,3 +37,20 @@
} }
public EntityPlayer getPlayer() public EntityPlayer getPlayer()
@@ -140,6 +146,16 @@
this.blockSnapshot = blockSnapshot;
this.placedBlock = blockSnapshot.getCurrentBlock();
this.placedAgainst = placedAgainst;
+ // Cauldron start - handle event on bukkit side
+ org.bukkit.craftbukkit.block.CraftBlockState blockstate = org.bukkit.craftbukkit.block.CraftBlockState.getBlockState(super.world, super.x, super.y,
+ super.z);
+ org.bukkit.event.block.BlockPlaceEvent bukkitEvent = CraftEventFactory.callBlockPlaceEvent(super.world, player, blockstate, super.x, super.y,
+ super.z);
+ if (bukkitEvent.isCancelled() || !bukkitEvent.canBuild())
+ {
+ this.setCanceled(true);
+ }
+ // Cauldron end
if (DEBUG)
{
System.out.printf("Created PlaceEvent - [PlacedBlock: %s ][PlacedAgainst: %s ][ItemStack: %s ][Player: %s ]\n", placedBlock, placedAgainst, player.getCurrentEquippedItem(), player);

View File

@ -22,6 +22,8 @@ import javax.management.MBeanServer;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.EntityLivingBase;
import net.minecraft.entity.IEntityMultiPart;
import net.minecraft.entity.boss.IBossDisplayData;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
@ -147,32 +149,36 @@ public class CauldronHooks
public static boolean checkBoundingBoxSize(Entity entity, AxisAlignedBB aabb) public static boolean checkBoundingBoxSize(Entity entity, AxisAlignedBB aabb)
{ {
if (!(entity instanceof EntityLivingBase) || entity instanceof EntityPlayer) return false; // only check living entities that are not players if (entity instanceof EntityLivingBase && (!(entity instanceof IBossDisplayData) || !(entity instanceof IEntityMultiPart))
int logSize = MinecraftServer.cauldronConfig.largeBoundingBoxLogSize.getValue(); && !(entity instanceof EntityPlayer))
if (logSize <= 0 || !MinecraftServer.cauldronConfig.checkEntityBoundingBoxes.getValue()) return false;
int x = MathHelper.floor_double(aabb.minX);
int x1 = MathHelper.floor_double(aabb.maxX + 1.0D);
int y = MathHelper.floor_double(aabb.minY);
int y1 = MathHelper.floor_double(aabb.maxY + 1.0D);
int z = MathHelper.floor_double(aabb.minZ);
int z1 = MathHelper.floor_double(aabb.maxZ + 1.0D);
int size = Math.abs(x1-x) * Math.abs(y1-y) * Math.abs(z1-z);
if (size > MinecraftServer.cauldronConfig.largeBoundingBoxLogSize.getValue())
{ {
logWarning("Entity being removed for bounding box restrictions"); int logSize = MinecraftServer.cauldronConfig.largeBoundingBoxLogSize.getValue();
logWarning("BB Size: {0} > {1} avg edge: {2}", size, logSize, aabb.getAverageEdgeLength()); if (logSize <= 0 || !MinecraftServer.cauldronConfig.checkEntityBoundingBoxes.getValue()) return false;
logWarning("Motion: ({0}, {1}, {2})", entity.motionX, entity.motionY, entity.motionZ); int x = MathHelper.floor_double(aabb.minX);
logWarning("Calculated bounding box: {0}", aabb); int x1 = MathHelper.floor_double(aabb.maxX + 1.0D);
logWarning("Entity bounding box: {0}", entity.getBoundingBox()); int y = MathHelper.floor_double(aabb.minY);
logWarning("Entity: {0}", entity); int y1 = MathHelper.floor_double(aabb.maxY + 1.0D);
NBTTagCompound tag = new NBTTagCompound(); int z = MathHelper.floor_double(aabb.minZ);
entity.writeToNBT(tag); int z1 = MathHelper.floor_double(aabb.maxZ + 1.0D);
logWarning("Entity NBT: {0}", tag);
logStack(); int size = Math.abs(x1 - x) * Math.abs(y1 - y) * Math.abs(z1 - z);
entity.setDead(); if (size > MinecraftServer.cauldronConfig.largeBoundingBoxLogSize.getValue())
return true; {
logWarning("Entity being removed for bounding box restrictions");
logWarning("BB Size: {0} > {1} avg edge: {2}", size, logSize, aabb.getAverageEdgeLength());
logWarning("Motion: ({0}, {1}, {2})", entity.motionX, entity.motionY, entity.motionZ);
logWarning("Calculated bounding box: {0}", aabb);
logWarning("Entity bounding box: {0}", entity.getBoundingBox());
logWarning("Entity: {0}", entity);
NBTTagCompound tag = new NBTTagCompound();
entity.writeToNBT(tag);
logWarning("Entity NBT: {0}", tag);
logStack();
entity.setDead();
return true;
}
} }
return false; return false;
} }

View File

@ -12,7 +12,7 @@ public class CauldronWorldConfig extends WorldConfig
public void init() public void init()
{ {
entityDespawnImmediate = getBoolean( "entity-despawn-immediate", true); entityDespawnImmediate = getBoolean( "entity-despawn-immediate", false);
this.save(); this.save();
} }
} }

View File

@ -40,7 +40,10 @@ public class CraftChunk implements Chunk {
} }
public net.minecraft.world.chunk.Chunk getHandle() { public net.minecraft.world.chunk.Chunk getHandle() {
net.minecraft.world.chunk.Chunk c = weakChunk.get(); net.minecraft.world.chunk.Chunk c = null;
if (weakChunk != null) {
c = weakChunk.get();
}
if (c == null) { if (c == null) {
c = worldServer.getChunkFromChunkCoords(x, z); c = worldServer.getChunkFromChunkCoords(x, z);

View File

@ -9,9 +9,9 @@ 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.EntityLiving;
import net.minecraft.entity.IEntityLivingData; import net.minecraft.entity.IEntityLivingData;
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;
@ -504,28 +504,28 @@ public class CraftWorld implements World {
} }
world.captureTreeGeneration = true; world.captureTreeGeneration = true;
world.captureBlockStates = true; 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.captureBlockStates = false; world.captureBlockSnapshots = false;
world.captureTreeGeneration = false; world.captureTreeGeneration = false;
if (grownTree) { // Copy block data to delegate if (grownTree) { // Copy block data to delegate
for (BlockState blockstate : world.capturedBlockStates) { for (BlockSnapshot blocksnapshot : world.capturedBlockSnapshots) {
int x = blockstate.getX(); int x = blocksnapshot.x;
int y = blockstate.getY(); int y = blocksnapshot.y;
int z = blockstate.getZ(); int z = blocksnapshot.z;
net.minecraft.block.Block oldBlock = world.getBlock(x, y, z); net.minecraft.block.Block oldBlock = world.getBlock(x, y, z);
int newId = blockstate.getTypeId(); int newId = net.minecraft.block.Block.getIdFromBlock(blocksnapshot.replacedBlock);
int data = blockstate.getRawData(); int data = blocksnapshot.meta;
int flag = ((CraftBlockState)blockstate).getFlag(); int flag = blocksnapshot.flag;
delegate.setTypeIdAndData(x, y, z, newId, data); delegate.setTypeIdAndData(x, y, z, newId, data);
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.capturedBlockStates.clear(); world.capturedBlockSnapshots.clear();
return true; return true;
} }
else { else {
world.capturedBlockStates.clear(); world.capturedBlockSnapshots.clear();
return false; return false;
} }
} }

View File

@ -13,9 +13,11 @@ import org.bukkit.metadata.MetadataValue;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import java.util.List; import java.util.List;
// Cauldron start // Cauldron start
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.BlockSnapshot;
// Cauldron end // Cauldron end
public class CraftBlockState implements BlockState { public class CraftBlockState implements BlockState {
@ -57,6 +59,30 @@ public class CraftBlockState implements BlockState {
this.flag = flag; this.flag = flag;
} }
public CraftBlockState(BlockSnapshot blocksnapshot)
{
this.world = blocksnapshot.world.getWorld();
this.x = blocksnapshot.x;
this.y = blocksnapshot.y;
this.z = blocksnapshot.z;
this.type = net.minecraft.block.Block.getIdFromBlock(blocksnapshot.replacedBlock);
this.light = (byte) blocksnapshot.replacedBlock.getLightValue();
this.chunk = (CraftChunk) this.world.getBlockAt(this.x, this.y, this.z).getChunk();
this.flag = 3;
TileEntity te = this.world.getHandle().getTileEntity(this.x, this.y, this.z);
if (te != null)
{
this.nbt = new NBTTagCompound();
te.writeToNBT(this.nbt);
}
else
{
this.nbt = null;
}
this.createData((byte) blocksnapshot.meta);
}
public static CraftBlockState getBlockState(net.minecraft.world.World world, int x, int y, int z) { public static CraftBlockState getBlockState(net.minecraft.world.World world, int x, int y, int z) {
return new CraftBlockState(world.getWorld().getBlockAt(x, y, z)); return new CraftBlockState(world.getWorld().getBlockAt(x, y, z));
} }

View File

@ -949,6 +949,10 @@ public class CraftEventFactory {
event = new PlayerAchievementAwardedEvent(player, CraftStatistic.getBukkitAchievement((net.minecraft.stats.Achievement) statistic)); event = new PlayerAchievementAwardedEvent(player, CraftStatistic.getBukkitAchievement((net.minecraft.stats.Achievement) statistic));
} else { } else {
org.bukkit.Statistic stat = CraftStatistic.getBukkitStatistic(statistic); org.bukkit.Statistic stat = CraftStatistic.getBukkitStatistic(statistic);
if (stat == null)
{
return null;
}
switch (stat) { switch (stat) {
case FALL_ONE_CM: case FALL_ONE_CM:
case BOAT_ONE_CM: case BOAT_ONE_CM:

View File

@ -371,10 +371,12 @@ public final class CraftItemStack extends ItemStack {
return false; return false;
} }
net.minecraft.nbt.NBTTagCompound tag = new net.minecraft.nbt.NBTTagCompound(); if (item.stackTagCompound == null)
item.setTagCompound(tag); {
item.stackTagCompound = item.writeToNBT(new net.minecraft.nbt.NBTTagCompound());
}
((CraftMetaItem) itemMeta).applyToItem(tag); ((CraftMetaItem)itemMeta).applyToItem(item.stackTagCompound);
return true; return true;
} }