3
0

Initial commit (Forge 1291).

This commit is contained in:
gamerforEA
2015-03-22 20:38:04 +03:00
commit 16773ead6a
611 changed files with 64826 additions and 0 deletions

View File

@ -0,0 +1,52 @@
--- ../src-base/minecraft/net/minecraft/block/Block.java
+++ ../src-work/minecraft/net/minecraft/block/Block.java
@@ -122,6 +122,7 @@
private String unlocalizedName;
@SideOnly(Side.CLIENT)
protected IIcon blockIcon;
+ public boolean isForgeBlock; // Cauldron
private static final String __OBFID = "CL_00000199";
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 @@
return this;
}
+ // Spigot start
+ public static float range(float min, float value, float max)
+ {
+ if (value < min)
+ {
+ return min;
+ }
+
+ if (value > max)
+ {
+ return max;
+ }
+
+ return value;
+ }
+ // Spigot end
+
@SideOnly(Side.CLIENT)
protected String getTextureName()
{

View File

@ -0,0 +1,32 @@
--- ../src-base/minecraft/net/minecraft/block/BlockBasePressurePlate.java
+++ ../src-work/minecraft/net/minecraft/block/BlockBasePressurePlate.java
@@ -11,6 +11,8 @@
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public abstract class BlockBasePressurePlate extends Block
{
private String field_150067_a;
@@ -122,7 +124,20 @@
int i1 = this.func_150065_e(p_150062_1_, p_150062_2_, p_150062_3_, p_150062_4_);
boolean flag = p_150062_5_ > 0;
boolean flag1 = i1 > 0;
+ // CraftBukkit start - Interact Pressure Plate
+ org.bukkit.World bworld = p_150062_1_.getWorld();
+ org.bukkit.plugin.PluginManager manager = p_150062_1_.getServer().getPluginManager();
+ if (flag != flag1)
+ {
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bworld.getBlockAt(p_150062_2_, p_150062_3_, p_150062_4_), p_150062_5_, i1);
+ manager.callEvent(eventRedstone);
+ flag1 = eventRedstone.getNewCurrent() > 0;
+ i1 = eventRedstone.getNewCurrent();
+ }
+
+ // CraftBukkit end
+
if (p_150062_5_ != i1)
{
p_150062_1_.setBlockMetadataWithNotify(p_150062_2_, p_150062_3_, p_150062_4_, this.func_150066_d(i1), 2);

View File

@ -0,0 +1,89 @@
--- ../src-base/minecraft/net/minecraft/block/BlockButton.java
+++ ../src-work/minecraft/net/minecraft/block/BlockButton.java
@@ -16,6 +16,10 @@
import net.minecraftforge.common.util.ForgeDirection;
import static net.minecraftforge.common.util.ForgeDirection.*;
+// CraftBukkit start
+import org.bukkit.event.block.BlockRedstoneEvent;
+import org.bukkit.event.entity.EntityInteractEvent;
+// CraftBukkit end
public abstract class BlockButton extends Block
{
@@ -209,6 +213,19 @@
}
else
{
+ // CraftBukkit start
+ org.bukkit.block.Block block = p_149727_1_.getWorld().getBlockAt(p_149727_2_, p_149727_3_, p_149727_4_);
+ int old = (k1 != 8) ? 15 : 0;
+ int current = (k1 == 8) ? 15 : 0;
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
+ p_149727_1_.getServer().getPluginManager().callEvent(eventRedstone);
+
+ if ((eventRedstone.getNewCurrent() > 0) != (k1 == 8))
+ {
+ return true;
+ }
+
+ // CraftBukkit end
p_149727_1_.setBlockMetadataWithNotify(p_149727_2_, p_149727_3_, p_149727_4_, j1 + k1, 3);
p_149727_1_.markBlockRangeForRenderUpdate(p_149727_2_, p_149727_3_, p_149727_4_, p_149727_2_, p_149727_3_, p_149727_4_);
p_149727_1_.playSoundEffect((double)p_149727_2_ + 0.5D, (double)p_149727_3_ + 0.5D, (double)p_149727_4_ + 0.5D, "random.click", 0.3F, 0.6F);
@@ -262,6 +279,18 @@
if ((l & 8) != 0)
{
+ // CraftBukkit start
+ org.bukkit.block.Block block = p_149674_1_.getWorld().getBlockAt(p_149674_2_, p_149674_3_, p_149674_4_);
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 15, 0);
+ p_149674_1_.getServer().getPluginManager().callEvent(eventRedstone);
+
+ if (eventRedstone.getNewCurrent() > 0)
+ {
+ return;
+ }
+
+ // CraftBukkit end
+
if (this.field_150047_a)
{
this.func_150046_n(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_);
@@ -309,6 +338,36 @@
List list = p_150046_1_.getEntitiesWithinAABB(EntityArrow.class, AxisAlignedBB.getBoundingBox((double)p_150046_2_ + this.minX, (double)p_150046_3_ + this.minY, (double)p_150046_4_ + this.minZ, (double)p_150046_2_ + this.maxX, (double)p_150046_3_ + this.maxY, (double)p_150046_4_ + this.maxZ));
boolean flag1 = !list.isEmpty();
+ // CraftBukkit start - Call interact event when arrows turn on wooden buttons
+ if (flag != flag1 && flag1)
+ {
+ org.bukkit.block.Block block = p_150046_1_.getWorld().getBlockAt(p_150046_2_, p_150046_3_, p_150046_4_);
+ boolean allowed = false;
+
+ // If all of the events are cancelled block the button press, else allow
+ for (Object object : list)
+ {
+ if (object != null)
+ {
+ EntityInteractEvent event = new EntityInteractEvent(((Entity) object).getBukkitEntity(), block);
+ p_150046_1_.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ allowed = true;
+ break;
+ }
+ }
+ }
+
+ if (!allowed)
+ {
+ return;
+ }
+ }
+
+ // CraftBukkit end
+
if (flag1 && !flag)
{
p_150046_1_.setBlockMetadataWithNotify(p_150046_2_, p_150046_3_, p_150046_4_, i1 | 8, 3);

View File

@ -0,0 +1,31 @@
--- ../src-base/minecraft/net/minecraft/block/BlockCactus.java
+++ ../src-work/minecraft/net/minecraft/block/BlockCactus.java
@@ -17,6 +17,8 @@
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.common.IPlantable;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockCactus extends Block implements IPlantable
{
@SideOnly(Side.CLIENT)
@@ -47,9 +49,9 @@
{
int i1 = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_);
- if (i1 == 15)
+ if (i1 >= (byte) range(3, (p_149674_1_.growthOdds / p_149674_1_.getSpigotConfig().cactusModifier * 15) + 0.5F, 15)) // Spigot // Cauldron
{
- p_149674_1_.setBlock(p_149674_2_, p_149674_3_ + 1, p_149674_4_, this);
+ CraftEventFactory.handleBlockGrowEvent(p_149674_1_, p_149674_2_, p_149674_3_ + 1, p_149674_4_, this, 0); // CraftBukkit
p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, 0, 4);
this.onNeighborBlockChange(p_149674_1_, p_149674_2_, p_149674_3_ + 1, p_149674_4_, this);
}
@@ -135,6 +137,7 @@
public void onEntityCollidedWithBlock(World p_149670_1_, int p_149670_2_, int p_149670_3_, int p_149670_4_, Entity p_149670_5_)
{
+ // Cauldron - moved CraftBukkit hook to func_145775_I() - doBlockCollisions
p_149670_5_.attackEntityFrom(DamageSource.cactus, 1.0F);
}

View File

@ -0,0 +1,32 @@
--- ../src-base/minecraft/net/minecraft/block/BlockCake.java
+++ ../src-work/minecraft/net/minecraft/block/BlockCake.java
@@ -12,6 +12,10 @@
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
+// CraftBukkit start
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.network.play.server.S06PacketUpdateHealth;
+// CraftBukkit end
public class BlockCake extends Block
{
@@ -104,7 +108,17 @@
{
if (p_150036_5_.canEat(false))
{
- p_150036_5_.getFoodStats().addStats(2, 0.1F);
+ // CraftBukkit start
+ int oldFoodLevel = p_150036_5_.getFoodStats().foodLevel;
+ org.bukkit.event.entity.FoodLevelChangeEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callFoodLevelChangeEvent(p_150036_5_, 2 + oldFoodLevel);
+
+ if (!event.isCancelled())
+ {
+ p_150036_5_.getFoodStats().addStats(event.getFoodLevel() - oldFoodLevel, 0.1F);
+ }
+
+ ((EntityPlayerMP) p_150036_5_).playerNetServerHandler.sendPacket(new S06PacketUpdateHealth(((EntityPlayerMP) p_150036_5_).getBukkitEntity().getScaledHealth(), p_150036_5_.getFoodStats().foodLevel, p_150036_5_.getFoodStats().foodSaturationLevel));
+ // CraftBukkit end
int l = p_150036_1_.getBlockMetadata(p_150036_2_, p_150036_3_, p_150036_4_) + 1;
if (l >= 6)

View File

@ -0,0 +1,12 @@
--- ../src-base/minecraft/net/minecraft/block/BlockCocoa.java
+++ ../src-work/minecraft/net/minecraft/block/BlockCocoa.java
@@ -51,7 +51,8 @@
if (i1 < 2)
{
++i1;
- p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, i1 << 2 | getDirection(l), 2);
+ // CraftBukkit
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, this, i1 << 2 | getDirection(l));
}
}
}

View File

@ -0,0 +1,34 @@
--- ../src-base/minecraft/net/minecraft/block/BlockCommandBlock.java
+++ ../src-work/minecraft/net/minecraft/block/BlockCommandBlock.java
@@ -10,6 +10,8 @@
import net.minecraft.tileentity.TileEntityCommandBlock;
import net.minecraft.world.World;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockCommandBlock extends BlockContainer
{
private static final String __OBFID = "CL_00000219";
@@ -31,13 +33,20 @@
boolean flag = p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_);
int l = p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_);
boolean flag1 = (l & 1) != 0;
+ // CraftBukkit start
+ org.bukkit.block.Block bukkitBlock = p_149695_1_.getWorld().getBlockAt(p_149695_2_, p_149695_3_, p_149695_4_);
+ int old = flag1 ? 15 : 0;
+ int current = flag ? 15 : 0;
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, old, current);
+ p_149695_1_.getServer().getPluginManager().callEvent(eventRedstone);
+ // CraftBukkit end
- if (flag && !flag1)
+ if (eventRedstone.getNewCurrent() > 0 && !(eventRedstone.getOldCurrent() > 0)) // CraftBukkit
{
p_149695_1_.setBlockMetadataWithNotify(p_149695_2_, p_149695_3_, p_149695_4_, l | 1, 4);
p_149695_1_.scheduleBlockUpdate(p_149695_2_, p_149695_3_, p_149695_4_, this, this.tickRate(p_149695_1_));
}
- else if (!flag && flag1)
+ else if (!(eventRedstone.getNewCurrent() > 0) && eventRedstone.getOldCurrent() > 0) // CraftBukkit
{
p_149695_1_.setBlockMetadataWithNotify(p_149695_2_, p_149695_3_, p_149695_4_, l & -2, 4);
}

View File

@ -0,0 +1,15 @@
--- ../src-base/minecraft/net/minecraft/block/BlockCrops.java
+++ ../src-work/minecraft/net/minecraft/block/BlockCrops.java
@@ -49,10 +49,9 @@
{
float f = this.func_149864_n(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_);
- if (p_149674_5_.nextInt((int)(25.0F / f) + 1) == 0)
+ if (p_149674_5_.nextInt((int)(p_149674_1_.growthOdds / p_149674_1_.getSpigotConfig().wheatModifier * (25.0F / f)) + 1) == 0) // Spigot // Cauldron
{
- ++l;
- p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, l, 2);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, this, ++l); // CraftBukkit
}
}
}

View File

@ -0,0 +1,10 @@
--- ../src-base/minecraft/net/minecraft/block/BlockDaylightDetector.java
+++ ../src-work/minecraft/net/minecraft/block/BlockDaylightDetector.java
@@ -73,6 +73,7 @@
if (l != i1)
{
+ i1 = org.bukkit.craftbukkit.event.CraftEventFactory.callRedstoneChange(p_149957_1_, p_149957_2_, p_149957_3_, p_149957_4_, l, i1).getNewCurrent(); // CraftBukkit - Call BlockRedstoneEvent
p_149957_1_.setBlockMetadataWithNotify(p_149957_2_, p_149957_3_, p_149957_4_, i1, 3);
}
}

View File

@ -0,0 +1,28 @@
--- ../src-base/minecraft/net/minecraft/block/BlockDispenser.java
+++ ../src-work/minecraft/net/minecraft/block/BlockDispenser.java
@@ -30,6 +30,7 @@
{
public static final IRegistry dispenseBehaviorRegistry = new RegistryDefaulted(new BehaviorDefaultDispenseItem());
protected Random field_149942_b = new Random();
+ public static boolean eventFired = false; // CraftBukkit
@SideOnly(Side.CLIENT)
protected IIcon field_149944_M;
@SideOnly(Side.CLIENT)
@@ -124,7 +125,8 @@
}
}
- protected void func_149941_e(World p_149941_1_, int p_149941_2_, int p_149941_3_, int p_149941_4_)
+ // CraftBukkit - protected -> public
+ public void func_149941_e(World p_149941_1_, int p_149941_2_, int p_149941_3_, int p_149941_4_)
{
BlockSourceImpl blocksourceimpl = new BlockSourceImpl(p_149941_1_, p_149941_2_, p_149941_3_, p_149941_4_);
TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();
@@ -145,6 +147,7 @@
if (ibehaviordispenseitem != IBehaviorDispenseItem.itemDispenseBehaviorProvider)
{
ItemStack itemstack1 = ibehaviordispenseitem.dispense(blocksourceimpl, itemstack);
+ eventFired = false; // CraftBukkit - reset event status
tileentitydispenser.setInventorySlotContents(l, itemstack1.stackSize == 0 ? null : itemstack1);
}
}

View File

@ -0,0 +1,48 @@
--- ../src-base/minecraft/net/minecraft/block/BlockDoor.java
+++ ../src-work/minecraft/net/minecraft/block/BlockDoor.java
@@ -16,6 +16,8 @@
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockDoor extends Block
{
@SideOnly(Side.CLIENT)
@@ -329,15 +331,32 @@
{
this.dropBlockAsItem(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, l, 0);
}
+
+ // CraftBukkit start
}
- else
+ else if (p_149695_5_.canProvidePower())
{
- boolean flag1 = p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_) || p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_ + 1, p_149695_4_);
+ org.bukkit.World bworld = p_149695_1_.getWorld();
+ org.bukkit.block.Block bukkitBlock = bworld.getBlockAt(p_149695_2_, p_149695_3_, p_149695_4_);
+ org.bukkit.block.Block blockTop = bworld.getBlockAt(p_149695_2_, p_149695_3_ + 1, p_149695_4_);
+ int power = bukkitBlock.getBlockPower();
+ int powerTop = blockTop.getBlockPower();
- if ((flag1 || p_149695_5_.canProvidePower()) && p_149695_5_ != this)
+ if (powerTop > power)
{
- this.func_150014_a(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, flag1);
+ power = powerTop;
}
+
+ int oldPower = (p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_) & 4) > 0 ? 15 : 0;
+
+ if (oldPower == 0 ^ power == 0)
+ {
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, oldPower, power);
+ p_149695_1_.getServer().getPluginManager().callEvent(eventRedstone);
+ this.func_150014_a(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, eventRedstone.getNewCurrent() > 0);
+ }
+
+ // CraftBukkit end
}
}
else

View File

@ -0,0 +1,44 @@
--- ../src-base/minecraft/net/minecraft/block/BlockDragonEgg.java
+++ ../src-work/minecraft/net/minecraft/block/BlockDragonEgg.java
@@ -10,6 +10,8 @@
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
+import org.bukkit.event.block.BlockFromToEvent; // CraftBukkit
+
public class BlockDragonEgg extends Block
{
private static final String __OBFID = "CL_00000232";
@@ -43,7 +45,8 @@
if (!BlockFalling.fallInstantly && p_150018_1_.checkChunksExist(p_150018_2_ - b0, p_150018_3_ - b0, p_150018_4_ - b0, p_150018_2_ + b0, p_150018_3_ + b0, p_150018_4_ + b0))
{
- EntityFallingBlock entityfallingblock = new EntityFallingBlock(p_150018_1_, (double)((float)p_150018_2_ + 0.5F), (double)((float)p_150018_3_ + 0.5F), (double)((float)p_150018_4_ + 0.5F), this);
+ // CraftBukkit - added data
+ EntityFallingBlock entityfallingblock = new EntityFallingBlock(p_150018_1_, (double)((float) p_150018_2_ + 0.5F), (double)((float) p_150018_3_ + 0.5F), (double)((float) p_150018_4_ + 0.5F), this, p_150018_1_.getBlockMetadata(p_150018_2_, p_150018_3_, p_150018_4_));
p_150018_1_.spawnEntityInWorld(entityfallingblock);
}
else
@@ -86,6 +89,22 @@
if (p_150019_1_.getBlock(i1, j1, k1).blockMaterial == Material.air)
{
+ // CraftBukkit start
+ org.bukkit.block.Block from = p_150019_1_.getWorld().getBlockAt(p_150019_2_, p_150019_3_, p_150019_4_);
+ org.bukkit.block.Block to = p_150019_1_.getWorld().getBlockAt(i1, j1, k1);
+ BlockFromToEvent event = new BlockFromToEvent(from, to);
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+
+ if (event.isCancelled())
+ {
+ return;
+ }
+
+ i1 = event.getToBlock().getX();
+ j1 = event.getToBlock().getY();
+ k1 = event.getToBlock().getZ();
+ // CraftBukkit end
+
if (!p_150019_1_.isRemote)
{
p_150019_1_.setBlock(i1, j1, k1, this, p_150019_1_.getBlockMetadata(p_150019_2_, p_150019_3_, p_150019_4_), 2);

View File

@ -0,0 +1,59 @@
--- ../src-base/minecraft/net/minecraft/block/BlockDropper.java
+++ ../src-work/minecraft/net/minecraft/block/BlockDropper.java
@@ -13,6 +13,11 @@
import net.minecraft.tileentity.TileEntityHopper;
import net.minecraft.util.Facing;
import net.minecraft.world.World;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.inventory.InventoryMoveItemEvent;
+import net.minecraft.inventory.InventoryLargeChest;
+// CraftBukkit end
public class BlockDropper extends BlockDispenser
{
@@ -38,7 +43,7 @@
return new TileEntityDropper();
}
- protected void func_149941_e(World p_149941_1_, int p_149941_2_, int p_149941_3_, int p_149941_4_)
+ public void func_149941_e(World p_149941_1_, int p_149941_2_, int p_149941_3_, int p_149941_4_) // CraftBukkit - protected -> public
{
BlockSourceImpl blocksourceimpl = new BlockSourceImpl(p_149941_1_, p_149941_2_, p_149941_3_, p_149941_4_);
TileEntityDispenser tileentitydispenser = (TileEntityDispenser)blocksourceimpl.getBlockTileEntity();
@@ -60,10 +65,33 @@
if (iinventory != null)
{
- itemstack1 = TileEntityHopper.func_145889_a(iinventory, itemstack.copy().splitStack(1), Facing.oppositeSide[i1]);
+ // CraftBukkit start - Fire event when pushing items into other inventories
+ CraftItemStack oitemstack = CraftItemStack.asCraftMirror(itemstack.copy().splitStack(1));
+ org.bukkit.inventory.Inventory destinationInventory;
- if (itemstack1 == null)
+ // Have to special case large chests as they work oddly
+ if (iinventory instanceof InventoryLargeChest)
{
+ destinationInventory = new org.bukkit.craftbukkit.inventory.CraftInventoryDoubleChest((InventoryLargeChest) iinventory);
+ }
+ else
+ {
+ destinationInventory = iinventory.getOwner().getInventory();
+ }
+
+ InventoryMoveItemEvent event = new InventoryMoveItemEvent(tileentitydispenser.getOwner().getInventory(), oitemstack.clone(), destinationInventory, true);
+ p_149941_1_.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled())
+ {
+ return;
+ }
+
+ itemstack1 = TileEntityHopper.func_145889_a(iinventory, CraftItemStack.asNMSCopy(event.getItem()), Facing.oppositeSide[i1]);
+
+ if (event.getItem().equals(oitemstack) && itemstack1 == null)
+ {
+ // CraftBukkit end
itemstack1 = itemstack.copy();
if (--itemstack1.stackSize == 0)

View File

@ -0,0 +1,162 @@
--- ../src-base/minecraft/net/minecraft/block/BlockDynamicLiquid.java
+++ ../src-work/minecraft/net/minecraft/block/BlockDynamicLiquid.java
@@ -5,6 +5,11 @@
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
+// CraftBukkit start
+import org.bukkit.block.BlockFace;
+import org.bukkit.event.block.BlockFromToEvent;
+// CraftBukkit end
+
public class BlockDynamicLiquid extends BlockLiquid
{
int field_149815_a;
@@ -37,6 +42,12 @@
int i1 = this.tickRate(p_149674_1_);
int j1;
+ // Cauldron - move CB edit to after variable initialization for coremod compatibility
+ // CraftBukkit start
+ org.bukkit.World bworld = p_149674_1_.getWorld();
+ org.bukkit.Server server = p_149674_1_.getServer();
+ org.bukkit.block.Block source = bworld == null ? null : bworld.getBlockAt(p_149674_2_, p_149674_3_, p_149674_4_);
+ // CraftBukkit end
if (l > 0)
{
byte b1 = -100;
@@ -66,17 +77,22 @@
}
}
- if (this.field_149815_a >= 2 && this.blockMaterial == Material.water)
+ // Cauldron start - allow disabling infinite water sources
+ if(net.minecraft.server.MinecraftServer.getServer().cauldronConfig.infiniteWaterSource.getValue())
{
- if (p_149674_1_.getBlock(p_149674_2_, p_149674_3_ - 1, p_149674_4_).getMaterial().isSolid())
+ if (this.field_149815_a >= 2 && this.blockMaterial == Material.water)
{
- j1 = 0;
+ if (p_149674_1_.getBlock(p_149674_2_, p_149674_3_ - 1, p_149674_4_).getMaterial().isSolid())
+ {
+ j1 = 0;
+ }
+ else if (p_149674_1_.getBlock(p_149674_2_, p_149674_3_ - 1, p_149674_4_).getMaterial() == this.blockMaterial && p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_ - 1, p_149674_4_) == 0)
+ {
+ j1 = 0;
+ }
}
- else if (p_149674_1_.getBlock(p_149674_2_, p_149674_3_ - 1, p_149674_4_).getMaterial() == this.blockMaterial && p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_ - 1, p_149674_4_) == 0)
- {
- j1 = 0;
- }
}
+ // Cauldron end
if (this.blockMaterial == Material.lava && l < 8 && j1 < 8 && j1 > l && p_149674_5_.nextInt(4) != 0)
{
@@ -89,6 +105,13 @@
{
this.func_149811_n(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_);
}
+ // Cauldron start - allow lava decaying at a 'natural' rate - see https://mojang.atlassian.net/browse/MC-4631 Lava decay fails to schedule block update
+ else if (net.minecraft.server.MinecraftServer.getServer().cauldronConfig.flowingLavaDecay.getValue())
+ {
+ // Ensure that even if the flow decay was skipped, it will retry at the material's natural flow period.
+ p_149674_1_.scheduleBlockUpdate(p_149674_2_, p_149674_3_, p_149674_4_, this, this.tickRate(p_149674_1_));
+ }
+ // Cauldron end
}
else
{
@@ -113,21 +136,34 @@
if (this.func_149809_q(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_))
{
- if (this.blockMaterial == Material.lava && p_149674_1_.getBlock(p_149674_2_, p_149674_3_ - 1, p_149674_4_).getMaterial() == Material.water)
+ // CraftBukkit start - Send "down" to the server
+ BlockFromToEvent event = new BlockFromToEvent(source, BlockFace.DOWN);
+
+ if (server != null)
{
- p_149674_1_.setBlock(p_149674_2_, p_149674_3_ - 1, p_149674_4_, Blocks.stone);
- this.func_149799_m(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_);
- return;
+ server.getPluginManager().callEvent(event);
}
- if (l >= 8)
+ if (!event.isCancelled())
{
- this.func_149813_h(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_, l);
+ if (this.blockMaterial == Material.lava && p_149674_1_.getBlock(p_149674_2_, p_149674_3_ - 1, p_149674_4_).getMaterial() == Material.water)
+ {
+ p_149674_1_.setBlock(p_149674_2_, p_149674_3_ - 1, p_149674_4_, Blocks.stone);
+ this.func_149799_m(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_);
+ return;
+ }
+
+ if (l >= 8)
+ {
+ this.func_149813_h(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_, l);
+ }
+ else
+ {
+ this.func_149813_h(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_, l + 8);
+ }
}
- else
- {
- this.func_149813_h(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_, l + 8);
- }
+
+ // CraftBukkit end
}
else if (l >= 0 && (l == 0 || this.func_149807_p(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_)))
{
@@ -144,25 +180,31 @@
return;
}
- if (aboolean[0])
- {
- this.func_149813_h(p_149674_1_, p_149674_2_ - 1, p_149674_3_, p_149674_4_, j1);
- }
+ // CraftBukkit start - All four cardinal directions. Do not change the order!
+ BlockFace[] faces = new BlockFace[] { BlockFace.WEST, BlockFace.EAST, BlockFace.NORTH, BlockFace.SOUTH };
+ int index = 0;
- if (aboolean[1])
+ for (BlockFace currentFace : faces)
{
- this.func_149813_h(p_149674_1_, p_149674_2_ + 1, p_149674_3_, p_149674_4_, j1);
- }
+ if (aboolean[index])
+ {
+ BlockFromToEvent event = new BlockFromToEvent(source, currentFace);
- if (aboolean[2])
- {
- this.func_149813_h(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_ - 1, j1);
- }
+ if (server != null)
+ {
+ server.getPluginManager().callEvent(event);
+ }
- if (aboolean[3])
- {
- this.func_149813_h(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_ + 1, j1);
+ if (!event.isCancelled())
+ {
+ this.func_149813_h(p_149674_1_, p_149674_2_ + currentFace.getModX(), p_149674_3_, p_149674_4_ + currentFace.getModZ(), j1);
+ }
+ }
+
+ index++;
}
+
+ // CraftBukkit end
}
}

View File

@ -0,0 +1,22 @@
--- ../src-base/minecraft/net/minecraft/block/BlockEndPortal.java
+++ ../src-work/minecraft/net/minecraft/block/BlockEndPortal.java
@@ -15,6 +15,8 @@
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
+import org.bukkit.event.entity.EntityPortalEnterEvent; // CraftBukkit
+
public class BlockEndPortal extends BlockContainer
{
public static boolean field_149948_a;
@@ -64,6 +66,10 @@
{
if (p_149670_5_.ridingEntity == null && p_149670_5_.riddenByEntity == null && !p_149670_1_.isRemote)
{
+ // CraftBukkit start - Entity in portal
+ EntityPortalEnterEvent event = new EntityPortalEnterEvent(p_149670_5_.getBukkitEntity(), new org.bukkit.Location(p_149670_1_.getWorld(), p_149670_2_, p_149670_3_, p_149670_4_));
+ p_149670_1_.getServer().getPluginManager().callEvent(event);
+ // CraftBukkit end
p_149670_5_.travelToDimension(1);
}
}

View File

@ -0,0 +1,57 @@
--- ../src-base/minecraft/net/minecraft/block/BlockFarmland.java
+++ ../src-work/minecraft/net/minecraft/block/BlockFarmland.java
@@ -15,6 +15,11 @@
import net.minecraftforge.common.IPlantable;
import net.minecraftforge.common.util.ForgeDirection;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityInteractEvent;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
+
public class BlockFarmland extends Block
{
@SideOnly(Side.CLIENT)
@@ -64,6 +69,15 @@
}
else if (!this.func_149822_e(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_))
{
+ // CraftBukkit start
+ org.bukkit.block.Block block = p_149674_1_.getWorld().getBlockAt(p_149674_2_, p_149674_3_, p_149674_4_);
+
+ if (CraftEventFactory.callBlockFadeEvent(block, Blocks.dirt).isCancelled())
+ {
+ return;
+ }
+
+ // CraftBukkit end
p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.dirt);
}
}
@@ -82,6 +96,26 @@
return;
}
+ // CraftBukkit start - Interact soil
+ // Cauldron start - validate data before sending event
+ org.bukkit.event.Cancellable cancellable = null;
+
+ if (p_149746_5_ instanceof EntityPlayer)
+ {
+ cancellable = CraftEventFactory.callPlayerInteractEvent((EntityPlayer) p_149746_5_, org.bukkit.event.block.Action.PHYSICAL, p_149746_2_, p_149746_3_, p_149746_4_, -1, null);
+ }
+ else if (p_149746_1_ != null && p_149746_1_.getWorld() != null && p_149746_5_ != null)
+ {
+ cancellable = new EntityInteractEvent(p_149746_5_.getBukkitEntity(), p_149746_1_.getWorld().getBlockAt(p_149746_2_, p_149746_3_, p_149746_4_));
+ p_149746_1_.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
+ }
+
+ if (cancellable != null && cancellable.isCancelled())
+ {
+ return;
+ }
+ // Cauldron end
+ // CraftBukkit end
p_149746_1_.setBlock(p_149746_2_, p_149746_3_, p_149746_4_, Blocks.dirt);
}
}

View File

@ -0,0 +1,129 @@
--- ../src-base/minecraft/net/minecraft/block/BlockFire.java
+++ ../src-work/minecraft/net/minecraft/block/BlockFire.java
@@ -17,6 +17,11 @@
import net.minecraft.world.WorldProviderEnd;
import net.minecraftforge.common.util.ForgeDirection;
import static net.minecraftforge.common.util.ForgeDirection.*;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.block.BlockBurnEvent;
+import org.bukkit.event.block.BlockSpreadEvent;
+// CraftBukkit end
public class BlockFire extends Block
{
@@ -105,12 +110,12 @@
if (!this.canPlaceBlockAt(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_))
{
- p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_);
+ fireExtinguished(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); // CraftBukkit - invalid place location
}
if (!flag && p_149674_1_.isRaining() && (p_149674_1_.canLightningStrikeAt(p_149674_2_, p_149674_3_, p_149674_4_) || p_149674_1_.canLightningStrikeAt(p_149674_2_ - 1, p_149674_3_, p_149674_4_) || p_149674_1_.canLightningStrikeAt(p_149674_2_ + 1, p_149674_3_, p_149674_4_) || p_149674_1_.canLightningStrikeAt(p_149674_2_, p_149674_3_, p_149674_4_ - 1) || p_149674_1_.canLightningStrikeAt(p_149674_2_, p_149674_3_, p_149674_4_ + 1)))
{
- p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_);
+ fireExtinguished(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); // CraftBukkit - extinguished by rain
}
else
{
@@ -127,12 +132,12 @@
{
if (!World.doesBlockHaveSolidTopSurface(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_) || l > 3)
{
- p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_);
+ fireExtinguished(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); // CraftBukkit - burn out of inflammable block
}
}
else if (!flag && !this.canCatchFire(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_, UP) && l == 15 && p_149674_5_.nextInt(4) == 0)
{
- p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_);
+ fireExtinguished(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_); // CraftBukkit - burn out
}
else
{
@@ -186,7 +191,29 @@
k2 = 15;
}
- p_149674_1_.setBlock(i1, k1, j1, this, k2, 3);
+ // CraftBukkit start - Call to stop spread of fire
+ if (p_149674_1_.getBlock(i1, k1, j1) != Blocks.fire)
+ {
+ if (CraftEventFactory.callBlockIgniteEvent(p_149674_1_, i1, k1, j1, p_149674_2_, p_149674_3_, p_149674_4_).isCancelled())
+ {
+ continue;
+ }
+
+ org.bukkit.Server server = p_149674_1_.getServer();
+ org.bukkit.World bworld = p_149674_1_.getWorld();
+ org.bukkit.block.BlockState blockState = bworld.getBlockAt(i1, k1, j1).getState();
+ blockState.setTypeId(Block.getIdFromBlock(this));
+ blockState.setData(new org.bukkit.material.MaterialData(Block.getIdFromBlock(this), (byte) k2));
+ BlockSpreadEvent spreadEvent = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(p_149674_2_, p_149674_3_, p_149674_4_), blockState);
+ server.getPluginManager().callEvent(spreadEvent);
+
+ if (!spreadEvent.isCancelled())
+ {
+ blockState.update(true);
+ }
+ }
+
+ // CraftBukkit end
}
}
}
@@ -216,7 +243,18 @@
if (p_149841_6_.nextInt(p_149841_5_) < j1)
{
boolean flag = p_149841_1_.getBlock(p_149841_2_, p_149841_3_, p_149841_4_) == Blocks.tnt;
+ // CraftBukkit start
+ org.bukkit.block.Block theBlock = p_149841_1_.getWorld().getBlockAt(p_149841_2_, p_149841_3_, p_149841_4_);
+ BlockBurnEvent event = new BlockBurnEvent(theBlock);
+ p_149841_1_.getServer().getPluginManager().callEvent(event);
+ if (event.isCancelled())
+ {
+ return;
+ }
+
+ // CraftBukkit end
+
if (p_149841_6_.nextInt(p_149841_7_ + 10) < 5 && !p_149841_1_.canLightningStrikeAt(p_149841_2_, p_149841_3_, p_149841_4_))
{
int k1 = p_149841_7_ + p_149841_6_.nextInt(5) / 4;
@@ -297,7 +335,7 @@
{
if (!World.doesBlockHaveSolidTopSurface(p_149695_1_, p_149695_2_, p_149695_3_ - 1, p_149695_4_) && !this.canNeighborBurn(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_))
{
- p_149695_1_.setBlockToAir(p_149695_2_, p_149695_3_, p_149695_4_);
+ fireExtinguished(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_); // CraftBukkit - fuel block gone
}
}
@@ -307,7 +345,7 @@
{
if (!World.doesBlockHaveSolidTopSurface(p_149726_1_, p_149726_2_, p_149726_3_ - 1, p_149726_4_) && !this.canNeighborBurn(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_))
{
- p_149726_1_.setBlockToAir(p_149726_2_, p_149726_3_, p_149726_4_);
+ fireExtinguished(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_); // CraftBukkit - fuel block broke
}
else
{
@@ -398,6 +436,16 @@
}
}
+ // CraftBukkit start
+ private void fireExtinguished(World world, int x, int y, int z)
+ {
+ if (!CraftEventFactory.callBlockFadeEvent(world.getWorld().getBlockAt(x, y, z), Blocks.air).isCancelled())
+ {
+ world.setBlockToAir(x, y, z);
+ }
+ }
+ // CraftBukkit end
+
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister p_149651_1_)
{

View File

@ -0,0 +1,64 @@
--- ../src-base/minecraft/net/minecraft/block/BlockGrass.java
+++ ../src-work/minecraft/net/minecraft/block/BlockGrass.java
@@ -15,6 +15,12 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+// CraftBukkit start
+import org.bukkit.block.BlockState;
+import org.bukkit.event.block.BlockSpreadEvent;
+import org.bukkit.event.block.BlockFadeEvent;
+// CraftBukkit end
+
public class BlockGrass extends Block implements IGrowable
{
private static final Logger logger = LogManager.getLogger();
@@ -45,11 +51,25 @@
{
if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) < 4 && p_149674_1_.getBlockLightOpacity(p_149674_2_, p_149674_3_ + 1, p_149674_4_) > 2)
{
- p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.dirt);
+ // CraftBukkit start
+ org.bukkit.World bworld = p_149674_1_.getWorld();
+ BlockState blockState = bworld.getBlockAt(p_149674_2_, p_149674_3_, p_149674_4_).getState();
+ blockState.setTypeId(Block.getIdFromBlock(Blocks.dirt));
+ BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState);
+ p_149674_1_.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ blockState.update(true);
+ }
+
+ // CraftBukkit end
}
else if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) >= 9)
{
- for (int l = 0; l < 4; ++l)
+ int numGrowth = Math.min(4, Math.max(20, (int)(4 * 100F / p_149674_1_.growthOdds))); // Spigot
+
+ for (int l = 0; l < numGrowth; ++l) // Spigot
{
int i1 = p_149674_2_ + p_149674_5_.nextInt(3) - 1;
int j1 = p_149674_3_ + p_149674_5_.nextInt(5) - 3;
@@ -58,7 +78,19 @@
if (p_149674_1_.getBlock(i1, j1, k1) == Blocks.dirt && p_149674_1_.getBlockMetadata(i1, j1, k1) == 0 && p_149674_1_.getBlockLightValue(i1, j1 + 1, k1) >= 4 && p_149674_1_.getBlockLightOpacity(i1, j1 + 1, k1) <= 2)
{
- p_149674_1_.setBlock(i1, j1, k1, Blocks.grass);
+ // CraftBukkit start
+ org.bukkit.World bworld = p_149674_1_.getWorld();
+ BlockState blockState = bworld.getBlockAt(i1, j1, k1).getState();
+ blockState.setTypeId(Block.getIdFromBlock(Blocks.grass));
+ BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(p_149674_2_, p_149674_3_, p_149674_4_), blockState);
+ p_149674_1_.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ blockState.update(true);
+ }
+
+ // CraftBukkit end
}
}
}

View File

@ -0,0 +1,19 @@
--- ../src-base/minecraft/net/minecraft/block/BlockHopper.java
+++ ../src-work/minecraft/net/minecraft/block/BlockHopper.java
@@ -22,6 +22,7 @@
import net.minecraft.util.IIcon;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
+import net.minecraft.inventory.IInventory; // CraftBukkit
public class BlockHopper extends BlockContainer
{
@@ -210,7 +211,7 @@
public static int getDirectionFromMetadata(int p_149918_0_)
{
- return p_149918_0_ & 7;
+ return Math.min(p_149918_0_ & 7, 5); // CraftBukkit - Fix AIOOBE in callers
}
public static boolean func_149917_c(int p_149917_0_)

View File

@ -0,0 +1,17 @@
--- ../src-base/minecraft/net/minecraft/block/BlockIce.java
+++ ../src-work/minecraft/net/minecraft/block/BlockIce.java
@@ -86,6 +86,14 @@
{
if (p_149674_1_.getSavedLightValue(EnumSkyBlock.Block, p_149674_2_, p_149674_3_, p_149674_4_) > 11 - this.getLightOpacity())
{
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(p_149674_1_.getWorld().getBlockAt(p_149674_2_, p_149674_3_, p_149674_4_), Blocks.water).isCancelled())
+ {
+ return;
+ }
+
+ // CraftBukkit end
+
if (p_149674_1_.provider.isHellWorld)
{
p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_);

View File

@ -0,0 +1,26 @@
--- ../src-base/minecraft/net/minecraft/block/BlockJukebox.java
+++ ../src-work/minecraft/net/minecraft/block/BlockJukebox.java
@@ -163,8 +163,23 @@
public void func_145857_a(ItemStack p_145857_1_)
{
+ // CraftBukkit start - There can only be one
+ if (p_145857_1_ != null)
+ {
+ p_145857_1_.stackSize = 1;
+ }
+
+ // CraftBukkit end
this.field_145858_a = p_145857_1_;
this.markDirty();
}
+
+ // Cauldron start
+ @Override
+ public boolean canUpdate()
+ {
+ return false;
+ }
+ // Cauldron end
}
}

View File

@ -0,0 +1,28 @@
--- ../src-base/minecraft/net/minecraft/block/BlockLeaves.java
+++ ../src-work/minecraft/net/minecraft/block/BlockLeaves.java
@@ -18,6 +18,8 @@
import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
+import org.bukkit.event.block.LeavesDecayEvent; // CraftBukkit
+
public abstract class BlockLeaves extends BlockLeavesBase implements IShearable
{
int[] field_150128_a;
@@ -222,6 +224,16 @@
private void removeLeaves(World p_150126_1_, int p_150126_2_, int p_150126_3_, int p_150126_4_)
{
+ // CraftBukkit start
+ LeavesDecayEvent event = new LeavesDecayEvent(p_150126_1_.getWorld().getBlockAt(p_150126_2_, p_150126_3_, p_150126_4_));
+ p_150126_1_.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled())
+ {
+ return;
+ }
+
+ // CraftBukkit end
this.dropBlockAsItem(p_150126_1_, p_150126_2_, p_150126_3_, p_150126_4_, p_150126_1_.getBlockMetadata(p_150126_2_, p_150126_3_, p_150126_4_), 0);
p_150126_1_.setBlockToAir(p_150126_2_, p_150126_3_, p_150126_4_);
}

View File

@ -0,0 +1,31 @@
--- ../src-base/minecraft/net/minecraft/block/BlockLever.java
+++ ../src-work/minecraft/net/minecraft/block/BlockLever.java
@@ -13,6 +13,8 @@
import net.minecraftforge.common.util.ForgeDirection;
import static net.minecraftforge.common.util.ForgeDirection.*;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockLever extends Block
{
private static final String __OBFID = "CL_00000264";
@@ -270,6 +272,19 @@
int i1 = p_149727_1_.getBlockMetadata(p_149727_2_, p_149727_3_, p_149727_4_);
int j1 = i1 & 7;
int k1 = 8 - (i1 & 8);
+ // CraftBukkit start - Interact Lever
+ org.bukkit.block.Block block = p_149727_1_.getWorld().getBlockAt(p_149727_2_, p_149727_3_, p_149727_4_);
+ int old = (k1 != 8) ? 15 : 0;
+ int current = (k1 == 8) ? 15 : 0;
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, old, current);
+ p_149727_1_.getServer().getPluginManager().callEvent(eventRedstone);
+
+ if ((eventRedstone.getNewCurrent() > 0) != (k1 == 8))
+ {
+ return true;
+ }
+
+ // CraftBukkit end
p_149727_1_.setBlockMetadataWithNotify(p_149727_2_, p_149727_3_, p_149727_4_, j1 + k1, 3);
p_149727_1_.playSoundEffect((double)p_149727_2_ + 0.5D, (double)p_149727_3_ + 0.5D, (double)p_149727_4_ + 0.5D, "random.click", 0.3F, k1 > 0 ? 0.6F : 0.5F);
p_149727_1_.notifyBlocksOfNeighborChange(p_149727_2_, p_149727_3_, p_149727_4_, this);

View File

@ -0,0 +1,60 @@
--- ../src-base/minecraft/net/minecraft/block/BlockMushroom.java
+++ ../src-work/minecraft/net/minecraft/block/BlockMushroom.java
@@ -6,6 +6,12 @@
import net.minecraft.world.gen.feature.WorldGenBigMushroom;
import net.minecraftforge.common.util.ForgeDirection;
+// CraftBukkit start
+import org.bukkit.block.BlockState;
+import org.bukkit.event.block.BlockSpreadEvent;
+import org.bukkit.TreeType;
+// CraftBukkit end
+
public class BlockMushroom extends BlockBush implements IGrowable
{
private static final String __OBFID = "CL_00000272";
@@ -19,7 +25,9 @@
public void updateTick(World p_149674_1_, int p_149674_2_, int p_149674_3_, int p_149674_4_, Random p_149674_5_)
{
- if (p_149674_5_.nextInt(25) == 0)
+ final int sourceX = p_149674_2_, sourceY = p_149674_3_, sourceZ = p_149674_4_; // CraftBukkit
+
+ if (p_149674_5_.nextInt(Math.max(1, (int) p_149674_1_.growthOdds / p_149674_1_.getSpigotConfig().mushroomModifier * 25)) == 0) // Spigot // Cauldron
{
byte b0 = 4;
int l = 5;
@@ -66,7 +74,19 @@
if (p_149674_1_.isAirBlock(i1, j1, k1) && this.canBlockStay(p_149674_1_, i1, j1, k1))
{
- p_149674_1_.setBlock(i1, j1, k1, this, 0, 2);
+ // CraftBukkit start
+ org.bukkit.World bworld = p_149674_1_.getWorld();
+ BlockState blockState = bworld.getBlockAt(i1, j1, k1).getState();
+ blockState.setTypeId(Block.getIdFromBlock(this)); // nms: this.id, 0, 2
+ BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(sourceX, sourceY, sourceZ), blockState);
+ p_149674_1_.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ blockState.update(true);
+ }
+
+ // CraftBukkit end
}
}
}
@@ -102,10 +122,12 @@
if (this == Blocks.brown_mushroom)
{
+ BlockSapling.treeType = TreeType.BROWN_MUSHROOM; // CraftBukkit
worldgenbigmushroom = new WorldGenBigMushroom(0);
}
else if (this == Blocks.red_mushroom)
{
+ BlockSapling.treeType = TreeType.RED_MUSHROOM; // CraftBukkit
worldgenbigmushroom = new WorldGenBigMushroom(1);
}

View File

@ -0,0 +1,64 @@
--- ../src-base/minecraft/net/minecraft/block/BlockMycelium.java
+++ ../src-work/minecraft/net/minecraft/block/BlockMycelium.java
@@ -12,6 +12,12 @@
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
+// CraftBukkit start
+import org.bukkit.block.BlockState;
+import org.bukkit.event.block.BlockFadeEvent;
+import org.bukkit.event.block.BlockSpreadEvent;
+// CraftBukkit end
+
public class BlockMycelium extends Block
{
@SideOnly(Side.CLIENT)
@@ -39,11 +45,25 @@
{
if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) < 4 && p_149674_1_.getBlockLightOpacity(p_149674_2_, p_149674_3_ + 1, p_149674_4_) > 2)
{
- p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.dirt);
+ // CraftBukkit start
+ org.bukkit.World bworld = p_149674_1_.getWorld();
+ BlockState blockState = bworld.getBlockAt(p_149674_2_, p_149674_3_, p_149674_4_).getState();
+ blockState.setTypeId(Block.getIdFromBlock(Blocks.dirt));
+ BlockFadeEvent event = new BlockFadeEvent(blockState.getBlock(), blockState);
+ p_149674_1_.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ blockState.update(true);
+ }
+
+ // CraftBukkit end
}
else if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) >= 9)
{
- for (int l = 0; l < 4; ++l)
+ int numGrowth = Math.min(4, Math.max(20, (int)(4 * 100F / p_149674_1_.growthOdds))); // Spigot
+
+ for (int l = 0; l < numGrowth; ++l) // Spigot
{
int i1 = p_149674_2_ + p_149674_5_.nextInt(3) - 1;
int j1 = p_149674_3_ + p_149674_5_.nextInt(5) - 3;
@@ -52,7 +72,19 @@
if (p_149674_1_.getBlock(i1, j1, k1) == Blocks.dirt && p_149674_1_.getBlockMetadata(i1, j1, k1) == 0 && p_149674_1_.getBlockLightValue(i1, j1 + 1, k1) >= 4 && p_149674_1_.getBlockLightOpacity(i1, j1 + 1, k1) <= 2)
{
- p_149674_1_.setBlock(i1, j1, k1, this);
+ // CraftBukkit start
+ org.bukkit.World bworld = p_149674_1_.getWorld();
+ BlockState blockState = bworld.getBlockAt(i1, j1, k1).getState();
+ blockState.setTypeId(Block.getIdFromBlock(this));
+ BlockSpreadEvent event = new BlockSpreadEvent(blockState.getBlock(), bworld.getBlockAt(p_149674_2_, p_149674_3_, p_149674_4_), blockState);
+ p_149674_1_.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ blockState.update(true);
+ }
+
+ // CraftBukkit end
}
}
}

View File

@ -0,0 +1,11 @@
--- ../src-base/minecraft/net/minecraft/block/BlockNetherWart.java
+++ ../src-work/minecraft/net/minecraft/block/BlockNetherWart.java
@@ -45,7 +45,7 @@
if (l < 3 && p_149674_5_.nextInt(10) == 0)
{
++l;
- p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, l, 2);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, this, l); // CraftBukkit
}
super.updateTick(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_5_);

View File

@ -0,0 +1,32 @@
--- ../src-base/minecraft/net/minecraft/block/BlockNetherrack.java
+++ ../src-work/minecraft/net/minecraft/block/BlockNetherrack.java
@@ -4,6 +4,11 @@
import net.minecraft.block.material.Material;
import net.minecraft.creativetab.CreativeTabs;
+// CraftBukkit start
+import org.bukkit.event.block.BlockRedstoneEvent;
+import net.minecraft.world.World;
+// CraftBukkit end
+
public class BlockNetherrack extends Block
{
private static final String __OBFID = "CL_00000275";
@@ -18,4 +23,17 @@
{
return MapColor.netherrackColor;
}
+
+ // CraftBukkit start
+ public void doPhysics(World world, int i, int j, int k, int l)
+ {
+ if (Block.getBlockById(l) != null && Block.getBlockById(l).canProvidePower())
+ {
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(i, j, k);
+ int power = block.getBlockPower();
+ BlockRedstoneEvent event = new BlockRedstoneEvent(block, power, power);
+ world.getServer().getPluginManager().callEvent(event);
+ }
+ }
+ // CraftBukkit end
}

View File

@ -0,0 +1,116 @@
--- ../src-base/minecraft/net/minecraft/block/BlockPistonBase.java
+++ ../src-work/minecraft/net/minecraft/block/BlockPistonBase.java
@@ -21,6 +21,12 @@
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
+// CraftBukkit start
+import org.bukkit.craftbukkit.block.CraftBlock;
+import org.bukkit.event.block.BlockPistonRetractEvent;
+import org.bukkit.event.block.BlockPistonExtendEvent;
+// CraftBukkit end
+
public class BlockPistonBase extends Block
{
private final boolean isSticky;
@@ -128,13 +134,37 @@
if (flag && !isExtended(l))
{
- if (canExtend(p_150078_1_, p_150078_2_, p_150078_3_, p_150078_4_, i1))
+ // CraftBukkit start
+ int length = canExtend_IntCB(p_150078_1_, p_150078_2_, p_150078_3_, p_150078_4_, i1);
+
+ if (length >= 0)
{
+ org.bukkit.block.Block block = p_150078_1_.getWorld().getBlockAt(p_150078_2_, p_150078_3_, p_150078_4_);
+ BlockPistonExtendEvent event = new BlockPistonExtendEvent(block, length, CraftBlock.notchToBlockFace(i1));
+ p_150078_1_.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled())
+ {
+ return;
+ }
+
+ // CraftBukkit end
p_150078_1_.addBlockEvent(p_150078_2_, p_150078_3_, p_150078_4_, this, 0, i1);
}
}
else if (!flag && isExtended(l))
{
+ // CraftBukkit start
+ org.bukkit.block.Block block = p_150078_1_.getWorld().getBlockAt(p_150078_2_, p_150078_3_, p_150078_4_);
+ BlockPistonRetractEvent event = new BlockPistonRetractEvent(block, CraftBlock.notchToBlockFace(i1));
+ p_150078_1_.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled())
+ {
+ return;
+ }
+
+ // CraftBukkit end
p_150078_1_.setBlockMetadataWithNotify(p_150078_2_, p_150078_3_, p_150078_4_, i1, 2);
p_150078_1_.addBlockEvent(p_150078_2_, p_150078_3_, p_150078_4_, this, 1, i1);
}
@@ -297,6 +327,11 @@
public static int getPistonOrientation(int p_150076_0_)
{
+ if ((p_150076_0_ & 7) >= Facing.oppositeSide.length)
+ {
+ return 7; // CraftBukkit - check for AIOOB on piston data
+ }
+
return p_150076_0_ & 7;
}
@@ -366,7 +401,13 @@
}
}
- private static boolean canExtend(World p_150077_0_, int p_150077_1_, int p_150077_2_, int p_150077_3_, int p_150077_4_)
+ // Cauldron start - vanilla compatibility
+ private static boolean canExtend(World world, int i, int j, int k, int l) {
+ return canExtend_IntCB(world, i, j, k, l) >= 0;
+ }
+ // Cauldron end
+
+ private static int canExtend_IntCB(World p_150077_0_, int p_150077_1_, int p_150077_2_, int p_150077_3_, int p_150077_4_) // CraftBukkit int -> boolean
{
int i1 = p_150077_1_ + Facing.offsetsXForSide[p_150077_4_];
int j1 = p_150077_2_ + Facing.offsetsYForSide[p_150077_4_];
@@ -379,7 +420,7 @@
{
if (j1 <= 0 || j1 >= p_150077_0_.getHeight())
{
- return false;
+ return -1; // CraftBukkit
}
Block block = p_150077_0_.getBlock(i1, j1, k1);
@@ -388,14 +429,14 @@
{
if (!canPushBlock(block, p_150077_0_, i1, j1, k1, true))
{
- return false;
+ return -1; // CraftBukkit
}
if (block.getMobilityFlag() != 1)
{
if (l1 == 12)
{
- return false;
+ return -1; // CraftBukkit
}
i1 += Facing.offsetsXForSide[p_150077_4_];
@@ -407,7 +448,7 @@
}
}
- return true;
+ return l1; // CraftBukkit
}
}

View File

@ -0,0 +1,28 @@
--- ../src-base/minecraft/net/minecraft/block/BlockPistonExtension.java
+++ ../src-work/minecraft/net/minecraft/block/BlockPistonExtension.java
@@ -55,6 +55,12 @@
public void breakBlock(World p_149749_1_, int p_149749_2_, int p_149749_3_, int p_149749_4_, Block p_149749_5_, int p_149749_6_)
{
super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
+
+ if ((p_149749_6_ & 7) >= Facing.oppositeSide.length)
+ {
+ return; // CraftBukkit - fix a piston AIOOBE issue
+ }
+
int i1 = Facing.oppositeSide[getDirectionMeta(p_149749_6_)];
p_149749_2_ += Facing.offsetsXForSide[i1];
p_149749_3_ += Facing.offsetsYForSide[i1];
@@ -200,6 +206,12 @@
public void onNeighborBlockChange(World p_149695_1_, int p_149695_2_, int p_149695_3_, int p_149695_4_, Block p_149695_5_)
{
int l = getDirectionMeta(p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_));
+
+ if ((l & 7) >= Facing.oppositeSide.length)
+ {
+ return; // CraftBukkit - fix a piston AIOOBE issue
+ }
+
Block block1 = p_149695_1_.getBlock(p_149695_2_ - Facing.offsetsXForSide[l], p_149695_3_ - Facing.offsetsYForSide[l], p_149695_4_ - Facing.offsetsZForSide[l]);
if (block1 != Blocks.piston && block1 != Blocks.sticky_piston)

View File

@ -0,0 +1,383 @@
--- ../src-base/minecraft/net/minecraft/block/BlockPortal.java
+++ ../src-work/minecraft/net/minecraft/block/BlockPortal.java
@@ -14,6 +14,11 @@
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
+// CraftBukkit start
+import org.bukkit.event.entity.EntityPortalEnterEvent;
+import org.bukkit.event.world.PortalCreateEvent;
+// CraftBukkit end
+
public class BlockPortal extends BlockBreakable
{
public static final int[][] field_150001_a = new int[][] {new int[0], {3, 1}, {2, 0}};
@@ -29,7 +34,7 @@
{
super.updateTick(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_5_);
- if (p_149674_1_.provider.isSurfaceWorld() && p_149674_1_.getGameRules().getGameRuleBooleanValue("doMobSpawning") && p_149674_5_.nextInt(2000) < p_149674_1_.difficultySetting.getDifficultyId())
+ if (p_149674_1_.getSpigotConfig().enableZombiePigmenPortalSpawns && p_149674_1_.provider.isSurfaceWorld() && p_149674_1_.getGameRules().getGameRuleBooleanValue("doMobSpawning") && p_149674_5_.nextInt(2000) < p_149674_1_.difficultySetting.getDifficultyId()) // Spigot // Cauldron
{
int l;
@@ -104,13 +109,15 @@
if (size.func_150860_b() && size.field_150864_e == 0)
{
- size.func_150859_c();
- return true;
+ // CraftBukkit start - return portalcreator
+ return size.CB_func_150859_c(); // Cauldron
+ //return true;
}
else if (size1.func_150860_b() && size1.field_150864_e == 0)
{
- size1.func_150859_c();
- return true;
+ return size1.CB_func_150859_c(); // Cauldron
+ //return true;
+ // CraftBukkit end
}
else
{
@@ -181,6 +188,10 @@
{
if (p_149670_5_.ridingEntity == null && p_149670_5_.riddenByEntity == null)
{
+ // CraftBukkit start - Entity in portal
+ EntityPortalEnterEvent event = new EntityPortalEnterEvent(p_149670_5_.getBukkitEntity(), new org.bukkit.Location(p_149670_1_.getWorld(), p_149670_2_, p_149670_3_, p_149670_4_));
+ p_149670_1_.getServer().getPluginManager().callEvent(event);
+ // CraftBukkit end
p_149670_5_.setInPortal();
}
}
@@ -239,175 +250,223 @@
}
public static class Size
+ {
+ private final World field_150867_a;
+ private final int field_150865_b;
+ private final int field_150866_c;
+ private final int field_150863_d;
+ private int field_150864_e = 0;
+ private ChunkCoordinates field_150861_f;
+ private int field_150862_g;
+ private int field_150868_h;
+ java.util.Collection<org.bukkit.block.Block> blocks; // CraftBukkit
+ private static final String __OBFID = "CL_00000285";
+
+ public Size(World p_i45415_1_, int p_i45415_2_, int p_i45415_3_, int p_i45415_4_, int p_i45415_5_)
{
- private final World field_150867_a;
- private final int field_150865_b;
- private final int field_150866_c;
- private final int field_150863_d;
- private int field_150864_e = 0;
- private ChunkCoordinates field_150861_f;
- private int field_150862_g;
- private int field_150868_h;
- private static final String __OBFID = "CL_00000285";
+ this.field_150867_a = p_i45415_1_;
+ this.field_150865_b = p_i45415_5_;
+ this.field_150863_d = BlockPortal.field_150001_a[p_i45415_5_][0];
+ this.field_150866_c = BlockPortal.field_150001_a[p_i45415_5_][1];
- public Size(World p_i45415_1_, int p_i45415_2_, int p_i45415_3_, int p_i45415_4_, int p_i45415_5_)
+ for (int i1 = p_i45415_3_; p_i45415_3_ > i1 - 21 && p_i45415_3_ > 0 && this.func_150857_a(p_i45415_1_.getBlock(p_i45415_2_, p_i45415_3_ - 1, p_i45415_4_)); --p_i45415_3_)
{
- this.field_150867_a = p_i45415_1_;
- this.field_150865_b = p_i45415_5_;
- this.field_150863_d = BlockPortal.field_150001_a[p_i45415_5_][0];
- this.field_150866_c = BlockPortal.field_150001_a[p_i45415_5_][1];
+ ;
+ }
- for (int i1 = p_i45415_3_; p_i45415_3_ > i1 - 21 && p_i45415_3_ > 0 && this.func_150857_a(p_i45415_1_.getBlock(p_i45415_2_, p_i45415_3_ - 1, p_i45415_4_)); --p_i45415_3_)
+ int j1 = this.func_150853_a(p_i45415_2_, p_i45415_3_, p_i45415_4_, this.field_150863_d) - 1;
+
+ if (j1 >= 0)
+ {
+ this.field_150861_f = new ChunkCoordinates(p_i45415_2_ + j1 * Direction.offsetX[this.field_150863_d], p_i45415_3_, p_i45415_4_ + j1 * Direction.offsetZ[this.field_150863_d]);
+ this.field_150868_h = this.func_150853_a(this.field_150861_f.posX, this.field_150861_f.posY, this.field_150861_f.posZ, this.field_150866_c);
+
+ if (this.field_150868_h < 2 || this.field_150868_h > 21)
{
- ;
+ this.field_150861_f = null;
+ this.field_150868_h = 0;
}
+ }
- int j1 = this.func_150853_a(p_i45415_2_, p_i45415_3_, p_i45415_4_, this.field_150863_d) - 1;
+ if (this.field_150861_f != null)
+ {
+ this.field_150862_g = this.func_150858_a();
+ }
+ }
- if (j1 >= 0)
- {
- this.field_150861_f = new ChunkCoordinates(p_i45415_2_ + j1 * Direction.offsetX[this.field_150863_d], p_i45415_3_, p_i45415_4_ + j1 * Direction.offsetZ[this.field_150863_d]);
- this.field_150868_h = this.func_150853_a(this.field_150861_f.posX, this.field_150861_f.posY, this.field_150861_f.posZ, this.field_150866_c);
+ protected int func_150853_a(int p_150853_1_, int p_150853_2_, int p_150853_3_, int p_150853_4_)
+ {
+ int j1 = Direction.offsetX[p_150853_4_];
+ int k1 = Direction.offsetZ[p_150853_4_];
+ int i1;
+ Block block;
- if (this.field_150868_h < 2 || this.field_150868_h > 21)
- {
- this.field_150861_f = null;
- this.field_150868_h = 0;
- }
+ for (i1 = 0; i1 < 22; ++i1)
+ {
+ block = this.field_150867_a.getBlock(p_150853_1_ + j1 * i1, p_150853_2_, p_150853_3_ + k1 * i1);
+
+ if (!this.func_150857_a(block))
+ {
+ break;
}
- if (this.field_150861_f != null)
+ Block block1 = this.field_150867_a.getBlock(p_150853_1_ + j1 * i1, p_150853_2_ - 1, p_150853_3_ + k1 * i1);
+
+ if (block1 != Blocks.obsidian)
{
- this.field_150862_g = this.func_150858_a();
+ break;
}
}
- protected int func_150853_a(int p_150853_1_, int p_150853_2_, int p_150853_3_, int p_150853_4_)
+ block = this.field_150867_a.getBlock(p_150853_1_ + j1 * i1, p_150853_2_, p_150853_3_ + k1 * i1);
+ return block == Blocks.obsidian ? i1 : 0;
+ }
+
+ protected int func_150858_a()
+ {
+ this.blocks = new java.util.HashSet<org.bukkit.block.Block>(); // CraftBukkit
+ org.bukkit.World bworld = this.field_150867_a.getWorld();
+ int i;
+ int j;
+ int k;
+ int l;
+ label56:
+
+ for (this.field_150862_g = 0; this.field_150862_g < 21; ++this.field_150862_g)
{
- int j1 = Direction.offsetX[p_150853_4_];
- int k1 = Direction.offsetZ[p_150853_4_];
- int i1;
- Block block;
+ i = this.field_150861_f.posY + this.field_150862_g;
- for (i1 = 0; i1 < 22; ++i1)
+ for (j = 0; j < this.field_150868_h; ++j)
{
- block = this.field_150867_a.getBlock(p_150853_1_ + j1 * i1, p_150853_2_, p_150853_3_ + k1 * i1);
+ k = this.field_150861_f.posX + j * Direction.offsetX[BlockPortal.field_150001_a[this.field_150865_b][1]];
+ l = this.field_150861_f.posZ + j * Direction.offsetZ[BlockPortal.field_150001_a[this.field_150865_b][1]];
+ Block block = this.field_150867_a.getBlock(k, i, l);
if (!this.func_150857_a(block))
{
- break;
+ break label56;
}
- Block block1 = this.field_150867_a.getBlock(p_150853_1_ + j1 * i1, p_150853_2_ - 1, p_150853_3_ + k1 * i1);
-
- if (block1 != Blocks.obsidian)
+ if (block == Blocks.portal)
{
- break;
+ ++this.field_150864_e;
}
- }
- block = this.field_150867_a.getBlock(p_150853_1_ + j1 * i1, p_150853_2_, p_150853_3_ + k1 * i1);
- return block == Blocks.obsidian ? i1 : 0;
- }
-
- protected int func_150858_a()
- {
- int i;
- int j;
- int k;
- int l;
- label56:
-
- for (this.field_150862_g = 0; this.field_150862_g < 21; ++this.field_150862_g)
- {
- i = this.field_150861_f.posY + this.field_150862_g;
-
- for (j = 0; j < this.field_150868_h; ++j)
+ if (j == 0)
{
- k = this.field_150861_f.posX + j * Direction.offsetX[BlockPortal.field_150001_a[this.field_150865_b][1]];
- l = this.field_150861_f.posZ + j * Direction.offsetZ[BlockPortal.field_150001_a[this.field_150865_b][1]];
- Block block = this.field_150867_a.getBlock(k, i, l);
+ block = this.field_150867_a.getBlock(k + Direction.offsetX[BlockPortal.field_150001_a[this.field_150865_b][0]], i, l + Direction.offsetZ[BlockPortal.field_150001_a[this.field_150865_b][0]]);
- if (!this.func_150857_a(block))
+ if (block != Blocks.obsidian)
{
break label56;
+ // CraftBukkit start - add the block to our list
}
-
- if (block == Blocks.portal)
+ else
{
- ++this.field_150864_e;
+ blocks.add(bworld.getBlockAt(k + Direction.offsetX[BlockPortal.field_150001_a[this.field_150865_b][0]], i, l + Direction.offsetZ[BlockPortal.field_150001_a[this.field_150865_b][0]]));
+ // CraftBukkit end
}
+ }
+ else if (j == this.field_150868_h - 1)
+ {
+ block = this.field_150867_a.getBlock(k + Direction.offsetX[BlockPortal.field_150001_a[this.field_150865_b][1]], i, l + Direction.offsetZ[BlockPortal.field_150001_a[this.field_150865_b][1]]);
- if (j == 0)
+ if (block != Blocks.obsidian)
{
- block = this.field_150867_a.getBlock(k + Direction.offsetX[BlockPortal.field_150001_a[this.field_150865_b][0]], i, l + Direction.offsetZ[BlockPortal.field_150001_a[this.field_150865_b][0]]);
-
- if (block != Blocks.obsidian)
- {
- break label56;
- }
+ break label56;
+ // CraftBukkit start - add the block to our list
}
- else if (j == this.field_150868_h - 1)
+ else
{
- block = this.field_150867_a.getBlock(k + Direction.offsetX[BlockPortal.field_150001_a[this.field_150865_b][1]], i, l + Direction.offsetZ[BlockPortal.field_150001_a[this.field_150865_b][1]]);
-
- if (block != Blocks.obsidian)
- {
- break label56;
- }
+ blocks.add(bworld.getBlockAt(k + Direction.offsetX[BlockPortal.field_150001_a[this.field_150865_b][1]], i, l + Direction.offsetZ[BlockPortal.field_150001_a[this.field_150865_b][1]]));
+ // CraftBukkit end
}
}
}
+ }
- for (i = 0; i < this.field_150868_h; ++i)
- {
- j = this.field_150861_f.posX + i * Direction.offsetX[BlockPortal.field_150001_a[this.field_150865_b][1]];
- k = this.field_150861_f.posY + this.field_150862_g;
- l = this.field_150861_f.posZ + i * Direction.offsetZ[BlockPortal.field_150001_a[this.field_150865_b][1]];
+ for (i = 0; i < this.field_150868_h; ++i)
+ {
+ j = this.field_150861_f.posX + i * Direction.offsetX[BlockPortal.field_150001_a[this.field_150865_b][1]];
+ k = this.field_150861_f.posY + this.field_150862_g;
+ l = this.field_150861_f.posZ + i * Direction.offsetZ[BlockPortal.field_150001_a[this.field_150865_b][1]];
- if (this.field_150867_a.getBlock(j, k, l) != Blocks.obsidian)
- {
- this.field_150862_g = 0;
- break;
- }
- }
-
- if (this.field_150862_g <= 21 && this.field_150862_g >= 3)
+ if (this.field_150867_a.getBlock(j, k, l) != Blocks.obsidian)
{
- return this.field_150862_g;
- }
- else
- {
- this.field_150861_f = null;
- this.field_150868_h = 0;
this.field_150862_g = 0;
- return 0;
+ break;
}
}
- protected boolean func_150857_a(Block p_150857_1_)
+ if (this.field_150862_g <= 21 && this.field_150862_g >= 3)
{
- return p_150857_1_.blockMaterial == Material.air || p_150857_1_ == Blocks.fire || p_150857_1_ == Blocks.portal;
+ return this.field_150862_g;
}
+ else
+ {
+ this.field_150861_f = null;
+ this.field_150868_h = 0;
+ this.field_150862_g = 0;
+ return 0;
+ }
+ }
- public boolean func_150860_b()
+ protected boolean func_150857_a(Block p_150857_1_)
+ {
+ return p_150857_1_.blockMaterial == Material.air || p_150857_1_ == Blocks.fire || p_150857_1_ == Blocks.portal;
+ }
+
+ public boolean func_150860_b()
+ {
+ return this.field_150861_f != null && this.field_150868_h >= 2 && this.field_150868_h <= 21 && this.field_150862_g >= 3 && this.field_150862_g <= 21;
+ }
+
+ // Cauldron start - vanilla compatibility
+ public void func_150859_c()
+ {
+ this.CB_func_150859_c();
+ }
+ // Cauldron end
+
+ public boolean CB_func_150859_c()
+ {
+ org.bukkit.World bworld = this.field_150867_a.getWorld();
+
+ // Copy below for loop
+ for (int i = 0; i < this.field_150868_h; ++i)
{
- return this.field_150861_f != null && this.field_150868_h >= 2 && this.field_150868_h <= 21 && this.field_150862_g >= 3 && this.field_150862_g <= 21;
+ int j = this.field_150861_f.posX + Direction.offsetX[this.field_150866_c] * i;
+ int k = this.field_150861_f.posZ + Direction.offsetZ[this.field_150866_c] * i;
+
+ for (int l = 0; l < this.field_150862_g; ++l)
+ {
+ int i1 = this.field_150861_f.posY + l;
+ bworld.getBlockAt(j, i1, k);
+ }
}
- public void func_150859_c()
+ PortalCreateEvent event = new PortalCreateEvent(blocks, bworld, PortalCreateEvent.CreateReason.FIRE);
+ this.field_150867_a.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled())
{
+ return false;
+ }
+ // CraftBukkit end
+
for (int i = 0; i < this.field_150868_h; ++i)
{
int j = this.field_150861_f.posX + Direction.offsetX[this.field_150866_c] * i;
int k = this.field_150861_f.posZ + Direction.offsetZ[this.field_150866_c] * i;
-
+
for (int l = 0; l < this.field_150862_g; ++l)
{
int i1 = this.field_150861_f.posY + l;
this.field_150867_a.setBlock(j, i1, k, Blocks.portal, this.field_150865_b, 2);
}
}
+
+ return true; // CraftBukkit
}
}
}

View File

@ -0,0 +1,47 @@
--- ../src-base/minecraft/net/minecraft/block/BlockPressurePlate.java
+++ ../src-work/minecraft/net/minecraft/block/BlockPressurePlate.java
@@ -8,6 +8,8 @@
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
+import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
+
public class BlockPressurePlate extends BlockBasePressurePlate
{
private BlockPressurePlate.Sensitivity field_150069_a;
@@ -54,8 +56,34 @@
while (iterator.hasNext())
{
- Entity entity = (Entity)iterator.next();
+ Entity entity = (Entity) iterator.next();
+ // CraftBukkit start - Call interact event when turning on a pressure plate
+ if (this.func_150060_c(p_150065_1_.getBlockMetadata(p_150065_2_, p_150065_3_, p_150065_4_)) == 0)
+ {
+ org.bukkit.World bworld = p_150065_1_.getWorld();
+ org.bukkit.plugin.PluginManager manager = p_150065_1_.getServer().getPluginManager();
+ org.bukkit.event.Cancellable cancellable;
+
+ if (entity instanceof EntityPlayer)
+ {
+ cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityPlayer) entity, org.bukkit.event.block.Action.PHYSICAL, p_150065_2_, p_150065_3_, p_150065_4_, -1, null);
+ }
+ else
+ {
+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), bworld.getBlockAt(p_150065_2_, p_150065_3_, p_150065_4_));
+ manager.callEvent((EntityInteractEvent) cancellable);
+ }
+
+ // We only want to block turning the plate on if all events are cancelled
+ if (cancellable.isCancelled())
+ {
+ continue;
+ }
+ }
+
+ // CraftBukkit end
+
if (!entity.doesEntityNotTriggerPressurePlate())
{
return 15;

View File

@ -0,0 +1,63 @@
--- ../src-base/minecraft/net/minecraft/block/BlockPressurePlateWeighted.java
+++ ../src-work/minecraft/net/minecraft/block/BlockPressurePlateWeighted.java
@@ -5,6 +5,12 @@
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
+// CraftBukkit start
+import java.util.List;
+import net.minecraft.entity.player.EntityPlayer;
+import org.bukkit.event.entity.EntityInteractEvent;
+// CraftBukkit end
+
public class BlockPressurePlateWeighted extends BlockBasePressurePlate
{
private final int field_150068_a;
@@ -18,18 +24,43 @@
protected int func_150065_e(World p_150065_1_, int p_150065_2_, int p_150065_3_, int p_150065_4_)
{
- int l = Math.min(p_150065_1_.getEntitiesWithinAABB(Entity.class, this.func_150061_a(p_150065_2_, p_150065_3_, p_150065_4_)).size(), this.field_150068_a);
+ // CraftBukkit start
+ int l = 0;
+ java.util.Iterator iterator = p_150065_1_.getEntitiesWithinAABB(Entity.class, this.func_150061_a(p_150065_2_, p_150065_3_, p_150065_4_)).iterator();
- if (l <= 0)
+ while (iterator.hasNext())
{
- return 0;
+ Entity entity = (Entity) iterator.next();
+ org.bukkit.event.Cancellable cancellable;
+
+ if (entity instanceof EntityPlayer)
+ {
+ cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityPlayer) entity, org.bukkit.event.block.Action.PHYSICAL, p_150065_2_, p_150065_3_, p_150065_4_, -1, null);
}
else
{
+ cancellable = new EntityInteractEvent(entity.getBukkitEntity(), p_150065_1_.getWorld().getBlockAt(p_150065_2_, p_150065_3_, p_150065_4_));
+ p_150065_1_.getServer().getPluginManager().callEvent((EntityInteractEvent) cancellable);
+ }
+
+ // We only want to block turning the plate on if all events are cancelled
+ if (!cancellable.isCancelled())
+ {
+ l++;
+ }
+ }
+
+ l = Math.min(l, this.field_150068_a);
+ // CraftBukkit end
+
+ if (l <= 0)
+ {
+ return 0;
+ }
+
float f = (float)Math.min(this.field_150068_a, l) / (float)this.field_150068_a;
return MathHelper.ceiling_float_int(f * 15.0F);
}
- }
protected int func_150060_c(int p_150060_1_)
{

View File

@ -0,0 +1,126 @@
--- ../src-base/minecraft/net/minecraft/block/BlockPumpkin.java
+++ ../src-work/minecraft/net/minecraft/block/BlockPumpkin.java
@@ -14,6 +14,12 @@
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
+// CraftBukkit start
+import org.bukkit.craftbukkit.util.BlockStateListPopulator;
+import org.bukkit.event.block.BlockRedstoneEvent;
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
+// CraftBukkit end
+
public class BlockPumpkin extends BlockDirectional
{
private boolean field_149985_a;
@@ -45,15 +51,18 @@
{
if (!p_149726_1_.isRemote)
{
- p_149726_1_.setBlock(p_149726_2_, p_149726_3_, p_149726_4_, getBlockById(0), 0, 2);
- p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_, getBlockById(0), 0, 2);
- p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 2, p_149726_4_, getBlockById(0), 0, 2);
+ // CraftBukkit start - Use BlockStateListPopulator
+ BlockStateListPopulator blockList = new BlockStateListPopulator(p_149726_1_.getWorld());
+ blockList.setTypeId(p_149726_2_, p_149726_3_, p_149726_4_, 0);
+ blockList.setTypeId(p_149726_2_, p_149726_3_ - 1, p_149726_4_, 0);
+ blockList.setTypeId(p_149726_2_, p_149726_3_ - 2, p_149726_4_, 0);
EntitySnowman entitysnowman = new EntitySnowman(p_149726_1_);
- entitysnowman.setLocationAndAngles((double)p_149726_2_ + 0.5D, (double)p_149726_3_ - 1.95D, (double)p_149726_4_ + 0.5D, 0.0F, 0.0F);
- p_149726_1_.spawnEntityInWorld(entitysnowman);
- p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_, p_149726_4_, getBlockById(0));
- p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 1, p_149726_4_, getBlockById(0));
- p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 2, p_149726_4_, getBlockById(0));
+ entitysnowman.setLocationAndAngles((double) p_149726_2_ + 0.5D, (double) p_149726_3_ - 1.95D, (double) p_149726_4_ + 0.5D, 0.0F, 0.0F);
+
+ if (p_149726_1_.addEntity(entitysnowman, SpawnReason.BUILD_SNOWMAN))
+ {
+ blockList.updateList();
+ }
}
for (int i1 = 0; i1 < 120; ++i1)
@@ -68,45 +77,38 @@
if (flag || flag1)
{
- p_149726_1_.setBlock(p_149726_2_, p_149726_3_, p_149726_4_, getBlockById(0), 0, 2);
- p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_, getBlockById(0), 0, 2);
- p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 2, p_149726_4_, getBlockById(0), 0, 2);
+ // CraftBukkit start - Use BlockStateListPopulator
+ BlockStateListPopulator blockList = new BlockStateListPopulator(p_149726_1_.getWorld());
+ blockList.setTypeId(p_149726_2_, p_149726_3_, p_149726_4_, 0);
+ blockList.setTypeId(p_149726_2_, p_149726_3_ - 1, p_149726_4_, 0);
+ blockList.setTypeId(p_149726_2_, p_149726_3_ - 2, p_149726_4_, 0);
if (flag)
{
- p_149726_1_.setBlock(p_149726_2_ - 1, p_149726_3_ - 1, p_149726_4_, getBlockById(0), 0, 2);
- p_149726_1_.setBlock(p_149726_2_ + 1, p_149726_3_ - 1, p_149726_4_, getBlockById(0), 0, 2);
+ blockList.setTypeId(p_149726_2_ - 1, p_149726_3_ - 1, p_149726_4_, 0);
+ blockList.setTypeId(p_149726_2_ + 1, p_149726_3_ - 1, p_149726_4_, 0);
}
else
{
- p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_ - 1, getBlockById(0), 0, 2);
- p_149726_1_.setBlock(p_149726_2_, p_149726_3_ - 1, p_149726_4_ + 1, getBlockById(0), 0, 2);
+ blockList.setTypeId(p_149726_2_, p_149726_3_ - 1, p_149726_4_ - 1, 0);
+ blockList.setTypeId(p_149726_2_, p_149726_3_ - 1, p_149726_4_ + 1, 0);
}
EntityIronGolem entityirongolem = new EntityIronGolem(p_149726_1_);
entityirongolem.setPlayerCreated(true);
- entityirongolem.setLocationAndAngles((double)p_149726_2_ + 0.5D, (double)p_149726_3_ - 1.95D, (double)p_149726_4_ + 0.5D, 0.0F, 0.0F);
- p_149726_1_.spawnEntityInWorld(entityirongolem);
+ entityirongolem.setLocationAndAngles((double) p_149726_2_ + 0.5D, (double) p_149726_3_ - 1.95D, (double) p_149726_4_ + 0.5D, 0.0F, 0.0F);
- for (int l = 0; l < 120; ++l)
+ if (p_149726_1_.addEntity(entityirongolem, SpawnReason.BUILD_IRONGOLEM))
{
- p_149726_1_.spawnParticle("snowballpoof", (double)p_149726_2_ + p_149726_1_.rand.nextDouble(), (double)(p_149726_3_ - 2) + p_149726_1_.rand.nextDouble() * 3.9D, (double)p_149726_4_ + p_149726_1_.rand.nextDouble(), 0.0D, 0.0D, 0.0D);
- }
+ for (int i1 = 0; i1 < 120; ++i1)
+ {
+ p_149726_1_.spawnParticle("snowballpoof", (double) p_149726_2_ + p_149726_1_.rand.nextDouble(), (double)(p_149726_3_ - 2) + p_149726_1_.rand.nextDouble() * 3.9D, (double) p_149726_4_ + p_149726_1_.rand.nextDouble(), 0.0D, 0.0D, 0.0D);
+ }
- p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_, p_149726_4_, getBlockById(0));
- p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 1, p_149726_4_, getBlockById(0));
- p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 2, p_149726_4_, getBlockById(0));
-
- if (flag)
- {
- p_149726_1_.notifyBlockChange(p_149726_2_ - 1, p_149726_3_ - 1, p_149726_4_, getBlockById(0));
- p_149726_1_.notifyBlockChange(p_149726_2_ + 1, p_149726_3_ - 1, p_149726_4_, getBlockById(0));
+ blockList.updateList();
}
- else
- {
- p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 1, p_149726_4_ - 1, getBlockById(0));
- p_149726_1_.notifyBlockChange(p_149726_2_, p_149726_3_ - 1, p_149726_4_ + 1, getBlockById(0));
- }
+
+ // CraftBukkit end
}
}
}
@@ -122,6 +124,19 @@
p_149689_1_.setBlockMetadataWithNotify(p_149689_2_, p_149689_3_, p_149689_4_, l, 2);
}
+ // CraftBukkit start
+ public void onNeighborBlockChange(World world, int i, int j, int k, Block block)
+ {
+ if (block != null && block.canProvidePower())
+ {
+ org.bukkit.block.Block bukkitBlock = world.getWorld().getBlockAt(i, j, k);
+ int power = bukkitBlock.getBlockPower();
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, power, power);
+ world.getServer().getPluginManager().callEvent(eventRedstone);
+ }
+ }
+ // CraftBukkit end
+
@SideOnly(Side.CLIENT)
public void registerBlockIcons(IIconRegister p_149651_1_)
{

View File

@ -0,0 +1,29 @@
--- ../src-base/minecraft/net/minecraft/block/BlockRailDetector.java
+++ ../src-work/minecraft/net/minecraft/block/BlockRailDetector.java
@@ -16,6 +16,8 @@
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockRailDetector extends BlockRailBase
{
@SideOnly(Side.CLIENT)
@@ -86,6 +88,17 @@
flag1 = true;
}
+ // CraftBukkit start
+ if (flag != flag1)
+ {
+ org.bukkit.block.Block block = p_150054_1_.getWorld().getBlockAt(p_150054_2_, p_150054_3_, p_150054_4_);
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, flag ? 15 : 0, flag1 ? 15 : 0);
+ p_150054_1_.getServer().getPluginManager().callEvent(eventRedstone);
+ flag1 = eventRedstone.getNewCurrent() > 0;
+ }
+
+ // CraftBukkit end
+
if (flag1 && !flag)
{
p_150054_1_.setBlockMetadataWithNotify(p_150054_2_, p_150054_3_, p_150054_4_, p_150054_5_ | 8, 3);

View File

@ -0,0 +1,43 @@
--- ../src-base/minecraft/net/minecraft/block/BlockRedstoneDiode.java
+++ ../src-work/minecraft/net/minecraft/block/BlockRedstoneDiode.java
@@ -13,6 +13,8 @@
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public abstract class BlockRedstoneDiode extends BlockDirectional
{
protected final boolean isRepeaterPowered;
@@ -44,16 +46,30 @@
{
int l = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_);
- if (!this.func_149910_g(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, l))
+ if (!this.func_149910_g((IBlockAccess) p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, l)) // CraftBukkit - Cast world to IBlockAccess to call the right method.
{
boolean flag = this.isGettingInput(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, l);
if (this.isRepeaterPowered && !flag)
{
+ // CraftBukkit start
+ if (CraftEventFactory.callRedstoneChange(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, 15, 0).getNewCurrent() != 0)
+ {
+ return;
+ }
+
+ // CraftBukkit end
p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, this.getBlockUnpowered(), l, 2);
}
else if (!this.isRepeaterPowered)
{
+ // CraftBukkit start
+ if (CraftEventFactory.callRedstoneChange(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, 0, 15).getNewCurrent() != 15)
+ {
+ return;
+ }
+
+ // CraftBukkit end
p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, this.getBlockPowered(), l, 2);
if (!flag)

View File

@ -0,0 +1,53 @@
--- ../src-base/minecraft/net/minecraft/block/BlockRedstoneLight.java
+++ ../src-work/minecraft/net/minecraft/block/BlockRedstoneLight.java
@@ -9,6 +9,8 @@
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockRedstoneLight extends Block
{
private final boolean field_150171_a;
@@ -35,6 +37,13 @@
}
else if (!this.field_150171_a && p_149726_1_.isBlockIndirectlyGettingPowered(p_149726_2_, p_149726_3_, p_149726_4_))
{
+ // CraftBukkit start
+ if (CraftEventFactory.callRedstoneChange(p_149726_1_, p_149726_2_, p_149726_3_, p_149726_4_, 0, 15).getNewCurrent() != 15)
+ {
+ return;
+ }
+
+ // CraftBukkit end
p_149726_1_.setBlock(p_149726_2_, p_149726_3_, p_149726_4_, Blocks.lit_redstone_lamp, 0, 2);
}
}
@@ -50,6 +59,13 @@
}
else if (!this.field_150171_a && p_149695_1_.isBlockIndirectlyGettingPowered(p_149695_2_, p_149695_3_, p_149695_4_))
{
+ // CraftBukkit start
+ if (CraftEventFactory.callRedstoneChange(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, 0, 15).getNewCurrent() != 15)
+ {
+ return;
+ }
+
+ // CraftBukkit end
p_149695_1_.setBlock(p_149695_2_, p_149695_3_, p_149695_4_, Blocks.lit_redstone_lamp, 0, 2);
}
}
@@ -59,6 +75,13 @@
{
if (!p_149674_1_.isRemote && this.field_150171_a && !p_149674_1_.isBlockIndirectlyGettingPowered(p_149674_2_, p_149674_3_, p_149674_4_))
{
+ // CraftBukkit start
+ if (CraftEventFactory.callRedstoneChange(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, 15, 0).getNewCurrent() != 0)
+ {
+ return;
+ }
+
+ // CraftBukkit end
p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.redstone_lamp, 0, 2);
}
}

View File

@ -0,0 +1,44 @@
--- ../src-base/minecraft/net/minecraft/block/BlockRedstoneOre.java
+++ ../src-work/minecraft/net/minecraft/block/BlockRedstoneOre.java
@@ -13,6 +13,8 @@
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
+import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
+
public class BlockRedstoneOre extends Block
{
private boolean field_150187_a;
@@ -43,8 +45,30 @@
public void onEntityWalking(World p_149724_1_, int p_149724_2_, int p_149724_3_, int p_149724_4_, Entity p_149724_5_)
{
- this.func_150185_e(p_149724_1_, p_149724_2_, p_149724_3_, p_149724_4_);
- super.onEntityWalking(p_149724_1_, p_149724_2_, p_149724_3_, p_149724_4_, p_149724_5_);
+ // CraftBukkit start
+ if (p_149724_5_ instanceof EntityPlayer)
+ {
+ org.bukkit.event.player.PlayerInteractEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityPlayer) p_149724_5_, org.bukkit.event.block.Action.PHYSICAL, p_149724_2_, p_149724_3_, p_149724_4_, -1, null);
+
+ if (!event.isCancelled())
+ {
+ this.func_150185_e(p_149724_1_, p_149724_2_, p_149724_3_, p_149724_4_);
+ super.onEntityWalking(p_149724_1_, p_149724_2_, p_149724_3_, p_149724_4_, p_149724_5_);
+ }
+ }
+ else
+ {
+ EntityInteractEvent event = new EntityInteractEvent(p_149724_5_.getBukkitEntity(), p_149724_1_.getWorld().getBlockAt(p_149724_2_, p_149724_3_, p_149724_4_));
+ p_149724_1_.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ this.func_150185_e(p_149724_1_, p_149724_2_, p_149724_3_, p_149724_4_);
+ super.onEntityWalking(p_149724_1_, p_149724_2_, p_149724_3_, p_149724_4_, p_149724_5_);
+ }
+ }
+
+ // CraftBukkit end
}
public boolean onBlockActivated(World p_149727_1_, int p_149727_2_, int p_149727_3_, int p_149727_4_, EntityPlayer p_149727_5_, int p_149727_6_, float p_149727_7_, float p_149727_8_, float p_149727_9_)

View File

@ -0,0 +1,62 @@
--- ../src-base/minecraft/net/minecraft/block/BlockRedstoneTorch.java
+++ ../src-work/minecraft/net/minecraft/block/BlockRedstoneTorch.java
@@ -13,6 +13,8 @@
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockRedstoneTorch extends BlockTorch
{
private boolean field_150113_a;
@@ -125,10 +127,30 @@
list.remove(0);
}
+ // CraftBukkit start
+ org.bukkit.plugin.PluginManager manager = p_149674_1_.getServer().getPluginManager();
+ org.bukkit.block.Block block = p_149674_1_.getWorld().getBlockAt(p_149674_2_, p_149674_3_, p_149674_4_);
+ int oldCurrent = this.field_150113_a ? 15 : 0;
+ BlockRedstoneEvent event = new BlockRedstoneEvent(block, oldCurrent, oldCurrent);
+ // CraftBukkit end
+
if (this.field_150113_a)
{
if (flag)
{
+ // CraftBukkit start
+ if (oldCurrent != 0)
+ {
+ event.setNewCurrent(0);
+ manager.callEvent(event);
+
+ if (event.getNewCurrent() != 0)
+ {
+ return;
+ }
+ }
+
+ // CraftBukkit end
p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.unlit_redstone_torch, p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_), 3);
if (this.func_150111_a(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, true))
@@ -147,6 +169,19 @@
}
else if (!flag && !this.func_150111_a(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, false))
{
+ // CraftBukkit start
+ if (oldCurrent != 15)
+ {
+ event.setNewCurrent(15);
+ manager.callEvent(event);
+
+ if (event.getNewCurrent() != 15)
+ {
+ return;
+ }
+ }
+
+ // CraftBukkit end
p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.redstone_torch, p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_), 3);
}
}

View File

@ -0,0 +1,39 @@
--- ../src-base/minecraft/net/minecraft/block/BlockRedstoneWire.java
+++ ../src-work/minecraft/net/minecraft/block/BlockRedstoneWire.java
@@ -18,6 +18,8 @@
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockRedstoneWire extends Block
{
private boolean field_150181_a = true;
@@ -159,8 +161,17 @@
i3 = l1;
}
+ // CraftBukkit start
if (k1 != i3)
{
+ BlockRedstoneEvent event = new BlockRedstoneEvent(p_150175_1_.getWorld().getBlockAt(p_150175_2_, p_150175_3_, p_150175_4_), k1, i3);
+ p_150175_1_.getServer().getPluginManager().callEvent(event);
+ i3 = event.getNewCurrent();
+ }
+
+ // CraftBukkit end
+ if (k1 != i3)
+ {
p_150175_1_.setBlockMetadataWithNotify(p_150175_2_, p_150175_3_, p_150175_4_, i3, 2);
this.field_150179_b.add(new ChunkPosition(p_150175_2_, p_150175_3_, p_150175_4_));
this.field_150179_b.add(new ChunkPosition(p_150175_2_ - 1, p_150175_3_, p_150175_4_));
@@ -294,7 +305,8 @@
}
}
- private int func_150178_a(World p_150178_1_, int p_150178_2_, int p_150178_3_, int p_150178_4_, int p_150178_5_)
+ // CraftBukkit - private -> public
+ public int func_150178_a(World p_150178_1_, int p_150178_2_, int p_150178_3_, int p_150178_4_, int p_150178_5_)
{
if (p_150178_1_.getBlock(p_150178_2_, p_150178_3_, p_150178_4_) != this)
{

View File

@ -0,0 +1,14 @@
--- ../src-base/minecraft/net/minecraft/block/BlockReed.java
+++ ../src-work/minecraft/net/minecraft/block/BlockReed.java
@@ -44,9 +44,9 @@
{
int i1 = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_);
- if (i1 == 15)
+ if (i1 >= (byte) range(3, (p_149674_1_.growthOdds / p_149674_1_.getSpigotConfig().caneModifier * 15) + 0.5F, 15)) // Spigot // Cauldron
{
- p_149674_1_.setBlock(p_149674_2_, p_149674_3_ + 1, p_149674_4_, this);
+ org.bukkit.craftbukkit.event.CraftEventFactory.handleBlockGrowEvent(p_149674_1_, p_149674_2_, p_149674_3_ + 1, p_149674_4_, this, 0); // CraftBukkit
p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, 0, 4);
}
else

View File

@ -0,0 +1,122 @@
--- ../src-base/minecraft/net/minecraft/block/BlockSapling.java
+++ ../src-work/minecraft/net/minecraft/block/BlockSapling.java
@@ -22,10 +22,18 @@
import net.minecraft.world.gen.feature.WorldGenTrees;
import net.minecraft.world.gen.feature.WorldGenerator;
+// CraftBukkit start
+import org.bukkit.Location;
+import org.bukkit.TreeType;
+import org.bukkit.block.BlockState;
+import org.bukkit.event.world.StructureGrowEvent;
+// CraftBukkit end
+
public class BlockSapling extends BlockBush implements IGrowable
{
public static final String[] field_149882_a = new String[] {"oak", "spruce", "birch", "jungle", "acacia", "roofed_oak"};
private static final IIcon[] field_149881_b = new IIcon[field_149882_a.length];
+ public static TreeType treeType; // CraftBukkit
private static final String __OBFID = "CL_00000305";
protected BlockSapling()
@@ -41,9 +49,31 @@
{
super.updateTick(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_5_);
- if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) >= 9 && p_149674_5_.nextInt(7) == 0)
+ if (p_149674_1_.getBlockLightValue(p_149674_2_, p_149674_3_ + 1, p_149674_4_) >= 9 && (p_149674_5_.nextInt(Math.max(2, (int)((p_149674_1_.growthOdds / p_149674_1_.getSpigotConfig().saplingModifier * 7) + 0.5F))) == 0)) // Spigot // Cauldron
{
+ // Cauldron start
+ p_149674_1_.captureTreeGeneration = true;
this.func_149879_c(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_5_);
+ p_149674_1_.captureTreeGeneration = false;
+ if (p_149674_1_.capturedBlockStates.size() > 0)
+ {
+ TreeType treeType = BlockSapling.treeType;
+ BlockSapling.treeType = null;
+ Location location = new Location(p_149674_1_.getWorld(), p_149674_2_, p_149674_3_, p_149674_4_);
+ List<BlockState> blocks = (List<BlockState>) p_149674_1_.capturedBlockStates.clone();
+ p_149674_1_.capturedBlockStates.clear();
+ StructureGrowEvent event = null;
+ if (treeType != null) {
+ event = new StructureGrowEvent(location, treeType, false, null, blocks);
+ org.bukkit.Bukkit.getPluginManager().callEvent(event);
+ }
+ if (event == null || !event.isCancelled()) {
+ for (BlockState blockstate : blocks) {
+ blockstate.update(true);
+ }
+ }
+ }
+ //Cauldron end
}
}
}
@@ -73,7 +103,20 @@
{
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;
- Object object = p_149878_5_.nextInt(10) == 0 ? new WorldGenBigTree(true) : new WorldGenTrees(true);
+ // CraftBukkit start
+ Object object = null;
+ if (p_149878_5_.nextInt(10) == 0)
+ {
+ treeType = TreeType.BIG_TREE; // CraftBukkit
+ object = new WorldGenBigTree(true);
+ }
+ else
+ {
+ treeType = TreeType.TREE; // CraftBukkit
+ object = new WorldGenTrees(true);
+ }
+ // CraftBukkit end
+
int i1 = 0;
int j1 = 0;
boolean flag = false;
@@ -84,6 +127,7 @@
default:
break;
case 1:
+ treeType = TreeType.REDWOOD; // CraftBukkit
label78:
for (i1 = 0; i1 >= -1; --i1)
@@ -108,6 +152,7 @@
break;
case 2:
+ treeType = TreeType.BIRCH; // CraftBukkit
object = new WorldGenForest(true, false);
break;
case 3:
@@ -119,6 +164,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))
{
+ treeType = TreeType.JUNGLE; // CraftBukkit
object = new WorldGenMegaJungle(true, 10, 20, 3, 3);
flag = true;
break label93;
@@ -130,11 +176,13 @@
{
j1 = 0;
i1 = 0;
+ treeType = TreeType.SMALL_JUNGLE; // CraftBukkit
object = new WorldGenTrees(true, 4 + p_149878_5_.nextInt(7), 3, 3, false);
}
break;
case 4:
+ treeType = TreeType.ACACIA; // CraftBukkit
object = new WorldGenSavannaTree(true);
break;
case 5:
@@ -147,6 +195,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))
{
object = new WorldGenCanopyTree(true);
+ treeType = TreeType.DARK_OAK; // CraftBukkit
flag = true;
break label108;
}

View File

@ -0,0 +1,29 @@
--- ../src-base/minecraft/net/minecraft/block/BlockSign.java
+++ ../src-work/minecraft/net/minecraft/block/BlockSign.java
@@ -14,6 +14,8 @@
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockSign extends BlockContainer
{
private Class field_149968_a;
@@ -163,6 +165,17 @@
}
super.onNeighborBlockChange(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, p_149695_5_);
+
+ // CraftBukkit start
+ if (p_149695_5_ != null && p_149695_5_.canProvidePower())
+ {
+ org.bukkit.block.Block bukkitBlock = p_149695_1_.getWorld().getBlockAt(p_149695_2_, p_149695_3_, p_149695_4_);
+ int power = bukkitBlock.getBlockPower();
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bukkitBlock, power, power);
+ p_149695_1_.getServer().getPluginManager().callEvent(eventRedstone);
+ }
+
+ // CraftBukkit end
}
@SideOnly(Side.CLIENT)

View File

@ -0,0 +1,156 @@
--- ../src-base/minecraft/net/minecraft/block/BlockSkull.java
+++ ../src-work/minecraft/net/minecraft/block/BlockSkull.java
@@ -27,6 +27,11 @@
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
+// CraftBukkit start
+import org.bukkit.craftbukkit.util.BlockStateListPopulator;
+import org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason;
+// CraftBukkit end
+
public class BlockSkull extends BlockContainer
{
private static final String __OBFID = "CL_00000307";
@@ -172,16 +177,18 @@
{
if (p_149965_1_.getBlock(p_149965_2_, p_149965_3_ - 1, p_149965_4_ + l) == Blocks.soul_sand && p_149965_1_.getBlock(p_149965_2_, p_149965_3_ - 1, p_149965_4_ + l + 1) == Blocks.soul_sand && p_149965_1_.getBlock(p_149965_2_, p_149965_3_ - 2, p_149965_4_ + l + 1) == Blocks.soul_sand && p_149965_1_.getBlock(p_149965_2_, p_149965_3_ - 1, p_149965_4_ + l + 2) == Blocks.soul_sand && this.func_149966_a(p_149965_1_, p_149965_2_, p_149965_3_, p_149965_4_ + l, 1) && this.func_149966_a(p_149965_1_, p_149965_2_, p_149965_3_, p_149965_4_ + l + 1, 1) && this.func_149966_a(p_149965_1_, p_149965_2_, p_149965_3_, p_149965_4_ + l + 2, 1))
{
+ // CraftBukkit start - Use BlockStateListPopulator
+ BlockStateListPopulator blockList = new BlockStateListPopulator(p_149965_1_.getWorld());
p_149965_1_.setBlockMetadataWithNotify(p_149965_2_, p_149965_3_, p_149965_4_ + l, 8, 2);
p_149965_1_.setBlockMetadataWithNotify(p_149965_2_, p_149965_3_, p_149965_4_ + l + 1, 8, 2);
p_149965_1_.setBlockMetadataWithNotify(p_149965_2_, p_149965_3_, p_149965_4_ + l + 2, 8, 2);
- p_149965_1_.setBlock(p_149965_2_, p_149965_3_, p_149965_4_ + l, getBlockById(0), 0, 2);
- p_149965_1_.setBlock(p_149965_2_, p_149965_3_, p_149965_4_ + l + 1, getBlockById(0), 0, 2);
- p_149965_1_.setBlock(p_149965_2_, p_149965_3_, p_149965_4_ + l + 2, getBlockById(0), 0, 2);
- p_149965_1_.setBlock(p_149965_2_, p_149965_3_ - 1, p_149965_4_ + l, getBlockById(0), 0, 2);
- p_149965_1_.setBlock(p_149965_2_, p_149965_3_ - 1, p_149965_4_ + l + 1, getBlockById(0), 0, 2);
- p_149965_1_.setBlock(p_149965_2_, p_149965_3_ - 1, p_149965_4_ + l + 2, getBlockById(0), 0, 2);
- p_149965_1_.setBlock(p_149965_2_, p_149965_3_ - 2, p_149965_4_ + l + 1, getBlockById(0), 0, 2);
+ blockList.setTypeAndData(p_149965_2_, p_149965_3_, p_149965_4_ + l, getBlockById(0), 0, 2);
+ blockList.setTypeAndData(p_149965_2_, p_149965_3_, p_149965_4_ + l + 1, getBlockById(0), 0, 2);
+ blockList.setTypeAndData(p_149965_2_, p_149965_3_, p_149965_4_ + l + 2, getBlockById(0), 0, 2);
+ blockList.setTypeAndData(p_149965_2_, p_149965_3_ - 1, p_149965_4_ + l, getBlockById(0), 0, 2);
+ blockList.setTypeAndData(p_149965_2_, p_149965_3_ - 1, p_149965_4_ + l + 1, getBlockById(0), 0, 2);
+ blockList.setTypeAndData(p_149965_2_, p_149965_3_ - 1, p_149965_4_ + l + 2, getBlockById(0), 0, 2);
+ blockList.setTypeAndData(p_149965_2_, p_149965_3_ - 2, p_149965_4_ + l + 1, getBlockById(0), 0, 2);
if (!p_149965_1_.isRemote)
{
@@ -190,18 +197,21 @@
entitywither.renderYawOffset = 90.0F;
entitywither.func_82206_m();
- if (!p_149965_1_.isRemote)
+ if (p_149965_1_.addEntity(entitywither, SpawnReason.BUILD_WITHER))
{
- iterator = p_149965_1_.getEntitiesWithinAABB(EntityPlayer.class, entitywither.boundingBox.expand(50.0D, 50.0D, 50.0D)).iterator();
-
- while (iterator.hasNext())
+ if (!p_149965_1_.isRemote)
{
- entityplayer = (EntityPlayer)iterator.next();
- entityplayer.triggerAchievement(AchievementList.field_150963_I);
+ iterator = p_149965_1_.getEntitiesWithinAABB(EntityPlayer.class, entitywither.boundingBox.expand(50.0D, 50.0D, 50.0D)).iterator();
+
+ while (iterator.hasNext())
+ {
+ entityplayer = (EntityPlayer) iterator.next();
+ entityplayer.triggerAchievement(AchievementList.field_150963_I);
+ }
}
- }
- p_149965_1_.spawnEntityInWorld(entitywither);
+ blockList.updateList();
+ }
}
for (i1 = 0; i1 < 120; ++i1)
@@ -209,13 +219,7 @@
p_149965_1_.spawnParticle("snowballpoof", (double)p_149965_2_ + p_149965_1_.rand.nextDouble(), (double)(p_149965_3_ - 2) + p_149965_1_.rand.nextDouble() * 3.9D, (double)(p_149965_4_ + l + 1) + p_149965_1_.rand.nextDouble(), 0.0D, 0.0D, 0.0D);
}
- p_149965_1_.notifyBlockChange(p_149965_2_, p_149965_3_, p_149965_4_ + l, getBlockById(0));
- p_149965_1_.notifyBlockChange(p_149965_2_, p_149965_3_, p_149965_4_ + l + 1, getBlockById(0));
- p_149965_1_.notifyBlockChange(p_149965_2_, p_149965_3_, p_149965_4_ + l + 2, getBlockById(0));
- p_149965_1_.notifyBlockChange(p_149965_2_, p_149965_3_ - 1, p_149965_4_ + l, getBlockById(0));
- p_149965_1_.notifyBlockChange(p_149965_2_, p_149965_3_ - 1, p_149965_4_ + l + 1, getBlockById(0));
- p_149965_1_.notifyBlockChange(p_149965_2_, p_149965_3_ - 1, p_149965_4_ + l + 2, getBlockById(0));
- p_149965_1_.notifyBlockChange(p_149965_2_, p_149965_3_ - 2, p_149965_4_ + l + 1, getBlockById(0));
+ // CraftBukkit end
return;
}
}
@@ -224,16 +228,18 @@
{
if (p_149965_1_.getBlock(p_149965_2_ + l, p_149965_3_ - 1, p_149965_4_) == Blocks.soul_sand && p_149965_1_.getBlock(p_149965_2_ + l + 1, p_149965_3_ - 1, p_149965_4_) == Blocks.soul_sand && p_149965_1_.getBlock(p_149965_2_ + l + 1, p_149965_3_ - 2, p_149965_4_) == Blocks.soul_sand && p_149965_1_.getBlock(p_149965_2_ + l + 2, p_149965_3_ - 1, p_149965_4_) == Blocks.soul_sand && this.func_149966_a(p_149965_1_, p_149965_2_ + l, p_149965_3_, p_149965_4_, 1) && this.func_149966_a(p_149965_1_, p_149965_2_ + l + 1, p_149965_3_, p_149965_4_, 1) && this.func_149966_a(p_149965_1_, p_149965_2_ + l + 2, p_149965_3_, p_149965_4_, 1))
{
+ // CraftBukkit start - Use BlockStateListPopulator
+ BlockStateListPopulator blockList = new BlockStateListPopulator(p_149965_1_.getWorld());
p_149965_1_.setBlockMetadataWithNotify(p_149965_2_ + l, p_149965_3_, p_149965_4_, 8, 2);
p_149965_1_.setBlockMetadataWithNotify(p_149965_2_ + l + 1, p_149965_3_, p_149965_4_, 8, 2);
p_149965_1_.setBlockMetadataWithNotify(p_149965_2_ + l + 2, p_149965_3_, p_149965_4_, 8, 2);
- p_149965_1_.setBlock(p_149965_2_ + l, p_149965_3_, p_149965_4_, getBlockById(0), 0, 2);
- p_149965_1_.setBlock(p_149965_2_ + l + 1, p_149965_3_, p_149965_4_, getBlockById(0), 0, 2);
- p_149965_1_.setBlock(p_149965_2_ + l + 2, p_149965_3_, p_149965_4_, getBlockById(0), 0, 2);
- p_149965_1_.setBlock(p_149965_2_ + l, p_149965_3_ - 1, p_149965_4_, getBlockById(0), 0, 2);
- p_149965_1_.setBlock(p_149965_2_ + l + 1, p_149965_3_ - 1, p_149965_4_, getBlockById(0), 0, 2);
- p_149965_1_.setBlock(p_149965_2_ + l + 2, p_149965_3_ - 1, p_149965_4_, getBlockById(0), 0, 2);
- p_149965_1_.setBlock(p_149965_2_ + l + 1, p_149965_3_ - 2, p_149965_4_, getBlockById(0), 0, 2);
+ blockList.setTypeAndData(p_149965_2_ + l, p_149965_3_, p_149965_4_, getBlockById(0), 0, 2);
+ blockList.setTypeAndData(p_149965_2_ + l + 1, p_149965_3_, p_149965_4_, getBlockById(0), 0, 2);
+ blockList.setTypeAndData(p_149965_2_ + l + 2, p_149965_3_, p_149965_4_, getBlockById(0), 0, 2);
+ blockList.setTypeAndData(p_149965_2_ + l, p_149965_3_ - 1, p_149965_4_, getBlockById(0), 0, 2);
+ blockList.setTypeAndData(p_149965_2_ + l + 1, p_149965_3_ - 1, p_149965_4_, getBlockById(0), 0, 2);
+ blockList.setTypeAndData(p_149965_2_ + l + 2, p_149965_3_ - 1, p_149965_4_, getBlockById(0), 0, 2);
+ blockList.setTypeAndData(p_149965_2_ + l + 1, p_149965_3_ - 2, p_149965_4_, getBlockById(0), 0, 2);
if (!p_149965_1_.isRemote)
{
@@ -241,18 +247,21 @@
entitywither.setLocationAndAngles((double)(p_149965_2_ + l) + 1.5D, (double)p_149965_3_ - 1.45D, (double)p_149965_4_ + 0.5D, 0.0F, 0.0F);
entitywither.func_82206_m();
- if (!p_149965_1_.isRemote)
+ if (p_149965_1_.addEntity(entitywither, SpawnReason.BUILD_WITHER))
{
- iterator = p_149965_1_.getEntitiesWithinAABB(EntityPlayer.class, entitywither.boundingBox.expand(50.0D, 50.0D, 50.0D)).iterator();
-
- while (iterator.hasNext())
+ if (!p_149965_1_.isRemote)
{
- entityplayer = (EntityPlayer)iterator.next();
- entityplayer.triggerAchievement(AchievementList.field_150963_I);
+ iterator = p_149965_1_.getEntitiesWithinAABB(EntityPlayer.class, entitywither.boundingBox.expand(50.0D, 50.0D, 50.0D)).iterator();
+
+ while (iterator.hasNext())
+ {
+ entityplayer = (EntityPlayer) iterator.next();
+ entityplayer.triggerAchievement(AchievementList.field_150963_I);
+ }
}
- }
- p_149965_1_.spawnEntityInWorld(entitywither);
+ blockList.updateList();
+ }
}
for (i1 = 0; i1 < 120; ++i1)
@@ -260,13 +269,7 @@
p_149965_1_.spawnParticle("snowballpoof", (double)(p_149965_2_ + l + 1) + p_149965_1_.rand.nextDouble(), (double)(p_149965_3_ - 2) + p_149965_1_.rand.nextDouble() * 3.9D, (double)p_149965_4_ + p_149965_1_.rand.nextDouble(), 0.0D, 0.0D, 0.0D);
}
- p_149965_1_.notifyBlockChange(p_149965_2_ + l, p_149965_3_, p_149965_4_, getBlockById(0));
- p_149965_1_.notifyBlockChange(p_149965_2_ + l + 1, p_149965_3_, p_149965_4_, getBlockById(0));
- p_149965_1_.notifyBlockChange(p_149965_2_ + l + 2, p_149965_3_, p_149965_4_, getBlockById(0));
- p_149965_1_.notifyBlockChange(p_149965_2_ + l, p_149965_3_ - 1, p_149965_4_, getBlockById(0));
- p_149965_1_.notifyBlockChange(p_149965_2_ + l + 1, p_149965_3_ - 1, p_149965_4_, getBlockById(0));
- p_149965_1_.notifyBlockChange(p_149965_2_ + l + 2, p_149965_3_ - 1, p_149965_4_, getBlockById(0));
- p_149965_1_.notifyBlockChange(p_149965_2_ + l + 1, p_149965_3_ - 2, p_149965_4_, getBlockById(0));
+ // CraftBukkit end
return;
}
}

View File

@ -0,0 +1,17 @@
--- ../src-base/minecraft/net/minecraft/block/BlockSnow.java
+++ ../src-work/minecraft/net/minecraft/block/BlockSnow.java
@@ -114,6 +114,14 @@
{
if (p_149674_1_.getSavedLightValue(EnumSkyBlock.Block, p_149674_2_, p_149674_3_, p_149674_4_) > 11)
{
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callBlockFadeEvent(p_149674_1_.getWorld().getBlockAt(p_149674_2_, p_149674_3_, p_149674_4_), Blocks.air).isCancelled())
+ {
+ return;
+ }
+
+ // CraftBukkit end
+ this.dropBlockAsItem(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_), 0);
p_149674_1_.setBlockToAir(p_149674_2_, p_149674_3_, p_149674_4_);
}
}

View File

@ -0,0 +1,57 @@
--- ../src-base/minecraft/net/minecraft/block/BlockStaticLiquid.java
+++ ../src-work/minecraft/net/minecraft/block/BlockStaticLiquid.java
@@ -5,6 +5,8 @@
import net.minecraft.init.Blocks;
import net.minecraft.world.World;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockStaticLiquid extends BlockLiquid
{
private static final String __OBFID = "CL_00000315";
@@ -43,6 +45,11 @@
{
int l = p_149674_5_.nextInt(3);
int i1;
+ // CraftBukkit start - Prevent lava putting something on fire, remember igniter block coords
+ int x = p_149674_2_;
+ int y = p_149674_3_;
+ int z = p_149674_4_;
+ // CraftBukkit end
for (i1 = 0; i1 < l; ++i1)
{
@@ -55,6 +62,16 @@
{
if (this.isFlammable(p_149674_1_, p_149674_2_ - 1, p_149674_3_, p_149674_4_) || this.isFlammable(p_149674_1_, p_149674_2_ + 1, p_149674_3_, p_149674_4_) || this.isFlammable(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_ - 1) || this.isFlammable(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_ + 1) || this.isFlammable(p_149674_1_, p_149674_2_, p_149674_3_ - 1, p_149674_4_) || this.isFlammable(p_149674_1_, p_149674_2_, p_149674_3_ + 1, p_149674_4_))
{
+ // CraftBukkit start - Prevent lava putting something on fire
+ if (p_149674_1_.getBlock(p_149674_2_, p_149674_3_, p_149674_4_) != Blocks.fire)
+ {
+ if (CraftEventFactory.callBlockIgniteEvent(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, x, y, z).isCancelled())
+ {
+ continue;
+ }
+ }
+
+ // CraftBukkit end
p_149674_1_.setBlock(p_149674_2_, p_149674_3_, p_149674_4_, Blocks.fire);
return;
}
@@ -77,6 +94,16 @@
if (p_149674_1_.isAirBlock(p_149674_2_, p_149674_3_ + 1, p_149674_4_) && this.isFlammable(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_))
{
+ // CraftBukkit start - Prevent lava putting something on fire
+ if (p_149674_1_.getBlock(p_149674_2_, p_149674_3_ + 1, p_149674_4_) != Blocks.fire)
+ {
+ if (CraftEventFactory.callBlockIgniteEvent(p_149674_1_, p_149674_2_, p_149674_3_ + 1, p_149674_4_, x, y, z).isCancelled())
+ {
+ continue;
+ }
+ }
+
+ // CraftBukkit end
p_149674_1_.setBlock(p_149674_2_, p_149674_3_ + 1, p_149674_4_, Blocks.fire);
}
}

View File

@ -0,0 +1,37 @@
--- ../src-base/minecraft/net/minecraft/block/BlockStem.java
+++ ../src-work/minecraft/net/minecraft/block/BlockStem.java
@@ -17,6 +17,8 @@
import net.minecraft.world.World;
import static net.minecraftforge.common.util.ForgeDirection.*;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockStem extends BlockBush implements IGrowable
{
private final Block field_149877_a;
@@ -46,14 +48,14 @@
{
float f = this.func_149875_n(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_);
- if (p_149674_5_.nextInt((int)(25.0F / f) + 1) == 0)
+ if (p_149674_5_.nextInt((int)(p_149674_1_.growthOdds / (this == Blocks.pumpkin_stem ? p_149674_1_.getSpigotConfig().pumpkinModifier : p_149674_1_.spigotConfig.melonModifier) * (25.0F / f)) + 1) == 0) // Spigot // Cauldron
{
int l = p_149674_1_.getBlockMetadata(p_149674_2_, p_149674_3_, p_149674_4_);
if (l < 7)
{
++l;
- p_149674_1_.setBlockMetadataWithNotify(p_149674_2_, p_149674_3_, p_149674_4_, l, 2);
+ CraftEventFactory.handleBlockGrowEvent(p_149674_1_, p_149674_2_, p_149674_3_, p_149674_4_, this, l); // CraftBukkit
}
else
{
@@ -105,7 +107,7 @@
if (p_149674_1_.isAirBlock(j1, p_149674_3_, k1) && (block.canSustainPlant(p_149674_1_, j1, p_149674_3_ - 1, k1, UP, this) || block == Blocks.dirt || block == Blocks.grass))
{
- p_149674_1_.setBlock(j1, p_149674_3_, k1, this.field_149877_a);
+ CraftEventFactory.handleBlockGrowEvent(p_149674_1_, j1, p_149674_3_, k1, this.field_149877_a, 0); // CraftBukkit
}
}
}

View File

@ -0,0 +1,32 @@
--- ../src-base/minecraft/net/minecraft/block/BlockTrapDoor.java
+++ ../src-work/minecraft/net/minecraft/block/BlockTrapDoor.java
@@ -13,6 +13,8 @@
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockTrapDoor extends Block
{
/** Set this to allow trapdoors to remain free-floating */
@@ -176,6 +178,20 @@
if (flag || p_149695_5_.canProvidePower())
{
+ // CraftBukkit start
+ org.bukkit.World bworld = p_149695_1_.getWorld();
+ org.bukkit.block.Block bblock = bworld.getBlockAt(p_149695_2_, p_149695_3_, p_149695_4_);
+ int power = bblock.getBlockPower();
+ int oldPower = (p_149695_1_.getBlockMetadata(p_149695_2_, p_149695_3_, p_149695_4_) & 4) > 0 ? 15 : 0;
+
+ if (oldPower == 0 ^ power == 0 || p_149695_5_.canProvidePower())
+ {
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(bblock, oldPower, power);
+ p_149695_1_.getServer().getPluginManager().callEvent(eventRedstone);
+ flag = eventRedstone.getNewCurrent() > 0;
+ }
+
+ // CraftBukkit end
this.func_150120_a(p_149695_1_, p_149695_2_, p_149695_3_, p_149695_4_, flag);
}
}

View File

@ -0,0 +1,63 @@
--- ../src-base/minecraft/net/minecraft/block/BlockTripWire.java
+++ ../src-work/minecraft/net/minecraft/block/BlockTripWire.java
@@ -16,6 +16,8 @@
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
+import org.bukkit.event.entity.EntityInteractEvent; // CraftBukkit
+
public class BlockTripWire extends Block
{
private static final String __OBFID = "CL_00000328";
@@ -208,6 +210,51 @@
}
}
+ // CraftBukkit start - Call interact even when triggering connected tripwire
+ if (flag != flag1 && flag1 && (p_150140_1_.getBlockMetadata(p_150140_2_, p_150140_3_, p_150140_4_) & 4) == 4)
+ {
+ org.bukkit.World bworld = p_150140_1_.getWorld();
+ org.bukkit.plugin.PluginManager manager = p_150140_1_.getServer().getPluginManager();
+ org.bukkit.block.Block block = bworld.getBlockAt(p_150140_2_, p_150140_3_, p_150140_4_);
+ boolean allowed = false;
+
+ // If all of the events are cancelled block the tripwire trigger, else allow
+ for (Object object : list)
+ {
+ if (object != null)
+ {
+ org.bukkit.event.Cancellable cancellable;
+
+ if (object instanceof EntityPlayer)
+ {
+ cancellable = org.bukkit.craftbukkit.event.CraftEventFactory.callPlayerInteractEvent((EntityPlayer) object, org.bukkit.event.block.Action.PHYSICAL, p_150140_2_, p_150140_3_, p_150140_4_, -1, null);
+ }
+ else if (object instanceof Entity)
+ {
+ cancellable = new EntityInteractEvent(((Entity) object).getBukkitEntity(), block);
+ manager.callEvent((EntityInteractEvent) cancellable);
+ }
+ else
+ {
+ continue;
+ }
+
+ if (!cancellable.isCancelled())
+ {
+ allowed = true;
+ break;
+ }
+ }
+ }
+
+ if (!allowed)
+ {
+ return;
+ }
+ }
+
+ // CraftBukkit end
+
if (flag1 && !flag)
{
l |= 1;

View File

@ -0,0 +1,29 @@
--- ../src-base/minecraft/net/minecraft/block/BlockTripWireHook.java
+++ ../src-work/minecraft/net/minecraft/block/BlockTripWireHook.java
@@ -12,6 +12,8 @@
import net.minecraftforge.common.util.ForgeDirection;
import static net.minecraftforge.common.util.ForgeDirection.*;
+import org.bukkit.event.block.BlockRedstoneEvent; // CraftBukkit
+
public class BlockTripWireHook extends Block
{
private static final String __OBFID = "CL_00000329";
@@ -210,6 +212,17 @@
this.func_150135_a(p_150136_1_, l2, p_150136_3_, i3, flag4, flag5, flag2, flag3);
}
+ // CraftBukkit start
+ org.bukkit.block.Block block = p_150136_1_.getWorld().getBlockAt(p_150136_2_, p_150136_3_, p_150136_4_);
+ BlockRedstoneEvent eventRedstone = new BlockRedstoneEvent(block, 15, 0);
+ p_150136_1_.getServer().getPluginManager().callEvent(eventRedstone);
+
+ if (eventRedstone.getNewCurrent() > 0)
+ {
+ return;
+ }
+
+ // CraftBukkit end
this.func_150135_a(p_150136_1_, p_150136_2_, p_150136_3_, p_150136_4_, flag4, flag5, flag2, flag3);
if (!p_150136_5_)

View File

@ -0,0 +1,77 @@
--- ../src-base/minecraft/net/minecraft/block/BlockVine.java
+++ ../src-work/minecraft/net/minecraft/block/BlockVine.java
@@ -21,6 +21,8 @@
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.IShearable;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class BlockVine extends Block implements IShearable
{
private static final String __OBFID = "CL_00000330";
@@ -268,7 +270,11 @@
if (j2 > 0)
{
- p_149674_1_.setBlock(p_149674_2_, p_149674_3_ + 1, p_149674_4_, this, j2, 2);
+ // CraftBukkit start - Call BlockSpreadEvent
+ org.bukkit.block.Block source = p_149674_1_.getWorld().getBlockAt(p_149674_2_, p_149674_3_, p_149674_4_);
+ org.bukkit.block.Block block = p_149674_1_.getWorld().getBlockAt(p_149674_2_, p_149674_3_ + 1, p_149674_4_);
+ CraftEventFactory.handleBlockSpreadEvent(block, source, this, l1);
+ // CraftBukkit end
}
}
}
@@ -290,27 +296,34 @@
{
l1 = k1 + 1 & 3;
i2 = k1 + 3 & 3;
+ // CraftBukkit start - Call BlockSpreadEvent
+ org.bukkit.block.Block source = p_149674_1_.getWorld().getBlockAt(p_149674_2_, p_149674_3_, p_149674_4_);
+ org.bukkit.block.Block bukkitBlock = p_149674_1_.getWorld().getBlockAt(p_149674_2_ + Direction.offsetX[k1], p_149674_3_, p_149674_4_ + Direction.offsetZ[k1]);
if ((i1 & 1 << l1) != 0 && this.func_150093_a(p_149674_1_.getBlock(p_149674_2_ + Direction.offsetX[k1] + Direction.offsetX[l1], p_149674_3_, p_149674_4_ + Direction.offsetZ[k1] + Direction.offsetZ[l1])))
{
- p_149674_1_.setBlock(p_149674_2_ + Direction.offsetX[k1], p_149674_3_, p_149674_4_ + Direction.offsetZ[k1], this, 1 << l1, 2);
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, 1 << l1);
}
else if ((i1 & 1 << i2) != 0 && this.func_150093_a(p_149674_1_.getBlock(p_149674_2_ + Direction.offsetX[k1] + Direction.offsetX[i2], p_149674_3_, p_149674_4_ + Direction.offsetZ[k1] + Direction.offsetZ[i2])))
{
- p_149674_1_.setBlock(p_149674_2_ + Direction.offsetX[k1], p_149674_3_, p_149674_4_ + Direction.offsetZ[k1], this, 1 << i2, 2);
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, 1 << i2);
}
else if ((i1 & 1 << l1) != 0 && p_149674_1_.isAirBlock(p_149674_2_ + Direction.offsetX[k1] + Direction.offsetX[l1], p_149674_3_, p_149674_4_ + Direction.offsetZ[k1] + Direction.offsetZ[l1]) && this.func_150093_a(p_149674_1_.getBlock(p_149674_2_ + Direction.offsetX[l1], p_149674_3_, p_149674_4_ + Direction.offsetZ[l1])))
{
- p_149674_1_.setBlock(p_149674_2_ + Direction.offsetX[k1] + Direction.offsetX[l1], p_149674_3_, p_149674_4_ + Direction.offsetZ[k1] + Direction.offsetZ[l1], this, 1 << (k1 + 2 & 3), 2);
+ bukkitBlock = p_149674_1_.getWorld().getBlockAt(p_149674_2_ + Direction.offsetX[k1] + Direction.offsetX[l1], p_149674_3_, p_149674_4_ + Direction.offsetZ[k1] + Direction.offsetZ[l1]);
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, 1 << (k1 + 2 & 3));
}
else if ((i1 & 1 << i2) != 0 && p_149674_1_.isAirBlock(p_149674_2_ + Direction.offsetX[k1] + Direction.offsetX[i2], p_149674_3_, p_149674_4_ + Direction.offsetZ[k1] + Direction.offsetZ[i2]) && this.func_150093_a(p_149674_1_.getBlock(p_149674_2_ + Direction.offsetX[i2], p_149674_3_, p_149674_4_ + Direction.offsetZ[i2])))
{
- p_149674_1_.setBlock(p_149674_2_ + Direction.offsetX[k1] + Direction.offsetX[i2], p_149674_3_, p_149674_4_ + Direction.offsetZ[k1] + Direction.offsetZ[i2], this, 1 << (k1 + 2 & 3), 2);
+ bukkitBlock = p_149674_1_.getWorld().getBlockAt(p_149674_2_ + Direction.offsetX[k1] + Direction.offsetX[i2], p_149674_3_, p_149674_4_ + Direction.offsetZ[k1] + Direction.offsetZ[i2]);
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, 1 << (k1 + 2 & 3));
}
else if (this.func_150093_a(p_149674_1_.getBlock(p_149674_2_ + Direction.offsetX[k1], p_149674_3_ + 1, p_149674_4_ + Direction.offsetZ[k1])))
{
- p_149674_1_.setBlock(p_149674_2_ + Direction.offsetX[k1], p_149674_3_, p_149674_4_ + Direction.offsetZ[k1], this, 0, 2);
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, 0);
}
+
+ // CraftBukkit end
}
else if (block.blockMaterial.isOpaque() && block.renderAsNormalBlock())
{
@@ -327,7 +340,11 @@
if (l1 > 0)
{
- p_149674_1_.setBlock(p_149674_2_, p_149674_3_ - 1, p_149674_4_, this, l1, 2);
+ // CraftBukkit start - Call BlockSpreadEvent
+ org.bukkit.block.Block source = p_149674_1_.getWorld().getBlockAt(p_149674_2_, p_149674_3_, p_149674_4_);
+ org.bukkit.block.Block bukkitBlock = p_149674_1_.getWorld().getBlockAt(p_149674_2_, p_149674_3_ - 1, p_149674_4_);
+ CraftEventFactory.handleBlockSpreadEvent(bukkitBlock, source, this, l1);
+ // CraftBukkit end
}
}
else if (block == this)

View File

@ -0,0 +1,26 @@
--- ../src-base/minecraft/net/minecraft/client/Minecraft.java
+++ ../src-work/minecraft/net/minecraft/client/Minecraft.java
@@ -148,6 +148,7 @@
import net.minecraft.util.Timer;
import net.minecraft.util.Util;
import net.minecraft.world.EnumDifficulty;
+import net.minecraft.world.MinecraftException;
import net.minecraft.world.WorldProviderEnd;
import net.minecraft.world.WorldProviderHell;
import net.minecraft.world.WorldSettings;
@@ -2644,7 +2645,14 @@
if (integratedserver != null)
{
- integratedserver.stopServer();
+ try
+ {
+ integratedserver.stopServer();
+ }
+ catch (MinecraftException e)
+ {
+ e.printStackTrace();
+ }
}
}
}

View File

@ -0,0 +1,74 @@
--- ../src-base/minecraft/net/minecraft/command/CommandHandler.java
+++ ../src-work/minecraft/net/minecraft/command/CommandHandler.java
@@ -16,6 +16,11 @@
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.CommandEvent;
+// Cauldron start
+import org.bukkit.craftbukkit.command.CraftSimpleCommandMap;
+import org.bukkit.craftbukkit.command.ModCustomCommand;
+import cpw.mods.fml.common.FMLCommonHandler;
+// Cauldron end
public class CommandHandler implements ICommandManager
{
@@ -48,7 +53,7 @@
throw new CommandNotFoundException();
}
- if (icommand.canCommandSenderUseCommand(p_71556_1_))
+ if (true || icommand.canCommandSenderUseCommand(p_71556_1_)) // Cauldron start - disable check for permissions since we handle it on Bukkit side
{
CommandEvent event = new CommandEvent(icommand, p_71556_1_, astring);
if (MinecraftForge.EVENT_BUS.post(event))
@@ -134,11 +139,30 @@
public ICommand registerCommand(ICommand p_71560_1_)
{
- List list = p_71560_1_.getCommandAliases();
- this.commandMap.put(p_71560_1_.getCommandName(), p_71560_1_);
- this.commandSet.add(p_71560_1_);
+ // Cauldron start - register commands with permission nodes, defaulting to class name
+ return registerCommand(p_71560_1_, p_71560_1_.getClass().getName());
+ }
+ public ICommand registerCommand(String permissionGroup, ICommand par1ICommand)
+ {
+ return registerCommand(par1ICommand, permissionGroup + "." + par1ICommand.getCommandName());
+ }
+
+ public ICommand registerCommand(ICommand par1ICommand, String permissionNode)
+ {
+ List list = par1ICommand.getCommandAliases();
+ this.commandMap.put(par1ICommand.getCommandName(), par1ICommand);
+ this.commandSet.add(par1ICommand);
+ // register vanilla commands with Bukkit to support permissions.
+ CraftSimpleCommandMap commandMap = FMLCommonHandler.instance().getMinecraftServerInstance().server.getCraftCommandMap();
+ ModCustomCommand customCommand = new ModCustomCommand(par1ICommand.getCommandName());
+ customCommand.setPermission(permissionNode);
if (list != null)
+ customCommand.setAliases(list);
+ commandMap.register(par1ICommand.getCommandName(), customCommand);
+ LogManager.getLogger().info("Registered command " + par1ICommand.getCommandName() + " with permission node " + permissionNode);
+
+ if (list != null)
{
Iterator iterator = list.iterator();
@@ -149,13 +173,14 @@
if (icommand1 == null || !icommand1.getCommandName().equals(s))
{
- this.commandMap.put(s, p_71560_1_);
+ this.commandMap.put(s, par1ICommand);
}
}
}
- return p_71560_1_;
+ return par1ICommand;
}
+ // Cauldron end
private static String[] dropFirstString(String[] p_71559_0_)
{

View File

@ -0,0 +1,24 @@
--- ../src-base/minecraft/net/minecraft/command/PlayerSelector.java
+++ ../src-work/minecraft/net/minecraft/command/PlayerSelector.java
@@ -7,6 +7,7 @@
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
+import net.minecraft.command.server.CommandBlockLogic;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ChunkCoordinates;
@@ -51,6 +52,13 @@
public static EntityPlayerMP[] matchPlayers(ICommandSender p_82380_0_, String p_82380_1_)
{
+ // CraftBukkit start
+ if (!(p_82380_0_ instanceof CommandBlockLogic))
+ {
+ return null;
+ }
+
+ // CraftBukkit end
Matcher matcher = tokenPattern.matcher(p_82380_1_);
if (matcher.matches())

View File

@ -0,0 +1,76 @@
--- ../src-base/minecraft/net/minecraft/command/ServerCommandManager.java
+++ ../src-work/minecraft/net/minecraft/command/ServerCommandManager.java
@@ -39,8 +39,16 @@
{
private static final String __OBFID = "CL_00000922";
+ // Cauldron start - moved commands to it's own method to be executed further in server startup + changed to registerVanillaCommand
public ServerCommandManager()
{
+ CommandBase.setAdminCommander(this);
+ }
+
+ public void registerVanillaCommands()
+ {
+ // Cauldron - do not register vanilla commands replaced by Bukkit
+ /*
this.registerCommand(new CommandTime());
this.registerCommand(new CommandGameMode());
this.registerCommand(new CommandDifficulty());
@@ -56,7 +64,6 @@
this.registerCommand(new CommandEmote());
this.registerCommand(new CommandShowSeed());
this.registerCommand(new CommandHelp());
- this.registerCommand(new CommandDebug());
this.registerCommand(new CommandMessage());
this.registerCommand(new CommandBroadcast());
this.registerCommand(new CommandSetSpawnpoint());
@@ -64,17 +71,23 @@
this.registerCommand(new CommandGameRule());
this.registerCommand(new CommandClearInventory());
this.registerCommand(new CommandTestFor());
- this.registerCommand(new CommandSpreadPlayers());
- this.registerCommand(new CommandPlaySound());
- this.registerCommand(new CommandScoreboard());
- this.registerCommand(new CommandAchievement());
- this.registerCommand(new CommandSummon());
- this.registerCommand(new CommandSetBlock());
- this.registerCommand(new CommandTestForBlock());
- this.registerCommand(new CommandMessageRaw());
+ */
+ // Cauldron start - add permission nodes for rest of vanilla commands
+ this.registerCommand("vanilla.command", new CommandDebug());
+ this.registerCommand("vanilla.command", new CommandSpreadPlayers());
+ this.registerCommand("vanilla.command", new CommandPlaySound());
+ this.registerCommand("vanilla.command", new CommandScoreboard());
+ this.registerCommand("vanilla.command", new CommandAchievement());
+ this.registerCommand("vanilla.command", new CommandSummon());
+ this.registerCommand("vanilla.command", new CommandSetBlock());
+ this.registerCommand("vanilla.command", new CommandTestForBlock());
+ this.registerCommand("vanilla.command", new CommandMessageRaw());
+ this.registerCommand("vanilla.command", new CommandNetstat());
+ // Cauldron end
if (MinecraftServer.getServer().isDedicatedServer())
{
+ /*
this.registerCommand(new CommandOp());
this.registerCommand(new CommandDeOp());
this.registerCommand(new CommandStop());
@@ -90,7 +103,7 @@
this.registerCommand(new CommandListPlayers());
this.registerCommand(new CommandWhitelist());
this.registerCommand(new CommandSetPlayerTimeout());
- this.registerCommand(new CommandNetstat());
+ */
}
else
{
@@ -98,6 +111,7 @@
}
CommandBase.setAdminCommander(this);
+ // Cauldron end
}
public void func_152372_a(ICommandSender p_152372_1_, ICommand p_152372_2_, int p_152372_3_, String p_152372_4_, Object ... p_152372_5_)

View File

@ -0,0 +1,212 @@
--- ../src-base/minecraft/net/minecraft/command/server/CommandBlockLogic.java
+++ ../src-work/minecraft/net/minecraft/command/server/CommandBlockLogic.java
@@ -9,18 +9,30 @@
import net.minecraft.command.ICommandSender;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.server.MinecraftServer;
+import net.minecraft.tileentity.TileEntityCommandBlockListener;
import net.minecraft.util.ChatComponentText;
import net.minecraft.util.IChatComponent;
import net.minecraft.world.World;
+// CraftBukkit start
+import java.util.ArrayList;
+import org.apache.logging.log4j.Level;
+import org.bukkit.craftbukkit.command.VanillaCommandWrapper;
+import com.google.common.base.Joiner;
+import net.minecraft.command.PlayerSelector;
+import net.minecraft.entity.EntityMinecartCommandBlockListener;
+import net.minecraft.entity.player.EntityPlayerMP;
+// CraftBukkit end
+
public abstract class CommandBlockLogic implements ICommandSender
{
private static final SimpleDateFormat field_145766_a = new SimpleDateFormat("HH:mm:ss");
private int field_145764_b;
private boolean field_145765_c = true;
private IChatComponent field_145762_d = null;
- private String field_145763_e = "";
+ public String field_145763_e = ""; // CraftBukkit - private -> public
private String field_145761_f = "@";
+ protected org.bukkit.command.CommandSender sender; // CraftBukkit - add sender;
private static final String __OBFID = "CL_00000128";
public int func_145760_g()
@@ -94,8 +106,143 @@
if (minecraftserver != null && minecraftserver.isCommandBlockEnabled())
{
- ICommandManager icommandmanager = minecraftserver.getCommandManager();
- this.field_145764_b = icommandmanager.executeCommand(this, this.field_145763_e);
+ // CraftBukkit start - Handle command block commands using Bukkit dispatcher
+ org.bukkit.command.SimpleCommandMap commandMap = minecraftserver.server.getCommandMap();
+ Joiner joiner = Joiner.on(" ");
+ String command = this.field_145763_e;
+
+ if (this.field_145763_e.startsWith("/"))
+ {
+ command = this.field_145763_e.substring(1);
+ }
+
+ String[] args = command.split(" ");
+ ArrayList<String[]> commands = new ArrayList<String[]>();
+
+ // Block disallowed commands
+ if (args[0].equalsIgnoreCase("stop") || args[0].equalsIgnoreCase("kick") || args[0].equalsIgnoreCase("op") ||
+ args[0].equalsIgnoreCase("deop") || args[0].equalsIgnoreCase("ban") || args[0].equalsIgnoreCase("ban-ip") ||
+ args[0].equalsIgnoreCase("pardon") || args[0].equalsIgnoreCase("pardon-ip") || args[0].equalsIgnoreCase("reload"))
+ {
+ this.field_145764_b = 0;
+ return;
+ }
+
+ // If the world has no players don't run
+ if (this.getEntityWorld().playerEntities.isEmpty())
+ {
+ this.field_145764_b = 0;
+ return;
+ }
+
+ // Handle vanilla commands;
+ if (minecraftserver.server.getCommandBlockOverride(args[0]))
+ {
+ org.bukkit.command.Command commandBlockCommand = commandMap.getCommand("minecraft:" + args[0]);
+
+ if (commandBlockCommand instanceof VanillaCommandWrapper)
+ {
+ this.field_145764_b = ((VanillaCommandWrapper) commandBlockCommand).dispatchVanillaCommandBlock(this, this.field_145763_e);
+ return;
+ }
+ }
+
+ // Make sure this is a valid command
+ if (commandMap.getCommand(args[0]) == null)
+ {
+ // Cauldron start - execute command using the vanilla command manager if it isn't in the bukkit command map
+ net.minecraft.command.ICommandManager icommandmanager = minecraftserver.getCommandManager();
+ icommandmanager.executeCommand(this, this.field_145763_e);
+ return;
+ // Cauldron end
+ }
+
+ // testfor command requires special handling
+ if (args[0].equalsIgnoreCase("testfor"))
+ {
+ if (args.length < 2)
+ {
+ this.field_145764_b = 0;
+ return;
+ }
+
+ EntityPlayerMP[] players = PlayerSelector.matchPlayers(this, args[1]);
+
+ if (players != null && players.length > 0)
+ {
+ this.field_145764_b = players.length;
+ return;
+ }
+ else
+ {
+ EntityPlayerMP player = MinecraftServer.getServer().getConfigurationManager().func_152612_a(args[1]);
+
+ if (player == null)
+ {
+ this.field_145764_b = 0;
+ return;
+ }
+ else
+ {
+ this.field_145764_b = 1;
+ return;
+ }
+ }
+ }
+
+ commands.add(args);
+ // Find positions of command block syntax, if any
+ ArrayList<String[]> newCommands = new ArrayList<String[]>();
+
+ for (int i = 0; i < args.length; i++)
+ {
+ if (PlayerSelector.hasArguments(args[i]))
+ {
+ for (int j = 0; j < commands.size(); j++)
+ {
+ newCommands.addAll(this.buildCommands(commands.get(j), i));
+ }
+
+ ArrayList<String[]> temp = commands;
+ commands = newCommands;
+ newCommands = temp;
+ newCommands.clear();
+ }
+ }
+
+ int completed = 0;
+
+ // Now dispatch all of the commands we ended up with
+ for (int i = 0; i < commands.size(); i++)
+ {
+ try
+ {
+ if (commandMap.dispatch(sender, joiner.join(java.util.Arrays.asList(commands.get(i)))))
+ {
+ completed++;
+ }
+ }
+ catch (Throwable exception)
+ {
+ if (this instanceof TileEntityCommandBlockListener)
+ {
+ TileEntityCommandBlockListener listener = (TileEntityCommandBlockListener) this;
+ MinecraftServer.getLogger().log(Level.WARN, String.format("CommandBlock at (%d,%d,%d) failed to handle command", listener.getPlayerCoordinates().posX, listener.getPlayerCoordinates().posY, listener.getPlayerCoordinates().posZ), exception);
+ }
+ else if (this instanceof EntityMinecartCommandBlockListener)
+ {
+ EntityMinecartCommandBlockListener listener = (EntityMinecartCommandBlockListener) this;
+ MinecraftServer.getLogger().log(Level.WARN, String.format("MinecartCommandBlock at (%d,%d,%d) failed to handle command", listener.getPlayerCoordinates().posX, listener.getPlayerCoordinates().posY, listener.getPlayerCoordinates().posZ), exception);
+ }
+ else
+ {
+ MinecraftServer.getLogger().log(Level.WARN, String.format("Unknown CommandBlock failed to handle command"), exception);
+ }
+ }
+ }
+
+ this.field_145764_b = completed;
+ // CraftBukkit end
}
else
{
@@ -103,6 +250,31 @@
}
}
+ // CraftBukkit start
+ private ArrayList<String[]> buildCommands(String[] args, int pos)
+ {
+ ArrayList<String[]> commands = new ArrayList<String[]>();
+ EntityPlayerMP[] players = PlayerSelector.matchPlayers(this, args[pos]);
+
+ if (players != null)
+ {
+ for (EntityPlayerMP player : players)
+ {
+ if (player.worldObj != this.getEntityWorld())
+ {
+ continue;
+ }
+
+ String[] command = args.clone();
+ command[pos] = player.getCommandSenderName();
+ commands.add(command);
+ }
+ }
+
+ return commands;
+ }
+ // CraftBukkit end
+
public String getCommandSenderName()
{
return this.field_145761_f;

View File

@ -0,0 +1,101 @@
--- ../src-base/minecraft/net/minecraft/dispenser/BehaviorDefaultDispenseItem.java
+++ ../src-work/minecraft/net/minecraft/dispenser/BehaviorDefaultDispenseItem.java
@@ -6,6 +6,11 @@
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
+// CraftBukkit start
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.block.BlockDispenseEvent;
+// CraftBukkit end
+
public class BehaviorDefaultDispenseItem implements IBehaviorDispenseItem
{
private static final String __OBFID = "CL_00001195";
@@ -23,10 +28,17 @@
EnumFacing enumfacing = BlockDispenser.func_149937_b(p_82487_1_.getBlockMetadata());
IPosition iposition = BlockDispenser.func_149939_a(p_82487_1_);
ItemStack itemstack1 = p_82487_2_.splitStack(1);
- doDispense(p_82487_1_.getWorld(), itemstack1, 6, enumfacing, iposition);
+ // CraftBukkit start
+ if (!doDispense(p_82487_1_.getWorld(), itemstack1, 6, enumfacing, p_82487_1_))
+ {
+ p_82487_2_.stackSize++;
+ }
+
+ // CraftBukkit end
return p_82487_2_;
}
+ // Cauldron start - vanilla compatibility
public static void doDispense(World p_82486_0_, ItemStack p_82486_1_, int p_82486_2_, EnumFacing p_82486_3_, IPosition p_82486_4_)
{
double d0 = p_82486_4_.getX();
@@ -42,7 +54,67 @@
entityitem.motionZ += p_82486_0_.rand.nextGaussian() * 0.007499999832361937D * (double)p_82486_2_;
p_82486_0_.spawnEntityInWorld(entityitem);
}
+ // Cauldron end
+ // CraftBukkit start - void -> boolean return, IPosition -> ISourceBlock last argument
+ public static boolean doDispense(World world, ItemStack itemstack, int i, EnumFacing enumfacing, IBlockSource iblocksource)
+ {
+ IPosition iposition = BlockDispenser.func_149939_a(iblocksource);
+ // CraftBukkit end
+ double d0 = iposition.getX();
+ double d1 = iposition.getY();
+ double d2 = iposition.getZ();
+ EntityItem entityitem = new EntityItem(world, d0, d1 - 0.3D, d2, itemstack);
+ double d3 = world.rand.nextDouble() * 0.1D + 0.2D;
+ entityitem.motionX = (double) enumfacing.getFrontOffsetX() * d3;
+ entityitem.motionY = 0.20000000298023224D;
+ entityitem.motionZ = (double) enumfacing.getFrontOffsetZ() * d3;
+ entityitem.motionX += world.rand.nextGaussian() * 0.007499999832361937D * (double) i;
+ entityitem.motionY += world.rand.nextGaussian() * 0.007499999832361937D * (double) i;
+ entityitem.motionZ += world.rand.nextGaussian() * 0.007499999832361937D * (double) i;
+ // CraftBukkit start
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(iblocksource.getXInt(), iblocksource.getYInt(), iblocksource.getZInt());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack);
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector(entityitem.motionX, entityitem.motionY, entityitem.motionZ));
+
+ if (!BlockDispenser.eventFired)
+ {
+ world.getServer().getPluginManager().callEvent(event);
+ }
+
+ if (event.isCancelled())
+ {
+ return false;
+ }
+
+ entityitem.setEntityItemStack(CraftItemStack.asNMSCopy(event.getItem()));
+ entityitem.motionX = event.getVelocity().getX();
+ entityitem.motionY = event.getVelocity().getY();
+ entityitem.motionZ = event.getVelocity().getZ();
+
+ if (!event.getItem().equals(craftItem))
+ {
+ // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IBehaviorDispenseItem ibehaviordispenseitem = (IBehaviorDispenseItem) BlockDispenser.dispenseBehaviorRegistry.getObject(eventStack.getItem());
+
+ if (ibehaviordispenseitem != IBehaviorDispenseItem.itemDispenseBehaviorProvider && ibehaviordispenseitem.getClass() != BehaviorDefaultDispenseItem.class)
+ {
+ ibehaviordispenseitem.dispense(iblocksource, eventStack);
+ }
+ else
+ {
+ world.spawnEntityInWorld(entityitem);
+ }
+
+ return false;
+ }
+
+ world.spawnEntityInWorld(entityitem);
+ return true;
+ // CraftBukkit end
+ }
+
protected void playDispenseSound(IBlockSource p_82485_1_)
{
p_82485_1_.getWorld().playAuxSFX(1000, p_82485_1_.getXInt(), p_82485_1_.getYInt(), p_82485_1_.getZInt(), 0);

View File

@ -0,0 +1,59 @@
--- ../src-base/minecraft/net/minecraft/dispenser/BehaviorProjectileDispense.java
+++ ../src-work/minecraft/net/minecraft/dispenser/BehaviorProjectileDispense.java
@@ -7,6 +7,12 @@
import net.minecraft.util.EnumFacing;
import net.minecraft.world.World;
+// CraftBukkit start
+import net.minecraft.tileentity.TileEntityDispenser;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.block.BlockDispenseEvent;
+// CraftBukkit end
+
public abstract class BehaviorProjectileDispense extends BehaviorDefaultDispenseItem
{
private static final String __OBFID = "CL_00001394";
@@ -17,9 +23,42 @@
IPosition iposition = BlockDispenser.func_149939_a(p_82487_1_);
EnumFacing enumfacing = BlockDispenser.func_149937_b(p_82487_1_.getBlockMetadata());
IProjectile iprojectile = this.getProjectileEntity(world, iposition);
+ // CraftBukkit start
+ ItemStack itemstack1 = p_82487_2_.splitStack(1);
+ org.bukkit.block.Block block = world.getWorld().getBlockAt(p_82487_1_.getXInt(), p_82487_1_.getYInt(), p_82487_1_.getZInt());
+ CraftItemStack craftItem = CraftItemStack.asCraftMirror(itemstack1);
+ BlockDispenseEvent event = new BlockDispenseEvent(block, craftItem.clone(), new org.bukkit.util.Vector((double) enumfacing.getFrontOffsetX(), (double)((float) enumfacing.getFrontOffsetY() + 0.1F), (double) enumfacing.getFrontOffsetZ()));
+
+ if (!BlockDispenser.eventFired)
+ {
+ world.getServer().getPluginManager().callEvent(event);
+ }
+
+ if (event.isCancelled())
+ {
+ p_82487_2_.stackSize++;
+ return p_82487_2_;
+ }
+
+ if (!event.getItem().equals(craftItem))
+ {
+ p_82487_2_.stackSize++;
+ // Chain to handler for new item
+ ItemStack eventStack = CraftItemStack.asNMSCopy(event.getItem());
+ IBehaviorDispenseItem ibehaviordispenseitem = (IBehaviorDispenseItem) BlockDispenser.dispenseBehaviorRegistry.getObject(eventStack.getItem());
+
+ if (ibehaviordispenseitem != IBehaviorDispenseItem.itemDispenseBehaviorProvider && ibehaviordispenseitem != this)
+ {
+ ibehaviordispenseitem.dispense(p_82487_1_, eventStack);
+ return p_82487_2_;
+ }
+ }
+
iprojectile.setThrowableHeading((double)enumfacing.getFrontOffsetX(), (double)((float)enumfacing.getFrontOffsetY() + 0.1F), (double)enumfacing.getFrontOffsetZ(), this.func_82500_b(), this.func_82498_a());
+ ((Entity) iprojectile).projectileSource = new org.bukkit.craftbukkit.projectiles.CraftBlockProjectileSource((TileEntityDispenser) p_82487_1_.getBlockTileEntity());
+ // CraftBukkit end
world.spawnEntityInWorld((Entity)iprojectile);
- p_82487_2_.splitStack(1);
+ // p_82487_2_.splitStack(1); // CraftBukkit - Handled during event processing
return p_82487_2_;
}

View File

@ -0,0 +1,11 @@
--- ../src-base/minecraft/net/minecraft/enchantment/Enchantment.java
+++ ../src-work/minecraft/net/minecraft/enchantment/Enchantment.java
@@ -56,6 +56,8 @@
{
enchantmentsList[p_i1926_1_] = this;
}
+
+ org.bukkit.enchantments.Enchantment.registerEnchantment(new org.bukkit.craftbukkit.enchantments.CraftEnchantment(this)); // CraftBukkit
}
public int getWeight()

View File

@ -0,0 +1,775 @@
--- ../src-base/minecraft/net/minecraft/entity/Entity.java
+++ ../src-work/minecraft/net/minecraft/entity/Entity.java
@@ -45,13 +45,51 @@
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
+import net.minecraftforge.cauldron.CauldronHooks;
import net.minecraftforge.common.IExtendedEntityProperties;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.EntityEvent;
import net.minecraftforge.fluids.IFluidBlock;
+// CraftBukkit start
+import net.minecraft.entity.passive.EntityTameable;
+import net.minecraft.entity.player.EntityPlayerMP;
+import org.bukkit.Bukkit;
+import org.bukkit.Location;
+import org.bukkit.Server;
+import org.bukkit.TravelAgent;
+import org.bukkit.block.BlockFace;
+import org.bukkit.entity.Hanging;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.entity.Painting;
+import org.bukkit.entity.Vehicle;
+import org.spigotmc.CustomTimingsHandler; // Spigot
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
+import org.bukkit.event.painting.PaintingBreakByEntityEvent;
+import org.bukkit.event.vehicle.VehicleBlockCollisionEvent;
+import org.bukkit.event.vehicle.VehicleEnterEvent;
+import org.bukkit.event.vehicle.VehicleExitEvent;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.entity.CraftEntity;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityCombustEvent;
+import org.bukkit.event.entity.EntityPortalEvent;
+import org.bukkit.event.hanging.HangingBreakByEntityEvent;
+import org.bukkit.plugin.PluginManager;
+// CraftBukkit end
+import net.minecraft.world.Teleporter; // Cauldron
+
public abstract class Entity
{
+ // CraftBukkit start
+ private static final int CURRENT_LEVEL = 2;
+ static boolean isLevelAtLeast(NBTTagCompound tag, int level)
+ {
+ return tag.hasKey("Bukkit.updateLevel") && tag.getInteger("Bukkit.updateLevel") >= level;
+ }
+ // CraftBukkit end
+
private static int nextEntityID;
private int entityId;
public double renderDistanceWeight;
@@ -100,12 +138,12 @@
protected Random rand;
public int ticksExisted;
public int fireResistance;
- private int fire;
- protected boolean inWater;
+ public int fire; // CraftBukkit - private -> public
+ public boolean inWater; // Spigot - protected -> public
public int hurtResistantTime;
private boolean firstUpdate;
protected boolean isImmuneToFire;
- protected DataWatcher dataWatcher;
+ public DataWatcher dataWatcher; // CraftBukkit - protected -> public
private double entityRiderPitchDelta;
private double entityRiderYawDelta;
public boolean addedToChunk;
@@ -126,8 +164,10 @@
public int dimension;
protected int teleportDirection;
private boolean invulnerable;
- protected UUID entityUniqueID;
+ public UUID entityUniqueID; // CraftBukkit - protected -> public
public Entity.EnumEntitySize myEntitySize;
+ public boolean valid; // CraftBukkit
+ public org.bukkit.projectiles.ProjectileSource projectileSource; // CraftBukkit - For projectiles only
private static final String __OBFID = "CL_00001533";
/** Forge: Used to store custom data for each entity. */
private NBTTagCompound customEntityData;
@@ -135,7 +175,16 @@
public ArrayList<EntityItem> capturedDrops = new ArrayList<EntityItem>();
private UUID persistentID;
+ // Spigot start
+ public CustomTimingsHandler tickTimer = org.bukkit.craftbukkit.SpigotTimings.getEntityTimings(this); // Spigot
+ public final byte activationType = org.spigotmc.ActivationRange.initializeEntityActivationType(this);
+ public final boolean defaultActivationState;
+ public long activatedTick = 0;
+ public boolean fromMobSpawner;
+ public void inactiveTick() { }
+ // Spigot end
protected HashMap<String, IExtendedEntityProperties> extendedProperties;
+ public String spawnReason; // Cauldron - used to handle CraftBukkit's SpawnReason with CustomSpawners
public int getEntityId()
{
@@ -159,7 +208,7 @@
this.rand = new Random();
this.fireResistance = 1;
this.firstUpdate = true;
- this.entityUniqueID = UUID.randomUUID();
+ this.entityUniqueID = new UUID(rand.nextLong(), rand.nextLong()); // Spigot
this.myEntitySize = Entity.EnumEntitySize.SIZE_2;
this.worldObj = p_i1582_1_;
this.setPosition(0.0D, 0.0D, 0.0D);
@@ -167,8 +216,15 @@
if (p_i1582_1_ != null)
{
this.dimension = p_i1582_1_.provider.dimensionId;
+ // Spigot start
+ this.defaultActivationState = org.spigotmc.ActivationRange.initializeEntityActivationState(this, p_i1582_1_.getSpigotConfig()); // Cauldron
}
+ else
+ {
+ this.defaultActivationState = false;
+ }
+ // Spigot end
this.dataWatcher = new DataWatcher(this);
this.dataWatcher.addObject(0, Byte.valueOf((byte)0));
this.dataWatcher.addObject(1, Short.valueOf((short)300));
@@ -277,6 +333,41 @@
protected void setRotation(float p_70101_1_, float p_70101_2_)
{
+ // CraftBukkit start - yaw was sometimes set to NaN, so we need to set it back to 0
+ if (Float.isNaN(p_70101_1_))
+ {
+ p_70101_1_ = 0;
+ }
+
+ if ((p_70101_1_ == Float.POSITIVE_INFINITY) || (p_70101_1_ == Float.NEGATIVE_INFINITY))
+ {
+ if (this instanceof EntityPlayerMP)
+ {
+ this.worldObj.getServer().getLogger().warning(((CraftPlayer) this.getBukkitEntity()).getName() + " was caught trying to crash the server with an invalid yaw");
+ ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Nope");
+ }
+
+ p_70101_1_ = 0;
+ }
+
+ // pitch was sometimes set to NaN, so we need to set it back to 0.
+ if (Float.isNaN(p_70101_2_))
+ {
+ p_70101_2_ = 0;
+ }
+
+ if ((p_70101_2_ == Float.POSITIVE_INFINITY) || (p_70101_2_ == Float.NEGATIVE_INFINITY))
+ {
+ if (this instanceof EntityPlayerMP)
+ {
+ this.worldObj.getServer().getLogger().warning(((CraftPlayer) this.getBukkitEntity()).getName() + " was caught trying to crash the server with an invalid pitch");
+ ((CraftPlayer) this.getBukkitEntity()).kickPlayer("Nope");
+ }
+
+ p_70101_2_ = 0;
+ }
+
+ // CraftBukkit end
this.rotationYaw = p_70101_1_ % 360.0F;
this.rotationPitch = p_70101_2_ % 360.0F;
}
@@ -343,7 +434,7 @@
if (this.inPortal)
{
- if (minecraftserver.getAllowNether())
+ if (true || minecraftserver.getAllowNether()) // CraftBukkit
{
if (this.ridingEntity == null && this.portalCounter++ >= i)
{
@@ -457,7 +548,35 @@
{
if (!this.isImmuneToFire)
{
- this.attackEntityFrom(DamageSource.lava, 4.0F);
+ // CraftBukkit start - Fallen in lava TODO: this event spams!
+ this.attackEntityFrom(DamageSource.lava, 4);
+
+ if (this instanceof EntityLivingBase)
+ {
+ if (this.fire <= 0)
+ {
+ // not on fire yet
+ // TODO: shouldn't be sending null for the block.
+ org.bukkit.block.Block damager = null; // ((WorldServer) this.l).getWorld().getBlockAt(i, j, k);
+ org.bukkit.entity.Entity damagee = this.getBukkitEntity();
+ EntityCombustEvent combustEvent = new org.bukkit.event.entity.EntityCombustByBlockEvent(damager, damagee, 15);
+ this.worldObj.getServer().getPluginManager().callEvent(combustEvent);
+
+ if (!combustEvent.isCancelled())
+ {
+ this.setFire(combustEvent.getDuration());
+ }
+ }
+ else
+ {
+ // This will be called every single tick the entity is in lava, so don't throw an event
+ this.setFire(15);
+ }
+
+ return;
+ }
+
+ // CraftBukkit end - we also don't throw an event unless the object in lava is living, to save on some event calls
this.setFire(15);
}
}
@@ -492,6 +611,30 @@
public void moveEntity(double p_70091_1_, double p_70091_3_, double p_70091_5_)
{
+ // CraftBukkit start - Don't do anything if we aren't moving
+ // We need to do this regardless of whether or not we are moving thanks to portals
+ try
+ {
+ this.func_145775_I();
+ }
+ catch (Throwable throwable)
+ {
+ CrashReport crashreport = CrashReport.makeCrashReport(throwable, "Checking entity block collision");
+ CrashReportCategory crashreportcategory = crashreport.makeCategory("Entity being checked for collision");
+ this.addEntityCrashInfo(crashreportcategory);
+ throw new ReportedException(crashreport);
+ }
+
+ // Check if we're moving
+ if (p_70091_1_ == 0 && p_70091_3_ == 0 && p_70091_5_ == 0 && this.ridingEntity == null && this.riddenByEntity == null)
+ {
+ return;
+ }
+
+ // CraftBukkit end
+ if (!CauldronHooks.checkEntitySpeed(this, p_70091_1_, p_70091_3_, p_70091_5_)) return; // Check for entities violating the speed limit
+ org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.startTiming(); // Spigot
+
if (this.noClip)
{
this.boundingBox.offset(p_70091_1_, p_70091_3_, p_70091_5_);
@@ -756,6 +899,35 @@
d10 = this.posY - d4;
d11 = this.posZ - d5;
+ // CraftBukkit start
+ if ((this.isCollidedHorizontally) && (this.getBukkitEntity() instanceof Vehicle))
+ {
+ 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));
+
+ if (d6 > p_70091_1_)
+ {
+ block = block.getRelative(BlockFace.EAST);
+ }
+ else if (d6 < p_70091_1_)
+ {
+ block = block.getRelative(BlockFace.WEST);
+ }
+ else if (d8 > p_70091_5_)
+ {
+ block = block.getRelative(BlockFace.SOUTH);
+ }
+ else if (d8 < p_70091_5_)
+ {
+ block = block.getRelative(BlockFace.NORTH);
+ }
+
+ VehicleBlockCollisionEvent event = new VehicleBlockCollisionEvent(vehicle, block);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+ }
+
+ // CraftBukkit end
+
if (this.canTriggerWalking() && !flag && this.ridingEntity == null)
{
int j1 = MathHelper.floor_double(this.posX);
@@ -798,6 +970,8 @@
}
}
+ // CraftBukkit start - Move to the top of the method
+ /*
try
{
this.func_145775_I();
@@ -809,7 +983,8 @@
this.addEntityCrashInfo(crashreportcategory);
throw new ReportedException(crashreport);
}
-
+ */
+ // CraftBukkit end
boolean flag2 = this.isWet();
if (this.worldObj.func_147470_e(this.boundingBox.contract(0.001D, 0.001D, 0.001D)))
@@ -820,8 +995,20 @@
{
++this.fire;
- if (this.fire == 0)
+ // CraftBukkit start - Not on fire yet
+ if (this.fire <= 0) // Only throw events on the first combust, otherwise it spams
{
+ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ this.setFire(event.getDuration());
+ }
+ }
+ else
+ {
+ // CraftBukkit end
this.setFire(8);
}
}
@@ -839,6 +1026,8 @@
this.worldObj.theProfiler.endSection();
}
+
+ org.bukkit.craftbukkit.SpigotTimings.entityMoveTimer.stopTiming(); // Spigot
}
protected String getSwimSound()
@@ -867,7 +1056,11 @@
try
{
+ // Cauldron start - damage hook for custom blocks
+ CraftEventFactory.blockDamage = this.worldObj.getWorld().getBlockAt(k1, l1, i2);
block.onEntityCollidedWithBlock(this.worldObj, k1, l1, i2, this);
+ CraftEventFactory.blockDamage = null;
+ // Cauldron end
}
catch (Throwable throwable)
{
@@ -928,6 +1121,7 @@
return null;
}
+ // Cauldron start - vanilla compatibility
protected void dealFireDamage(int p_70081_1_)
{
if (!this.isImmuneToFire)
@@ -935,7 +1129,16 @@
this.attackEntityFrom(DamageSource.inFire, (float)p_70081_1_);
}
}
+ // Cauldron end
+ protected void dealFireDamage(float par1) // CraftBukkit signature change
+ {
+ if (!this.isImmuneToFire)
+ {
+ this.attackEntityFrom(DamageSource.inFire, (float)par1);
+ }
+ }
+
public final boolean isImmuneToFire()
{
return this.isImmuneToFire;
@@ -1184,6 +1387,8 @@
public void onCollideWithPlayer(EntityPlayer p_70100_1_) {}
+ int numCollisions = 0; // Spigot
+
public void applyEntityCollision(Entity p_70108_1_)
{
if (p_70108_1_.riddenByEntity != this && p_70108_1_.ridingEntity != this)
@@ -1310,6 +1515,20 @@
{
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}));
+
+ // CraftBukkit start - Checking for NaN pitch/yaw and resetting to zero
+ // TODO: make sure this is the best way to address this.
+ if (Float.isNaN(this.rotationYaw))
+ {
+ this.rotationYaw = 0;
+ }
+
+ if (Float.isNaN(this.rotationPitch))
+ {
+ this.rotationPitch = 0;
+ }
+
+ // CraftBukkit end
p_70109_1_.setTag("Rotation", this.newFloatNBTList(new float[] {this.rotationYaw, this.rotationPitch}));
p_70109_1_.setFloat("FallDistance", this.fallDistance);
p_70109_1_.setShort("Fire", (short)this.fire);
@@ -1320,6 +1539,12 @@
p_70109_1_.setInteger("PortalCooldown", this.timeUntilPortal);
p_70109_1_.setLong("UUIDMost", this.getUniqueID().getMostSignificantBits());
p_70109_1_.setLong("UUIDLeast", this.getUniqueID().getLeastSignificantBits());
+ // CraftBukkit start
+ p_70109_1_.setLong("WorldUUIDLeast", this.worldObj.getSaveHandler().getUUID().getLeastSignificantBits());
+ p_70109_1_.setLong("WorldUUIDMost", this.worldObj.getSaveHandler().getUUID().getMostSignificantBits());
+ p_70109_1_.setInteger("Bukkit.updateLevel", CURRENT_LEVEL);
+ p_70109_1_.setInteger("Spigot.ticksLived", this.ticksExisted);
+ // CraftBukkit end
if (customEntityData != null)
{
p_70109_1_.setTag("ForgeData", customEntityData);
@@ -1370,7 +1595,7 @@
this.motionX = nbttaglist1.func_150309_d(0);
this.motionY = nbttaglist1.func_150309_d(1);
this.motionZ = nbttaglist1.func_150309_d(2);
-
+ /* CraftBukkit start - Moved section down
if (Math.abs(this.motionX) > 10.0D)
{
this.motionX = 0.0D;
@@ -1385,7 +1610,7 @@
{
this.motionZ = 0.0D;
}
-
+ // CraftBukkit end */
this.prevPosX = this.lastTickPosX = this.posX = nbttaglist.func_150309_d(0);
this.prevPosY = this.lastTickPosY = this.posY = nbttaglist.func_150309_d(1);
this.prevPosZ = this.lastTickPosZ = this.posZ = nbttaglist.func_150309_d(2);
@@ -1436,6 +1661,76 @@
{
this.setPosition(this.posX, this.posY, this.posZ);
}
+
+ // CraftBukkit start
+ if (this instanceof EntityLivingBase)
+ {
+ EntityLivingBase entity = (EntityLivingBase) this;
+ this.ticksExisted = p_70020_1_.getInteger("Spigot.ticksLived");
+
+ // Reset the persistence for tamed animals
+ if (entity instanceof EntityTameable && !isLevelAtLeast(p_70020_1_, 2) && !p_70020_1_.getBoolean("PersistenceRequired"))
+ {
+ EntityLiving entityliving = (EntityLiving) entity;
+ entityliving.persistenceRequired = !entityliving.canDespawn();
+ }
+ }
+
+ // CraftBukkit end
+
+ // CraftBukkit start - Exempt Vehicles from notch's sanity check
+ if (!(this.getBukkitEntity() instanceof Vehicle))
+ {
+ if (Math.abs(this.motionX) > 10.0D)
+ {
+ this.motionX = 0.0D;
+ }
+
+ if (Math.abs(this.motionY) > 10.0D)
+ {
+ this.motionY = 0.0D;
+ }
+
+ if (Math.abs(this.motionZ) > 10.0D)
+ {
+ this.motionZ = 0.0D;
+ }
+ }
+
+ // CraftBukkit end
+
+ // CraftBukkit start - Reset world
+ if (this instanceof EntityPlayerMP)
+ {
+ Server server = Bukkit.getServer();
+ org.bukkit.World bworld = null;
+ // TODO: Remove World related checks, replaced with WorldUID.
+ String worldName = p_70020_1_.getString("World");
+
+ if (p_70020_1_.hasKey("WorldUUIDMost") && p_70020_1_.hasKey("WorldUUIDLeast"))
+ {
+ UUID uid = new UUID(p_70020_1_.getLong("WorldUUIDMost"), p_70020_1_.getLong("WorldUUIDLeast"));
+ bworld = server.getWorld(uid);
+ }
+ else
+ {
+ bworld = server.getWorld(worldName);
+ }
+
+ if (bworld == null)
+ {
+ EntityPlayerMP entityPlayer = (EntityPlayerMP) this;
+ // Cauldron start - use CraftBukkit's fallback world code if no valid world is found.
+ entityPlayer.setWorld(MinecraftServer.getServer().worldServerForDimension(entityPlayer.dimension));
+ }
+ else
+ {
+ this.setWorld(((CraftWorld) bworld).getHandle());
+ // Cauldron end
+ }
+ }
+
+ // CraftBukkit end
}
catch (Throwable throwable)
{
@@ -1653,6 +1948,31 @@
public void mountEntity(Entity p_70078_1_)
{
+ // CraftBukkit start
+ this.setPassengerOf(p_70078_1_);
+ }
+
+ protected CraftEntity bukkitEntity;
+
+ public CraftEntity getBukkitEntity()
+ {
+ if (this.bukkitEntity == null)
+ {
+ this.bukkitEntity = CraftEntity.getEntity(this.worldObj.getServer(), this);
+ }
+
+ return this.bukkitEntity;
+ }
+
+ public void setPassengerOf(Entity p_70078_1_)
+ {
+ // mountEntity(null) doesn't really fly for overloaded methods,
+ // so this method is needed
+ Entity originalVehicle = this.ridingEntity;
+ Entity originalPassenger = this.ridingEntity == null ? null : this.ridingEntity.riddenByEntity;
+ PluginManager pluginManager = Bukkit.getPluginManager();
+ this.getBukkitEntity(); // make sure bukkitEntity is initialised
+ // CraftBukkit end
this.entityRiderPitchDelta = 0.0D;
this.entityRiderYawDelta = 0.0D;
@@ -1660,6 +1980,20 @@
{
if (this.ridingEntity != null)
{
+ // CraftBukkit start
+ if ((this.bukkitEntity instanceof LivingEntity) && (this.ridingEntity.getBukkitEntity() instanceof Vehicle))
+ {
+ VehicleExitEvent event = new VehicleExitEvent((Vehicle) this.ridingEntity.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
+ pluginManager.callEvent(event);
+
+ if (event.isCancelled() || this.ridingEntity != originalVehicle)
+ {
+ return;
+ }
+ }
+
+ // CraftBukkit end
+ pluginManager.callEvent(new org.spigotmc.event.entity.EntityDismountEvent(this.getBukkitEntity(), this.ridingEntity.getBukkitEntity())); // Spigot
this.setLocationAndAngles(this.ridingEntity.posX, this.ridingEntity.boundingBox.minY + (double)this.ridingEntity.height, this.ridingEntity.posZ, this.rotationYaw, this.rotationPitch);
this.ridingEntity.riddenByEntity = null;
}
@@ -1668,22 +2002,61 @@
}
else
{
- if (this.ridingEntity != null)
+ // CraftBukkit start
+ if ((this.bukkitEntity instanceof LivingEntity) && (p_70078_1_.getBukkitEntity() instanceof Vehicle) && p_70078_1_.worldObj.chunkExists((int) p_70078_1_.posX >> 4, (int) p_70078_1_.posZ >> 4))
{
- this.ridingEntity.riddenByEntity = null;
- }
+ // It's possible to move from one vehicle to another. We need to check if they're already in a vehicle, and fire an exit event if they are.
+ VehicleExitEvent exitEvent = null;
- if (p_70078_1_ != null)
- {
- for (Entity entity1 = p_70078_1_.ridingEntity; entity1 != null; entity1 = entity1.ridingEntity)
+ if (this.ridingEntity != null && this.ridingEntity.getBukkitEntity() instanceof Vehicle)
{
- if (entity1 == this)
+ exitEvent = new VehicleExitEvent((Vehicle) this.ridingEntity.getBukkitEntity(), (LivingEntity) this.bukkitEntity);
+ pluginManager.callEvent(exitEvent);
+
+ if (exitEvent.isCancelled() || this.ridingEntity != originalVehicle || (this.ridingEntity != null && this.ridingEntity.riddenByEntity != originalPassenger))
{
return;
}
}
+
+ VehicleEnterEvent event = new VehicleEnterEvent((Vehicle) p_70078_1_.getBukkitEntity(), this.bukkitEntity);
+ pluginManager.callEvent(event);
+
+ // If a plugin messes with the vehicle or the vehicle's passenger
+ if (event.isCancelled() || this.ridingEntity != originalVehicle || (this.ridingEntity != null && this.ridingEntity.riddenByEntity != originalPassenger))
+ {
+ // If we only cancelled the enterevent then we need to put the player in a decent position.
+ if (exitEvent != null && this.ridingEntity == originalVehicle && this.ridingEntity != null && this.ridingEntity.riddenByEntity == originalPassenger)
+ {
+ 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 = null;
+ }
+
+ return;
+ }
}
+ // CraftBukkit end
+ // Spigot Start
+ if (p_70078_1_.worldObj.chunkExists((int) p_70078_1_.posX >> 4, (int) p_70078_1_.posZ >> 4))
+ {
+ org.spigotmc.event.entity.EntityMountEvent event = new org.spigotmc.event.entity.EntityMountEvent(this.getBukkitEntity(), p_70078_1_.getBukkitEntity());
+ pluginManager.callEvent(event);
+
+ if (event.isCancelled())
+ {
+ return;
+ }
+ }
+
+ // Spigot End
+
+ if (this.ridingEntity != null)
+ {
+ this.ridingEntity.riddenByEntity = null;
+ }
+
this.ridingEntity = p_70078_1_;
p_70078_1_.riddenByEntity = this;
}
@@ -1860,12 +2233,59 @@
public void onStruckByLightning(EntityLightningBolt p_70077_1_)
{
- this.dealFireDamage(5);
+ // CraftBukkit start
+ final org.bukkit.entity.Entity thisBukkitEntity = this.getBukkitEntity();
+ if (thisBukkitEntity == null) return; // Cauldron - skip mod entities with no wrapper (TODO: create a wrapper)
+ if (p_70077_1_ == null) return; // Cauldron - skip null entities, see #392
+ final org.bukkit.entity.Entity stormBukkitEntity = p_70077_1_.getBukkitEntity();
+ if (stormBukkitEntity == null) return; // Cauldron - skip mod entities with no wrapper (TODO: create a wrapper)
+ final PluginManager pluginManager = Bukkit.getPluginManager();
+
+ if (thisBukkitEntity instanceof Hanging)
+ {
+ HangingBreakByEntityEvent hangingEvent = new HangingBreakByEntityEvent((Hanging) thisBukkitEntity, stormBukkitEntity);
+ PaintingBreakByEntityEvent paintingEvent = null;
+
+ if (thisBukkitEntity instanceof Painting) {
+ paintingEvent = new PaintingBreakByEntityEvent((Painting) thisBukkitEntity, stormBukkitEntity);
+ }
+
+ pluginManager.callEvent(hangingEvent);
+
+ if (paintingEvent != null) {
+ paintingEvent.setCancelled(hangingEvent.isCancelled());
+ pluginManager.callEvent(paintingEvent);
+ }
+
+ if (hangingEvent.isCancelled() || (paintingEvent != null && paintingEvent.isCancelled())) {
+ return;
+ }
+ }
+
+ if (this.isImmuneToFire) {
+ return;
+ }
+ CraftEventFactory.entityDamage = p_70077_1_;
+ if (!this.attackEntityFrom(DamageSource.inFire, 5.0F)) {
+ CraftEventFactory.entityDamage = null;
+ return;
+ }
+
+ // CraftBukkit end
++this.fire;
if (this.fire == 0)
{
- this.setFire(8);
+ // CraftBukkit start - Call a combust event when lightning strikes
+ EntityCombustByEntityEvent entityCombustEvent = new EntityCombustByEntityEvent(stormBukkitEntity, thisBukkitEntity, 8);
+ pluginManager.callEvent(entityCombustEvent);
+
+ if (!entityCombustEvent.isCancelled())
+ {
+ this.setFire(entityCombustEvent.getDuration());
+ }
+
+ // CraftBukkit end
}
}
@@ -2038,36 +2458,62 @@
{
this.worldObj.theProfiler.startSection("changeDimension");
MinecraftServer minecraftserver = MinecraftServer.getServer();
- int j = this.dimension;
- WorldServer worldserver = minecraftserver.worldServerForDimension(j);
- WorldServer worldserver1 = minecraftserver.worldServerForDimension(p_71027_1_);
- this.dimension = p_71027_1_;
+ // CraftBukkit start - Move logic into new function "teleportToLocation"
+ // int j = this.dimension;
+ // Cauldron start - Allow Forge hotloading on teleport
+ WorldServer exitWorld = minecraftserver.worldServerForDimension(p_71027_1_);
- if (j == 1 && p_71027_1_ == 1)
+ Location enter = this.getBukkitEntity().getLocation();
+ Location exit = exitWorld != null ? minecraftserver.getConfigurationManager().calculateTarget(enter, minecraftserver.worldServerForDimension(p_71027_1_)) : null;
+ boolean useTravelAgent = exitWorld != null && !(this.dimension == 1 && exitWorld.dimension == 1); // don't use agent for custom worlds or return from THE_END
+ // Cauldron start - check if teleporter is instance of TravelAgent before attempting to cast to it
+ Teleporter teleporter = exit != null ? ((CraftWorld) exit.getWorld()).getHandle().getDefaultTeleporter() : null;
+ TravelAgent agent = (teleporter != null && teleporter instanceof TravelAgent) ? (TravelAgent)teleporter : org.bukkit.craftbukkit.CraftTravelAgent.DEFAULT; // return arbitrary TA to compensate for implementation dependent plugins
+ // Cauldron end
+ EntityPortalEvent event = new EntityPortalEvent(this.getBukkitEntity(), enter, exit, agent);
+ event.useTravelAgent(useTravelAgent);
+ event.getEntity().getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled() || event.getTo() == null || !this.isEntityAlive())
{
- worldserver1 = minecraftserver.worldServerForDimension(0);
- this.dimension = 0;
+ return;
}
+ exit = event.useTravelAgent() ? event.getPortalTravelAgent().findOrCreate(event.getTo()) : event.getTo();
+ this.teleportTo(exit, true);
+ }
+ }
+
+ public void teleportTo(Location exit, boolean portal)
+ {
+ if (true)
+ {
+ WorldServer worldserver = ((CraftWorld) this.getBukkitEntity().getLocation().getWorld()).getHandle();
+ WorldServer worldserver1 = ((CraftWorld) exit.getWorld()).getHandle();
+ int i = worldserver1.dimension;
+ // CraftBukkit end
+ this.dimension = i;
this.worldObj.removeEntity(this);
this.isDead = false;
this.worldObj.theProfiler.startSection("reposition");
- minecraftserver.getConfigurationManager().transferEntityToWorld(this, j, worldserver, worldserver1);
+ // CraftBukkit start - Ensure chunks are loaded in case TravelAgent is not used which would initially cause chunks to load during find/create
+ // minecraftserver.getPlayerList().a(this, j, worldserver, worldserver1);
+ boolean before = worldserver1.theChunkProviderServer.loadChunkOnProvideRequest; // Cauldron start - load chunks on provide request
+ worldserver1.theChunkProviderServer.loadChunkOnProvideRequest = true;
+ worldserver1.func_73046_m().getConfigurationManager().repositionEntity(this, exit, portal);
+ worldserver1.theChunkProviderServer.loadChunkOnProvideRequest = before; // Cauldron end
+ // CraftBukkit end
this.worldObj.theProfiler.endStartSection("reloading");
Entity entity = EntityList.createEntityByName(EntityList.getEntityString(this), worldserver1);
if (entity != null)
{
entity.copyDataFrom(this, true);
-
- if (j == 1 && p_71027_1_ == 1)
- {
- ChunkCoordinates chunkcoordinates = worldserver1.getSpawnPoint();
- chunkcoordinates.posY = this.worldObj.getTopSolidOrLiquidBlock(chunkcoordinates.posX, chunkcoordinates.posZ);
- entity.setLocationAndAngles((double)chunkcoordinates.posX, (double)chunkcoordinates.posY, (double)chunkcoordinates.posZ, entity.rotationYaw, entity.rotationPitch);
- }
-
worldserver1.spawnEntityInWorld(entity);
+ // CraftBukkit start - Forward the CraftEntity to the new entity
+ this.getBukkitEntity().setHandle(entity);
+ entity.bukkitEntity = this.getBukkitEntity();
+ // CraftBukkit end
}
this.isDead = true;
@@ -2077,7 +2523,6 @@
this.worldObj.theProfiler.endSection();
}
}
-
public float func_145772_a(Explosion p_145772_1_, World p_145772_2_, int p_145772_3_, int p_145772_4_, int p_145772_5_, Block p_145772_6_)
{
return p_145772_6_.getExplosionResistance(this, p_145772_2_, p_145772_3_, p_145772_4_, p_145772_5_, posX, posY + getEyeHeight(), posZ);

View File

@ -0,0 +1,80 @@
--- ../src-base/minecraft/net/minecraft/entity/EntityAgeable.java
+++ ../src-work/minecraft/net/minecraft/entity/EntityAgeable.java
@@ -10,6 +10,36 @@
{
private float field_98056_d = -1.0F;
private float field_98057_e;
+ public boolean ageLocked = false; // CraftBukkit
+
+ // Spigot start
+ @Override
+ public void inactiveTick()
+ {
+ super.inactiveTick();
+
+ if (this.worldObj.isRemote || this.ageLocked)
+ {
+ // CraftBukkit
+ this.setScaleForAge(this.isChild());
+ }
+ else
+ {
+ int i = this.getGrowingAge();
+
+ if (i < 0)
+ {
+ ++i;
+ this.setGrowingAge(i);
+ }
+ else if (i > 0)
+ {
+ --i;
+ this.setGrowingAge(i);
+ }
+ }
+ }
+ // Spigot end
private static final String __OBFID = "CL_00001530";
public EntityAgeable(World p_i1578_1_)
@@ -37,7 +67,7 @@
{
entityageable.setGrowingAge(-24000);
entityageable.setLocationAndAngles(this.posX, this.posY, this.posZ, 0.0F, 0.0F);
- this.worldObj.spawnEntityInWorld(entityageable);
+ this.worldObj.addEntity(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SPAWNER_EGG); // CraftBukkit
if (itemstack.hasDisplayName())
{
@@ -48,7 +78,7 @@
{
--itemstack.stackSize;
- if (itemstack.stackSize <= 0)
+ if (itemstack.stackSize == 0) // CraftBukkit - allow less than 0 stacks as "infinite"
{
p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, (ItemStack)null);
}
@@ -99,19 +129,21 @@
{
super.writeEntityToNBT(p_70014_1_);
p_70014_1_.setInteger("Age", this.getGrowingAge());
+ p_70014_1_.setBoolean("AgeLocked", this.ageLocked); // CraftBukkit
}
public void readEntityFromNBT(NBTTagCompound p_70037_1_)
{
super.readEntityFromNBT(p_70037_1_);
this.setGrowingAge(p_70037_1_.getInteger("Age"));
+ this.ageLocked = p_70037_1_.getBoolean("AgeLocked"); // CraftBukkit
}
public void onLivingUpdate()
{
super.onLivingUpdate();
- if (this.worldObj.isRemote)
+ if (this.worldObj.isRemote || this.ageLocked) // CraftBukkit
{
this.setScaleForAge(this.isChild());
}

View File

@ -0,0 +1,105 @@
--- ../src-base/minecraft/net/minecraft/entity/EntityCreature.java
+++ ../src-work/minecraft/net/minecraft/entity/EntityCreature.java
@@ -13,12 +13,18 @@
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
+// CraftBukkit start
+import org.bukkit.craftbukkit.entity.CraftEntity;
+import org.bukkit.event.entity.EntityTargetEvent;
+import org.bukkit.event.entity.EntityUnleashEvent;
+// CraftBukkit end
+
public abstract class EntityCreature extends EntityLiving
{
public static final UUID field_110179_h = UUID.fromString("E199AD21-BA8A-4C53-8D13-6182D5C69D3A");
public static final AttributeModifier field_110181_i = (new AttributeModifier(field_110179_h, "Fleeing speed bonus", 2.0D, 2)).setSaved(false);
- private PathEntity pathToEntity;
- protected Entity entityToAttack;
+ public PathEntity pathToEntity; // CraftBukkit - private -> public
+ public Entity entityToAttack; // CraftBukkit - protected -> public
protected boolean hasAttacked;
protected int fleeingTick;
private ChunkCoordinates homePosition = new ChunkCoordinates(0, 0, 0);
@@ -52,8 +58,29 @@
if (this.entityToAttack == null)
{
- this.entityToAttack = this.findPlayerToAttack();
+ // CraftBukkit start
+ Entity target = this.findPlayerToAttack();
+ if (target != null)
+ {
+ EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), target.getBukkitEntity(), EntityTargetEvent.TargetReason.CLOSEST_PLAYER);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ if (event.getTarget() == null)
+ {
+ this.entityToAttack = null;
+ }
+ else
+ {
+ this.entityToAttack = ((CraftEntity) event.getTarget()).getHandle();
+ }
+ }
+ }
+
+ // CraftBukkit end
+
if (this.entityToAttack != null)
{
this.pathToEntity = this.worldObj.getPathEntityToEntity(this, this.entityToAttack, f4, true, false, false, true);
@@ -70,7 +97,23 @@
}
else
{
- this.entityToAttack = null;
+ // CraftBukkit start
+ EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, EntityTargetEvent.TargetReason.TARGET_DIED);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ if (event.getTarget() == null)
+ {
+ this.entityToAttack = null;
+ }
+ else
+ {
+ this.entityToAttack = ((CraftEntity) event.getTarget()).getHandle();
+ }
+ }
+
+ // CraftBukkit end
}
if (this.entityToAttack instanceof EntityPlayerMP && ((EntityPlayerMP)this.entityToAttack).theItemInWorldManager.isCreative())
@@ -122,7 +165,8 @@
double d1 = vec3.xCoord - this.posX;
double d2 = vec3.zCoord - this.posZ;
double d3 = vec3.yCoord - (double)i;
- float f1 = (float)(Math.atan2(d2, d1) * 180.0D / Math.PI) - 90.0F;
+ // CraftBukkit - Math -> TrigMath
+ float f1 = (float)(org.bukkit.craftbukkit.TrigMath.atan2(d2, d1) * 180.0D / Math.PI) - 90.0F;
float f2 = MathHelper.wrapAngleTo180_float(f1 - this.rotationYaw);
this.moveForward = (float)this.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue();
@@ -303,6 +347,7 @@
{
if (f > 10.0F)
{
+ this.worldObj.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
this.clearLeashed(true, true);
}
@@ -335,6 +380,7 @@
if (f > 10.0F)
{
+ this.worldObj.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), EntityUnleashEvent.UnleashReason.DISTANCE)); // CraftBukkit
this.clearLeashed(true, true);
}
}

View File

@ -0,0 +1,119 @@
--- ../src-base/minecraft/net/minecraft/entity/EntityHanging.java
+++ ../src-work/minecraft/net/minecraft/entity/EntityHanging.java
@@ -10,6 +10,14 @@
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
+// CraftBukkit start
+import net.minecraft.entity.item.EntityPainting;
+import org.bukkit.entity.Hanging;
+import org.bukkit.entity.Painting;
+import org.bukkit.event.hanging.HangingBreakEvent;
+import org.bukkit.event.painting.PaintingBreakEvent;
+// CraftBukkit end
+
public abstract class EntityHanging extends Entity
{
private int tickCounter1;
@@ -125,6 +133,38 @@
if (!this.isDead && !this.onValidSurface())
{
+ // CraftBukkit start
+ Material material = this.worldObj.getBlock((int) this.posX, (int) this.posY, (int) this.posZ).getMaterial();
+ HangingBreakEvent.RemoveCause cause;
+
+ if (!material.equals(Material.air))
+ {
+ // TODO: This feels insufficient to catch 100% of suffocation cases
+ cause = HangingBreakEvent.RemoveCause.OBSTRUCTION;
+ }
+ else
+ {
+ cause = HangingBreakEvent.RemoveCause.PHYSICS;
+ }
+
+ HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), cause);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+ PaintingBreakEvent paintingEvent = null;
+
+ if (this instanceof EntityPainting)
+ {
+ // Fire old painting event until it can be removed
+ paintingEvent = new PaintingBreakEvent((Painting) this.getBukkitEntity(), PaintingBreakEvent.RemoveCause.valueOf(cause.name()));
+ paintingEvent.setCancelled(event.isCancelled());
+ this.worldObj.getServer().getPluginManager().callEvent(paintingEvent);
+ }
+
+ if (isDead || event.isCancelled() || (paintingEvent != null && paintingEvent.isCancelled()))
+ {
+ return;
+ }
+
+ // CraftBukkit end
this.setDead();
this.onBroken((Entity)null);
}
@@ -233,6 +273,39 @@
{
if (!this.isDead && !this.worldObj.isRemote)
{
+ // CraftBukkit start
+ HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.DEFAULT);
+ PaintingBreakEvent paintingEvent = null;
+
+ if (p_70097_1_.getEntity() != null)
+ {
+ event = new org.bukkit.event.hanging.HangingBreakByEntityEvent((Hanging) this.getBukkitEntity(), p_70097_1_.getEntity() == null ? null : p_70097_1_.getEntity().getBukkitEntity());
+
+ if (this instanceof EntityPainting)
+ {
+ // Fire old painting event until it can be removed
+ paintingEvent = new org.bukkit.event.painting.PaintingBreakByEntityEvent((Painting) this.getBukkitEntity(), p_70097_1_.getEntity() == null ? null : p_70097_1_.getEntity().getBukkitEntity());
+ }
+ }
+ else if (p_70097_1_.isExplosion())
+ {
+ event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.EXPLOSION);
+ }
+
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (paintingEvent != null)
+ {
+ paintingEvent.setCancelled(event.isCancelled());
+ this.worldObj.getServer().getPluginManager().callEvent(paintingEvent);
+ }
+
+ if (this.isDead || event.isCancelled() || (paintingEvent != null && paintingEvent.isCancelled()))
+ {
+ return true;
+ }
+
+ // CraftBukkit end
this.setDead();
this.setBeenAttacked();
this.onBroken(p_70097_1_.getEntity());
@@ -246,6 +319,22 @@
{
if (!this.worldObj.isRemote && !this.isDead && p_70091_1_ * p_70091_1_ + p_70091_3_ * p_70091_3_ + p_70091_5_ * p_70091_5_ > 0.0D)
{
+ if (this.isDead)
+ {
+ return; // CraftBukkit
+ }
+
+ // CraftBukkit start
+ // TODO - Does this need its own cause? Seems to only be triggered by pistons
+ HangingBreakEvent event = new HangingBreakEvent((Hanging) this.getBukkitEntity(), HangingBreakEvent.RemoveCause.PHYSICS);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (this.isDead || event.isCancelled())
+ {
+ return;
+ }
+
+ // CraftBukkit end
this.setDead();
this.onBroken((Entity)null);
}

View File

@ -0,0 +1,74 @@
--- ../src-base/minecraft/net/minecraft/entity/EntityLeashKnot.java
+++ ../src-work/minecraft/net/minecraft/entity/EntityLeashKnot.java
@@ -11,6 +11,12 @@
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.world.World;
+ // CraftBukkit start
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.network.play.server.S1BPacketEntityAttach;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+// CraftBukkit end
+
public class EntityLeashKnot extends EntityHanging
{
private static final String __OBFID = "CL_00001548";
@@ -84,6 +90,14 @@
if (entityliving.getLeashed() && entityliving.getLeashedToEntity() == p_130002_1_)
{
+ // CraftBukkit start
+ if (CraftEventFactory.callPlayerLeashEntityEvent(entityliving, this, p_130002_1_).isCancelled())
+ {
+ ((EntityPlayerMP) p_130002_1_).playerNetServerHandler.sendPacket(new S1BPacketEntityAttach(1, entityliving, entityliving.getLeashedToEntity()));
+ continue;
+ }
+
+ // CraftBukkit end
entityliving.setLeashedToEntity(this, true);
flag = true;
}
@@ -93,9 +107,12 @@
if (!this.worldObj.isRemote && !flag)
{
- this.setDead();
+ // CraftBukkit start - Move below
+ //this.setDead();
+ boolean die = true;
- if (p_130002_1_.capabilities.isCreativeMode)
+ // CraftBukkit end
+ if (true || p_130002_1_.capabilities.isCreativeMode) // CraftBukkit - Process for non-creative as well
{
d0 = 7.0D;
list = this.worldObj.getEntitiesWithinAABB(EntityLiving.class, AxisAlignedBB.getBoundingBox(this.posX - d0, this.posY - d0, this.posZ - d0, this.posX + d0, this.posY + d0, this.posZ + d0));
@@ -110,11 +127,27 @@
if (entityliving.getLeashed() && entityliving.getLeashedToEntity() == this)
{
- entityliving.clearLeashed(true, false);
+ // CraftBukkit start
+ if (CraftEventFactory.callPlayerUnleashEntityEvent(entityliving, p_130002_1_).isCancelled())
+ {
+ die = false;
+ continue;
+ }
+
+ entityliving.clearLeashed(true, !p_130002_1_.capabilities.isCreativeMode); // false -> survival mode boolean
+ // CraftBukkit end
}
}
}
}
+
+ // CraftBukkit start
+ if (die)
+ {
+ this.setDead();
+ }
+
+ // CraftBukkit end
}
return true;

View File

@ -0,0 +1,162 @@
--- ../src-base/minecraft/net/minecraft/entity/EntityLiving.java
+++ ../src-work/minecraft/net/minecraft/entity/EntityLiving.java
@@ -38,6 +38,13 @@
import cpw.mods.fml.common.eventhandler.Event.Result;
import net.minecraftforge.event.ForgeEventFactory;
+// CraftBukkit start
+import net.minecraft.entity.player.EntityPlayerMP;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityUnleashEvent;
+import org.bukkit.event.entity.EntityUnleashEvent.UnleashReason;
+// CraftBukkit end
+
public abstract class EntityLiving extends EntityLivingBase
{
public int livingSoundTime;
@@ -52,9 +59,9 @@
private EntityLivingBase attackTarget;
private EntitySenses senses;
private ItemStack[] equipment = new ItemStack[5];
- protected float[] equipmentDropChances = new float[5];
- private boolean canPickUpLoot;
- private boolean persistenceRequired;
+ public float[] equipmentDropChances = new float[5]; // CraftBukkit - protected -> public
+ public boolean canPickUpLoot; // CraftBukkit - private -> public
+ public boolean persistenceRequired; // CraftBukkit - private -> public
protected float defaultPitch;
private Entity currentTarget;
protected int numTicksToChaseTarget;
@@ -311,9 +318,23 @@
public void readEntityFromNBT(NBTTagCompound p_70037_1_)
{
super.readEntityFromNBT(p_70037_1_);
- this.setCanPickUpLoot(p_70037_1_.getBoolean("CanPickUpLoot"));
- this.persistenceRequired = p_70037_1_.getBoolean("PersistenceRequired");
+ // CraftBukkit start - If looting or persistence is false only use it if it was set after we started using it
+ boolean data = p_70037_1_.getBoolean("CanPickUpLoot");
+ if (isLevelAtLeast(p_70037_1_, 1) || data)
+ {
+ this.canPickUpLoot = data;
+ }
+
+ data = p_70037_1_.getBoolean("PersistenceRequired");
+
+ if (isLevelAtLeast(p_70037_1_, 1) || data)
+ {
+ this.persistenceRequired = data;
+ }
+
+ // CraftBukkit end
+
if (p_70037_1_.hasKey("CustomName", 8) && p_70037_1_.getString("CustomName").length() > 0)
{
this.setCustomNameTag(p_70037_1_.getString("CustomName"));
@@ -521,15 +542,36 @@
this.entityAge = 0;
}
}
+ // Cauldron start - Force despawn of entity if a player isn't near
+ else if (this.worldObj.cauldronConfig.entityDespawnImmediate && this.canDespawn())
+ {
+ this.despawn("No Player : Immediate");
+ }
+ // Cauldron end
}
}
+ // Cauldron start
+ private void despawn(String reason) {
+ this.setDead();
+ net.minecraftforge.cauldron.CauldronHooks.logEntityDespawn(this, reason);
+ }
+ // Cauldron end
+
protected void updateAITasks()
{
++this.entityAge;
this.worldObj.theProfiler.startSection("checkDespawn");
this.despawnEntity();
this.worldObj.theProfiler.endSection();
+
+ // Spigot Start
+ if (this.fromMobSpawner)
+ {
+ return;
+ }
+
+ // Spigot End
this.worldObj.theProfiler.startSection("sensing");
this.senses.clearSensingCache();
this.worldObj.theProfiler.endSection();
@@ -1005,6 +1047,14 @@
{
if (this.getLeashed() && this.getLeashedToEntity() == p_130002_1_)
{
+ // CraftBukkit start
+ if (CraftEventFactory.callPlayerUnleashEntityEvent(this, p_130002_1_).isCancelled())
+ {
+ ((EntityPlayerMP) p_130002_1_).playerNetServerHandler.sendPacket(new S1BPacketEntityAttach(1, this, this.getLeashedToEntity()));
+ return false;
+ }
+
+ // CraftBukkit end
this.clearLeashed(true, !p_130002_1_.capabilities.isCreativeMode);
return true;
}
@@ -1016,6 +1066,14 @@
{
if (!(this instanceof EntityTameable) || !((EntityTameable)this).isTamed())
{
+ // CraftBukkit start
+ if (CraftEventFactory.callPlayerLeashEntityEvent(this, p_130002_1_, p_130002_1_).isCancelled())
+ {
+ ((EntityPlayerMP) p_130002_1_).playerNetServerHandler.sendPacket(new S1BPacketEntityAttach(1, this, this.getLeashedToEntity()));
+ return false;
+ }
+
+ // CraftBukkit end
this.setLeashedToEntity(p_130002_1_, true);
--itemstack.stackSize;
return true;
@@ -1023,6 +1081,14 @@
if (((EntityTameable)this).func_152114_e(p_130002_1_))
{
+ // CraftBukkit start
+ if (CraftEventFactory.callPlayerLeashEntityEvent(this, p_130002_1_, p_130002_1_).isCancelled())
+ {
+ ((EntityPlayerMP) p_130002_1_).playerNetServerHandler.sendPacket(new S1BPacketEntityAttach(1, this, this.getLeashedToEntity()));
+ return false;
+ }
+
+ // CraftBukkit end
this.setLeashedToEntity(p_130002_1_, true);
--itemstack.stackSize;
return true;
@@ -1049,6 +1115,7 @@
{
if (this.leashedToEntity == null || this.leashedToEntity.isDead)
{
+ this.worldObj.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.HOLDER_GONE)); // CraftBukkit
this.clearLeashed(true, true);
}
}
@@ -1136,10 +1203,16 @@
}
else
{
+ this.worldObj.getServer().getPluginManager().callEvent(new EntityUnleashEvent(this.getBukkitEntity(), UnleashReason.UNKNOWN)); // CraftBukkit
this.clearLeashed(false, true);
}
}
this.field_110170_bx = null;
}
+
+ public boolean canDespawn_CB()
+ {
+ return this.canDespawn();
+ }
}

View File

@ -0,0 +1,657 @@
--- ../src-base/minecraft/net/minecraft/entity/EntityLivingBase.java
+++ ../src-work/minecraft/net/minecraft/entity/EntityLivingBase.java
@@ -50,14 +50,28 @@
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
import net.minecraftforge.common.ForgeHooks;
+import net.minecraftforge.common.ISpecialArmor.ArmorProperties;
+// CraftBukkit start
+import net.minecraft.nbt.NBTTagInt;
+import net.minecraft.network.play.server.S28PacketEffect;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityDamageEvent;
+import org.bukkit.event.entity.EntityDamageEvent.DamageModifier;
+import org.bukkit.event.entity.EntityRegainHealthEvent;
+// CraftBukkit end
+import org.bukkit.craftbukkit.SpigotTimings; // Spigot
+import org.bukkit.craftbukkit.inventory.CraftItemStack; // Cauldron
+
+import com.google.common.base.Function;
+
public abstract class EntityLivingBase extends Entity
{
private static final UUID sprintingSpeedBoostModifierUUID = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D");
private static final AttributeModifier sprintingSpeedBoostModifier = (new AttributeModifier(sprintingSpeedBoostModifierUUID, "Sprinting speed boost", 0.30000001192092896D, 2)).setSaved(false);
private BaseAttributeMap attributeMap;
- private final CombatTracker _combatTracker = new CombatTracker(this);
- private final HashMap activePotionsMap = new HashMap();
+ public CombatTracker _combatTracker = new CombatTracker(this); // CraftBukkit - private -> public, remove final
+ public final HashMap activePotionsMap = new HashMap(); // CraftBukkit - protected -> public
private final ItemStack[] previousEquipment = new ItemStack[5];
public boolean isSwingInProgress;
public int swingProgressInt;
@@ -83,7 +97,7 @@
public float rotationYawHead;
public float prevRotationYawHead;
public float jumpMovementFactor = 0.02F;
- protected EntityPlayer attackingPlayer;
+ public EntityPlayer attackingPlayer; // CraftBukkit - protected -> public
protected int recentlyHit;
protected boolean dead;
protected int entityAge;
@@ -93,7 +107,7 @@
protected float field_70763_ax;
protected float field_70741_aB;
protected int scoreValue;
- protected float lastDamage;
+ public float lastDamage; // CraftBukkit - protected -> public
protected boolean isJumping;
public float moveStrafing;
public float moveForward;
@@ -104,21 +118,26 @@
protected double newPosZ;
protected double newRotationYaw;
protected double newRotationPitch;
- private boolean potionsNeedUpdate = true;
- private EntityLivingBase entityLivingToAttack;
+ public boolean potionsNeedUpdate = true; // CraftBukkit - private -> public
+ public EntityLivingBase entityLivingToAttack; // CraftBukkit - private -> public
private int revengeTimer;
private EntityLivingBase lastAttacker;
private int lastAttackerTime;
private float landMovementFactor;
private int jumpTicks;
private float field_110151_bq;
+ // CraftBukkit start
+ public int expToDrop;
+ public int maxAirTicks = 300;
+ // CraftBukkit end
private static final String __OBFID = "CL_00001549";
public EntityLivingBase(World p_i1594_1_)
{
super(p_i1594_1_);
this.applyEntityAttributes();
- this.setHealth(this.getMaxHealth());
+ // CraftBukkit - this.setHealth(getMaxHealth()) inlined and simplified to skip the instanceof check for EntityPlayer, as getBukkitEntity() is not initialized in constructor
+ this.dataWatcher.updateObject(6, (float) this.getEntityAttribute(SharedMonsterAttributes.maxHealth).getAttributeValue());
this.preventEntitySpawning = true;
this.field_70770_ap = (float)(Math.random() + 1.0D) * 0.01F;
this.setPosition(this.posX, this.posY, this.posZ);
@@ -173,7 +192,18 @@
}
else if (!this.worldObj.isRemote && this.fallDistance > 3.0F)
{
- this.worldObj.playAuxSFX(2006, i, j, k, MathHelper.ceiling_float_int(this.fallDistance - 3.0F));
+ // CraftBukkit start - supply player as argument in particles for visibility API to work
+ if (this instanceof EntityPlayerMP)
+ {
+ this.worldObj.playAuxSFXAtEntity((EntityPlayer) this, 2006, i, j, k, MathHelper.ceiling_float_int(this.fallDistance - 3.0F));
+ ((EntityPlayerMP) this).playerNetServerHandler.sendPacket(new S28PacketEffect(2006, i, j, k, MathHelper
+ .ceiling_float_int(this.fallDistance - 3.0F), false));
+ }
+ else
+ {
+ this.worldObj.playAuxSFX(2006, i, j, k, MathHelper.ceiling_float_int(this.fallDistance - 3.0F));
+ }
+ // CraftBukkit end
}
block.onFallenUpon(this.worldObj, i, j, k, this, this.fallDistance);
@@ -234,7 +264,12 @@
}
else
{
- this.setAir(300);
+ // CraftBukkit start - Only set if needed to work around a DataWatcher inefficiency
+ if (this.getAir() != 300)
+ {
+ this.setAir(maxAirTicks);
+ }
+ // CraftBukkit end
}
if (this.isEntityAlive() && this.isWet())
@@ -299,6 +334,22 @@
this.worldObj.theProfiler.endSection();
}
+ // CraftBukkit start
+ public int getExpReward()
+ {
+ int exp = this.getExperiencePoints(this.attackingPlayer);
+
+ if (!this.worldObj.isRemote && (this.recentlyHit > 0 || this.isPlayer()) && this.func_146066_aG())
+ {
+ return exp;
+ }
+ else
+ {
+ return 0;
+ }
+ }
+ // CraftBukkit end
+
public boolean isChild()
{
return false;
@@ -308,22 +359,21 @@
{
++this.deathTime;
- if (this.deathTime == 20)
+ if (this.deathTime >= 20 && !this.isDead) // CraftBukkit - (this.deathTicks == 20) -> (this.deathTicks >= 20 && !this.dead)
{
int i;
+ // CraftBukkit start - Update getExpReward() above if the removed if() changes!
+ i = this.expToDrop;
- if (!this.worldObj.isRemote && (this.recentlyHit > 0 || this.isPlayer()) && this.func_146066_aG() && this.worldObj.getGameRules().getGameRuleBooleanValue("doMobLoot"))
+ while (i > 0)
{
- i = this.getExperiencePoints(this.attackingPlayer);
-
- while (i > 0)
- {
- int j = EntityXPOrb.getXPSplit(i);
- i -= j;
- this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j));
- }
+ int j = EntityXPOrb.getXPSplit(i);
+ i -= j;
+ this.worldObj.spawnEntityInWorld(new EntityXPOrb(this.worldObj, this.posX, this.posY, this.posZ, j));
}
+ this.expToDrop = 0;
+ // CraftBukkit end
this.setDead();
for (i = 0; i < 20; ++i)
@@ -485,6 +535,22 @@
}
}
+ // CraftBukkit start
+ if (p_70037_1_.hasKey("Bukkit.MaxHealth"))
+ {
+ NBTBase nbtbase = p_70037_1_.getTag("Bukkit.MaxHealth");
+
+ if (nbtbase.getId() == 5)
+ {
+ this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue((double) ((NBTTagFloat) nbtbase).func_150291_c());
+ }
+ else if (nbtbase.getId() == 3)
+ {
+ this.getEntityAttribute(SharedMonsterAttributes.maxHealth).setBaseValue((double) ((NBTTagInt) nbtbase).func_150287_d());
+ }
+ }
+ // CraftBukkit end
+
if (p_70037_1_.hasKey("HealF", 99))
{
this.setHealth(p_70037_1_.getFloat("HealF"));
@@ -614,12 +680,14 @@
public boolean isPotionActive(int p_82165_1_)
{
- return this.activePotionsMap.containsKey(Integer.valueOf(p_82165_1_));
+ // CraftBukkit - Add size check for efficiency
+ return this.activePotionsMap.size() != 0 && this.activePotionsMap.containsKey(Integer.valueOf(p_82165_1_));
}
public boolean isPotionActive(Potion p_70644_1_)
{
- return this.activePotionsMap.containsKey(Integer.valueOf(p_70644_1_.id));
+ // CraftBukkit - Add size check for efficiency
+ return this.activePotionsMap.size() != 0 && this.activePotionsMap.containsKey(Integer.valueOf(p_70644_1_.id));
}
public PotionEffect getActivePotionEffect(Potion p_70660_1_)
@@ -710,25 +778,66 @@
}
}
+ // CraftBukkit start - Delegate so we can handle providing a reason for health being regained
public void heal(float p_70691_1_)
{
+ heal(p_70691_1_, EntityRegainHealthEvent.RegainReason.CUSTOM);
+ }
+
+ public void heal(float p_70691_1_, EntityRegainHealthEvent.RegainReason regainReason)
+ {
p_70691_1_ = net.minecraftforge.event.ForgeEventFactory.onLivingHeal(this, p_70691_1_);
if (p_70691_1_ <= 0) return;
float f1 = this.getHealth();
if (f1 > 0.0F)
{
- this.setHealth(f1 + p_70691_1_);
+ EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), p_70691_1_, regainReason);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ this.setHealth((float) (this.getHealth() + event.getAmount()));
+ }
}
}
public final float getHealth()
{
+ // CraftBukkit start - Use unscaled health
+ if (this instanceof EntityPlayerMP)
+ {
+ return (float) ((EntityPlayerMP) this).getBukkitEntity().getHealth();
+ }
+ // CraftBukkit end
return this.dataWatcher.getWatchableObjectFloat(6);
}
public void setHealth(float p_70606_1_)
{
+ // CraftBukkit start - Handle scaled health
+ if (this instanceof EntityPlayerMP)
+ {
+ org.bukkit.craftbukkit.entity.CraftPlayer player = ((EntityPlayerMP) this).getBukkitEntity();
+
+ // Squeeze
+ if (p_70606_1_ < 0.0F)
+ {
+ player.setRealHealth(0.0D);
+ }
+ else if (p_70606_1_ > player.getMaxHealth())
+ {
+ player.setRealHealth(player.getMaxHealth());
+ }
+ else
+ {
+ player.setRealHealth(p_70606_1_);
+ }
+
+ this.dataWatcher.updateObject(6, Float.valueOf(player.getScaledHealth()));
+ return;
+ }
+ // CraftBukkit end
this.dataWatcher.updateObject(6, Float.valueOf(MathHelper.clamp_float(p_70606_1_, 0.0F, this.getMaxHealth())));
}
@@ -757,7 +866,8 @@
}
else
{
- if ((p_70097_1_ == DamageSource.anvil || p_70097_1_ == DamageSource.fallingBlock) && this.getEquipmentInSlot(4) != null)
+ // CraftBukkit - Moved into damageEntity_CB(DamageSource, float)
+ if (false && (p_70097_1_ == DamageSource.anvil || p_70097_1_ == DamageSource.fallingBlock) && this.getEquipmentInSlot(4) != null)
{
this.getEquipmentInSlot(4).damageItem((int)(p_70097_2_ * 4.0F + this.rand.nextFloat() * p_70097_2_ * 2.0F), this);
p_70097_2_ *= 0.75F;
@@ -773,16 +883,27 @@
return false;
}
- this.damageEntity(p_70097_1_, p_70097_2_ - this.lastDamage);
+ // CraftBukkit start
+ if (!this.damageEntity_CB(p_70097_1_, p_70097_2_ - this.lastDamage))
+ {
+ return false;
+ }
+ // CraftBukkit end
this.lastDamage = p_70097_2_;
flag = false;
}
else
{
+ // CraftBukkit start
+ float previousHealth = this.getHealth();
+ if (!this.damageEntity_CB(p_70097_1_, p_70097_2_))
+ {
+ return false;
+ }
this.lastDamage = p_70097_2_;
- this.prevHealth = this.getHealth();
+ this.prevHealth = previousHealth;
this.hurtResistantTime = this.maxHurtResistantTime;
- this.damageEntity(p_70097_1_, p_70097_2_);
+ // CraftBukkit end
this.hurtTime = this.maxHurtTime = 10;
}
@@ -938,6 +1059,22 @@
if (!ForgeHooks.onLivingDrops(this, p_70645_1_, capturedDrops, i, recentlyHit > 0, j))
{
+ // Cauldron start - capture drops for plugins then fire event
+ if (this.capturedDrops.size() > 0)
+ {
+ java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
+ for (EntityItem item : capturedDrops)
+ {
+ loot.add(CraftItemStack.asCraftMirror(item.getEntityItem()));
+ }
+ CraftEventFactory.callEntityDeathEvent(this, loot);
+ }
+ else
+ {
+ CraftEventFactory.callEntityDeathEvent(this);
+ }
+ // Cauldron end
+
for (EntityItem item : capturedDrops)
{
worldObj.spawnEntityInWorld(item);
@@ -1010,8 +1147,17 @@
if (i > 0)
{
+ // CraftBukkit start
+ if (!this.attackEntityFrom(DamageSource.fall, (float) i))
+ {
+ return;
+ }
+ }
+ // CraftBukkit end
+ if (i > 0)
+ {
this.playSound(this.func_146067_o(i), 1.0F, 1.0F);
- this.attackEntityFrom(DamageSource.fall, (float)i);
+ // this.attackEntityFrom(DamageSource.fall, (float)i); // CraftBukkit - moved up
int j = MathHelper.floor_double(this.posX);
int k = MathHelper.floor_double(this.posY - 0.20000000298023224D - (double)this.yOffset);
int l = MathHelper.floor_double(this.posZ);
@@ -1065,7 +1211,7 @@
{
int i = 25 - this.getTotalArmorValue();
float f1 = p_70655_2_ * (float)i;
- this.damageArmor(p_70655_2_);
+ // this.damageArmor(p_70655_2_); // CraftBukkit - Moved into damageEntity_CB(DamageSource, float)
p_70655_2_ = f1 / 25.0F;
}
@@ -1089,7 +1235,8 @@
int j;
float f1;
- if (this.isPotionActive(Potion.resistance) && p_70672_1_ != DamageSource.outOfWorld)
+ // CraftBukkit - Moved to damageEntity_CB(DamageSource, float)
+ if (false && this.isPotionActive(Potion.resistance) && p_70672_1_ != DamageSource.outOfWorld)
{
i = (this.getActivePotionEffect(Potion.resistance).getAmplifier() + 1) * 5;
j = 25 - i;
@@ -1122,26 +1269,156 @@
}
}
+ // Cauldron start - vanilla compatibility
protected void damageEntity(DamageSource p_70665_1_, float p_70665_2_)
{
+ this.damageEntity_CB(p_70665_1_, p_70665_2_);
+ }
+
+ // Cauldron end
+
+ // CraftBukkit start
+ protected boolean damageEntity_CB(final DamageSource damagesource, float f)
+ { // void -> boolean, add final
if (!this.isEntityInvulnerable())
{
- p_70665_2_ = ForgeHooks.onLivingHurt(this, p_70665_1_, p_70665_2_);
- if (p_70665_2_ <= 0) return;
- p_70665_2_ = this.applyArmorCalculations(p_70665_1_, p_70665_2_);
- p_70665_2_ = this.applyPotionDamageCalculations(p_70665_1_, p_70665_2_);
- float f1 = p_70665_2_;
- p_70665_2_ = Math.max(p_70665_2_ - this.getAbsorptionAmount(), 0.0F);
- this.setAbsorptionAmount(this.getAbsorptionAmount() - (f1 - p_70665_2_));
+ final boolean human = this instanceof EntityPlayer;
+ float originalDamage = f;
+ // Cauldron start - apply forge damage hook
+ f = ForgeHooks.onLivingHurt(this, damagesource, f);
+ if (f <= 0) return false;
+ // Cauldron end
+ Function<Double, Double> hardHat = new Function<Double, Double>() {
+ @Override
+ public Double apply(Double f)
+ {
+ if ((damagesource == DamageSource.anvil || damagesource == DamageSource.fallingBlock)
+ && EntityLivingBase.this.getEquipmentInSlot(4) != null)
+ {
+ return -(f - (f * 0.75F));
+ }
+ return -0.0;
+ }
+ };
- if (p_70665_2_ != 0.0F)
+ float hardHatModifier = hardHat.apply((double) f).floatValue();
+ f += hardHatModifier;
+
+ Function<Double, Double> blocking = new Function<Double, Double>() {
+ @Override
+ public Double apply(Double f)
+ {
+ if (human)
+ {
+ if (!damagesource.isUnblockable() && ((EntityPlayer) EntityLivingBase.this).isBlocking() && f > 0.0F)
+ {
+ return -(f - ((1.0F + f) * 0.5F));
+ }
+ }
+ return -0.0;
+ }
+ };
+ float blockingModifier = blocking.apply((double) f).floatValue();
+ f += blockingModifier;
+
+ Function<Double, Double> armor = new Function<Double, Double>() {
+ @Override
+ public Double apply(Double f)
+ {
+ // Cauldron start - apply forge armor hook
+ if (human)
+ {
+ return -(f - ArmorProperties.ApplyArmor(EntityLivingBase.this, ((EntityPlayer) EntityLivingBase.this).inventory.armorInventory,
+ damagesource, f.floatValue()));
+ }
+ // Cauldron end
+ return -(f - EntityLivingBase.this.applyArmorCalculations(damagesource, f.floatValue()));
+ }
+ };
+ float armorModifier = armor.apply((double) f).floatValue();
+ f += armorModifier;
+
+ Function<Double, Double> resistance = new Function<Double, Double>() {
+ @Override
+ public Double apply(Double f)
+ {
+ if (!damagesource.isDamageAbsolute() && EntityLivingBase.this.isPotionActive(Potion.resistance) && damagesource != DamageSource.outOfWorld)
+ {
+ int i = (EntityLivingBase.this.getActivePotionEffect(Potion.resistance).getAmplifier() + 1) * 5;
+ int j = 25 - i;
+ float f1 = f.floatValue() * (float) j;
+ return -(f - (f1 / 25.0F));
+ }
+ return -0.0;
+ }
+ };
+ float resistanceModifier = resistance.apply((double) f).floatValue();
+ f += resistanceModifier;
+
+ Function<Double, Double> magic = new Function<Double, Double>() {
+ @Override
+ public Double apply(Double f)
+ {
+ return -(f - EntityLivingBase.this.applyPotionDamageCalculations(damagesource, f.floatValue()));
+ }
+ };
+ float magicModifier = magic.apply((double) f).floatValue();
+ f += magicModifier;
+
+ Function<Double, Double> absorption = new Function<Double, Double>() {
+ @Override
+ public Double apply(Double f)
+ {
+ return -(Math.max(f - Math.max(f - EntityLivingBase.this.getAbsorptionAmount(), 0.0F), 0.0F));
+ }
+ };
+ float absorptionModifier = absorption.apply((double) f).floatValue();
+
+ EntityDamageEvent event = CraftEventFactory.handleLivingEntityDamageEvent(this, damagesource, originalDamage, hardHatModifier, blockingModifier,
+ armorModifier, resistanceModifier, magicModifier, absorptionModifier, hardHat, blocking, armor, resistance, magic, absorption);
+ if (event.isCancelled())
{
+ return false;
+ }
+
+ f = (float) event.getFinalDamage();
+
+ // Apply damage to helmet
+ if ((damagesource == DamageSource.anvil || damagesource == DamageSource.fallingBlock) && this.getEquipmentInSlot(4) != null)
+ {
+ this.getEquipmentInSlot(4).damageItem((int) (event.getDamage() * 4.0F + this.rand.nextFloat() * event.getDamage() * 2.0F), this);
+ }
+
+ // Apply damage to armor
+ if (!damagesource.isUnblockable())
+ {
+ float armorDamage = (float) (event.getDamage() + event.getDamage(DamageModifier.BLOCKING) + event.getDamage(DamageModifier.HARD_HAT));
+ this.damageArmor(armorDamage);
+ }
+
+ absorptionModifier = (float) -event.getDamage(DamageModifier.ABSORPTION);
+ this.setAbsorptionAmount(Math.max(this.getAbsorptionAmount() - absorptionModifier, 0.0F));
+ if (f != 0.0F)
+ {
+ if (human)
+ {
+ ((EntityPlayer) this).addExhaustion(damagesource.getHungerDamage());
+ }
+ // CraftBukkit end
float f2 = this.getHealth();
- this.setHealth(f2 - p_70665_2_);
- this.func_110142_aN().func_94547_a(p_70665_1_, f2, p_70665_2_);
- this.setAbsorptionAmount(this.getAbsorptionAmount() - p_70665_2_);
+ this.setHealth(f2 - f);
+ this.func_110142_aN().func_94547_a(damagesource, f2, f);
+ // CraftBukkit start
+ if (human)
+ {
+ return true;
+ }
+ // CraftBukkit end
+ this.setAbsorptionAmount(this.getAbsorptionAmount() - f);
}
+ return true; // CraftBukkit
}
+ return false; // CraftBukkit
}
public CombatTracker func_110142_aN()
@@ -1558,6 +1835,7 @@
public void onUpdate()
{
if (ForgeHooks.onLivingUpdate(this)) return;
+ SpigotTimings.timerEntityBaseTick.startTiming(); // Spigot
super.onUpdate();
if (!this.worldObj.isRemote)
@@ -1608,7 +1886,9 @@
}
}
+ SpigotTimings.timerEntityBaseTick.stopTiming(); // Spigot
this.onLivingUpdate();
+ SpigotTimings.timerEntityTickRest.startTiming(); // Spigot
double d0 = this.posX - this.prevPosX;
double d1 = this.posZ - this.prevPosZ;
float f = (float)(d0 * d0 + d1 * d1);
@@ -1621,7 +1901,8 @@
{
f3 = 1.0F;
f2 = (float)Math.sqrt((double)f) * 3.0F;
- f1 = (float)Math.atan2(d1, d0) * 180.0F / (float)Math.PI - 90.0F;
+ // CraftBukkit - Math -> TrigMath
+ f1 = (float) org.bukkit.craftbukkit.TrigMath.atan2(d1, d0) * 180.0F / (float)Math.PI - 90.0F;
}
if (this.swingProgress > 0.0F)
@@ -1682,6 +1963,7 @@
this.worldObj.theProfiler.endSection();
this.field_70764_aw += f2;
+ SpigotTimings.timerEntityTickRest.stopTiming(); // Spigot
}
protected float func_110146_f(float p_110146_1_, float p_110146_2_)
@@ -1757,6 +2039,7 @@
this.motionZ = 0.0D;
}
+ SpigotTimings.timerEntityAI.startTiming(); // Spigot
this.worldObj.theProfiler.startSection("ai");
if (this.isMovementBlocked())
@@ -1783,6 +2066,7 @@
}
}
+ SpigotTimings.timerEntityAI.stopTiming(); // Spigot
this.worldObj.theProfiler.endSection();
this.worldObj.theProfiler.startSection("jump");
@@ -1811,13 +2095,17 @@
this.moveStrafing *= 0.98F;
this.moveForward *= 0.98F;
this.randomYawVelocity *= 0.9F;
+ SpigotTimings.timerEntityAIMove.startTiming(); // Spigot
this.moveEntityWithHeading(this.moveStrafing, this.moveForward);
+ SpigotTimings.timerEntityAIMove.stopTiming(); // Spigot
this.worldObj.theProfiler.endSection();
this.worldObj.theProfiler.startSection("push");
if (!this.worldObj.isRemote)
{
+ SpigotTimings.timerEntityAICollision.startTiming(); // Spigot
this.collideWithNearbyEntities();
+ SpigotTimings.timerEntityAICollision.stopTiming(); // Spigot
}
this.worldObj.theProfiler.endSection();
@@ -1829,17 +2117,36 @@
{
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(0.20000000298023224D, 0.0D, 0.20000000298023224D));
- if (list != null && !list.isEmpty())
+ if (this.canBeCollidedWith() && list != null && !list.isEmpty()) // Spigot: Add this.canBeCollidedWith() condition
{
+ numCollisions -= worldObj.getSpigotConfig().maxCollisionsPerEntity; // Spigot // Cauldron
+
for (int i = 0; i < list.size(); ++i)
{
- Entity entity = (Entity)list.get(i);
+ if (numCollisions > worldObj.getSpigotConfig().maxCollisionsPerEntity) // Cauldron
+ {
+ break; // Spigot
+ }
+ Entity entity = (Entity) list.get(i);
+
+ // TODO better check now?
+ // CraftBukkit start - Only handle mob (non-player) collisions
+ // every other tick
+ if (entity instanceof EntityLivingBase && !(this instanceof EntityPlayerMP) && this.ticksExisted % 2 == 0)
+ {
+ continue;
+ }
+ // CraftBukkit end
+
if (entity.canBePushed())
{
+ entity.numCollisions++; // Spigot
+ numCollisions++; // Spigot
this.collideWithEntity(entity);
}
}
+ numCollisions = 0; // Spigot
}
}

View File

@ -0,0 +1,39 @@
--- ../src-base/minecraft/net/minecraft/entity/EntityMinecartCommandBlock.java
+++ ../src-work/minecraft/net/minecraft/entity/EntityMinecartCommandBlock.java
@@ -16,33 +16,9 @@
public class EntityMinecartCommandBlock extends EntityMinecart
{
- private final CommandBlockLogic field_145824_a = new CommandBlockLogic()
- {
- private static final String __OBFID = "CL_00001673";
- public void func_145756_e()
- {
- EntityMinecartCommandBlock.this.getDataWatcher().updateObject(23, this.func_145753_i());
- EntityMinecartCommandBlock.this.getDataWatcher().updateObject(24, IChatComponent.Serializer.func_150696_a(this.func_145749_h()));
- }
- @SideOnly(Side.CLIENT)
- public int func_145751_f()
- {
- return 1;
- }
- @SideOnly(Side.CLIENT)
- public void func_145757_a(ByteBuf p_145757_1_)
- {
- p_145757_1_.writeInt(EntityMinecartCommandBlock.this.getEntityId());
- }
- public ChunkCoordinates getPlayerCoordinates()
- {
- return new ChunkCoordinates(MathHelper.floor_double(EntityMinecartCommandBlock.this.posX), MathHelper.floor_double(EntityMinecartCommandBlock.this.posY + 0.5D), MathHelper.floor_double(EntityMinecartCommandBlock.this.posZ));
- }
- public World getEntityWorld()
- {
- return EntityMinecartCommandBlock.this.worldObj;
- }
- };
+ private final EntityMinecartCommandBlockListener field_145824_a_CB= new EntityMinecartCommandBlockListener(this); // CraftBukkit
+ private final CommandBlockLogic field_145824_a = field_145824_a_CB; // Cauldron
+
private int field_145823_b = 0;
private static final String __OBFID = "CL_00001672";

View File

@ -0,0 +1,27 @@
--- ../src-base/minecraft/net/minecraft/entity/EntityTracker.java
+++ ../src-work/minecraft/net/minecraft/entity/EntityTracker.java
@@ -38,6 +38,7 @@
import net.minecraft.world.chunk.Chunk;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import net.minecraft.server.MinecraftServer; // Spigot
import cpw.mods.fml.common.registry.EntityRegistry;
@@ -46,7 +47,7 @@
private static final Logger logger = LogManager.getLogger();
private final WorldServer theWorld;
private Set trackedEntities = new HashSet();
- private IntHashMap trackedEntityIDs = new IntHashMap();
+ public IntHashMap trackedEntityIDs = new IntHashMap(); // CraftBukkit - private -> public
private int entityViewDistance;
private static final String __OBFID = "CL_00001431";
@@ -184,6 +185,7 @@
public void addEntityToTracker(Entity p_72785_1_, int p_72785_2_, final int p_72785_3_, boolean p_72785_4_)
{
+ p_72785_2_ = org.spigotmc.TrackingRange.getEntityTrackingRange(p_72785_1_, p_72785_2_); // Spigot
if (p_72785_2_ > this.entityViewDistance)
{
p_72785_2_ = this.entityViewDistance;

View File

@ -0,0 +1,216 @@
--- ../src-base/minecraft/net/minecraft/entity/EntityTrackerEntry.java
+++ ../src-work/minecraft/net/minecraft/entity/EntityTrackerEntry.java
@@ -56,9 +56,15 @@
import net.minecraft.world.storage.MapData;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
+import net.minecraft.server.MinecraftServer; // Spigot
import cpw.mods.fml.common.network.internal.FMLNetworkHandler;
+// CraftBukkit start
+import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerVelocityEvent;
+// CraftBukkit end
+
public class EntityTrackerEntry
{
private static final Logger logger = LogManager.getLogger();
@@ -131,15 +137,15 @@
this.func_151259_a(new S1BPacketEntityAttach(0, this.myEntity, this.myEntity.ridingEntity));
}
- if (this.myEntity instanceof EntityItemFrame && this.ticks % 10 == 0)
+ if (this.myEntity instanceof EntityItemFrame /*&& this.ticks % 10 == 0*/) // CraftBukkit - Moved below, should always enter this block
{
EntityItemFrame entityitemframe = (EntityItemFrame)this.myEntity;
ItemStack itemstack = entityitemframe.getDisplayedItem();
- if (itemstack != null && itemstack.getItem() instanceof ItemMap)
+ if (this.ticks % 10 == 0 && itemstack != null && itemstack.getItem() instanceof ItemMap) // CraftBukkit - Moved this.m % 10 logic here so item frames do not enter the other blocks
{
MapData mapdata = Items.filled_map.getMapData(itemstack, this.myEntity.worldObj);
- Iterator iterator = p_73122_1_.iterator();
+ Iterator iterator = this.trackingPlayers.iterator(); // CraftBukkit
while (iterator.hasNext())
{
@@ -177,6 +183,22 @@
boolean flag = Math.abs(j1) >= 4 || Math.abs(k1) >= 4 || Math.abs(l1) >= 4 || this.ticks % 60 == 0;
boolean flag1 = Math.abs(l - this.lastYaw) >= 4 || Math.abs(i1 - this.lastPitch) >= 4;
+ // CraftBukkit start - Code moved from below
+ if (flag)
+ {
+ this.lastScaledXPosition = i;
+ this.lastScaledYPosition = j;
+ this.lastScaledZPosition = k;
+ }
+
+ if (flag1)
+ {
+ this.lastYaw = l;
+ this.lastPitch = i1;
+ }
+
+ // CraftBukkit end
+
if (this.ticks > 0 || this.myEntity instanceof EntityArrow)
{
if (j1 >= -128 && j1 < 128 && k1 >= -128 && k1 < 128 && l1 >= -128 && l1 < 128 && this.ticksSinceLastForcedTeleport <= 400 && !this.ridingEntity)
@@ -197,7 +219,15 @@
else
{
this.ticksSinceLastForcedTeleport = 0;
- object = new S18PacketEntityTeleport(this.myEntity.getEntityId(), i, j, k, (byte)l, (byte)i1);
+
+ // CraftBukkit start - Refresh list of who can see a player before sending teleport packet
+ if (this.myEntity instanceof EntityPlayerMP)
+ {
+ this.sendEventsToPlayers(new java.util.ArrayList(this.trackingPlayers));
+ }
+
+ // CraftBukkit end
+ object = new S18PacketEntityTeleport(this.myEntity.getEntityId(), i, j, k, (byte) l, (byte) i1);
}
}
@@ -224,7 +254,7 @@
}
this.sendMetadataToAllAssociatedPlayers();
-
+ /* CraftBukkit start - Code moved up
if (flag)
{
this.lastScaledXPosition = i;
@@ -237,7 +267,7 @@
this.lastYaw = l;
this.lastPitch = i1;
}
-
+ // CraftBukkit end */
this.ridingEntity = false;
}
else
@@ -275,7 +305,32 @@
if (this.myEntity.velocityChanged)
{
- this.func_151261_b(new S12PacketEntityVelocity(this.myEntity));
+ // CraftBukkit start - Create PlayerVelocity event
+ boolean cancelled = false;
+
+ if (this.myEntity instanceof EntityPlayerMP)
+ {
+ Player player = (Player) this.myEntity.getBukkitEntity();
+ org.bukkit.util.Vector velocity = player.getVelocity();
+ PlayerVelocityEvent event = new PlayerVelocityEvent(player, velocity);
+ this.myEntity.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled())
+ {
+ cancelled = true;
+ }
+ else if (!velocity.equals(event.getVelocity()))
+ {
+ player.setVelocity(velocity);
+ }
+ }
+
+ if (!cancelled)
+ {
+ this.func_151261_b((Packet)(new S12PacketEntityVelocity(this.myEntity)));
+ }
+
+ // CraftBukkit end
this.myEntity.velocityChanged = false;
}
}
@@ -296,6 +351,13 @@
if (!set.isEmpty())
{
+ // CraftBukkit start - Send scaled max health
+ if (this.myEntity instanceof EntityPlayerMP)
+ {
+ ((EntityPlayerMP) this.myEntity).getBukkitEntity().injectScaledMaxHealth(set, false);
+ }
+
+ // CraftBukkit end
this.func_151261_b(new S20PacketEntityProperties(this.myEntity.getEntityId(), set));
}
@@ -353,6 +415,19 @@
if (d0 >= (double)(-this.blocksDistanceThreshold) && d0 <= (double)this.blocksDistanceThreshold && d1 >= (double)(-this.blocksDistanceThreshold) && d1 <= (double)this.blocksDistanceThreshold)
{
+ // CraftBukkit start
+ if (this.myEntity instanceof EntityPlayerMP)
+ {
+ Player player = ((EntityPlayerMP) this.myEntity).getBukkitEntity();
+
+ if (!p_73117_1_.getBukkitEntity().canSee(player))
+ {
+ return;
+ }
+ }
+ // CraftBukkit end
+
+ p_73117_1_.destroyedItemsNetCache.remove(Integer.valueOf(this.myEntity.getEntityId()));
if (!this.trackingPlayers.contains(p_73117_1_) && (this.isPlayerWatchingThisChunk(p_73117_1_) || this.myEntity.forceSpawn))
{
this.trackingPlayers.add(p_73117_1_);
@@ -369,6 +444,13 @@
ServersideAttributeMap serversideattributemap = (ServersideAttributeMap)((EntityLivingBase)this.myEntity).getAttributeMap();
Collection collection = serversideattributemap.getWatchedAttributes();
+ // CraftBukkit start - If sending own attributes send scaled health instead of current maximum health
+ if (this.myEntity.getEntityId() == p_73117_1_.getEntityId())
+ {
+ ((EntityPlayerMP) this.myEntity).getBukkitEntity().injectScaledMaxHealth(collection, false);
+ }
+
+ // CraftBukkit end
if (!collection.isEmpty())
{
p_73117_1_.playerNetServerHandler.sendPacket(new S20PacketEntityProperties(this.myEntity.getEntityId(), collection));
@@ -397,6 +479,14 @@
p_73117_1_.playerNetServerHandler.sendPacket(new S1BPacketEntityAttach(0, this.myEntity, this.myEntity.ridingEntity));
}
+ // CraftBukkit start
+ if (this.myEntity.riddenByEntity != null)
+ {
+ p_73117_1_.playerNetServerHandler.sendPacket(new S1BPacketEntityAttach(0, this.myEntity.riddenByEntity, this.myEntity));
+ }
+
+ // CraftBukkit end
+
if (this.myEntity instanceof EntityLiving && ((EntityLiving)this.myEntity).getLeashedToEntity() != null)
{
p_73117_1_.playerNetServerHandler.sendPacket(new S1BPacketEntityAttach(1, this.myEntity, ((EntityLiving)this.myEntity).getLeashedToEntity()));
@@ -425,6 +515,11 @@
}
}
+ // CraftBukkit start - Fix for nonsensical head yaw
+ this.lastHeadMotion = MathHelper.floor_float(this.myEntity.getRotationYawHead() * 256.0F / 360.0F); // tracker.ao() should be getHeadRotation
+ this.func_151259_a(new S19PacketEntityHeadLook(this.myEntity, (byte) lastHeadMotion));
+ // CraftBukkit end
+
if (this.myEntity instanceof EntityLivingBase)
{
EntityLivingBase entitylivingbase = (EntityLivingBase)this.myEntity;
@@ -465,7 +560,10 @@
{
if (this.myEntity.isDead)
{
- logger.warn("Fetching addPacket for removed entity");
+ // CraftBukkit start - Remove useless error spam, just return
+ // logger.warn("Fetching addPacket for removed entity");
+ return null;
+ // CraftBukkit end
}
Packet pkt = FMLNetworkHandler.getEntitySpawningPacket(this.myEntity);

View File

@ -0,0 +1,25 @@
--- ../src-base/minecraft/net/minecraft/entity/ai/EntityAIArrowAttack.java
+++ ../src-work/minecraft/net/minecraft/entity/ai/EntityAIArrowAttack.java
@@ -5,6 +5,11 @@
import net.minecraft.entity.IRangedAttackMob;
import net.minecraft.util.MathHelper;
+// CraftBukkit start
+import net.minecraft.entity.Entity;
+import org.bukkit.event.entity.EntityTargetEvent;
+// CraftBukkit end
+
public class EntityAIArrowAttack extends EntityAIBase
{
private final EntityLiving entityHost;
@@ -67,6 +72,10 @@
public void resetTask()
{
+ // CraftBukkit start
+ EntityTargetEvent.TargetReason reason = this.attackTarget.isEntityAlive() ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
+ org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetEvent((Entity) rangedAttackEntityHost, null, reason);
+ // CraftBukkit end
this.attackTarget = null;
this.field_75318_f = 0;
this.rangedAttackTime = -1;

View File

@ -0,0 +1,30 @@
--- ../src-base/minecraft/net/minecraft/entity/ai/EntityAIAttackOnCollide.java
+++ ../src-work/minecraft/net/minecraft/entity/ai/EntityAIAttackOnCollide.java
@@ -7,6 +7,11 @@
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
+// CraftBukkit start
+import net.minecraft.entity.Entity;
+import org.bukkit.event.entity.EntityTargetEvent;
+// CraftBukkit end
+
public class EntityAIAttackOnCollide extends EntityAIBase
{
World worldObj;
@@ -73,6 +78,15 @@
public boolean continueExecuting()
{
EntityLivingBase entitylivingbase = this.attacker.getAttackTarget();
+ // CraftBukkit start
+ EntityTargetEvent.TargetReason reason = this.attacker.getAttackTarget() == null ? EntityTargetEvent.TargetReason.FORGOT_TARGET : EntityTargetEvent.TargetReason.TARGET_DIED;
+
+ if (this.attacker.getAttackTarget() == null || (this.attacker.getAttackTarget() != null && !this.attacker.getAttackTarget().isEntityAlive()))
+ {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetEvent(attacker, null, reason);
+ }
+
+ // CraftBukkit end
return entitylivingbase == null ? false : (!entitylivingbase.isEntityAlive() ? false : (!this.longMemory ? !this.attacker.getNavigator().noPath() : this.attacker.isWithinHomeDistance(MathHelper.floor_double(entitylivingbase.posX), MathHelper.floor_double(entitylivingbase.posY), MathHelper.floor_double(entitylivingbase.posZ))));
}

View File

@ -0,0 +1,17 @@
--- ../src-base/minecraft/net/minecraft/entity/ai/EntityAIBreakDoor.java
+++ ../src-work/minecraft/net/minecraft/entity/ai/EntityAIBreakDoor.java
@@ -58,6 +58,14 @@
if (this.breakingTime == 240 && this.theEntity.worldObj.difficultySetting == EnumDifficulty.HARD)
{
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callEntityBreakDoorEvent(this.theEntity, this.entityPosX, this.entityPosY, this.entityPosZ).isCancelled())
+ {
+ this.updateTask();
+ return;
+ }
+
+ // CraftBukkit end
this.theEntity.worldObj.setBlockToAir(this.entityPosX, this.entityPosY, this.entityPosZ);
this.theEntity.worldObj.playAuxSFX(1012, this.entityPosX, this.entityPosY, this.entityPosZ, 0);
this.theEntity.worldObj.playAuxSFX(2001, this.entityPosX, this.entityPosY, this.entityPosZ, Block.getIdFromBlock(this.field_151504_e));

View File

@ -0,0 +1,34 @@
--- ../src-base/minecraft/net/minecraft/entity/ai/EntityAIEatGrass.java
+++ ../src-work/minecraft/net/minecraft/entity/ai/EntityAIEatGrass.java
@@ -6,6 +6,11 @@
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.Material;
+// CraftBukkit end
+
public class EntityAIEatGrass extends EntityAIBase
{
private EntityLiving field_151500_b;
@@ -69,7 +74,8 @@
if (this.field_151501_c.getBlock(i, j, k) == Blocks.tallgrass)
{
- if (this.field_151501_c.getGameRules().getGameRuleBooleanValue("mobGriefing"))
+ // CraftBukkit
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.field_151500_b, this.field_151500_b.worldObj.getWorld().getBlockAt(i, j, k), Material.AIR, !this.field_151501_c.getGameRules().getGameRuleBooleanValue("mobGriefing")).isCancelled())
{
this.field_151501_c.func_147480_a(i, j, k, false);
}
@@ -78,7 +84,8 @@
}
else if (this.field_151501_c.getBlock(i, j - 1, k) == Blocks.grass)
{
- if (this.field_151501_c.getGameRules().getGameRuleBooleanValue("mobGriefing"))
+ // CraftBukkit
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this.field_151500_b, this.field_151500_b.worldObj.getWorld().getBlockAt(i, j - 1, k), Material.DIRT, !this.field_151501_c.getGameRules().getGameRuleBooleanValue("mobGriefing")).isCancelled())
{
this.field_151501_c.playAuxSFX(2001, i, j - 1, k, Block.getIdFromBlock(Blocks.grass));
this.field_151501_c.setBlock(i, j - 1, k, Blocks.dirt, 0, 2);

View File

@ -0,0 +1,42 @@
--- ../src-base/minecraft/net/minecraft/entity/ai/EntityAIMate.java
+++ ../src-work/minecraft/net/minecraft/entity/ai/EntityAIMate.java
@@ -4,6 +4,7 @@
import java.util.List;
import java.util.Random;
import net.minecraft.entity.EntityAgeable;
+import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.passive.EntityAnimal;
import net.minecraft.entity.passive.EntityCow;
@@ -12,6 +13,8 @@
import net.minecraft.stats.StatList;
import net.minecraft.world.World;
+import net.minecraft.entity.passive.EntityTameable; // CraftBukkit
+
public class EntityAIMate extends EntityAIBase
{
private EntityAnimal theAnimal;
@@ -93,6 +96,13 @@
if (entityageable != null)
{
+ // CraftBukkit start - set persistence for tame animals
+ if (entityageable instanceof EntityTameable && ((EntityTameable) entityageable).isTamed())
+ {
+ ((EntityLiving)entityageable).persistenceRequired = true; // Cauldron - fix illegal access error. SS bug?
+ }
+
+ // CraftBukkit end
EntityPlayer entityplayer = this.theAnimal.func_146083_cb();
if (entityplayer == null && this.targetMate.func_146083_cb() != null)
@@ -116,7 +126,7 @@
this.targetMate.resetInLove();
entityageable.setGrowingAge(-24000);
entityageable.setLocationAndAngles(this.theAnimal.posX, this.theAnimal.posY, this.theAnimal.posZ, 0.0F, 0.0F);
- this.theWorld.spawnEntityInWorld(entityageable);
+ this.theWorld.addEntity(entityageable, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
Random random = this.theAnimal.getRNG();
for (int i = 0; i < 7; ++i)

View File

@ -0,0 +1,26 @@
--- ../src-base/minecraft/net/minecraft/entity/ai/EntityAIPanic.java
+++ ../src-work/minecraft/net/minecraft/entity/ai/EntityAIPanic.java
@@ -3,6 +3,8 @@
import net.minecraft.entity.EntityCreature;
import net.minecraft.util.Vec3;
+import net.minecraft.entity.EntityLivingBase; // CraftBukkit
+
public class EntityAIPanic extends EntityAIBase
{
private EntityCreature theEntityCreature;
@@ -50,6 +52,14 @@
public boolean continueExecuting()
{
+ // CraftBukkit start - introduce a temporary timeout hack until this is fixed properly
+ if ((this.theEntityCreature.ticksExisted - this.theEntityCreature.func_142015_aE()) > 100)
+ {
+ this.theEntityCreature.setRevengeTarget((EntityLivingBase) null);
+ return false;
+ }
+
+ // CraftBukkit end
return !this.theEntityCreature.getNavigator().noPath();
}
}

View File

@ -0,0 +1,35 @@
--- ../src-base/minecraft/net/minecraft/entity/ai/EntityAIRunAroundLikeCrazy.java
+++ ../src-work/minecraft/net/minecraft/entity/ai/EntityAIRunAroundLikeCrazy.java
@@ -64,7 +64,8 @@
int i = this.horseHost.getTemper();
int j = this.horseHost.getMaxTemper();
- if (j > 0 && this.horseHost.getRNG().nextInt(j) < i)
+ // CraftBukkit
+ if (j > 0 && this.horseHost.getRNG().nextInt(j) < i && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this.horseHost, (EntityPlayer) this.horseHost.riddenByEntity).isCancelled() && this.horseHost.riddenByEntity instanceof EntityPlayer)
{
this.horseHost.setTamedBy((EntityPlayer)this.horseHost.riddenByEntity);
this.horseHost.worldObj.setEntityState(this.horseHost, (byte)7);
@@ -74,8 +75,20 @@
this.horseHost.increaseTemper(5);
}
- this.horseHost.riddenByEntity.mountEntity((Entity)null);
- this.horseHost.riddenByEntity = null;
+ // CraftBukkit start - Handle dismounting to account for VehicleExitEvent being fired.
+ if (this.horseHost.riddenByEntity != null)
+ {
+ this.horseHost.riddenByEntity.mountEntity((Entity) null);
+
+ // If the entity still has a passenger, then a plugin cancelled the event.
+ if (this.horseHost.riddenByEntity != null)
+ {
+ return;
+ }
+ }
+
+ // this.entity.passenger = null;
+ // CraftBukkit end
this.horseHost.makeHorseRearWithSound();
this.horseHost.worldObj.setEntityState(this.horseHost, (byte)6);
}

View File

@ -0,0 +1,11 @@
--- ../src-base/minecraft/net/minecraft/entity/ai/EntityAISit.java
+++ ../src-work/minecraft/net/minecraft/entity/ai/EntityAISit.java
@@ -19,7 +19,7 @@
{
if (!this.theEntity.isTamed())
{
- return false;
+ return this.isSitting && this.theEntity.getAttackTarget() == null; // CraftBukkit - Allow sitting for wild animals
}
else if (this.theEntity.isInWater())
{

View File

@ -0,0 +1,66 @@
--- ../src-base/minecraft/net/minecraft/entity/ai/EntityAITarget.java
+++ ../src-work/minecraft/net/minecraft/entity/ai/EntityAITarget.java
@@ -12,6 +12,11 @@
import net.minecraft.util.MathHelper;
import org.apache.commons.lang3.StringUtils;
+// CraftBukkit start
+import org.bukkit.craftbukkit.entity.CraftEntity;
+import org.bukkit.event.entity.EntityTargetEvent;
+// CraftBukkit end
+
public abstract class EntityAITarget extends EntityAIBase
{
protected EntityCreature taskOwner;
@@ -156,6 +161,51 @@
}
}
+ // CraftBukkit start - Check all the different target goals for the reason, default to RANDOM_TARGET
+ EntityTargetEvent.TargetReason reason = EntityTargetEvent.TargetReason.RANDOM_TARGET;
+
+ if (this instanceof EntityAIDefendVillage)
+ {
+ reason = EntityTargetEvent.TargetReason.DEFEND_VILLAGE;
+ }
+ else if (this instanceof EntityAIHurtByTarget)
+ {
+ reason = EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY;
+ }
+ else if (this instanceof EntityAINearestAttackableTarget)
+ {
+ if (p_75296_1_ instanceof EntityPlayer)
+ {
+ reason = EntityTargetEvent.TargetReason.CLOSEST_PLAYER;
+ }
+ }
+ else if (this instanceof EntityAIOwnerHurtByTarget)
+ {
+ reason = EntityTargetEvent.TargetReason.TARGET_ATTACKED_OWNER;
+ }
+ else if (this instanceof EntityAIOwnerHurtTarget)
+ {
+ reason = EntityTargetEvent.TargetReason.OWNER_ATTACKED_TARGET;
+ }
+
+ org.bukkit.event.entity.EntityTargetLivingEntityEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetLivingEvent(this.taskOwner, p_75296_1_, reason);
+
+ if (event.isCancelled() || event.getTarget() == null)
+ {
+ this.taskOwner.setAttackTarget(null);
+ return false;
+ }
+ else if (p_75296_1_.getBukkitEntity() != event.getTarget())
+ {
+ this.taskOwner.setAttackTarget((EntityLivingBase)((CraftEntity) event.getTarget()).getHandle());
+ }
+
+ if (this.taskOwner instanceof EntityCreature)
+ {
+ ((EntityCreature) this.taskOwner).entityToAttack = ((CraftEntity) event.getTarget()).getHandle();
+ }
+
+ // CraftBukkit end
return true;
}
}

View File

@ -0,0 +1,11 @@
--- ../src-base/minecraft/net/minecraft/entity/ai/EntityAIVillagerMate.java
+++ ../src-work/minecraft/net/minecraft/entity/ai/EntityAIVillagerMate.java
@@ -119,7 +119,7 @@
this.villagerObj.setGrowingAge(6000);
entityvillager.setGrowingAge(-24000);
entityvillager.setLocationAndAngles(this.villagerObj.posX, this.villagerObj.posY, this.villagerObj.posZ, 0.0F, 0.0F);
- this.worldObj.spawnEntityInWorld(entityvillager);
+ this.worldObj.addEntity(entityvillager, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.BREEDING); // CraftBukkit - added SpawnReason
this.worldObj.setEntityState(entityvillager, (byte)12);
}
}

View File

@ -0,0 +1,24 @@
--- ../src-base/minecraft/net/minecraft/entity/ai/EntityLookHelper.java
+++ ../src-work/minecraft/net/minecraft/entity/ai/EntityLookHelper.java
@@ -5,6 +5,8 @@
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.util.MathHelper;
+import org.bukkit.craftbukkit.TrigMath; // CraftBukkit
+
public class EntityLookHelper
{
private EntityLiving entity;
@@ -61,8 +63,10 @@
double d1 = this.posY - (this.entity.posY + (double)this.entity.getEyeHeight());
double d2 = this.posZ - this.entity.posZ;
double d3 = (double)MathHelper.sqrt_double(d0 * d0 + d2 * d2);
- float f = (float)(Math.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F;
- float f1 = (float)(-(Math.atan2(d1, d3) * 180.0D / Math.PI));
+ // CraftBukkit start - Math -> TrigMath
+ float f = (float)(TrigMath.atan2(d2, d0) * 180.0D / Math.PI) - 90.0F;
+ float f1 = (float)(-(TrigMath.atan2(d1, d3) * 180.0D / Math.PI));
+ // CraftBukkit end
this.entity.rotationPitch = this.updateRotation(this.entity.rotationPitch, f1, this.deltaLookPitch);
this.entity.rotationYawHead = this.updateRotation(this.entity.rotationYawHead, f, this.deltaLookYaw);
}

View File

@ -0,0 +1,12 @@
--- ../src-base/minecraft/net/minecraft/entity/ai/EntityMoveHelper.java
+++ ../src-work/minecraft/net/minecraft/entity/ai/EntityMoveHelper.java
@@ -56,7 +56,8 @@
if (d3 >= 2.500000277905201E-7D)
{
- float f = (float)(Math.atan2(d1, d0) * 180.0D / Math.PI) - 90.0F;
+ // CraftBukkit - Math -> TrigMath
+ float f = (float)(org.bukkit.craftbukkit.TrigMath.atan2(d1, d0) * 180.0D / Math.PI) - 90.0F;
this.entity.rotationYaw = this.limitAngle(this.entity.rotationYaw, f, 30.0F);
this.entity.setAIMoveSpeed((float)(this.speed * this.entity.getEntityAttribute(SharedMonsterAttributes.movementSpeed).getAttributeValue()));

View File

@ -0,0 +1,258 @@
--- ../src-base/minecraft/net/minecraft/entity/boss/EntityDragon.java
+++ ../src-work/minecraft/net/minecraft/entity/boss/EntityDragon.java
@@ -22,6 +22,19 @@
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
+// CraftBukkit start
+import net.minecraft.entity.player.EntityPlayerMP;
+import net.minecraft.network.play.server.S23PacketBlockChange;
+import org.bukkit.block.BlockState;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.util.BlockStateListPopulator;
+import org.bukkit.event.entity.EntityCreatePortalEvent;
+import org.bukkit.event.entity.EntityExplodeEvent;
+import org.bukkit.event.entity.EntityRegainHealthEvent;
+import org.bukkit.event.entity.EntityTargetEvent;
+import org.bukkit.Bukkit;
+// CraftBukkit end
+
public class EntityDragon extends EntityLiving implements IBossDisplayData, IEntityMultiPart, IMob
{
public double targetX;
@@ -44,6 +57,7 @@
private Entity target;
public int deathTicks;
public EntityEnderCrystal healingEnderCrystal;
+ private Explosion explosionSource = new Explosion(null, this, Double.NaN, Double.NaN, Double.NaN, Float.NaN); // CraftBukkit - reusable source for CraftTNTPrimed.getSource()
private static final String __OBFID = "CL_00001659";
public EntityDragon(World p_i1700_1_)
@@ -355,14 +369,25 @@
{
if (!this.worldObj.isRemote)
{
- this.attackEntityFromPart(this.dragonPartHead, DamageSource.setExplosionSource((Explosion)null), 10.0F);
+ CraftEventFactory.entityDamage = this.healingEnderCrystal; // CraftBukkit
+ this.attackEntityFromPart(this.dragonPartHead, DamageSource.setExplosionSource((Explosion) null), 10.0F);
+ CraftEventFactory.entityDamage = null; // CraftBukkit
}
this.healingEnderCrystal = null;
}
else if (this.ticksExisted % 10 == 0 && this.getHealth() < this.getMaxHealth())
{
- this.setHealth(this.getHealth() + 1.0F);
+ // CraftBukkit start
+ EntityRegainHealthEvent event = new EntityRegainHealthEvent(this.getBukkitEntity(), 1.0D, EntityRegainHealthEvent.RegainReason.ENDER_CRYSTAL);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ this.setHealth((float)(this.getHealth() + event.getAmount()));
+ }
+
+ // CraftBukkit end
}
}
@@ -429,7 +454,24 @@
if (this.rand.nextInt(2) == 0 && !this.worldObj.playerEntities.isEmpty())
{
- this.target = (Entity)this.worldObj.playerEntities.get(this.rand.nextInt(this.worldObj.playerEntities.size()));
+ // CraftBukkit start
+ Entity target = (Entity) this.worldObj.playerEntities.get(this.rand.nextInt(this.worldObj.playerEntities.size()));
+ EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), target.getBukkitEntity(), EntityTargetEvent.TargetReason.RANDOM_TARGET);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ if (event.getTarget() == null)
+ {
+ this.target = null;
+ }
+ else
+ {
+ this.target = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
+ }
+ }
+
+ // CraftBukkit end
}
else
{
@@ -468,6 +510,10 @@
int j1 = MathHelper.floor_double(p_70972_1_.maxZ);
boolean flag = false;
boolean flag1 = false;
+ // CraftBukkit start - Create a list to hold all the destroyed blocks
+ List<org.bukkit.block.Block> destroyedBlocks = new java.util.ArrayList<org.bukkit.block.Block>();
+ org.bukkit.craftbukkit.CraftWorld craftWorld = this.worldObj.getWorld();
+ // CraftBukkit end
for (int k1 = i; k1 <= l; ++k1)
{
@@ -481,7 +527,11 @@
{
if (block.canEntityDestroy(worldObj, k1, l1, i2, this) && this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing"))
{
- flag1 = this.worldObj.setBlockToAir(k1, l1, i2) || flag1;
+ // CraftBukkit start - Add blocks to list rather than destroying them
+ // flag1 = this.world.setAir(k1, l1, i2) || flag1;
+ flag1 = true;
+ destroyedBlocks.add(craftWorld.getBlockAt(k1, l1, i2));
+ // CraftBukkit end
}
else
{
@@ -494,6 +544,52 @@
if (flag1)
{
+ // CraftBukkit start - Set off an EntityExplodeEvent for the dragon exploding all these blocks
+ org.bukkit.entity.Entity bukkitEntity = this.getBukkitEntity();
+ EntityExplodeEvent event = new EntityExplodeEvent(bukkitEntity, bukkitEntity.getLocation(), destroyedBlocks, 0F);
+ Bukkit.getPluginManager().callEvent(event);
+
+ if (event.isCancelled())
+ {
+ // This flag literally means 'Dragon hit something hard' (Obsidian, White Stone or Bedrock) and will cause the dragon to slow down.
+ // We should consider adding an event extension for it, or perhaps returning true if the event is cancelled.
+ return flag;
+ }
+ else if (event.getYield() == 0F)
+ {
+ // Yield zero ==> no drops
+ for (org.bukkit.block.Block block : event.blockList())
+ {
+ this.worldObj.setBlockToAir(block.getX(), block.getY(), block.getZ());
+ }
+ }
+ else
+ {
+ for (org.bukkit.block.Block block : event.blockList())
+ {
+ org.bukkit.Material blockId = block.getType();
+
+ if (blockId == org.bukkit.Material.AIR)
+ {
+ continue;
+ }
+
+ int blockX = block.getX();
+ int blockY = block.getY();
+ int blockZ = block.getZ();
+ Block nmsBlock = org.bukkit.craftbukkit.util.CraftMagicNumbers.getBlock(blockId);
+
+ if (nmsBlock.canDropFromExplosion(explosionSource))
+ {
+ nmsBlock.dropBlockAsItemWithChance(this.worldObj, blockX, blockY, blockZ, block.getData(), event.getYield(), 0);
+ }
+
+ nmsBlock.onBlockDestroyedByExplosion(worldObj, blockX, blockY, blockZ, explosionSource);
+ this.worldObj.setBlockToAir(blockX, blockY, blockZ);
+ }
+ }
+
+ // CraftBukkit end
double d1 = p_70972_1_.minX + (p_70972_1_.maxX - p_70972_1_.minX) * (double)this.rand.nextFloat();
double d2 = p_70972_1_.minY + (p_70972_1_.maxY - p_70972_1_.minY) * (double)this.rand.nextFloat();
double d0 = p_70972_1_.minZ + (p_70972_1_.maxZ - p_70972_1_.minZ) * (double)this.rand.nextFloat();
@@ -531,13 +627,18 @@
return false;
}
- protected boolean func_82195_e(DamageSource p_82195_1_, float p_82195_2_)
+ public boolean func_82195_e(DamageSource p_82195_1_, float p_82195_2_) // CraftBukkit - protected -> public
{
return super.attackEntityFrom(p_82195_1_, p_82195_2_);
}
protected void onDeathUpdate()
{
+ if (this.isDead)
+ {
+ return; // CraftBukkit - can't kill what's already dead
+ }
+
++this.deathTicks;
if (this.deathTicks >= 180 && this.deathTicks <= 200)
@@ -555,7 +656,7 @@
{
if (this.deathTicks > 150 && this.deathTicks % 5 == 0)
{
- i = 1000;
+ i = this.expToDrop / 12; // CraftBukkit - drop experience as dragon falls from sky. use experience drop from death event. This is now set in getExpReward()
while (i > 0)
{
@@ -576,7 +677,7 @@
if (this.deathTicks == 200 && !this.worldObj.isRemote)
{
- i = 2000;
+ i = this.expToDrop - (10 * this.expToDrop / 12); // CraftBukkit - drop the remaining experience
while (i > 0)
{
@@ -595,6 +696,8 @@
byte b0 = 64;
BlockEndPortal.field_149948_a = true;
byte b1 = 4;
+ // CraftBukkit start - Replace any "this.world" in the following with just "world"!
+ BlockStateListPopulator world = new BlockStateListPopulator(this.worldObj.getWorld());
for (int k = b0 - 1; k <= b0 + 32; ++k)
{
@@ -641,6 +744,35 @@
this.worldObj.setBlock(p_70975_1_, b0 + 2, p_70975_2_ + 1, Blocks.torch);
this.worldObj.setBlock(p_70975_1_, b0 + 3, p_70975_2_, Blocks.bedrock);
this.worldObj.setBlock(p_70975_1_, b0 + 4, p_70975_2_, Blocks.dragon_egg);
+ EntityCreatePortalEvent event = new EntityCreatePortalEvent((org.bukkit.entity.LivingEntity) this.getBukkitEntity(), java.util.Collections.unmodifiableList(world.getList()), org.bukkit.PortalType.ENDER);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ for (BlockState state : event.getBlocks())
+ {
+ state.update(true);
+ }
+ }
+ else
+ {
+ for (BlockState state : event.getBlocks())
+ {
+ S23PacketBlockChange packet = new S23PacketBlockChange(state.getX(), state.getY(), state.getZ(), this.worldObj);
+
+ for (Iterator it = this.worldObj.playerEntities.iterator(); it.hasNext();)
+ {
+ EntityPlayer entity = (EntityPlayer) it.next();
+
+ if (entity instanceof EntityPlayerMP)
+ {
+ ((EntityPlayerMP) entity).playerNetServerHandler.sendPacket(packet);
+ }
+ }
+ }
+ }
+
+ // CraftBukkit end
BlockEndPortal.field_149948_a = false;
}
@@ -675,4 +807,13 @@
{
return 5.0F;
}
+
+ // CraftBukkit start
+ public int getExpReward()
+ {
+ // This value is equal to the amount of experience dropped while falling from the sky (10 * 1000)
+ // plus what is dropped when the dragon hits the ground (2000)
+ return 12000;
+ }
+ // CraftBukkit end
}

View File

@ -0,0 +1,57 @@
--- ../src-base/minecraft/net/minecraft/entity/boss/EntityWither.java
+++ ../src-work/minecraft/net/minecraft/entity/boss/EntityWither.java
@@ -34,6 +34,11 @@
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.ExplosionPrimeEvent;
+// CraftBukkit end
+
public class EntityWither extends EntityMob implements IBossDisplayData, IRangedAttackMob
{
private float[] field_82220_d = new float[2];
@@ -228,15 +233,25 @@
if (i <= 0)
{
- this.worldObj.newExplosion(this, this.posX, this.posY + (double)this.getEyeHeight(), this.posZ, 7.0F, false, this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing"));
- this.worldObj.playBroadcastSound(1013, (int)this.posX, (int)this.posY, (int)this.posZ, 0);
+ // CraftBukkit start
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 7.0F, false);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ this.worldObj.newExplosion(this, this.posX, this.posY + (double) this.getEyeHeight(), this.posZ, event.getRadius(), event.getFire(), this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing"));
+ }
+
+ // CraftBukkit end
+ this.worldObj.newExplosion(this, this.posX, this.posY + (double) this.getEyeHeight(), this.posZ, 7.0F, false, this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing"));
+ this.worldObj.playBroadcastSound(1013, (int) this.posX, (int) this.posY, (int) this.posZ, 0);
}
this.func_82215_s(i);
if (this.ticksExisted % 10 == 0)
{
- this.heal(10.0F);
+ this.heal(10.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.WITHER_SPAWN); // CraftBukkit
}
}
else
@@ -349,6 +364,13 @@
if (!block.isAir(worldObj, j2, k, l) && block.canEntityDestroy(worldObj, j2, k, l, this))
{
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, j2, k, l, Blocks.air, 0).isCancelled())
+ {
+ continue;
+ }
+
+ // CraftBukkit end
flag = this.worldObj.func_147480_a(j2, k, l, true) || flag;
}
}

View File

@ -0,0 +1,100 @@
--- ../src-base/minecraft/net/minecraft/entity/effect/EntityLightningBolt.java
+++ ../src-work/minecraft/net/minecraft/entity/effect/EntityLightningBolt.java
@@ -10,6 +10,8 @@
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class EntityLightningBolt extends EntityWeatherEffect
{
private int lightningState;
@@ -17,15 +19,25 @@
private int boltLivingTime;
private static final String __OBFID = "CL_00001666";
+ // CraftBukkit start
+ public boolean isEffect = false;
+
public EntityLightningBolt(World p_i1703_1_, double p_i1703_2_, double p_i1703_4_, double p_i1703_6_)
{
+ this(p_i1703_1_, p_i1703_2_, p_i1703_4_, p_i1703_6_, false);
+ }
+
+ public EntityLightningBolt(World p_i1703_1_, double p_i1703_2_, double p_i1703_4_, double p_i1703_6_, boolean isEffect)
+ {
super(p_i1703_1_);
+ this.isEffect = isEffect;
+ // CraftBukkit end
this.setLocationAndAngles(p_i1703_2_, p_i1703_4_, p_i1703_6_, 0.0F, 0.0F);
this.lightningState = 2;
this.boltVertex = this.rand.nextLong();
this.boltLivingTime = this.rand.nextInt(3) + 1;
- if (!p_i1703_1_.isRemote && p_i1703_1_.getGameRules().getGameRuleBooleanValue("doFireTick") && (p_i1703_1_.difficultySetting == EnumDifficulty.NORMAL || p_i1703_1_.difficultySetting == EnumDifficulty.HARD) && p_i1703_1_.doChunksNearChunkExist(MathHelper.floor_double(p_i1703_2_), MathHelper.floor_double(p_i1703_4_), MathHelper.floor_double(p_i1703_6_), 10))
+ if (!isEffect && !p_i1703_1_.isRemote && p_i1703_1_.getGameRules().getGameRuleBooleanValue("doFireTick") && (p_i1703_1_.difficultySetting == EnumDifficulty.NORMAL || p_i1703_1_.difficultySetting == EnumDifficulty.HARD) && p_i1703_1_.doChunksNearChunkExist(MathHelper.floor_double(p_i1703_2_), MathHelper.floor_double(p_i1703_4_), MathHelper.floor_double(p_i1703_6_), 10)) // CraftBukkit
{
int i = MathHelper.floor_double(p_i1703_2_);
int j = MathHelper.floor_double(p_i1703_4_);
@@ -33,7 +45,13 @@
if (p_i1703_1_.getBlock(i, j, k).getMaterial() == Material.air && Blocks.fire.canPlaceBlockAt(p_i1703_1_, i, j, k))
{
- p_i1703_1_.setBlock(i, j, k, Blocks.fire);
+ // CraftBukkit start
+ if (!CraftEventFactory.callBlockIgniteEvent(p_i1703_1_, i, j, k, this).isCancelled())
+ {
+ p_i1703_1_.setBlock(i, j, k, Blocks.fire);
+ }
+
+ // CraftBukkit end
}
for (i = 0; i < 4; ++i)
@@ -44,7 +62,13 @@
if (p_i1703_1_.getBlock(j, k, l).getMaterial() == Material.air && Blocks.fire.canPlaceBlockAt(p_i1703_1_, j, k, l))
{
- p_i1703_1_.setBlock(j, k, l, Blocks.fire);
+ // CraftBukkit start
+ if (!CraftEventFactory.callBlockIgniteEvent(p_i1703_1_, j, k, l, this).isCancelled())
+ {
+ p_i1703_1_.setBlock(j, k, l, Blocks.fire);
+ }
+
+ // CraftBukkit end
}
}
}
@@ -74,7 +98,8 @@
this.lightningState = 1;
this.boltVertex = this.rand.nextLong();
- if (!this.worldObj.isRemote && this.worldObj.getGameRules().getGameRuleBooleanValue("doFireTick") && this.worldObj.doChunksNearChunkExist(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ), 10))
+ // CraftBukkit
+ if (!isEffect && !this.worldObj.isRemote && this.worldObj.getGameRules().getGameRuleBooleanValue("doFireTick") && this.worldObj.doChunksNearChunkExist(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ), 10))
{
int i = MathHelper.floor_double(this.posX);
int j = MathHelper.floor_double(this.posY);
@@ -82,13 +107,19 @@
if (this.worldObj.getBlock(i, j, k).getMaterial() == Material.air && Blocks.fire.canPlaceBlockAt(this.worldObj, i, j, k))
{
- this.worldObj.setBlock(i, j, k, Blocks.fire);
+ // CraftBukkit start
+ if (!CraftEventFactory.callBlockIgniteEvent(worldObj, i, j, k, this).isCancelled())
+ {
+ this.worldObj.setBlock(i, j, k, Blocks.fire);
+ }
+
+ // CraftBukkit end
}
}
}
}
- if (this.lightningState >= 0)
+ if (this.lightningState >= 0 && !this.isEffect) // CraftBukkit - add !this.isEffect
{
if (this.worldObj.isRemote)
{

View File

@ -0,0 +1,239 @@
--- ../src-base/minecraft/net/minecraft/entity/item/EntityBoat.java
+++ ../src-work/minecraft/net/minecraft/entity/item/EntityBoat.java
@@ -17,6 +17,16 @@
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
+// CraftBukkit start
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.entity.Vehicle;
+import org.bukkit.event.vehicle.VehicleDamageEvent;
+import org.bukkit.event.vehicle.VehicleDestroyEvent;
+import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
+import org.bukkit.event.vehicle.VehicleMoveEvent;
+// CraftBukkit end
+
public class EntityBoat extends Entity
{
private boolean isBoatEmpty;
@@ -35,6 +45,32 @@
private double velocityZ;
private static final String __OBFID = "CL_00001667";
+ // CraftBukkit start
+ public double maxSpeed = 0.4D;
+ public double occupiedDeceleration = 0.2D;
+ public double unoccupiedDeceleration = -1;
+ public boolean landBoats = false;
+
+ @Override
+
+ /**
+ * Applies a velocity to each of the entities pushing them away from each other. Args: entity
+ */
+ public void applyEntityCollision(Entity entity)
+ {
+ org.bukkit.entity.Entity hitEntity = (entity == null) ? null : entity.getBukkitEntity();
+ VehicleEntityCollisionEvent event = new VehicleEntityCollisionEvent((Vehicle) this.getBukkitEntity(), hitEntity);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled())
+ {
+ return;
+ }
+
+ super.applyEntityCollision(entity);
+ }
+ // CraftBukkit end
+
public EntityBoat(World p_i1704_1_)
{
super(p_i1704_1_);
@@ -82,6 +118,7 @@
this.prevPosX = p_i1705_2_;
this.prevPosY = p_i1705_4_;
this.prevPosZ = p_i1705_6_;
+ this.worldObj.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleCreateEvent((Vehicle) this.getBukkitEntity())); // CraftBukkit
}
public double getMountedYOffset()
@@ -97,6 +134,19 @@
}
else if (!this.worldObj.isRemote && !this.isDead)
{
+ // CraftBukkit start
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ org.bukkit.entity.Entity attacker = (p_70097_1_.getEntity() == null) ? null : p_70097_1_.getEntity().getBukkitEntity();
+ VehicleDamageEvent event = new VehicleDamageEvent(vehicle, attacker, (double) p_70097_2_);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled())
+ {
+ return true;
+ }
+
+ // f = event.getDamage(); // TODO Why don't we do this?
+ // CraftBukkit end
this.setForwardDirection(-this.getForwardDirection());
this.setTimeSinceHit(10);
this.setDamageTaken(this.getDamageTaken() + p_70097_2_ * 10.0F);
@@ -105,6 +155,18 @@
if (flag || this.getDamageTaken() > 40.0F)
{
+ // CraftBukkit start
+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, attacker);
+ this.worldObj.getServer().getPluginManager().callEvent(destroyEvent);
+
+ if (destroyEvent.isCancelled())
+ {
+ this.setDamageTaken(40F); // Maximize damage so this doesn't get triggered again right away
+ return true;
+ }
+
+ // CraftBukkit end
+
if (this.riddenByEntity != null)
{
this.riddenByEntity.mountEntity(this);
@@ -181,6 +243,13 @@
public void onUpdate()
{
+ // CraftBukkit start
+ double prevX = this.posX;
+ double prevY = this.posY;
+ double prevZ = this.posZ;
+ float prevYaw = this.rotationYaw;
+ float prevPitch = this.rotationPitch;
+ // CraftBukkit end
super.onUpdate();
if (this.getTimeSinceHit() > 0)
@@ -303,7 +372,25 @@
this.motionX += -Math.sin((double)(f * (float)Math.PI / 180.0F)) * this.speedMultiplier * (double)entitylivingbase.moveForward * 0.05000000074505806D;
this.motionZ += Math.cos((double)(f * (float)Math.PI / 180.0F)) * this.speedMultiplier * (double)entitylivingbase.moveForward * 0.05000000074505806D;
}
+ // CraftBukkit start - Support unoccupied deceleration
+ else if (unoccupiedDeceleration >= 0)
+ {
+ this.motionX *= unoccupiedDeceleration;
+ this.motionZ *= unoccupiedDeceleration;
+ // Kill lingering speed
+ if (motionX <= 0.00001)
+ {
+ motionX = 0;
+ }
+
+ if (motionZ <= 0.00001)
+ {
+ motionZ = 0;
+ }
+ }
+
+ // CraftBukkit end
d2 = Math.sqrt(this.motionX * this.motionX + this.motionZ * this.motionZ);
if (d2 > 0.35D)
@@ -347,18 +434,32 @@
if (block == Blocks.snow_layer)
{
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, i1, k, j, Blocks.air, 0).isCancelled())
+ {
+ continue;
+ }
+
+ // CraftBukkit end
this.worldObj.setBlockToAir(i1, k, j);
this.isCollidedHorizontally = false;
}
else if (block == Blocks.waterlily)
{
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, i1, k, j, Blocks.air, 0).isCancelled())
+ {
+ continue;
+ }
+
+ // CraftBukkit end
this.worldObj.func_147480_a(i1, k, j, true);
this.isCollidedHorizontally = false;
}
}
}
- if (this.onGround)
+ if (this.onGround && !this.landBoats) // CraftBukkit
{
this.motionX *= 0.5D;
this.motionY *= 0.5D;
@@ -371,17 +472,27 @@
{
if (!this.worldObj.isRemote && !this.isDead)
{
- this.setDead();
+ // CraftBukkit start
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, null);
+ this.worldObj.getServer().getPluginManager().callEvent(destroyEvent);
- for (l = 0; l < 3; ++l)
+ if (!destroyEvent.isCancelled())
{
- this.func_145778_a(Item.getItemFromBlock(Blocks.planks), 1, 0.0F);
- }
+ this.setDead();
- for (l = 0; l < 2; ++l)
- {
- this.func_145778_a(Items.stick, 1, 0.0F);
+ for (l = 0; l < 3; ++l)
+ {
+ this.func_145778_a(Item.getItemFromBlock(Blocks.planks), 1, 0.0F);
+ }
+
+ for (l = 0; l < 2; ++l)
+ {
+ this.func_145778_a(Items.stick, 1, 0.0F);
+ }
}
+
+ // CraftBukkit end
}
}
else
@@ -415,7 +526,22 @@
this.rotationYaw = (float)((double)this.rotationYaw + d7);
this.setRotation(this.rotationYaw, this.rotationPitch);
+ // CraftBukkit start
+ org.bukkit.Server server = this.worldObj.getServer();
+ org.bukkit.World bworld = this.worldObj.getWorld();
+ Location from = new Location(bworld, prevX, prevY, prevZ, prevYaw, prevPitch);
+ Location to = new Location(bworld, this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ server.getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
+ if (!from.equals(to))
+ {
+ VehicleMoveEvent event = new VehicleMoveEvent(vehicle, from, to);
+ server.getPluginManager().callEvent(event);
+ }
+
+ // CraftBukkit end
+
if (!this.worldObj.isRemote)
{
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, this.boundingBox.expand(0.20000000298023224D, 0.0D, 0.20000000298023224D));
@@ -435,6 +561,7 @@
if (this.riddenByEntity != null && this.riddenByEntity.isDead)
{
+ this.riddenByEntity.ridingEntity = null; // CraftBukkit
this.riddenByEntity = null;
}
}

View File

@ -0,0 +1,49 @@
--- ../src-base/minecraft/net/minecraft/entity/item/EntityEnderCrystal.java
+++ ../src-work/minecraft/net/minecraft/entity/item/EntityEnderCrystal.java
@@ -10,6 +10,8 @@
import net.minecraft.world.World;
import net.minecraft.world.WorldProviderEnd;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class EntityEnderCrystal extends Entity
{
public int innerRotation;
@@ -56,7 +58,13 @@
if (this.worldObj.provider instanceof WorldProviderEnd && this.worldObj.getBlock(i, j, k) != Blocks.fire)
{
- this.worldObj.setBlock(i, j, k, Blocks.fire);
+ // CraftBukkit start
+ if (!CraftEventFactory.callBlockIgniteEvent(this.worldObj, i, j, k, this).isCancelled())
+ {
+ this.worldObj.setBlock(i, j, k, Blocks.fire);
+ }
+
+ // CraftBukkit end
}
}
@@ -85,6 +93,13 @@
{
if (!this.isDead && !this.worldObj.isRemote)
{
+ // CraftBukkit start - All non-living entities need this
+ if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, p_70097_1_, p_70097_2_))
+ {
+ return false;
+ }
+
+ // CraftBukkit end
this.health = 0;
if (this.health <= 0)
@@ -93,7 +108,7 @@
if (!this.worldObj.isRemote)
{
- this.worldObj.createExplosion((Entity)null, this.posX, this.posY, this.posZ, 6.0F, true);
+ this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, 6.0F, true); // CraftBukkit - (Entity) null -> this
}
}
}

View File

@ -0,0 +1,56 @@
--- ../src-base/minecraft/net/minecraft/entity/item/EntityEnderPearl.java
+++ ../src-work/minecraft/net/minecraft/entity/item/EntityEnderPearl.java
@@ -12,6 +12,12 @@
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.EnderTeleportEvent;
+// CraftBukkit start
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.player.PlayerTeleportEvent;
+// CraftBukkit end
+
public class EntityEnderPearl extends EntityThrowable
{
private static final String __OBFID = "CL_00001725";
@@ -52,18 +58,31 @@
if (entityplayermp.playerNetServerHandler.func_147362_b().isChannelOpen() && entityplayermp.worldObj == this.worldObj)
{
- EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, this.posX, this.posY, this.posZ, 5.0F);
- if (!MinecraftForge.EVENT_BUS.post(event))
- { // Don't indent to lower patch size
- if (this.getThrower().isRiding())
- {
- this.getThrower().mountEntity((Entity)null);
+ EnderTeleportEvent event = new EnderTeleportEvent(entityplayermp, this.posX, this.posY, this.posZ, 5);
+ // Cauldron start - invert condition; return if cancelled otherwise fall through to CB event
+ if (MinecraftForge.EVENT_BUS.post(event)){
+ this.setDead();
+ return;
}
+ // Cauldron end
+ // CraftBukkit start
+ org.bukkit.craftbukkit.entity.CraftPlayer player = entityplayermp.getBukkitEntity();
+ org.bukkit.Location location = getBukkitEntity().getLocation();
+ location.setPitch(player.getLocation().getPitch());
+ location.setYaw(player.getLocation().getYaw());
+ PlayerTeleportEvent teleEvent = new PlayerTeleportEvent(player, player.getLocation(), location, PlayerTeleportEvent.TeleportCause.ENDER_PEARL);
+ Bukkit.getPluginManager().callEvent(teleEvent);
- this.getThrower().setPositionAndUpdate(event.targetX, event.targetY, event.targetZ);
- this.getThrower().fallDistance = 0.0F;
- this.getThrower().attackEntityFrom(DamageSource.fall, event.attackDamage);
+ if (!teleEvent.isCancelled() && !entityplayermp.playerNetServerHandler.isDisconnected())
+ {
+ entityplayermp.playerNetServerHandler.teleport(teleEvent.getTo());
+ this.getThrower().fallDistance = 0.0F;
+ CraftEventFactory.entityDamage = this;
+ this.getThrower().attackEntityFrom(DamageSource.fall, 5.0F);
+ CraftEventFactory.entityDamage = null;
}
+
+ // CraftBukkit end
}
}

View File

@ -0,0 +1,24 @@
--- ../src-base/minecraft/net/minecraft/entity/item/EntityExpBottle.java
+++ ../src-work/minecraft/net/minecraft/entity/item/EntityExpBottle.java
@@ -43,9 +43,20 @@
{
if (!this.worldObj.isRemote)
{
- this.worldObj.playAuxSFX(2002, (int)Math.round(this.posX), (int)Math.round(this.posY), (int)Math.round(this.posZ), 0);
+ // CraftBukkit moved after event
+ //this.worldObj.playAuxSFX(2002, (int)Math.round(this.posX), (int)Math.round(this.posY), (int)Math.round(this.posZ), 0);
int i = 3 + this.worldObj.rand.nextInt(5) + this.worldObj.rand.nextInt(5);
+ // CraftBukkit start
+ org.bukkit.event.entity.ExpBottleEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callExpBottleEvent(this, i);
+ i = event.getExperience();
+ if (event.getShowEffect())
+ {
+ this.worldObj.playAuxSFX(2002, (int) Math.round(this.posX), (int) Math.round(this.posY), (int) Math.round(this.posZ), 0);
+ }
+
+ // CraftBukkit end
+
while (i > 0)
{
int j = EntityXPOrb.getXPSplit(i);

View File

@ -0,0 +1,57 @@
--- ../src-base/minecraft/net/minecraft/entity/item/EntityFallingBlock.java
+++ ../src-work/minecraft/net/minecraft/entity/item/EntityFallingBlock.java
@@ -19,9 +19,11 @@
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class EntityFallingBlock extends Entity
{
- private Block field_145811_e;
+ public Block field_145811_e; // CraftBukkit - private -> public
public int field_145814_a;
public int field_145812_b;
public boolean field_145813_c;
@@ -103,7 +105,8 @@
if (this.field_145812_b == 1)
{
- if (this.worldObj.getBlock(i, j, k) != this.field_145811_e)
+ // CraftBukkit - compare data and call event
+ if (this.field_145812_b != 1 || this.worldObj.getBlock(i, j, k) != this.field_145811_e || this.worldObj.getBlockMetadata(i, j, k) != this.field_145814_a || CraftEventFactory.callEntityChangeBlockEvent(this, i, j, k, Blocks.air, 0).isCancelled())
{
this.setDead();
return;
@@ -122,8 +125,17 @@
{
this.setDead();
- if (!this.field_145808_f && this.worldObj.canPlaceEntityOnSide(this.field_145811_e, i, j, k, true, 1, (Entity)null, (ItemStack)null) && !BlockFalling.func_149831_e(this.worldObj, i, j - 1, k) && this.worldObj.setBlock(i, j, k, this.field_145811_e, this.field_145814_a, 3))
+ // CraftBukkit start
+ if (!this.field_145808_f && this.worldObj.canPlaceEntityOnSide(this.field_145811_e, i, j, k, true, 1, (Entity) null, (ItemStack) null) && !BlockFalling.func_149831_e(this.worldObj, i, j - 1, k) /* mimic the false conditions of setTypeIdAndData */ && i >= -30000000 && k >= -30000000 && i < 30000000 && k < 30000000 && j > 0 && j < 256 && !(this.worldObj.getBlock(i, j, k) == this.field_145811_e && this.worldObj.getBlockMetadata(i, j, k) == this.field_145814_a))
{
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, i, j, k, this.field_145811_e, this.field_145814_a).isCancelled())
+ {
+ return;
+ }
+
+ this.worldObj.setBlock(i, j, k, this.field_145811_e, this.field_145814_a, 3);
+ // CraftBukkit end
+
if (this.field_145811_e instanceof BlockFalling)
{
((BlockFalling)this.field_145811_e).func_149828_a(this.worldObj, i, j, k, this.field_145814_a);
@@ -189,8 +201,10 @@
while (iterator.hasNext())
{
- Entity entity = (Entity)iterator.next();
- entity.attackEntityFrom(damagesource, (float)Math.min(MathHelper.floor_float((float)i * this.field_145816_i), this.field_145815_h));
+ Entity entity = (Entity) iterator.next();
+ CraftEventFactory.entityDamage = this; // CraftBukkit
+ entity.attackEntityFrom(damagesource,(float) Math.min(MathHelper.floor_float((float) i * this.field_145816_i), this.field_145815_h));
+ CraftEventFactory.entityDamage = null; // CraftBukkit
}
if (flag && (double)this.rand.nextFloat() < 0.05000000074505806D + (double)i * 0.05D)

View File

@ -0,0 +1,11 @@
--- ../src-base/minecraft/net/minecraft/entity/item/EntityFireworkRocket.java
+++ ../src-work/minecraft/net/minecraft/entity/item/EntityFireworkRocket.java
@@ -11,7 +11,7 @@
public class EntityFireworkRocket extends Entity
{
private int fireworkAge;
- private int lifetime;
+ public int lifetime; // CraftBukkit - private -> public
private static final String __OBFID = "CL_00001718";
public EntityFireworkRocket(World p_i1762_1_)

View File

@ -0,0 +1,280 @@
--- ../src-base/minecraft/net/minecraft/entity/item/EntityItem.java
+++ ../src-work/minecraft/net/minecraft/entity/item/EntityItem.java
@@ -22,6 +22,11 @@
import cpw.mods.fml.common.FMLCommonHandler;
import cpw.mods.fml.common.eventhandler.Event.Result;
+// CraftBukkit start
+import org.bukkit.event.player.PlayerPickupItemEvent;
+import net.minecraft.server.MinecraftServer;
+// CraftBukkit end
+
public class EntityItem extends Entity
{
private static final Logger logger = LogManager.getLogger();
@@ -31,6 +36,7 @@
private String field_145801_f;
private String field_145802_g;
public float hoverStart;
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit
private static final String __OBFID = "CL_00001669";
/**
@@ -55,6 +61,15 @@
public EntityItem(World p_i1710_1_, double p_i1710_2_, double p_i1710_4_, double p_i1710_6_, ItemStack p_i1710_8_)
{
this(p_i1710_1_, p_i1710_2_, p_i1710_4_, p_i1710_6_);
+
+ // CraftBukkit start - Can't set null items in the datawatcher
+ if (p_i1710_8_ == null || p_i1710_8_.getItem() == null)
+ {
+ return;
+ }
+
+ // CraftBukkit end
+
this.setEntityItemStack(p_i1710_8_);
this.lifespan = (p_i1710_8_.getItem() == null ? 6000 : p_i1710_8_.getItem().getEntityLifespan(p_i1710_8_, p_i1710_1_));
}
@@ -89,93 +104,102 @@
}
}
- if (this.getEntityItem() == null)
- {
- this.setDead();
+ super.onUpdate();
+ // CraftBukkit start - Use wall time for pickup and despawn timers
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
+ this.delayBeforeCanPickup -= elapsedTicks;
+ this.age += elapsedTicks;
+ this.lastTick = MinecraftServer.currentTick;
+ // CraftBukkit end
+
+ boolean forceUpdate = this.ticksExisted > 0 && this.ticksExisted % 25 == 0; // Cauldron - optimize item tick updates
+ this.prevPosX = this.posX;
+ this.prevPosY = this.posY;
+ this.prevPosZ = this.posZ;
+ this.motionY -= 0.03999999910593033D;
+ // Cauldron start - if forced
+ if (forceUpdate || noClip) {
+ this.noClip = this.func_145771_j(this.posX, (this.boundingBox.minY + this.boundingBox.maxY) / 2.0D, this.posZ);
}
- else
- {
- super.onUpdate();
+ // Cauldron end
+ this.moveEntity(this.motionX, this.motionY, this.motionZ);
+ boolean flag = (int)this.prevPosX != (int)this.posX || (int)this.prevPosY != (int)this.posY || (int)this.prevPosZ != (int)this.posZ;
- if (this.delayBeforeCanPickup > 0)
+ if ((flag && this.ticksExisted % 5 == 0) || forceUpdate) // Cauldron - if forced
+ {
+ if (this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)).getMaterial() == Material.lava)
{
- --this.delayBeforeCanPickup;
+ this.motionY = 0.20000000298023224D;
+ this.motionX = (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F);
+ this.motionZ = (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F);
+ this.playSound("random.fizz", 0.4F, 2.0F + this.rand.nextFloat() * 0.4F);
}
- this.prevPosX = this.posX;
- this.prevPosY = this.posY;
- this.prevPosZ = this.posZ;
- this.motionY -= 0.03999999910593033D;
- this.noClip = this.func_145771_j(this.posX, (this.boundingBox.minY + this.boundingBox.maxY) / 2.0D, this.posZ);
- this.moveEntity(this.motionX, this.motionY, this.motionZ);
- boolean flag = (int)this.prevPosX != (int)this.posX || (int)this.prevPosY != (int)this.posY || (int)this.prevPosZ != (int)this.posZ;
-
- if (flag || this.ticksExisted % 25 == 0)
+ if (forceUpdate && !this.worldObj.isRemote) // Cauldron - if forced
{
- if (this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.posY), MathHelper.floor_double(this.posZ)).getMaterial() == Material.lava)
- {
- this.motionY = 0.20000000298023224D;
- this.motionX = (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F);
- this.motionZ = (double)((this.rand.nextFloat() - this.rand.nextFloat()) * 0.2F);
- this.playSound("random.fizz", 0.4F, 2.0F + this.rand.nextFloat() * 0.4F);
- }
-
- if (!this.worldObj.isRemote)
- {
- this.searchForOtherItemsNearby();
- }
+ this.searchForOtherItemsNearby();
}
+ }
- float f = 0.98F;
+ float f = 0.98F;
- if (this.onGround)
- {
- f = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ)).slipperiness * 0.98F;
- }
+ if (this.onGround)
+ {
+ f = this.worldObj.getBlock(MathHelper.floor_double(this.posX), MathHelper.floor_double(this.boundingBox.minY) - 1, MathHelper.floor_double(this.posZ)).slipperiness * 0.98F;
+ }
- this.motionX *= (double)f;
- this.motionY *= 0.9800000190734863D;
- this.motionZ *= (double)f;
+ this.motionX *= (double)f;
+ this.motionY *= 0.9800000190734863D;
+ this.motionZ *= (double)f;
- if (this.onGround)
- {
- this.motionY *= -0.5D;
- }
+ if (this.onGround)
+ {
+ this.motionY *= -0.5D;
+ }
- ++this.age;
+ // ++this.age; // CraftBukkit - Moved up (base age on wall time)
- ItemStack item = getDataWatcher().getWatchableObjectItemStack(10);
-
- if (!this.worldObj.isRemote && this.age >= lifespan)
+ ItemStack item = getDataWatcher().getWatchableObjectItemStack(10);
+
+ if (!this.worldObj.isRemote && this.age >= lifespan - 1) // Cauldron adjust for age being off by one when it is first dropped
+ {
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.callItemDespawnEvent(this).isCancelled())
{
- if (item != null)
- {
- ItemExpireEvent event = new ItemExpireEvent(this, (item.getItem() == null ? 6000 : item.getItem().getEntityLifespan(item, worldObj)));
- if (MinecraftForge.EVENT_BUS.post(event))
- {
- lifespan += event.extraLife;
- }
- else
- {
- this.setDead();
- }
+ this.age = 0;
+ return;
+ }
+ // CraftBukkit end
+ if (item != null)
+ {
+ ItemExpireEvent event = new ItemExpireEvent(this, (item.getItem() == null ? this.worldObj.getSpigotConfig().itemDespawnRate : item.getItem().getEntityLifespan(item, worldObj))); // Spigot // Cauldron
+ if (MinecraftForge.EVENT_BUS.post(event))
+ {
+ lifespan += event.extraLife;
}
else
{
this.setDead();
}
}
-
- if (item != null && item.stackSize <= 0)
+ else
{
this.setDead();
}
}
+
+ if (item != null && item.stackSize <= 0)
+ {
+ this.setDead();
+ }
}
private void searchForOtherItemsNearby()
{
- Iterator iterator = this.worldObj.getEntitiesWithinAABB(EntityItem.class, this.boundingBox.expand(0.5D, 0.0D, 0.5D)).iterator();
+ // Spigot start
+ double radius = worldObj.getSpigotConfig().itemMerge; // Cauldron
+ Iterator iterator = this.worldObj.getEntitiesWithinAABB(EntityItem.class, this.boundingBox.expand(radius, radius, radius)).iterator();
+ // Spigot end
while (iterator.hasNext())
{
@@ -225,11 +249,13 @@
}
else
{
- itemstack1.stackSize += itemstack.stackSize;
- p_70289_1_.delayBeforeCanPickup = Math.max(p_70289_1_.delayBeforeCanPickup, this.delayBeforeCanPickup);
- p_70289_1_.age = Math.min(p_70289_1_.age, this.age);
- p_70289_1_.setEntityItemStack(itemstack1);
- this.setDead();
+ // Spigot start
+ itemstack.stackSize += itemstack1.stackSize;
+ this.delayBeforeCanPickup = Math.max(p_70289_1_.delayBeforeCanPickup, this.delayBeforeCanPickup);
+ this.age = Math.min(p_70289_1_.age, this.age);
+ this.setEntityItemStack(itemstack);
+ p_70289_1_.setDead();
+ // Spigot end
return true;
}
}
@@ -316,8 +342,27 @@
}
NBTTagCompound nbttagcompound1 = p_70037_1_.getCompoundTag("Item");
- this.setEntityItemStack(ItemStack.loadItemStackFromNBT(nbttagcompound1));
+ // CraftBukkit start
+ if (nbttagcompound1 != null)
+ {
+ ItemStack itemstack = ItemStack.loadItemStackFromNBT(nbttagcompound1);
+
+ if (itemstack != null)
+ {
+ this.setEntityItemStack(itemstack);
+ }
+ else
+ {
+ this.setDead();
+ }
+ }
+ else
+ {
+ this.setDead();
+ }
+
+ // CraftBukkit end
ItemStack item = getDataWatcher().getWatchableObjectItemStack(10);
if (item == null || item.stackSize <= 0)
@@ -350,6 +395,31 @@
ItemStack itemstack = this.getEntityItem();
int i = itemstack.stackSize;
+ // CraftBukkit start
+ int canHold = p_70100_1_.inventory.canHold(itemstack);
+ int remaining = itemstack.stackSize - canHold;
+
+ if (this.delayBeforeCanPickup <= 0 && canHold > 0)
+ {
+ itemstack.stackSize = canHold;
+ // Cauldron start - rename to cbEvent to fix naming collision
+ PlayerPickupItemEvent cbEvent = new PlayerPickupItemEvent((org.bukkit.entity.Player) p_70100_1_.getBukkitEntity(), (org.bukkit.entity.Item) this.getBukkitEntity(), remaining);
+ //cbEvent.setCancelled(!par1EntityPlayer.canPickUpLoot); TODO
+ this.worldObj.getServer().getPluginManager().callEvent(cbEvent);
+ itemstack.stackSize = canHold + remaining;
+
+ if (cbEvent.isCancelled())
+ {
+ return;
+ }
+ // Cauldron end
+
+ // Possibly < 0; fix here so we do not have to modify code below
+ this.delayBeforeCanPickup = 0;
+ }
+
+ // CraftBukkit end
+
if (this.delayBeforeCanPickup <= 0 && (this.field_145802_g == null || lifespan - this.age <= 200 || this.field_145802_g.equals(p_70100_1_.getCommandSenderName())) && (event.getResult() == Result.ALLOW || i <= 0 || p_70100_1_.inventory.addItemStackToInventory(itemstack)))
{
if (itemstack.getItem() == Item.getItemFromBlock(Blocks.log))

View File

@ -0,0 +1,16 @@
--- ../src-base/minecraft/net/minecraft/entity/item/EntityItemFrame.java
+++ ../src-work/minecraft/net/minecraft/entity/item/EntityItemFrame.java
@@ -45,6 +45,13 @@
{
if (!this.worldObj.isRemote)
{
+ // CraftBukkit start
+ if (org.bukkit.craftbukkit.event.CraftEventFactory.handleNonLivingEntityDamageEvent(this, p_70097_1_, p_70097_2_) || this.isDead)
+ {
+ return true;
+ }
+ // CraftBukkit end
+
this.func_146065_b(p_70097_1_.getEntity(), false);
this.setDisplayedItem((ItemStack)null);
}

View File

@ -0,0 +1,234 @@
--- ../src-base/minecraft/net/minecraft/entity/item/EntityMinecart.java
+++ ../src-work/minecraft/net/minecraft/entity/item/EntityMinecart.java
@@ -28,6 +28,15 @@
import net.minecraftforge.event.entity.minecart.MinecartCollisionEvent;
import net.minecraftforge.event.entity.minecart.MinecartUpdateEvent;
+// CraftBukkit start
+import org.bukkit.Location;
+import org.bukkit.entity.Vehicle;
+import org.bukkit.event.vehicle.VehicleDamageEvent;
+import org.bukkit.event.vehicle.VehicleDestroyEvent;
+import org.bukkit.event.vehicle.VehicleEntityCollisionEvent;
+import org.bukkit.util.Vector;
+// CraftBukkit end
+
public abstract class EntityMinecart extends Entity
{
private boolean isInReverse;
@@ -47,6 +56,17 @@
private double velocityZ;
private static final String __OBFID = "CL_00001670";
+ // CraftBukkit start
+ public boolean slowWhenEmpty = true;
+ private double derailedX = 0.5D;
+ private double derailedY = 0.5D;
+ private double derailedZ = 0.5D;
+ private double flyingX = 0.95D;
+ private double flyingY = 0.95D;
+ private double flyingZ = 0.95D;
+ public double maxSpeed = 0.4D;
+ // CraftBukkit end
+
/* Forge: Minecart Compatibility Layer Integration. */
public static float defaultMaxSpeedAirLateral = 0.4f;
public static float defaultMaxSpeedAirVertical = -1f;
@@ -138,6 +158,7 @@
this.prevPosX = p_i1713_2_;
this.prevPosY = p_i1713_4_;
this.prevPosZ = p_i1713_6_;
+ this.worldObj.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleCreateEvent((Vehicle) this.getBukkitEntity())); // CraftBukkit
}
public double getMountedYOffset()
@@ -155,6 +176,19 @@
}
else
{
+ // CraftBukkit start
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ org.bukkit.entity.Entity passenger = (p_70097_1_.getEntity() == null) ? null : p_70097_1_.getEntity().getBukkitEntity();
+ VehicleDamageEvent event = new VehicleDamageEvent(vehicle, passenger, p_70097_2_);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled())
+ {
+ return true;
+ }
+
+ p_70097_2_ = (float) event.getDamage();
+ // CraftBukkit end
this.setRollingDirection(-this.getRollingDirection());
this.setRollingAmplitude(10);
this.setBeenAttacked();
@@ -168,6 +202,18 @@
this.riddenByEntity.mountEntity(this);
}
+ // CraftBukkit start
+ VehicleDestroyEvent destroyEvent = new VehicleDestroyEvent(vehicle, passenger);
+ this.worldObj.getServer().getPluginManager().callEvent(destroyEvent);
+
+ if (destroyEvent.isCancelled())
+ {
+ this.setDamage(40); // Maximize damage so this doesn't
+ // get triggered again right away
+ return true;
+ }
+ // CraftBukkit end
+
if (flag && !this.hasCustomInventoryName())
{
this.setDead();
@@ -220,6 +266,14 @@
public void onUpdate()
{
+ // CraftBukkit start
+ double prevX = this.posX;
+ double prevY = this.posY;
+ double prevZ = this.posZ;
+ float prevYaw = this.rotationYaw;
+ float prevPitch = this.rotationPitch;
+ // CraftBukkit end
+
if (this.getRollingAmplitude() > 0)
{
this.setRollingAmplitude(this.getRollingAmplitude() - 1);
@@ -245,7 +299,7 @@
if (this.inPortal)
{
- if (minecraftserver.getAllowNether())
+ if (true || minecraftserver.getAllowNether()) // CraftBukkit - multi-world should still allow teleport even if default vanilla nether disabled
{
if (this.ridingEntity == null && this.portalCounter++ >= i)
{
@@ -324,7 +378,7 @@
--i;
}
- double d0 = 0.4D;
+ double d0 = this.maxSpeed; // CraftBukkit
double d2 = 0.0078125D;
Block block = this.worldObj.getBlock(l, i, i1);
@@ -368,7 +422,18 @@
}
this.setRotation(this.rotationYaw, this.rotationPitch);
+ // CraftBukkit start
+ org.bukkit.World bworld = this.worldObj.getWorld();
+ Location from = new Location(bworld, prevX, prevY, prevZ, prevYaw, prevPitch);
+ Location to = new Location(bworld, this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ this.worldObj.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleUpdateEvent(vehicle));
+ if (!from.equals(to))
+ {
+ this.worldObj.getServer().getPluginManager().callEvent(new org.bukkit.event.vehicle.VehicleMoveEvent(vehicle, from, to));
+ }
+ // CraftBukkit end
AxisAlignedBB box;
if (getCollisionHandler() != null)
{
@@ -445,18 +510,22 @@
if (this.onGround)
{
- this.motionX *= 0.5D;
- this.motionY *= 0.5D;
- this.motionZ *= 0.5D;
+ // CraftBukkit start
+ this.motionX *= this.derailedX;
+ this.motionY *= this.derailedY;
+ this.motionZ *= this.derailedZ;
+ // CraftBukkit end
}
this.moveEntity(this.motionX, moveY, this.motionZ);
if (!this.onGround)
{
+ // CraftBukkit start // Cauldron - CB changed to flyingX but Forge changed to getDragAir() - prefer Forge in this case
this.motionX *= getDragAir();
this.motionY *= getDragAir();
this.motionZ *= getDragAir();
+ // CraftBukkit end
}
}
@@ -678,7 +747,7 @@
protected void applyDrag()
{
- if (this.riddenByEntity != null)
+ if (this.riddenByEntity != null || !this.slowWhenEmpty) // CraftBukkit
{
this.motionX *= 0.996999979019165D;
this.motionY *= 0.0D;
@@ -866,6 +935,18 @@
{
if (p_70108_1_ != this.riddenByEntity)
{
+ // CraftBukkit start
+ Vehicle vehicle = (Vehicle) this.getBukkitEntity();
+ org.bukkit.entity.Entity hitEntity = (p_70108_1_ == null) ? null : p_70108_1_.getBukkitEntity();
+ VehicleEntityCollisionEvent collisionEvent = new VehicleEntityCollisionEvent(vehicle, hitEntity);
+ this.worldObj.getServer().getPluginManager().callEvent(collisionEvent);
+
+ if (collisionEvent.isCancelled())
+ {
+ return;
+ }
+ // CraftBukkit end
+
if (p_70108_1_ instanceof EntityLivingBase && !(p_70108_1_ instanceof EntityPlayer) && !(p_70108_1_ instanceof EntityIronGolem) && canBeRidden() && this.motionX * this.motionX + this.motionZ * this.motionZ > 0.01D && this.riddenByEntity == null && p_70108_1_.ridingEntity == null)
{
p_70108_1_.mountEntity(this);
@@ -875,7 +956,8 @@
double d1 = p_70108_1_.posZ - this.posZ;
double d2 = d0 * d0 + d1 * d1;
- if (d2 >= 9.999999747378752E-5D)
+ // CraftBukkit - collision
+ if (d2 >= 9.999999747378752E-5D && !collisionEvent.isCollisionCancelled())
{
d2 = (double)MathHelper.sqrt_double(d2);
d0 /= d2;
@@ -1089,6 +1171,34 @@
{
return this.entityName;
}
+
+ // CraftBukkit start - Methods for getting and setting flying and derailed
+ // velocity modifiers
+ public Vector getFlyingVelocityMod()
+ {
+ return new Vector(flyingX, flyingY, flyingZ);
+ }
+
+ public void setFlyingVelocityMod(Vector flying)
+ {
+ flyingX = flying.getX();
+ flyingY = flying.getY();
+ flyingZ = flying.getZ();
+ }
+
+ public Vector getDerailedVelocityMod()
+ {
+ return new Vector(derailedX, derailedY, derailedZ);
+ }
+
+ public void setDerailedVelocityMod(Vector derailed)
+ {
+ derailedX = derailed.getX();
+ derailedY = derailed.getY();
+ derailedZ = derailed.getZ();
+ }
+ // CraftBukkit end
+
/* =================================== FORGE START ===========================================*/
/**
* Moved to allow overrides.

View File

@ -0,0 +1,78 @@
--- ../src-base/minecraft/net/minecraft/entity/item/EntityMinecartContainer.java
+++ ../src-work/minecraft/net/minecraft/entity/item/EntityMinecartContainer.java
@@ -9,12 +9,61 @@
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
+// CraftBukkit start
+import java.util.List;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+import org.bukkit.inventory.InventoryHolder;
+// CraftBukkit end
+
public abstract class EntityMinecartContainer extends EntityMinecart implements IInventory
{
private ItemStack[] minecartContainerItems = new ItemStack[36];
private boolean dropContentsWhenDead = true;
private static final String __OBFID = "CL_00001674";
+ // CraftBukkit start
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ private int maxStack = MAX_STACK;
+
+ public ItemStack[] getContents()
+ {
+ return this.minecartContainerItems;
+ }
+
+ public void onOpen(CraftHumanEntity who)
+ {
+ transaction.add(who);
+ }
+
+ public void onClose(CraftHumanEntity who)
+ {
+ transaction.remove(who);
+ }
+
+ public List<HumanEntity> getViewers()
+ {
+ return transaction;
+ }
+
+ public InventoryHolder getOwner()
+ {
+ org.bukkit.entity.Entity cart = getBukkitEntity();
+
+ if (cart instanceof InventoryHolder)
+ {
+ return (InventoryHolder) cart;
+ }
+
+ return null;
+ }
+
+ public void setMaxStackSize(int size)
+ {
+ maxStack = size;
+ }
+ // CraftBukkit end
+
public EntityMinecartContainer(World p_i1716_1_)
{
super(p_i1716_1_);
@@ -147,6 +196,13 @@
public void travelToDimension(int p_71027_1_)
{
+ // Spigot Start
+ for (HumanEntity human : new java.util.ArrayList<HumanEntity>(transaction))
+ {
+ human.closeInventory();
+ }
+
+ // Spigot End
this.dropContentsWhenDead = false;
super.travelToDimension(p_71027_1_);
}

View File

@ -0,0 +1,10 @@
--- ../src-base/minecraft/net/minecraft/entity/item/EntityPainting.java
+++ ../src-work/minecraft/net/minecraft/entity/item/EntityPainting.java
@@ -19,6 +19,7 @@
public EntityPainting(World p_i1599_1_)
{
super(p_i1599_1_);
+ this.art = EntityPainting.EnumArt.values()[this.rand.nextInt(EntityPainting.EnumArt.values().length)]; // CraftBukkit - generate a non-null painting
}
public EntityPainting(World p_i1600_1_, int p_i1600_2_, int p_i1600_3_, int p_i1600_4_, int p_i1600_5_)

View File

@ -0,0 +1,57 @@
--- ../src-base/minecraft/net/minecraft/entity/item/EntityTNTPrimed.java
+++ ../src-work/minecraft/net/minecraft/entity/item/EntityTNTPrimed.java
@@ -7,11 +7,15 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.world.World;
+import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit
+
public class EntityTNTPrimed extends Entity
{
public int fuse;
private EntityLivingBase tntPlacedBy;
private static final String __OBFID = "CL_00001681";
+ public float yield = 4; // CraftBukkit
+ public boolean isIncendiary = false; // CraftBukkit
public EntityTNTPrimed(World p_i1729_1_)
{
@@ -68,12 +72,14 @@
if (this.fuse-- <= 0)
{
- this.setDead();
-
+ // CraftBukkit start - Need to reverse the order of the explosion and the entity death so we have a location for the event
if (!this.worldObj.isRemote)
{
this.explode();
}
+
+ this.setDead();
+ // CraftBukkit end
}
else
{
@@ -83,8 +89,19 @@
private void explode()
{
- float f = 4.0F;
- this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, f, true);
+ // CraftBukkit start
+ // float f = 4.0F;
+ org.bukkit.craftbukkit.CraftServer server = this.worldObj.getServer();
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) org.bukkit.craftbukkit.entity.CraftEntity.getEntity(server, this));
+ server.getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ // give 'this' instead of (Entity) null so we know what causes the damage
+ this.worldObj.newExplosion(this, this.posX, this.posY, this.posZ, event.getRadius(), event.getFire(), true);
+ }
+
+ // CraftBukkit end
}
protected void writeEntityToNBT(NBTTagCompound p_70014_1_)

View File

@ -0,0 +1,158 @@
--- ../src-base/minecraft/net/minecraft/entity/item/EntityXPOrb.java
+++ ../src-work/minecraft/net/minecraft/entity/item/EntityXPOrb.java
@@ -12,13 +12,18 @@
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.player.PlayerPickupXpEvent;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityTargetEvent;
+// CraftBukkit end
+
public class EntityXPOrb extends Entity
{
public int xpColor;
public int xpOrbAge;
public int field_70532_c;
private int xpOrbHealth = 5;
- public int xpValue;
+ public int xpValue; // CraftBukkit - private -> public
private EntityPlayer closestPlayer;
private int xpTargetColor;
private static final String __OBFID = "CL_00001544";
@@ -115,18 +120,27 @@
if (this.closestPlayer != null)
{
- double d1 = (this.closestPlayer.posX - this.posX) / d0;
- double d2 = (this.closestPlayer.posY + (double)this.closestPlayer.getEyeHeight() - this.posY) / d0;
- double d3 = (this.closestPlayer.posZ - this.posZ) / d0;
- double d4 = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3);
- double d5 = 1.0D - d4;
+ // CraftBukkit start
+ EntityTargetEvent event = CraftEventFactory.callEntityTargetEvent(this, closestPlayer, EntityTargetEvent.TargetReason.CLOSEST_PLAYER);
+ Entity target = event.getTarget() == null ? null : ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
- if (d5 > 0.0D)
+ if (!event.isCancelled() && target != null)
{
- d5 *= d5;
- this.motionX += d1 / d4 * d5 * 0.1D;
- this.motionY += d2 / d4 * d5 * 0.1D;
- this.motionZ += d3 / d4 * d5 * 0.1D;
+ double d1 = (target.posX - this.posX) / d0;
+ double d2 = (target.posY + (double) target.getEyeHeight() - this.posY) / d0;
+ double d3 = (target.posZ - this.posZ) / d0;
+ double d4 = Math.sqrt(d1 * d1 + d2 * d2 + d3 * d3);
+ double d5 = 1.0D - d4;
+
+ if (d5 > 0.0D)
+ {
+ d5 *= d5;
+ this.motionX += d1 / d4 * d5 * 0.1D;
+ this.motionY += d2 / d4 * d5 * 0.1D;
+ this.motionZ += d3 / d4 * d5 * 0.1D;
+ }
+
+ // CraftBukkit end
}
}
@@ -210,7 +224,7 @@
p_70100_1_.xpCooldown = 2;
this.worldObj.playSoundAtEntity(p_70100_1_, "random.orb", 0.1F, 0.5F * ((this.rand.nextFloat() - this.rand.nextFloat()) * 0.7F + 1.8F));
p_70100_1_.onItemPickup(this, 1);
- p_70100_1_.addExperience(this.xpValue);
+ p_70100_1_.addExperience(CraftEventFactory.callPlayerExpChangeEvent(p_70100_1_, this.xpValue).getAmount());
this.setDead();
}
}
@@ -229,6 +243,88 @@
public static int getXPSplit(int p_70527_0_)
{
+ // CraftBukkit start
+ if (p_70527_0_ > 162670129)
+ {
+ return p_70527_0_ - 100000;
+ }
+
+ if (p_70527_0_ > 81335063)
+ {
+ return 81335063;
+ }
+
+ if (p_70527_0_ > 40667527)
+ {
+ return 40667527;
+ }
+
+ if (p_70527_0_ > 20333759)
+ {
+ return 20333759;
+ }
+
+ if (p_70527_0_ > 10166857)
+ {
+ return 10166857;
+ }
+
+ if (p_70527_0_ > 5083423)
+ {
+ return 5083423;
+ }
+
+ if (p_70527_0_ > 2541701)
+ {
+ return 2541701;
+ }
+
+ if (p_70527_0_ > 1270849)
+ {
+ return 1270849;
+ }
+
+ if (p_70527_0_ > 635413)
+ {
+ return 635413;
+ }
+
+ if (p_70527_0_ > 317701)
+ {
+ return 317701;
+ }
+
+ if (p_70527_0_ > 158849)
+ {
+ return 158849;
+ }
+
+ if (p_70527_0_ > 79423)
+ {
+ return 79423;
+ }
+
+ if (p_70527_0_ > 39709)
+ {
+ return 39709;
+ }
+
+ if (p_70527_0_ > 19853)
+ {
+ return 19853;
+ }
+
+ if (p_70527_0_ > 9923)
+ {
+ return 9923;
+ }
+
+ if (p_70527_0_ > 4957)
+ {
+ return 4957;
+ }
+
+ // CraftBukkit end
return p_70527_0_ >= 2477 ? 2477 : (p_70527_0_ >= 1237 ? 1237 : (p_70527_0_ >= 617 ? 617 : (p_70527_0_ >= 307 ? 307 : (p_70527_0_ >= 149 ? 149 : (p_70527_0_ >= 73 ? 73 : (p_70527_0_ >= 37 ? 37 : (p_70527_0_ >= 17 ? 17 : (p_70527_0_ >= 7 ? 7 : (p_70527_0_ >= 3 ? 3 : 1)))))))));
}

View File

@ -0,0 +1,78 @@
--- ../src-base/minecraft/net/minecraft/entity/monster/EntityCreeper.java
+++ ../src-work/minecraft/net/minecraft/entity/monster/EntityCreeper.java
@@ -23,6 +23,11 @@
import net.minecraft.util.DamageSource;
import net.minecraft.world.World;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.ExplosionPrimeEvent;
+// CraftBukkit end
+
public class EntityCreeper extends EntityMob
{
private int lastActiveTime;
@@ -207,9 +212,35 @@
public void onStruckByLightning(EntityLightningBolt p_70077_1_)
{
super.onStruckByLightning(p_70077_1_);
- this.dataWatcher.updateObject(17, Byte.valueOf((byte)1));
+
+ // Cauldron start
+ if (p_70077_1_ != null)
+ {
+ // CraftBukkit start
+ if (CraftEventFactory.callCreeperPowerEvent(this, p_70077_1_, org.bukkit.event.entity.CreeperPowerEvent.PowerCause.LIGHTNING).isCancelled())
+ {
+ return;
+ }
+ }
+ // Cauldron end
+
+ this.setPowered(true);
}
+ public void setPowered(boolean powered)
+ {
+ if (!powered)
+ {
+ this.dataWatcher.updateObject(17, Byte.valueOf((byte) 0));
+ }
+ else
+ {
+ this.dataWatcher.updateObject(17, Byte.valueOf((byte) 1));
+ }
+
+ // CraftBukkit end
+ }
+
protected boolean interact(EntityPlayer p_70085_1_)
{
ItemStack itemstack = p_70085_1_.inventory.getCurrentItem();
@@ -235,17 +266,22 @@
if (!this.worldObj.isRemote)
{
boolean flag = this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing");
+ // CraftBukkit start
+ float radius = this.getPowered() ? 6.0F : 3.0F;
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), radius, false);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
- if (this.getPowered())
+ if (!event.isCancelled())
{
- this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)(this.explosionRadius * 2), flag);
+ this.worldObj.newExplosion(this, this.posX, this.posY, this.posZ, event.getRadius(), event.getFire(), flag);
+ this.setDead();
}
else
{
- this.worldObj.createExplosion(this, this.posX, this.posY, this.posZ, (float)this.explosionRadius, flag);
+ this.timeSinceIgnited = 0;
}
- this.setDead();
+ // CraftBukkit end
}
}

View File

@ -0,0 +1,72 @@
--- ../src-base/minecraft/net/minecraft/entity/monster/EntityEnderman.java
+++ ../src-work/minecraft/net/minecraft/entity/monster/EntityEnderman.java
@@ -24,6 +24,12 @@
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.event.entity.living.EnderTeleportEvent;
+// CraftBukkit start
+import org.bukkit.Location;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityTeleportEvent;
+// CraftBukkit end
+
public class EntityEnderman extends EntityMob
{
private static final UUID attackingSpeedBoostModifierUUID = UUID.fromString("020E0DFB-87AE-4653-9556-831010E291A0");
@@ -161,9 +167,15 @@
if (EntityEnderman.getCarriable(block))
{
- this.func_146081_a(block);
- this.setCarryingData(this.worldObj.getBlockMetadata(k, i, j));
- this.worldObj.setBlock(k, i, j, Blocks.air);
+ // CraftBukkit start - Pickup event
+ if (this.worldObj.getWorld() == null || !CraftEventFactory.callEntityChangeBlockEvent(this, this.worldObj.getWorld().getBlockAt(i, j, k), org.bukkit.Material.AIR).isCancelled()) // Cauldron
+ {
+ this.func_146081_a(block);
+ this.setCarryingData(this.worldObj.getBlockMetadata(i, j, k));
+ this.worldObj.setBlock(i, j, k, Blocks.air);
+ }
+
+ // CraftBukkit end
}
}
}
@@ -177,8 +189,14 @@
if (block.getMaterial() == Material.air && block1.getMaterial() != Material.air && block1.renderAsNormalBlock())
{
- this.worldObj.setBlock(k, i, j, this.func_146080_bZ(), this.getCarryingData(), 3);
- this.func_146081_a(Blocks.air);
+ // CraftBukkit start - Place event
+ if (!CraftEventFactory.callEntityChangeBlockEvent(this, i, j, k, this.func_146080_bZ(), this.getCarryingData()).isCancelled())
+ {
+ this.worldObj.setBlock(i, j, k, this.func_146080_bZ(), this.getCarryingData(), 3);
+ this.func_146081_a(Blocks.air);
+ }
+
+ // CraftBukkit end
}
}
}
@@ -306,8 +324,19 @@
if (flag1)
{
- this.setPosition(this.posX, this.posY, this.posZ);
+ // CraftBukkit start - Teleport event
+ EntityTeleportEvent teleport = new EntityTeleportEvent(this.getBukkitEntity(), new Location(this.worldObj.getWorld(), d3, d4, d5), new Location(this.worldObj.getWorld(), this.posX, this.posY, this.posZ));
+ this.worldObj.getServer().getPluginManager().callEvent(teleport);
+ if (teleport.isCancelled())
+ {
+ return false;
+ }
+
+ Location to = teleport.getTo();
+ this.setPosition(to.getX(), to.getY(), to.getZ());
+ // CraftBukkit end
+
if (this.worldObj.getCollidingBoundingBoxes(this, this.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(this.boundingBox))
{
flag = true;

View File

@ -0,0 +1,77 @@
--- ../src-base/minecraft/net/minecraft/entity/monster/EntityGhast.java
+++ ../src-work/minecraft/net/minecraft/entity/monster/EntityGhast.java
@@ -18,6 +18,11 @@
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
+// CraftBukkit start
+import org.bukkit.craftbukkit.entity.CraftEntity;
+import org.bukkit.event.entity.EntityTargetEvent;
+// CraftBukkit end
+
public class EntityGhast extends EntityFlying implements IMob
{
public int courseChangeCooldown;
@@ -117,13 +122,50 @@
if (this.targetedEntity != null && this.targetedEntity.isDead)
{
- this.targetedEntity = null;
+ // CraftBukkit start
+ EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, EntityTargetEvent.TargetReason.TARGET_DIED);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ if (event.getTarget() == null)
+ {
+ this.targetedEntity = null;
+ }
+ else
+ {
+ this.targetedEntity = ((CraftEntity) event.getTarget()).getHandle();
+ }
+ }
+
+ // CraftBukkit end
}
if (this.targetedEntity == null || this.aggroCooldown-- <= 0)
{
- this.targetedEntity = this.worldObj.getClosestVulnerablePlayerToEntity(this, 100.0D);
+ // CraftBukkit start
+ Entity target = this.worldObj.getClosestVulnerablePlayerToEntity(this, 100.0D);
+ if (target != null)
+ {
+ EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), target.getBukkitEntity(), EntityTargetEvent.TargetReason.CLOSEST_PLAYER);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ if (event.getTarget() == null)
+ {
+ this.targetedEntity = null;
+ }
+ else
+ {
+ this.targetedEntity = ((CraftEntity) event.getTarget()).getHandle();
+ }
+ }
+ }
+
+ // CraftBukkit end
+
if (this.targetedEntity != null)
{
this.aggroCooldown = 20;
@@ -152,7 +194,8 @@
{
this.worldObj.playAuxSFXAtEntity((EntityPlayer)null, 1008, (int)this.posX, (int)this.posY, (int)this.posZ, 0);
EntityLargeFireball entitylargefireball = new EntityLargeFireball(this.worldObj, this, d5, d6, d7);
- entitylargefireball.field_92057_e = this.explosionStrength;
+ // CraftBukkit - set bukkitYield when setting explosionpower
+ entitylargefireball.bukkitYield = entitylargefireball.field_92057_e = this.explosionStrength;
double d8 = 4.0D;
Vec3 vec3 = this.getLook(1.0F);
entitylargefireball.posX = this.posX + vec3.xCoord * d8;

View File

@ -0,0 +1,40 @@
--- ../src-base/minecraft/net/minecraft/entity/monster/EntityMob.java
+++ ../src-work/minecraft/net/minecraft/entity/monster/EntityMob.java
@@ -1,5 +1,6 @@
package net.minecraft.entity.monster;
+import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit
import net.minecraft.enchantment.EnchantmentHelper;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityCreature;
@@ -75,7 +76,29 @@
{
if (entity != this)
{
- this.entityToAttack = entity;
+ // CraftBukkit start - We still need to call events for entities without goals
+ if (entity != this.entityToAttack && (this instanceof EntityBlaze || this instanceof EntityEnderman || this instanceof EntitySpider || this instanceof EntityGiantZombie || this instanceof EntitySilverfish))
+ {
+ EntityTargetEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTargetEvent(this, entity, EntityTargetEvent.TargetReason.TARGET_ATTACKED_ENTITY);
+
+ if (!event.isCancelled())
+ {
+ if (event.getTarget() == null)
+ {
+ this.entityToAttack = null;
+ }
+ else
+ {
+ this.entityToAttack = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
+ }
+ }
+ }
+ else
+ {
+ this.entityToAttack = entity;
+ }
+
+ // CraftBukkit end
}
return true;

Some files were not shown because too many files have changed in this diff Show More