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,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;

View File

@ -0,0 +1,42 @@
--- ../src-base/minecraft/net/minecraft/entity/monster/EntityPigZombie.java
+++ ../src-work/minecraft/net/minecraft/entity/monster/EntityPigZombie.java
@@ -15,11 +15,13 @@
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
+import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit
+
public class EntityPigZombie extends EntityZombie
{
private static final UUID field_110189_bq = UUID.fromString("49455A49-7EC5-45BA-B886-3B90B23A1718");
private static final AttributeModifier field_110190_br = (new AttributeModifier(field_110189_bq, "Attacking speed boost", 0.45D, 0)).setSaved(false);
- private int angerLevel;
+ public int angerLevel; // CraftBukkit - private -> public
private int randomSoundDelay;
private Entity field_110191_bu;
private static final String __OBFID = "CL_00001693";
@@ -122,6 +124,24 @@
private void becomeAngryAt(Entity p_70835_1_)
{
+ // CraftBukkit start
+ org.bukkit.entity.Entity bukkitTarget = p_70835_1_ == null ? null : p_70835_1_.getBukkitEntity();
+ EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), bukkitTarget, EntityTargetEvent.TargetReason.PIG_ZOMBIE_TARGET);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled())
+ {
+ return;
+ }
+
+ if (event.getTarget() == null)
+ {
+ this.entityToAttack = null;
+ return;
+ }
+
+ p_70835_1_ = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
+ // CraftBukkit end
this.entityToAttack = p_70835_1_;
this.angerLevel = 400 + this.rand.nextInt(400);
this.randomSoundDelay = this.rand.nextInt(40);

View File

@ -0,0 +1,39 @@
--- ../src-base/minecraft/net/minecraft/entity/monster/EntitySilverfish.java
+++ ../src-work/minecraft/net/minecraft/entity/monster/EntitySilverfish.java
@@ -15,6 +15,8 @@
import net.minecraft.world.World;
import org.apache.commons.lang3.tuple.ImmutablePair;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class EntitySilverfish extends EntityMob
{
private int allySummonCooldown;
@@ -132,6 +134,13 @@
{
if (this.worldObj.getBlock(i + i1, j + l, k + j1) == Blocks.monster_egg)
{
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, i + i1, j + l, k + j1, Blocks.air, 0).isCancelled())
+ {
+ continue;
+ }
+
+ // CraftBukkit end
if (!this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing"))
{
int k1 = this.worldObj.getBlockMetadata(i + i1, j + l, k + j1);
@@ -168,6 +177,13 @@
if (BlockSilverfish.func_150196_a(block))
{
+ // CraftBukkit start
+ if (CraftEventFactory.callEntityChangeBlockEvent(this, i + Facing.offsetsXForSide[l1], j + Facing.offsetsYForSide[l1], k + Facing.offsetsZForSide[l1], Blocks.monster_egg, Block.getIdFromBlock(BlockSilverfish.getBlockById(i1))).isCancelled())
+ {
+ return;
+ }
+
+ // CraftBukkit end
this.worldObj.setBlock(i + Facing.offsetsXForSide[l1], j + Facing.offsetsYForSide[l1], k + Facing.offsetsZForSide[l1], Blocks.monster_egg, BlockSilverfish.func_150195_a(block, i1), 3);
this.spawnExplosionParticle();
this.setDead();

View File

@ -0,0 +1,54 @@
--- ../src-base/minecraft/net/minecraft/entity/monster/EntitySkeleton.java
+++ ../src-work/minecraft/net/minecraft/entity/monster/EntitySkeleton.java
@@ -36,6 +36,8 @@
import net.minecraft.world.World;
import net.minecraft.world.WorldProviderHell;
+import org.bukkit.event.entity.EntityCombustEvent; // CraftBukkit
+
public class EntitySkeleton extends EntityMob implements IRangedAttackMob
{
private EntityAIArrowAttack aiArrowAttack = new EntityAIArrowAttack(this, 1.0D, 20, 60, 15.0F);
@@ -148,7 +150,16 @@
if (flag)
{
- this.setFire(8);
+ // CraftBukkit start
+ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ this.setFire(event.getDuration());
+ }
+
+ // CraftBukkit end
}
}
}
@@ -312,8 +323,23 @@
entityarrow.setFire(100);
}
+ // CraftBukkit start
+ org.bukkit.event.entity.EntityShootBowEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callEntityShootBowEvent(this, this.getHeldItem(), entityarrow, 0.8F);
+
+ if (event.isCancelled())
+ {
+ event.getProjectile().remove();
+ return;
+ }
+
+ if (event.getProjectile() == entityarrow.getBukkitEntity())
+ {
+ worldObj.spawnEntityInWorld(entityarrow);
+ }
+
+ // CraftBukkit end
this.playSound("random.bow", 1.0F, 1.0F / (this.getRNG().nextFloat() * 0.4F + 0.8F));
- this.worldObj.spawnEntityInWorld(entityarrow);
+ // this.worldObj.spawnEntityInWorld(entityarrow); // CraftBukkit - moved up
}
public int getSkeletonType()

View File

@ -0,0 +1,94 @@
--- ../src-base/minecraft/net/minecraft/entity/monster/EntitySlime.java
+++ ../src-work/minecraft/net/minecraft/entity/monster/EntitySlime.java
@@ -14,12 +14,21 @@
import net.minecraft.world.biome.BiomeGenBase;
import net.minecraft.world.chunk.Chunk;
+// CraftBukkit start
+import org.bukkit.craftbukkit.entity.CraftEntity;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.event.entity.EntityTargetEvent;
+import org.bukkit.event.entity.SlimeSplitEvent;
+import net.minecraft.entity.Entity;
+// CraftBukkit end
+
public class EntitySlime extends EntityLiving implements IMob
{
public float squishAmount;
public float squishFactor;
public float prevSquishFactor;
private int slimeJumpDelay;
+ private Entity lastTarget; // CraftBukkit
private static final String __OBFID = "CL_00001698";
public EntitySlime(World p_i1742_1_)
@@ -37,7 +46,7 @@
this.dataWatcher.addObject(16, new Byte((byte)1));
}
- protected void setSlimeSize(int p_70799_1_)
+ public void setSlimeSize(int p_70799_1_) // CraftBukkit - protected -> public
{
this.dataWatcher.updateObject(16, new Byte((byte)p_70799_1_));
this.setSize(0.6F * (float)p_70799_1_, 0.6F * (float)p_70799_1_);
@@ -131,8 +140,27 @@
protected void updateEntityActionState()
{
this.despawnEntity();
- EntityPlayer entityplayer = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D);
+ // CraftBukkit start
+ Entity entityplayer = this.worldObj.getClosestVulnerablePlayerToEntity(this, 16.0D); // EntityPlayer -> Entity
+ EntityTargetEvent event = null;
+ if (entityplayer != null && !entityplayer.equals(lastTarget))
+ {
+ event = CraftEventFactory.callEntityTargetEvent(this, entityplayer, EntityTargetEvent.TargetReason.CLOSEST_PLAYER);
+ }
+ else if (lastTarget != null && entityplayer == null)
+ {
+ event = CraftEventFactory.callEntityTargetEvent(this, entityplayer, EntityTargetEvent.TargetReason.FORGOT_TARGET);
+ }
+
+ if (event != null && !event.isCancelled())
+ {
+ entityplayer = event.getTarget() == null ? null : ((CraftEntity) event.getTarget()).getHandle();
+ }
+
+ this.lastTarget = entityplayer;
+ // CraftBukkit end
+
if (entityplayer != null)
{
this.faceEntity(entityplayer, 10.0F, 20.0F);
@@ -190,7 +218,22 @@
if (!this.worldObj.isRemote && i > 1 && this.getHealth() <= 0.0F)
{
int j = 2 + this.rand.nextInt(3);
+ // CraftBukkit start
+ SlimeSplitEvent event = new SlimeSplitEvent((org.bukkit.entity.Slime) this.getBukkitEntity(), j);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+ if (!event.isCancelled() && event.getCount() > 0)
+ {
+ j = event.getCount();
+ }
+ else
+ {
+ super.setDead();
+ return;
+ }
+
+ // CraftBukkit end
+
for (int k = 0; k < j; ++k)
{
float f = ((float)(k % 2) - 0.5F) * (float)i / 4.0F;
@@ -198,7 +241,7 @@
EntitySlime entityslime = this.createInstance();
entityslime.setSlimeSize(i / 2);
entityslime.setLocationAndAngles(this.posX + (double)f, this.posY + 0.5D, this.posZ + (double)f1, this.rand.nextFloat() * 360.0F, 0.0F);
- this.worldObj.spawnEntityInWorld(entityslime);
+ this.worldObj.addEntity(entityslime, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.SLIME_SPLIT); // CraftBukkit - SpawnReason
}
}

View File

@ -0,0 +1,44 @@
--- ../src-base/minecraft/net/minecraft/entity/monster/EntitySnowman.java
+++ ../src-work/minecraft/net/minecraft/entity/monster/EntitySnowman.java
@@ -19,6 +19,12 @@
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.util.CraftMagicNumbers;
+import org.bukkit.event.block.EntityBlockFormEvent;
+// CraftBukkit end
+
public class EntitySnowman extends EntityGolem implements IRangedAttackMob
{
private static final String __OBFID = "CL_00001650";
@@ -61,7 +67,7 @@
if (this.worldObj.getBiomeGenForCoords(i, k).getFloatTemperature(i, j, k) > 1.0F)
{
- this.attackEntityFrom(DamageSource.onFire, 1.0F);
+ this.attackEntityFrom(CraftEventFactory.MELTING, 1.0F); // CraftBukkit - DamageSource.BURN -> CraftEventFactory.MELTING
}
for (int l = 0; l < 4; ++l)
@@ -72,7 +78,18 @@
if (this.worldObj.getBlock(i, j, k).getMaterial() == Material.air && this.worldObj.getBiomeGenForCoords(i, k).getFloatTemperature(i, j, k) < 0.8F && Blocks.snow_layer.canPlaceBlockAt(this.worldObj, i, j, k))
{
- this.worldObj.setBlock(i, j, k, Blocks.snow_layer);
+ // CraftBukkit start
+ org.bukkit.block.BlockState blockState = this.worldObj.getWorld().getBlockAt(i, j, k).getState();
+ blockState.setType(CraftMagicNumbers.getMaterial(Blocks.snow_layer));
+ EntityBlockFormEvent event = new EntityBlockFormEvent(this.getBukkitEntity(), blockState.getBlock(), blockState);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ blockState.update(true);
+ }
+
+ // CraftBukkit end
}
}
}

View File

@ -0,0 +1,38 @@
--- ../src-base/minecraft/net/minecraft/entity/monster/EntitySpider.java
+++ ../src-work/minecraft/net/minecraft/entity/monster/EntitySpider.java
@@ -14,6 +14,8 @@
import net.minecraft.world.EnumDifficulty;
import net.minecraft.world.World;
+import org.bukkit.event.entity.EntityTargetEvent; // CraftBukkit
+
public class EntitySpider extends EntityMob
{
private static final String __OBFID = "CL_00001699";
@@ -88,7 +90,25 @@
if (f1 > 0.5F && this.rand.nextInt(100) == 0)
{
- this.entityToAttack = null;
+ // CraftBukkit start
+ EntityTargetEvent event = new EntityTargetEvent(this.getBukkitEntity(), null, EntityTargetEvent.TargetReason.FORGOT_TARGET);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ if (event.getTarget() == null)
+ {
+ this.entityToAttack = null;
+ }
+ else
+ {
+ this.entityToAttack = ((org.bukkit.craftbukkit.entity.CraftEntity) event.getTarget()).getHandle();
+ }
+
+ return;
+ }
+
+ // CraftBukkit end
}
else
{

View File

@ -0,0 +1,109 @@
--- ../src-base/minecraft/net/minecraft/entity/monster/EntityZombie.java
+++ ../src-work/minecraft/net/minecraft/entity/monster/EntityZombie.java
@@ -46,6 +46,13 @@
import net.minecraftforge.event.ForgeEventFactory;
import net.minecraftforge.event.entity.living.ZombieEvent.SummonAidEvent;
+//CraftBukkit start
+import net.minecraft.server.MinecraftServer;
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
+import org.bukkit.event.entity.EntityCombustEvent;
+//CraftBukkit end
+
public class EntityZombie extends EntityMob
{
protected static final IAttribute field_110186_bp = (new RangedAttribute("zombie.spawnReinforcements", 0.0D, 0.0D, 1.0D)).setDescription("Spawn Reinforcements Chance");
@@ -56,6 +63,7 @@
private boolean field_146076_bu = false;
private float field_146074_bv = -1.0F;
private float field_146073_bw;
+ private int lastTick = MinecraftServer.currentTick; // CraftBukkit
private static final String __OBFID = "CL_00001702";
public EntityZombie(World p_i1745_1_)
@@ -64,7 +72,12 @@
this.getNavigator().setBreakDoors(true);
this.tasks.addTask(0, new EntityAISwimming(this));
this.tasks.addTask(2, new EntityAIAttackOnCollide(this, EntityPlayer.class, 1.0D, false));
- this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityVillager.class, 1.0D, true));
+
+ if (p_i1745_1_.getSpigotConfig().zombieAggressiveTowardsVillager) // Cauldron
+ {
+ this.tasks.addTask(4, new EntityAIAttackOnCollide(this, EntityVillager.class, 1.0D, true)); // Spigot
+ }
+
this.tasks.addTask(5, new EntityAIMoveTowardsRestriction(this, 1.0D));
this.tasks.addTask(6, new EntityAIMoveThroughVillage(this, 1.0D, false));
this.tasks.addTask(7, new EntityAIWander(this, 1.0D));
@@ -72,7 +85,12 @@
this.tasks.addTask(8, new EntityAILookIdle(this));
this.targetTasks.addTask(1, new EntityAIHurtByTarget(this, true));
this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityPlayer.class, 0, true));
- this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, 0, false));
+
+ if (p_i1745_1_.getSpigotConfig().zombieAggressiveTowardsVillager) // Cauldron
+ {
+ this.targetTasks.addTask(2, new EntityAINearestAttackableTarget(this, EntityVillager.class, 0, false)); // Spigot
+ }
+
this.setSize(0.6F, 1.8F);
}
@@ -204,7 +222,16 @@
if (flag)
{
- this.setFire(8);
+ // CraftBukkit start
+ EntityCombustEvent event = new EntityCombustEvent(this.getBukkitEntity(), 8);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ this.setFire(event.getDuration());
+ }
+
+ // CraftBukkit end
}
}
}
@@ -272,7 +299,7 @@
if (this.worldObj.checkNoEntityCollision(entityzombie.boundingBox) && this.worldObj.getCollidingBoundingBoxes(entityzombie, entityzombie.boundingBox).isEmpty() && !this.worldObj.isAnyLiquid(entityzombie.boundingBox))
{
- this.worldObj.spawnEntityInWorld(entityzombie);
+ this.worldObj.addEntity(entityzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.REINFORCEMENTS); // CraftBukkit
if (entitylivingbase != null) entityzombie.setAttackTarget(entitylivingbase);
entityzombie.onSpawnWithEgg((IEntityLivingData)null);
this.getEntityAttribute(field_110186_bp).applyModifier(new AttributeModifier("Zombie reinforcement caller charge", -0.05000000074505806D, 0));
@@ -292,6 +319,11 @@
if (!this.worldObj.isRemote && this.isConverting())
{
int i = this.getConversionTimeBoost();
+ // CraftBukkit start - Use wall time instead of ticks for villager conversion
+ int elapsedTicks = MinecraftServer.currentTick - this.lastTick;
+ this.lastTick = MinecraftServer.currentTick;
+ i *= elapsedTicks;
+ // CraftBukkit end
this.conversionTime -= i;
if (this.conversionTime <= 0)
@@ -313,7 +345,16 @@
if (this.getHeldItem() == null && this.isBurning() && this.rand.nextFloat() < (float)i * 0.3F)
{
- p_70652_1_.setFire(2 * i);
+ // CraftBukkit start
+ EntityCombustByEntityEvent event = new EntityCombustByEntityEvent(this.getBukkitEntity(), p_70652_1_.getBukkitEntity(), 2 * i);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ p_70652_1_.setFire(event.getDuration());
+ }
+
+ // CraftBukkit end
}
}

View File

@ -0,0 +1,42 @@
--- ../src-base/minecraft/net/minecraft/entity/passive/EntityCow.java
+++ ../src-work/minecraft/net/minecraft/entity/passive/EntityCow.java
@@ -17,6 +17,11 @@
import net.minecraft.item.ItemStack;
import net.minecraft.world.World;
+// CraftBukkit start
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+// CraftBukkit end
+
public class EntityCow extends EntityAnimal
{
private static final String __OBFID = "CL_00001640";
@@ -109,15 +114,25 @@
if (itemstack != null && itemstack.getItem() == Items.bucket && !p_70085_1_.capabilities.isCreativeMode)
{
+ // CraftBukkit start - Got milk?
+ org.bukkit.Location loc = this.getBukkitEntity().getLocation();
+ org.bukkit.event.player.PlayerBucketFillEvent event = CraftEventFactory.callPlayerBucketFillEvent(p_70085_1_, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ(), -1, itemstack, Items.milk_bucket);
+
+ if (event.isCancelled())
+ {
+ return false;
+ }
+
if (itemstack.stackSize-- == 1)
{
- p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, new ItemStack(Items.milk_bucket));
+ p_70085_1_.inventory.setInventorySlotContents(p_70085_1_.inventory.currentItem, CraftItemStack.asNMSCopy(event.getItemStack()));
}
else if (!p_70085_1_.inventory.addItemStackToInventory(new ItemStack(Items.milk_bucket)))
{
- p_70085_1_.dropPlayerItemWithRandomChoice(new ItemStack(Items.milk_bucket, 1, 0), false);
+ p_70085_1_.dropPlayerItemWithRandomChoice(CraftItemStack.asNMSCopy(event.getItemStack()), false);
}
+ // CraftBukkit end
return true;
}
else

View File

@ -0,0 +1,134 @@
--- ../src-base/minecraft/net/minecraft/entity/passive/EntityHorse.java
+++ ../src-work/minecraft/net/minecraft/entity/passive/EntityHorse.java
@@ -50,7 +50,7 @@
return p_82704_1_ instanceof EntityHorse && ((EntityHorse)p_82704_1_).func_110205_ce();
}
};
- private static final IAttribute horseJumpStrength = (new RangedAttribute("horse.jumpStrength", 0.7D, 0.0D, 2.0D)).setDescription("Jump Strength").setShouldWatch(true);
+ public static final IAttribute horseJumpStrength = (new RangedAttribute("horse.jumpStrength", 0.7D, 0.0D, 2.0D)).setDescription("Jump Strength").setShouldWatch(true); // CraftBukkit - private -> public
private static final String[] horseArmorTextures = new String[] {null, "textures/entity/horse/armor/horse_armor_iron.png", "textures/entity/horse/armor/horse_armor_gold.png", "textures/entity/horse/armor/horse_armor_diamond.png"};
private static final String[] field_110273_bx = new String[] {"", "meo", "goo", "dio"};
private static final int[] armorValues = new int[] {0, 5, 7, 11};
@@ -64,7 +64,7 @@
public int field_110278_bp;
public int field_110279_bq;
protected boolean horseJumping;
- private AnimalChest horseChest;
+ public AnimalChest horseChest; // CraftBukkit - private -> public
private boolean hasReproduced;
protected int temper;
protected float jumpPower;
@@ -78,6 +78,7 @@
private int field_110285_bP;
private String field_110286_bQ;
private String[] field_110280_bR = new String[3];
+ public int maxDomestication = 100; // CraftBukkit - store max domestication value
private static final String __OBFID = "CL_00001641";
public EntityHorse(World p_i1685_1_)
@@ -403,13 +404,13 @@
private int func_110225_cC()
{
int i = this.getHorseType();
- return this.isChested() && (i == 1 || i == 2) ? 17 : 2;
+ return this.isChested() /* && (i == 1 || i == 2) */ ? 17 : 2; // CraftBukkit - Remove type check
}
- private void func_110226_cD()
+ public void func_110226_cD() // CraftBukkit - private -> public
{
AnimalChest animalchest = this.horseChest;
- this.horseChest = new AnimalChest("HorseChest", this.func_110225_cC());
+ this.horseChest = new AnimalChest("HorseChest", this.func_110225_cC(), this); // CraftBukkit - add this horse
this.horseChest.func_110133_a(this.getCommandSenderName());
if (animalchest != null)
@@ -950,12 +951,25 @@
{
super.onDeath(p_70645_1_);
+ /* CraftBukkit start - Handle chest dropping in dropFewItems below
if (!this.worldObj.isRemote)
{
this.dropChestItems();
}
+ // CraftBukkit end */
}
+ // CraftBukkit start - Add method
+ protected void dropFewItems(boolean flag, int i) {
+ super.dropFewItems(flag, i);
+
+ // Moved from die method above
+ if (!this.worldObj.isRemote) {
+ this.dropChestItems();
+ }
+ }
+ // CraftBukkit end
+
public void onLivingUpdate()
{
if (this.rand.nextInt(200) == 0)
@@ -1278,6 +1292,7 @@
p_70014_1_.setInteger("Temper", this.getTemper());
p_70014_1_.setBoolean("Tame", this.isTame());
p_70014_1_.setString("OwnerUUID", this.func_152119_ch());
+ p_70014_1_.setInteger("Bukkit.MaxDomestication", this.maxDomestication); // CraftBukkit
if (this.isChested())
{
@@ -1327,6 +1342,13 @@
this.func_152120_b(p_70037_1_.getString("OwnerUUID"));
}
+ // CraftBukkit start
+ if (p_70037_1_.hasKey("Bukkit.MaxDomestication"))
+ {
+ this.maxDomestication = p_70037_1_.getInteger("Bukkit.MaxDomestication");
+ }
+
+ // CraftBukkit end
IAttributeInstance iattributeinstance = this.getAttributeMap().getAttributeInstanceByName("Speed");
if (iattributeinstance != null)
@@ -1566,24 +1588,33 @@
{
if (this.isHorseSaddled())
{
+ // CraftBukkit start - fire HorseJumpEvent, use event power
if (p_110206_1_ < 0)
{
p_110206_1_ = 0;
}
- else
- {
- this.field_110294_bI = true;
- this.makeHorseRear();
- }
+ float power;
+
if (p_110206_1_ >= 90)
{
- this.jumpPower = 1.0F;
+ power = 1.0F;
}
else
{
- this.jumpPower = 0.4F + 0.4F * (float)p_110206_1_ / 90.0F;
+ power = 0.4F + 0.4F * (float)p_110206_1_ / 90.0F;
}
+
+ org.bukkit.event.entity.HorseJumpEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callHorseJumpEvent(this, power);
+
+ if (!event.isCancelled())
+ {
+ this.field_110294_bI = true;
+ this.makeHorseRear();
+ this.jumpPower = event.getPower();
+ }
+
+ // CraftBukkit end
}
}

View File

@ -0,0 +1,11 @@
--- ../src-base/minecraft/net/minecraft/entity/passive/EntityMooshroom.java
+++ ../src-work/minecraft/net/minecraft/entity/passive/EntityMooshroom.java
@@ -12,6 +12,8 @@
import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
+import org.bukkit.event.player.PlayerShearEntityEvent; // CraftBukkit
+
public class EntityMooshroom extends EntityCow implements IShearable
{
private static final String __OBFID = "CL_00001645";

View File

@ -0,0 +1,21 @@
--- ../src-base/minecraft/net/minecraft/entity/passive/EntityOcelot.java
+++ ../src-work/minecraft/net/minecraft/entity/passive/EntityOcelot.java
@@ -89,7 +89,7 @@
protected boolean canDespawn()
{
- return !this.isTamed() && this.ticksExisted > 2400;
+ return !this.isTamed(); // CraftBukkit
}
public boolean isAIEnabled()
@@ -188,7 +188,8 @@
if (!this.worldObj.isRemote)
{
- if (this.rand.nextInt(3) == 0)
+ // CraftBukkit - added event call and isCancelled check
+ if (this.rand.nextInt(3) == 0 && !org.bukkit.craftbukkit.event.CraftEventFactory.callEntityTameEvent(this, p_70085_1_).isCancelled())
{
this.setTamed(true);
this.setTameSkin(1 + this.worldObj.rand.nextInt(3));

View File

@ -0,0 +1,36 @@
--- ../src-base/minecraft/net/minecraft/entity/passive/EntityPig.java
+++ ../src-work/minecraft/net/minecraft/entity/passive/EntityPig.java
@@ -22,6 +22,8 @@
import net.minecraft.stats.AchievementList;
import net.minecraft.world.World;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public class EntityPig extends EntityAnimal
{
private final EntityAIControlledByPlayer aiControlledByPlayer;
@@ -171,9 +173,23 @@
if (!this.worldObj.isRemote)
{
EntityPigZombie entitypigzombie = new EntityPigZombie(this.worldObj);
+
+ // Cauldron start
+ if (p_70077_1_ != null)
+ {
+ // CraftBukkit start
+ if (CraftEventFactory.callPigZapEvent(this, p_70077_1_, entitypigzombie).isCancelled())
+ {
+ return;
+ }
+
+ // CraftBukkit end
+ }
+ // Cauldron end
entitypigzombie.setCurrentItemOrArmor(0, new ItemStack(Items.golden_sword));
entitypigzombie.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
- this.worldObj.spawnEntityInWorld(entitypigzombie);
+ // CraftBukkit - added a reason for spawning this creature
+ this.worldObj.addEntity(entitypigzombie, org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.LIGHTNING);
this.setDead();
}
}

View File

@ -0,0 +1,42 @@
--- ../src-base/minecraft/net/minecraft/entity/passive/EntitySheep.java
+++ ../src-work/minecraft/net/minecraft/entity/passive/EntitySheep.java
@@ -32,6 +32,12 @@
import net.minecraft.world.World;
import net.minecraftforge.common.IShearable;
+// CraftBukkit start
+import net.minecraft.inventory.InventoryCraftResult;
+import org.bukkit.event.entity.SheepRegrowWoolEvent;
+import org.bukkit.event.player.PlayerShearEntityEvent;
+// CraftBukkit end
+
public class EntitySheep extends EntityAnimal implements IShearable
{
private final InventoryCrafting field_90016_e = new InventoryCrafting(new Container()
@@ -63,6 +69,7 @@
this.tasks.addTask(8, new EntityAILookIdle(this));
this.field_90016_e.setInventorySlotContents(0, new ItemStack(Items.dye, 1, 0));
this.field_90016_e.setInventorySlotContents(1, new ItemStack(Items.dye, 1, 0));
+ this.field_90016_e.resultInventory = new InventoryCraftResult(); // CraftBukkit - add result slot for event
}
protected boolean isAIEnabled()
@@ -231,8 +238,17 @@
public void eatGrassBonus()
{
- this.setSheared(false);
+ // CraftBukkit start
+ SheepRegrowWoolEvent event = new SheepRegrowWoolEvent((org.bukkit.entity.Sheep) this.getBukkitEntity());
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+ if (!event.isCancelled())
+ {
+ this.setSheared(false);
+ }
+
+ // CraftBukkit end
+
if (this.isChild())
{
this.addGrowth(60);

View File

@ -0,0 +1,39 @@
--- ../src-base/minecraft/net/minecraft/entity/passive/EntitySquid.java
+++ ../src-work/minecraft/net/minecraft/entity/passive/EntitySquid.java
@@ -8,6 +8,8 @@
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
+import org.bukkit.craftbukkit.TrigMath; // CraftBukkit
+
public class EntitySquid extends EntityWaterMob
{
public float squidPitch;
@@ -79,10 +81,12 @@
}
}
+ /* CraftBukkit start - Delegate to Entity to use existing inWater value
public boolean isInWater()
{
return this.worldObj.handleMaterialAcceleration(this.boundingBox.expand(0.0D, -0.6000000238418579D, 0.0D), Material.water, this);
}
+ // CraftBukkit end */
public void onLivingUpdate()
{
@@ -137,10 +141,12 @@
}
f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
- this.renderYawOffset += (-((float)Math.atan2(this.motionX, this.motionZ)) * 180.0F / (float)Math.PI - this.renderYawOffset) * 0.1F;
+ // CraftBukkit - Math -> TrigMath
+ this.renderYawOffset += (-((float) TrigMath.atan2(this.motionX, this.motionZ)) * 180.0F / (float)Math.PI - this.renderYawOffset) * 0.1F;
this.rotationYaw = this.renderYawOffset;
this.squidYaw += (float)Math.PI * this.field_70871_bB * 1.5F;
- this.squidPitch += (-((float)Math.atan2((double)f, this.motionY)) * 180.0F / (float)Math.PI - this.squidPitch) * 0.1F;
+ // CraftBukkit - Math -> TrigMath
+ this.squidPitch += (-((float) TrigMath.atan2((double) f, this.motionY)) * 180.0F / (float)Math.PI - this.squidPitch) * 0.1F;
}
else
{

View File

@ -0,0 +1,21 @@
--- ../src-base/minecraft/net/minecraft/entity/passive/EntityWolf.java
+++ ../src-work/minecraft/net/minecraft/entity/passive/EntityWolf.java
@@ -139,7 +139,8 @@
protected String getLivingSound()
{
- return this.isAngry() ? "mob.wolf.growl" : (this.rand.nextInt(3) == 0 ? (this.isTamed() && this.dataWatcher.getWatchableObjectFloat(18) < 10.0F ? "mob.wolf.whine" : "mob.wolf.panting") : "mob.wolf.bark");
+ // CraftBukkit - (getFloat(18) < 10) -> (getFloat(18) < this.getMaxHealth() / 2)
+ return this.isAngry() ? "mob.wolf.growl" : (this.rand.nextInt(3) == 0 ? (this.isTamed() && this.dataWatcher.getWatchableObjectFloat(18) < (this.getMaxHealth() / 2) ? "mob.wolf.whine" : "mob.wolf.panting") : "mob.wolf.bark");
}
protected String getHurtSound()
@@ -527,7 +528,7 @@
protected boolean canDespawn()
{
- return !this.isTamed() && this.ticksExisted > 2400;
+ return !this.isTamed(); // CraftBukkit
}
public boolean func_142018_a(EntityLivingBase p_142018_1_, EntityLivingBase p_142018_2_)

View File

@ -0,0 +1,484 @@
--- ../src-base/minecraft/net/minecraft/entity/player/EntityPlayer.java
+++ ../src-work/minecraft/net/minecraft/entity/player/EntityPlayer.java
@@ -92,6 +92,22 @@
import net.minecraftforge.event.entity.player.PlayerFlyableFallEvent;
import net.minecraftforge.event.entity.player.PlayerSleepInBedEvent;
+// CraftBukkit start
+import net.minecraft.network.play.server.S2FPacketSetSlot;
+
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.craftbukkit.entity.CraftItem;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.entity.Player;
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
+import org.bukkit.event.inventory.InventoryCloseEvent;
+import org.bukkit.event.player.PlayerBedEnterEvent;
+import org.bukkit.event.player.PlayerBedLeaveEvent;
+import org.bukkit.event.player.PlayerDropItemEvent;
+import org.bukkit.event.player.PlayerItemConsumeEvent;
+// CraftBukkit end
+
public abstract class EntityPlayer extends EntityLivingBase implements ICommandSender
{
public static final String PERSISTED_NBT_TAG = "PlayerPersisted";
@@ -102,7 +118,7 @@
private InventoryEnderChest theInventoryEnderChest = new InventoryEnderChest();
public Container inventoryContainer;
public Container openContainer;
- protected FoodStats foodStats = new FoodStats();
+ protected FoodStats foodStats = new FoodStats(this); // CraftBukkit - add this argument
protected int flyToggleTimer;
public float prevCameraYaw;
public float cameraYaw;
@@ -113,9 +129,19 @@
public double field_71094_bP;
public double field_71095_bQ;
public double field_71085_bR;
- protected boolean sleeping;
+ // CraftBukkit start
+ public boolean sleeping; // protected -> public
+ public boolean fauxSleeping;
+ public String spawnWorld = "";
+
+ @Override
+ public CraftHumanEntity getBukkitEntity()
+ {
+ return (CraftHumanEntity) super.getBukkitEntity();
+ }
+ // CraftBukkit end
public ChunkCoordinates playerLocation;
- private int sleepTimer;
+ public int sleepTimer; // CraftBukkit - private -> public
public float field_71079_bU;
@SideOnly(Side.CLIENT)
public float field_71082_cx;
@@ -124,6 +150,7 @@
private boolean spawnForced;
private ChunkCoordinates startMinecartRidingCoordinate;
public PlayerCapabilities capabilities = new PlayerCapabilities();
+ public int oldLevel = -1; // CraftBukkit
public int experienceLevel;
public int experienceTotal;
public float experience;
@@ -416,6 +443,42 @@
{
this.updateItemUse(this.itemInUse, 16);
int i = this.itemInUse.stackSize;
+ // CraftBukkit start
+ org.bukkit.inventory.ItemStack craftItem = CraftItemStack.asBukkitCopy(this.itemInUse);
+ PlayerItemConsumeEvent event = new PlayerItemConsumeEvent((Player) this.getBukkitEntity(), craftItem);
+ worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled())
+ {
+ // Update client
+ if (this instanceof EntityPlayerMP)
+ {
+ ((EntityPlayerMP) this).playerNetServerHandler.sendPacket(new S2FPacketSetSlot((byte) 0, openContainer.getSlotFromInventory(
+ (IInventory) this.inventory, this.inventory.currentItem).slotIndex, this.itemInUse));
+ // Spigot Start
+ ((EntityPlayerMP) this).getBukkitEntity().updateInventory();
+ ((EntityPlayerMP) this).getBukkitEntity().updateScaledHealth();
+ // Spigot End
+ }
+
+ return;
+ }
+
+ // Plugin modified the item, process it but don't remove it
+ if (!craftItem.equals(event.getItem()))
+ {
+ CraftItemStack.asNMSCopy(event.getItem()).onFoodEaten(this.worldObj, this);
+
+ // Update client
+ if (this instanceof EntityPlayerMP)
+ {
+ ((EntityPlayerMP) this).playerNetServerHandler.sendPacket(new S2FPacketSetSlot((byte) 0, openContainer.getSlotFromInventory(
+ (IInventory) this.inventory, this.inventory.currentItem).slotIndex, this.itemInUse));
+ }
+
+ return;
+ }
+ // CraftBukkit end
ItemStack itemstack = this.itemInUse.onFoodEaten(this.worldObj, this);
itemstack = ForgeEventFactory.onItemUseFinish(this, itemInUse, itemInUseCount, itemstack);
@@ -452,6 +515,7 @@
return this.getHealth() <= 0.0F || this.isPlayerSleeping();
}
+ // CraftBukkit - protected -> public
public void closeScreen()
{
this.openContainer = this.inventoryContainer;
@@ -459,23 +523,40 @@
public void mountEntity(Entity p_70078_1_)
{
+ // CraftBukkit start - mirror Entity mount changes
+ this.setPassengerOf(p_70078_1_);
+ }
+
+ public void setPassengerOf(Entity p_70078_1_)
+ {
+ // CraftBukkit end
if (this.ridingEntity != null && p_70078_1_ == null)
{
- if (!this.worldObj.isRemote)
- {
- this.dismountEntity(this.ridingEntity);
- }
+ worldObj.getServer().getPluginManager()
+ .callEvent(new org.spigotmc.event.entity.EntityDismountEvent(this.getBukkitEntity(), this.ridingEntity.getBukkitEntity())); // Spigot
+ // CraftBukkit start - use parent method instead to correctly fire
+ // VehicleExitEvent
+ Entity originalVehicle = this.ridingEntity;
+ // First statement moved down, second statement handled in parent
+ // method.
+ /*
+ * if (!this.world.isStatic) { this.l(this.vehicle); }
+ *
+ * if (this.vehicle != null) { this.vehicle.passenger = null; }
+ *
+ * this.vehicle = null;
+ */
+ super.setPassengerOf(p_70078_1_);
- if (this.ridingEntity != null)
+ if (!this.worldObj.isRemote && this.ridingEntity == null)
{
- this.ridingEntity.riddenByEntity = null;
+ this.dismountEntity(originalVehicle);
}
-
- this.ridingEntity = null;
+ // CraftBukkit end
}
else
{
- super.mountEntity(p_70078_1_);
+ super.setPassengerOf(p_70078_1_); // CraftBukkit - call new parent
}
}
@@ -532,7 +613,8 @@
if (this.worldObj.difficultySetting == EnumDifficulty.PEACEFUL && this.getHealth() < this.getMaxHealth() && this.worldObj.getGameRules().getGameRuleBooleanValue("naturalRegeneration") && this.ticksExisted % 20 * 12 == 0)
{
- this.heal(1.0F);
+ // CraftBukkit - added regain reason of "REGEN" for filtering purposes.
+ this.heal(1.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.REGEN);
}
this.inventory.decrementAnimations();
@@ -554,7 +636,8 @@
this.setAIMoveSpeed((float)iattributeinstance.getAttributeValue());
float f = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionZ * this.motionZ);
- float f1 = (float)Math.atan(-this.motionY * 0.20000000298023224D) * 15.0F;
+ // CraftBukkit - Math -> TrigMath
+ float f1 = (float) org.bukkit.craftbukkit.TrigMath.atan(-this.motionY * 0.20000000298023224D) * 15.0F;
if (f > 0.1F)
{
@@ -589,7 +672,7 @@
List list = this.worldObj.getEntitiesWithinAABBExcludingEntity(this, axisalignedbb);
- if (list != null)
+ if (list != null && this.canBeCollidedWith()) // Spigot: this.canBeCollidedWith() condition
{
for (int i = 0; i < list.size(); ++i)
{
@@ -687,12 +770,14 @@
public void addToPlayerScore(Entity p_70084_1_, int p_70084_2_)
{
this.addScore(p_70084_2_);
- Collection collection = this.getWorldScoreboard().func_96520_a(IScoreObjectiveCriteria.totalKillCount);
+ // CraftBukkit - Get our scores instead
+ Collection<Score> collection = this.worldObj.getServer().getScoreboardManager().getScoreboardScores(IScoreObjectiveCriteria.totalKillCount, this.getCommandSenderName(), new java.util.ArrayList<Score>());
if (p_70084_1_ instanceof EntityPlayer)
{
this.addStat(StatList.playerKillsStat, 1);
- collection.addAll(this.getWorldScoreboard().func_96520_a(IScoreObjectiveCriteria.playerKillCount));
+ // CraftBukkit - Get our scores instead
+ this.worldObj.getServer().getScoreboardManager().getScoreboardScores(IScoreObjectiveCriteria.playerKillCount, this.getCommandSenderName(), collection);
}
else
{
@@ -703,8 +788,7 @@
while (iterator.hasNext())
{
- ScoreObjective scoreobjective = (ScoreObjective)iterator.next();
- Score score = this.getWorldScoreboard().func_96529_a(this.getCommandSenderName(), scoreobjective);
+ Score score = (Score) iterator.next(); // CraftBukkit - Use our scores instead
score.func_96648_a();
}
}
@@ -777,6 +861,19 @@
entityitem.motionZ += Math.sin((double)f1) * (double)f;
}
+ // CraftBukkit start
+ Player player = (Player) this.getBukkitEntity();
+ CraftItem drop = new CraftItem(this.worldObj.getServer(), entityitem);
+ PlayerDropItemEvent event = new PlayerDropItemEvent(player, drop);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled())
+ {
+ player.getInventory().addItem(drop.getItemStack());
+ return null;
+ }
+ // CraftBukkit end
+
this.joinEntityItemWithWorld(entityitem);
this.addStat(StatList.dropStat, 1);
return entityitem;
@@ -881,6 +978,15 @@
this.wakeUpPlayer(true, true, false);
}
+ // CraftBukkit start
+ this.spawnWorld = p_70037_1_.getString("SpawnWorld");
+
+ if ("".equals(spawnWorld))
+ {
+ this.spawnWorld = this.worldObj.getServer().getWorlds().get(0).getName();
+ }
+ // CraftBukkit end
+
if (p_70037_1_.hasKey("SpawnX", 99) && p_70037_1_.hasKey("SpawnY", 99) && p_70037_1_.hasKey("SpawnZ", 99))
{
this.spawnChunk = new ChunkCoordinates(p_70037_1_.getInteger("SpawnX"), p_70037_1_.getInteger("SpawnY"), p_70037_1_.getInteger("SpawnZ"));
@@ -925,6 +1031,7 @@
p_70014_1_.setInteger("SpawnY", this.spawnChunk.posY);
p_70014_1_.setInteger("SpawnZ", this.spawnChunk.posZ);
p_70014_1_.setBoolean("SpawnForced", this.spawnForced);
+ p_70014_1_.setString("SpawnWorld", spawnWorld); // CraftBukkit - fixes bed spawns for multiworld worlds
}
NBTTagList spawnlist = new NBTTagList();
@@ -1003,7 +1110,7 @@
{
if (this.worldObj.difficultySetting == EnumDifficulty.PEACEFUL)
{
- p_70097_2_ = 0.0F;
+ return false; // CraftBukkit - p_70097_2_ = 0.0F; -> return false
}
if (this.worldObj.difficultySetting == EnumDifficulty.EASY)
@@ -1017,7 +1124,7 @@
}
}
- if (p_70097_2_ == 0.0F)
+ if (false && p_70097_2_ == 0.0F) // CraftBukkit - Don't filter out 0 damage
{
return false;
}
@@ -1039,9 +1146,40 @@
public boolean canAttackPlayer(EntityPlayer p_96122_1_)
{
- Team team = this.getTeam();
- Team team1 = p_96122_1_.getTeam();
- return team == null ? true : (!team.isSameTeam(team1) ? true : team.getAllowFriendlyFire());
+ // CraftBukkit start - Change to check OTHER player's scoreboard team
+ // according to API
+ // To summarize this method's logic, it's "Can parameter hurt this"
+ org.bukkit.scoreboard.Team team;
+
+ if (p_96122_1_ instanceof EntityPlayerMP)
+ {
+ EntityPlayerMP thatPlayer = (EntityPlayerMP) p_96122_1_;
+ team = thatPlayer.getBukkitEntity().getScoreboard().getPlayerTeam(thatPlayer.getBukkitEntity());
+
+ if (team == null || team.allowFriendlyFire())
+ {
+ return true;
+ }
+ }
+ else
+ {
+ // This should never be called, but is implemented anyway
+ org.bukkit.OfflinePlayer thisPlayer = p_96122_1_.worldObj.getServer().getOfflinePlayer(p_96122_1_.getCommandSenderName());
+ team = p_96122_1_.worldObj.getServer().getScoreboardManager().getMainScoreboard().getPlayerTeam(thisPlayer);
+
+ if (team == null || team.allowFriendlyFire())
+ {
+ return true;
+ }
+ }
+
+ if (this instanceof EntityPlayerMP)
+ {
+ return !team.hasPlayer(((EntityPlayerMP) this).getBukkitEntity());
+ }
+
+ return !team.hasPlayer(this.worldObj.getServer().getOfflinePlayer(this.getCommandSenderName()));
+ // CraftBukkit end
}
protected void damageArmor(float p_70675_1_)
@@ -1073,19 +1211,34 @@
return (float)i / (float)this.inventory.armorInventory.length;
}
+ // 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(DamageSource p_70665_1_, float p_70665_2_) // void
+ // ->
+ // boolean
+ {
+ if (true)
+ {
+ return super.damageEntity_CB(p_70665_1_, p_70665_2_);
+ }
+ // CraftBukkit end
if (!this.isEntityInvulnerable())
{
p_70665_2_ = ForgeHooks.onLivingHurt(this, p_70665_1_, p_70665_2_);
- if (p_70665_2_ <= 0) return;
+ if (p_70665_2_ <= 0) return false;
if (!p_70665_1_.isUnblockable() && this.isBlocking() && p_70665_2_ > 0.0F)
{
p_70665_2_ = (1.0F + p_70665_2_) * 0.5F;
}
p_70665_2_ = ArmorProperties.ApplyArmor(this, inventory.armorInventory, p_70665_1_, p_70665_2_);
- if (p_70665_2_ <= 0) return;
+ if (p_70665_2_ <= 0) return false;
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);
@@ -1099,6 +1252,7 @@
this.func_110142_aN().func_94547_a(p_70665_1_, f2, p_70665_2_);
}
}
+ return false;
}
public void func_146101_a(TileEntityFurnace p_146101_1_) {}
@@ -1134,7 +1288,8 @@
if (itemstack.interactWithEntity(this, (EntityLivingBase)p_70998_1_))
{
- if (itemstack.stackSize <= 0 && !this.capabilities.isCreativeMode)
+ // CraftBukkit - bypass infinite items; <= 0 -> == 0
+ if (itemstack.stackSize == 0 && !this.capabilities.isCreativeMode)
{
this.destroyCurrentEquippedItem();
}
@@ -1281,7 +1436,8 @@
{
itemstack.hitEntity((EntityLivingBase)object, this);
- if (itemstack.stackSize <= 0)
+ // CraftBukkit - bypass infinite items; <= 0 -> == 0
+ if (itemstack.stackSize == 0)
{
this.destroyCurrentEquippedItem();
}
@@ -1293,7 +1449,17 @@
if (j > 0)
{
- p_71059_1_.setFire(j * 4);
+ // CraftBukkit start - Call a combust event when
+ // somebody hits with a fire enchanted item
+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), p_71059_1_.getBukkitEntity(),
+ j * 4);
+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
+
+ if (!combustEvent.isCancelled())
+ {
+ p_71059_1_.setFire(combustEvent.getDuration());
+ }
+ // CraftBukkit end
}
}
@@ -1322,6 +1488,10 @@
if (this.openContainer != null)
{
+ // CraftBukkit start
+ InventoryCloseEvent event = new InventoryCloseEvent(this.openContainer.getBukkitView());
+ if (this.openContainer.getBukkitView() != null) Bukkit.getServer().getPluginManager().callEvent(event); // Cauldron - allow vanilla mods to bypass
+ // CraftBukkit end
this.openContainer.onContainerClosed(this);
}
}
@@ -1381,6 +1551,20 @@
this.mountEntity((Entity)null);
}
+ // CraftBukkit start
+ if (this.getBukkitEntity() instanceof Player)
+ {
+ Player player = (Player) this.getBukkitEntity();
+ org.bukkit.block.Block bed = this.worldObj.getWorld().getBlockAt(p_71018_1_, p_71018_2_, p_71018_3_);
+ PlayerBedEnterEvent cbEvent = new PlayerBedEnterEvent(player, bed);
+ this.worldObj.getServer().getPluginManager().callEvent(cbEvent);
+
+ if (cbEvent.isCancelled())
+ {
+ return EntityPlayer.EnumStatus.OTHER_PROBLEM;
+ }
+ }
+ // CraftBukkit end
this.setSize(0.2F, 0.2F);
this.yOffset = 0.2F;
@@ -1476,6 +1660,26 @@
this.worldObj.updateAllPlayersSleepingFlag();
}
+ // CraftBukkit start
+ if (this.getBukkitEntity() instanceof Player)
+ {
+ Player player = (Player) this.getBukkitEntity();
+ org.bukkit.block.Block bed;
+
+ if (chunkcoordinates != null)
+ {
+ bed = this.worldObj.getWorld().getBlockAt(chunkcoordinates.posX, chunkcoordinates.posY, chunkcoordinates.posZ);
+ }
+ else
+ {
+ bed = this.worldObj.getWorld().getBlockAt(player.getLocation());
+ }
+
+ PlayerBedLeaveEvent event = new PlayerBedLeaveEvent(player, bed);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+ }
+ // CraftBukkit end
+
if (p_70999_1_)
{
this.sleepTimer = 0;
@@ -1606,11 +1810,13 @@
{
this.spawnChunk = new ChunkCoordinates(p_71063_1_);
this.spawnForced = p_71063_2_;
+ this.spawnWorld = this.worldObj.worldInfo.getWorldName(); // CraftBukkit
}
else
{
this.spawnChunk = null;
this.spawnForced = false;
+ this.spawnWorld = ""; // CraftBukkit
}
}

View File

@ -0,0 +1,822 @@
--- ../src-base/minecraft/net/minecraft/entity/player/EntityPlayerMP.java
+++ ../src-work/minecraft/net/minecraft/entity/player/EntityPlayerMP.java
@@ -2,6 +2,7 @@
import com.google.common.collect.Sets;
import com.mojang.authlib.GameProfile;
+
import io.netty.buffer.Unpooled;
import java.io.IOException;
import java.util.ArrayList;
@@ -83,6 +84,7 @@
import net.minecraft.tileentity.TileEntityFurnace;
import net.minecraft.tileentity.TileEntityHopper;
import net.minecraft.tileentity.TileEntitySign;
+import net.minecraft.util.ChatComponentTranslation;
import net.minecraft.util.ChunkCoordinates;
import net.minecraft.util.DamageSource;
import net.minecraft.util.EntityDamageSource;
@@ -106,24 +108,38 @@
import net.minecraftforge.event.entity.player.PlayerDropsEvent;
import net.minecraftforge.event.world.ChunkWatchEvent;
+// CraftBukkit start
+import net.minecraft.util.CombatTracker;
+import net.minecraft.util.FoodStats;
+import net.minecraft.world.World;
+import org.bukkit.Bukkit;
+import org.bukkit.WeatherType;
+import org.bukkit.craftbukkit.CraftWorld;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.craftbukkit.event.CraftEventFactory;
+import org.bukkit.craftbukkit.inventory.CraftItemStack;
+import org.bukkit.event.inventory.InventoryType;
+import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
+// CraftBukkit end
+
public class EntityPlayerMP extends EntityPlayer implements ICrafting
{
private static final Logger logger = LogManager.getLogger();
- private String translator = "en_US";
+ public String translator = "en_US"; // CraftBukkit - private -> public
public NetHandlerPlayServer playerNetServerHandler;
public final MinecraftServer mcServer;
public final ItemInWorldManager theItemInWorldManager;
public double managedPosX;
public double managedPosZ;
public final List loadedChunks = new LinkedList();
- private final List destroyedItemsNetCache = new LinkedList();
+ public final List destroyedItemsNetCache = new LinkedList();
private final StatisticsFile field_147103_bO;
private float field_130068_bO = Float.MIN_VALUE;
private float lastHealth = -1.0E8F;
private int lastFoodLevel = -99999999;
private boolean wasHungry = true;
- private int lastExperience = -99999999;
- private int field_147101_bU = 60;
+ public int lastExperience = -99999999; // CraftBukkit - private -> public
+ public int field_147101_bU = 60; // CraftBukkit - private -> public
private EntityPlayer.EnumChatVisibility chatVisibility;
private boolean chatColours = true;
private long field_143005_bX = System.currentTimeMillis();
@@ -131,6 +147,39 @@
public boolean isChangingQuantityOnly;
public int ping;
public boolean playerConqueredTheEnd;
+ // CraftBukkit start
+ public String displayName;
+ public String listName;
+ public org.bukkit.Location compassTarget;
+ public int newExp = 0;
+ public int newLevel = 0;
+ public int newTotalExp = 0;
+ public boolean keepLevel = false;
+ public double maxHealthCache;
+ // CraftBukkit end
+ // Spigot start
+ public boolean collidesWithEntities = true;
+
+ @Override
+
+ /**
+ * Returns true if other Entities should be prevented from moving through this Entity.
+ */
+ public boolean canBeCollidedWith()
+ {
+ return this.collidesWithEntities && super.canBeCollidedWith();
+ }
+
+ @Override
+
+ /**
+ * Returns true if this entity should push and be pushed by other entities when colliding.
+ */
+ public boolean canBePushed()
+ {
+ return this.collidesWithEntities && super.canBePushed();
+ }
+ // Spigot end
private static final String __OBFID = "CL_00001440";
public EntityPlayerMP(MinecraftServer p_i45285_1_, WorldServer p_i45285_2_, GameProfile p_i45285_3_, ItemInWorldManager p_i45285_4_)
@@ -153,6 +202,13 @@
{
this.setPosition(this.posX, this.posY + 1.0D, this.posZ);
}
+
+ // CraftBukkit start
+ this.displayName = this.getCommandSenderName();
+ this.listName = this.getCommandSenderName();
+ // this.canPickUpLoot = true; TODO
+ this.maxHealthCache = this.getMaxHealth();
+ // CraftBukkit end
}
public void readEntityFromNBT(NBTTagCompound p_70037_1_)
@@ -170,14 +226,57 @@
this.theItemInWorldManager.setGameType(WorldSettings.GameType.getByID(p_70037_1_.getInteger("playerGameType")));
}
}
+
+ this.getBukkitEntity().readExtraData(p_70037_1_); // CraftBukkit
}
public void writeEntityToNBT(NBTTagCompound p_70014_1_)
{
super.writeEntityToNBT(p_70014_1_);
p_70014_1_.setInteger("playerGameType", this.theItemInWorldManager.getGameType().getID());
+ this.getBukkitEntity().setExtraData(p_70014_1_); // CraftBukkit
}
+ // CraftBukkit start - World fallback code, either respawn location or global spawn
+
+ /**
+ * Sets the reference to the World object.
+ */
+ public void setWorld(World world)
+ {
+ super.setWorld(world);
+
+ if (world == null)
+ {
+ this.isDead = false;
+ ChunkCoordinates position = null;
+
+ if (this.spawnWorld != null && !this.spawnWorld.equals(""))
+ {
+ CraftWorld cworld = (CraftWorld) Bukkit.getServer().getWorld(this.spawnWorld);
+
+ if (cworld != null && this.getBedLocation() != null)
+ {
+ world = cworld.getHandle();
+ position = EntityPlayer.verifyRespawnCoordinates(cworld.getHandle(), this.getBedLocation(), false);
+ }
+ }
+
+ if (world == null || position == null)
+ {
+ world = ((CraftWorld) Bukkit.getServer().getWorlds().get(0)).getHandle();
+ position = world.getSpawnPoint();
+ }
+
+ this.worldObj = world;
+ this.setPosition(position.posX + 0.5, position.posY, position.posZ + 0.5);
+ }
+
+ this.dimension = ((WorldServer) this.worldObj).provider.dimensionId;
+ this.theItemInWorldManager.setWorld((WorldServer) world);
+ }
+ // CraftBukkit end
+
public void addExperienceLevel(int p_82242_1_)
{
super.addExperienceLevel(p_82242_1_);
@@ -240,7 +339,7 @@
ArrayList arraylist1 = new ArrayList();
Chunk chunk;
- while (iterator1.hasNext() && arraylist.size() < S26PacketMapChunkBulk.func_149258_c())
+ while (iterator1.hasNext() && arraylist.size() < this.worldObj.getSpigotConfig().maxBulkChunk) // Spigot // Cauldron
{
ChunkCoordIntPair chunkcoordintpair = (ChunkCoordIntPair)iterator1.next();
@@ -253,8 +352,7 @@
if (chunk.func_150802_k())
{
arraylist.add(chunk);
- arraylist1.addAll(((WorldServer)this.worldObj).func_147486_a(chunkcoordintpair.chunkXPos * 16, 0, chunkcoordintpair.chunkZPos * 16, chunkcoordintpair.chunkXPos * 16 + 15, 256, chunkcoordintpair.chunkZPos * 16 + 15));
- //BugFix: 16 makes it load an extra chunk, which isn't associated with a player, which makes it not unload unless a player walks near it.
+ arraylist1.addAll(chunk.chunkTileEntityMap.values()); // CraftBukkit - Get tile entities directly from the chunk instead of the world
iterator1.remove();
}
}
@@ -309,9 +407,10 @@
}
}
+ // CraftBukkit - Optionally scale health
if (this.getHealth() != this.lastHealth || this.lastFoodLevel != this.foodStats.getFoodLevel() || this.foodStats.getSaturationLevel() == 0.0F != this.wasHungry)
{
- this.playerNetServerHandler.sendPacket(new S06PacketUpdateHealth(this.getHealth(), this.foodStats.getFoodLevel(), this.foodStats.getSaturationLevel()));
+ this.playerNetServerHandler.sendPacket(new S06PacketUpdateHealth(this.getBukkitEntity().getScaledHealth(), this.foodStats.getFoodLevel(), this.foodStats.getSaturationLevel()));
this.lastHealth = this.getHealth();
this.lastFoodLevel = this.foodStats.getFoodLevel();
this.wasHungry = this.foodStats.getSaturationLevel() == 0.0F;
@@ -320,16 +419,18 @@
if (this.getHealth() + this.getAbsorptionAmount() != this.field_130068_bO)
{
this.field_130068_bO = this.getHealth() + this.getAbsorptionAmount();
- Collection collection = this.getWorldScoreboard().func_96520_a(IScoreObjectiveCriteria.health);
- Iterator iterator = collection.iterator();
+ // CraftBukkit - Update ALL the scores!
+ this.worldObj.getServer().getScoreboardManager().updateAllScoresForList(IScoreObjectiveCriteria.health, this.getCommandSenderName(), com.google.common.collect.ImmutableList.of(this));
+ }
- while (iterator.hasNext())
- {
- ScoreObjective scoreobjective = (ScoreObjective)iterator.next();
- this.getWorldScoreboard().func_96529_a(this.getCommandSenderName(), scoreobjective).func_96651_a(Arrays.asList(new EntityPlayer[] {this}));
- }
+ // CraftBukkit start - Force max health updates
+ if (this.maxHealthCache != this.getMaxHealth())
+ {
+ this.getBukkitEntity().updateScaledHealth();
}
+ // CraftBukkit end
+
if (this.experienceTotal != this.lastExperience)
{
this.lastExperience = this.experienceTotal;
@@ -340,6 +441,20 @@
{
this.func_147098_j();
}
+
+ // CraftBukkit start
+ if (this.oldLevel == -1)
+ {
+ this.oldLevel = this.experienceLevel;
+ }
+
+ if (this.oldLevel != this.experienceLevel)
+ {
+ CraftEventFactory.callPlayerLevelChangeEvent(this.worldObj.getServer().getPlayer((EntityPlayerMP) this), this.oldLevel, this.experienceLevel);
+ this.oldLevel = this.experienceLevel;
+ }
+
+ // CraftBukkit end
}
catch (Throwable throwable)
{
@@ -402,34 +517,74 @@
public void onDeath(DamageSource p_70645_1_)
{
- if (ForgeHooks.onLivingDeath(this, p_70645_1_)) return;
- this.mcServer.getConfigurationManager().sendChatMsg(this.func_110142_aN().func_151521_b());
+ // CraftBukkit start
+ if (this.isDead || ForgeHooks.onLivingDeath(this, p_70645_1_)) // Cauldron - call Forge hook
+ {
+ return;
+ }
- if (!this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory"))
+ java.util.List<org.bukkit.inventory.ItemStack> loot = new java.util.ArrayList<org.bukkit.inventory.ItemStack>();
+ boolean keepInventory = this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory");
+
+ if (!keepInventory)
{
+ // Cauldron start - rework CraftBukkit logic to support Forge better
captureDrops = true;
capturedDrops.clear();
-
this.inventory.dropAllItems();
+ for (int i = 0; i < capturedDrops.size(); ++i)
+ {
+ if (capturedDrops.get(i) != null)
+ {
+ loot.add(CraftItemStack.asCraftMirror(capturedDrops.get(i).getEntityItem()));
+ }
+ }
+ // Cauldron end
+ }
+ IChatComponent chatmessage = this.func_110142_aN().func_151521_b();
+ String deathmessage = chatmessage.getUnformattedText();
+ org.bukkit.event.entity.PlayerDeathEvent event = CraftEventFactory.callPlayerDeathEvent(this, loot, deathmessage);
+ String deathMessage = event.getDeathMessage();
+
+ if (deathMessage != null && deathMessage.length() > 0)
+ {
+ if (deathMessage.equals(deathmessage))
+ {
+ this.mcServer.getConfigurationManager().sendChatMsg(chatmessage);
+ }
+ else
+ {
+ this.mcServer.getConfigurationManager().sendMessage(org.bukkit.craftbukkit.util.CraftChatMessage.fromString(deathMessage));
+ }
+ }
+
+ if (!keepInventory)
+ {
+ // Cauldron start - rework CraftBukkit logic to support Forge better
+ this.inventory.clearInventory(null, -1); // CraftBukkit - we clean the player's inventory after the EntityDeathEvent is called so plugins can get the exact state of the inventory.
captureDrops = false;
- PlayerDropsEvent event = new PlayerDropsEvent(this, p_70645_1_, capturedDrops, recentlyHit > 0);
- if (!MinecraftForge.EVENT_BUS.post(event))
+ PlayerDropsEvent forgeEvent = new PlayerDropsEvent(this, p_70645_1_, capturedDrops, recentlyHit > 0);
+
+ if (!MinecraftForge.EVENT_BUS.post(forgeEvent))
{
for (EntityItem item : capturedDrops)
{
joinEntityItemWithWorld(item);
}
}
+ // Cauldron end
}
- Collection collection = this.worldObj.getScoreboard().func_96520_a(IScoreObjectiveCriteria.deathCount);
+ this.closeScreen();
+ // CraftBukkit end
+ // CraftBukkit - Get our scores instead
+ Collection<Score> collection = this.worldObj.getServer().getScoreboardManager().getScoreboardScores(IScoreObjectiveCriteria.deathCount, this.getCommandSenderName(), new java.util.ArrayList<Score>());
Iterator iterator = collection.iterator();
while (iterator.hasNext())
{
- ScoreObjective scoreobjective = (ScoreObjective)iterator.next();
- Score score = this.getWorldScoreboard().func_96529_a(this.getCommandSenderName(), scoreobjective);
+ Score score = (Score) iterator.next(); // CraftBukkit - Use our scores instead
score.func_96648_a();
}
@@ -495,7 +650,8 @@
public boolean canAttackPlayer(EntityPlayer p_96122_1_)
{
- return !this.mcServer.isPVPEnabled() ? false : super.canAttackPlayer(p_96122_1_);
+ // CraftBukkit - this.mcServer.isPVPEnabled() -> this.world.pvpMode
+ return !this.worldObj.pvpMode ? false : super.canAttackPlayer(p_96122_1_);
}
public void travelToDimension(int p_71027_1_)
@@ -526,7 +682,10 @@
this.triggerAchievement(AchievementList.portal);
}
- this.mcServer.getConfigurationManager().transferPlayerToDimension(this, p_71027_1_);
+ // CraftBukkit start
+ TeleportCause cause = (this.dimension == 1 || p_71027_1_ == 1) ? TeleportCause.END_PORTAL : TeleportCause.NETHER_PORTAL;
+ this.mcServer.getConfigurationManager().transferPlayerToDimension(this, p_71027_1_, cause); // Cauldron
+ // CraftBukkit end
this.lastExperience = -1;
this.lastHealth = -1.0F;
this.lastFoodLevel = -1;
@@ -569,6 +728,11 @@
public void wakeUpPlayer(boolean p_70999_1_, boolean p_70999_2_, boolean p_70999_3_)
{
+ if (this.fauxSleeping && !this.sleeping)
+ {
+ return; // CraftBukkit - Can't leave bed if not in one!
+ }
+
if (this.isPlayerSleeping())
{
this.getServerForPlayer().getEntityTracker().func_151248_b(this, new S0BPacketAnimation(this, 2));
@@ -584,11 +748,27 @@
public void mountEntity(Entity p_70078_1_)
{
- super.mountEntity(p_70078_1_);
- this.playerNetServerHandler.sendPacket(new S1BPacketEntityAttach(0, this, this.ridingEntity));
- this.playerNetServerHandler.setPlayerLocation(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
+ // CraftBukkit start
+ this.setPassengerOf(p_70078_1_);
}
+ public void setPassengerOf(Entity entity)
+ {
+ // mount(null) doesn't really fly for overloaded methods,
+ // so this method is needed
+ Entity currentVehicle = this.ridingEntity;
+ super.setPassengerOf(entity);
+
+ // Check if the vehicle actually changed.
+ if (currentVehicle != this.ridingEntity)
+ {
+ this.playerNetServerHandler.sendPacket(new S1BPacketEntityAttach(0, this, this.ridingEntity));
+ this.playerNetServerHandler.setPlayerLocation(this.posX, this.posY, this.posZ, this.rotationYaw, this.rotationPitch);
+ }
+
+ // CraftBukkit end
+ }
+
protected void updateFallState(double p_70064_1_, boolean p_70064_3_) {}
public void handleFalling(double p_71122_1_, boolean p_71122_3_)
@@ -610,29 +790,64 @@
this.currentWindowId = this.currentWindowId % 100 + 1;
}
+ // CraftBukkit start - change signature from void to int
+ public int nextContainerCounter()
+ {
+ this.currentWindowId = this.currentWindowId % 100 + 1;
+ return this.currentWindowId;
+ }
+ // CraftBukkit end
+
public void displayGUIWorkbench(int p_71058_1_, int p_71058_2_, int p_71058_3_)
{
+ // CraftBukkit start - Inventory open hook
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerWorkbench(this.inventory, this.worldObj, p_71058_1_, p_71058_2_, p_71058_3_));
+
+ if (container == null)
+ {
+ return;
+ }
+
+ // CraftBukkit end
this.getNextWindowId();
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 1, "Crafting", 9, true));
- this.openContainer = new ContainerWorkbench(this.inventory, this.worldObj, p_71058_1_, p_71058_2_, p_71058_3_);
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addCraftingToCrafters(this);
}
public void displayGUIEnchantment(int p_71002_1_, int p_71002_2_, int p_71002_3_, String p_71002_4_)
{
+ // CraftBukkit start - Inventory open hook
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerEnchantment(this.inventory, this.worldObj, p_71002_1_, p_71002_2_, p_71002_3_));
+
+ if (container == null)
+ {
+ return;
+ }
+
+ // CraftBukkit end
this.getNextWindowId();
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 4, p_71002_4_ == null ? "" : p_71002_4_, 9, p_71002_4_ != null));
- this.openContainer = new ContainerEnchantment(this.inventory, this.worldObj, p_71002_1_, p_71002_2_, p_71002_3_);
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addCraftingToCrafters(this);
}
public void displayGUIAnvil(int p_82244_1_, int p_82244_2_, int p_82244_3_)
{
+ // CraftBukkit start - Inventory open hook
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerRepair(this.inventory, this.worldObj, p_82244_1_, p_82244_2_, p_82244_3_, this));
+
+ if (container == null)
+ {
+ return;
+ }
+
+ // CraftBukkit end
this.getNextWindowId();
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 8, "Repairing", 9, true));
- this.openContainer = new ContainerRepair(this.inventory, this.worldObj, p_82244_1_, p_82244_2_, p_82244_3_, this);
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addCraftingToCrafters(this);
}
@@ -644,71 +859,150 @@
this.closeScreen();
}
+ // CraftBukkit start - Inventory open hook
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerChest(this.inventory, p_71007_1_));
+
+ if (container == null)
+ {
+ p_71007_1_.closeInventory(); // Cauldron - prevent chest from being stuck in open state on clients
+ return;
+ }
+
+ // CraftBukkit end
this.getNextWindowId();
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 0, p_71007_1_.getInventoryName(), p_71007_1_.getSizeInventory(), p_71007_1_.hasCustomInventoryName()));
- this.openContainer = new ContainerChest(this.inventory, p_71007_1_);
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addCraftingToCrafters(this);
}
public void func_146093_a(TileEntityHopper p_146093_1_)
{
+ // CraftBukkit start - Inventory open hook
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHopper(this.inventory, p_146093_1_));
+
+ if (container == null)
+ {
+ p_146093_1_.closeInventory(); // Cauldron - prevent chest from being stuck in open state on clients
+ return;
+ }
+
+ // CraftBukkit end
this.getNextWindowId();
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 9, p_146093_1_.getInventoryName(), p_146093_1_.getSizeInventory(), p_146093_1_.hasCustomInventoryName()));
- this.openContainer = new ContainerHopper(this.inventory, p_146093_1_);
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addCraftingToCrafters(this);
}
public void displayGUIHopperMinecart(EntityMinecartHopper p_96125_1_)
{
+ // CraftBukkit start - Inventory open hook
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHopper(this.inventory, p_96125_1_));
+
+ if (container == null)
+ {
+ p_96125_1_.closeInventory(); // Cauldron - prevent chest from being stuck in open state on clients
+ return;
+ }
+
+ // CraftBukkit end
this.getNextWindowId();
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 9, p_96125_1_.getInventoryName(), p_96125_1_.getSizeInventory(), p_96125_1_.hasCustomInventoryName()));
- this.openContainer = new ContainerHopper(this.inventory, p_96125_1_);
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addCraftingToCrafters(this);
}
public void func_146101_a(TileEntityFurnace p_146101_1_)
{
+ // CraftBukkit start - Inventory open hook
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerFurnace(this.inventory, p_146101_1_));
+
+ if (container == null)
+ {
+ p_146101_1_.closeInventory(); // Cauldron - prevent chests from being stuck in open state on clients
+ return;
+ }
+
+ // CraftBukkit end
this.getNextWindowId();
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 2, p_146101_1_.getInventoryName(), p_146101_1_.getSizeInventory(), p_146101_1_.hasCustomInventoryName()));
- this.openContainer = new ContainerFurnace(this.inventory, p_146101_1_);
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addCraftingToCrafters(this);
}
public void func_146102_a(TileEntityDispenser p_146102_1_)
{
+ // CraftBukkit start - Inventory open hook
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerDispenser(this.inventory, p_146102_1_));
+
+ if (container == null)
+ {
+ p_146102_1_.closeInventory(); // Cauldron - prevent chests from being stuck in open state on clients
+ return;
+ }
+
+ // CraftBukkit end
this.getNextWindowId();
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, p_146102_1_ instanceof TileEntityDropper ? 10 : 3, p_146102_1_.getInventoryName(), p_146102_1_.getSizeInventory(), p_146102_1_.hasCustomInventoryName()));
- this.openContainer = new ContainerDispenser(this.inventory, p_146102_1_);
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addCraftingToCrafters(this);
}
public void func_146098_a(TileEntityBrewingStand p_146098_1_)
{
+ // CraftBukkit start - Inventory open hook
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerBrewingStand(this.inventory, p_146098_1_));
+
+ if (container == null)
+ {
+ p_146098_1_.closeInventory(); // Cauldron - prevent chests from being stuck in open state on clients
+ return;
+ }
+
+ // CraftBukkit end
this.getNextWindowId();
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 5, p_146098_1_.getInventoryName(), p_146098_1_.getSizeInventory(), p_146098_1_.hasCustomInventoryName()));
- this.openContainer = new ContainerBrewingStand(this.inventory, p_146098_1_);
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addCraftingToCrafters(this);
}
public void func_146104_a(TileEntityBeacon p_146104_1_)
{
+ // CraftBukkit start - Inventory open hook
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerBeacon(this.inventory, p_146104_1_));
+
+ if (container == null)
+ {
+ p_146104_1_.closeInventory(); // Cauldron - prevent chests from being stuck in open state on clients
+ return;
+ }
+
+ // CraftBukkit end
this.getNextWindowId();
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 7, p_146104_1_.getInventoryName(), p_146104_1_.getSizeInventory(), p_146104_1_.hasCustomInventoryName()));
- this.openContainer = new ContainerBeacon(this.inventory, p_146104_1_);
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addCraftingToCrafters(this);
}
public void displayGUIMerchant(IMerchant p_71030_1_, String p_71030_2_)
{
+ // CraftBukkit start - Inventory open hook
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerMerchant(this.inventory, p_71030_1_, this.worldObj));
+
+ if (container == null)
+ {
+ return;
+ }
+
+ // CraftBukkit end
this.getNextWindowId();
- this.openContainer = new ContainerMerchant(this.inventory, p_71030_1_, this.worldObj);
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addCraftingToCrafters(this);
InventoryMerchant inventorymerchant = ((ContainerMerchant)this.openContainer).getMerchantInventory();
@@ -725,7 +1019,7 @@
merchantrecipelist.func_151391_a(packetbuffer);
this.playerNetServerHandler.sendPacket(new S3FPacketCustomPayload("MC|TrList", packetbuffer));
}
- catch (IOException ioexception)
+ catch (Exception ioexception) // CraftBukkit - IOException -> Exception
{
logger.error("Couldn\'t send trade list", ioexception);
}
@@ -738,6 +1032,17 @@
public void displayGUIHorse(EntityHorse p_110298_1_, IInventory p_110298_2_)
{
+ // CraftBukkit start - Inventory open hook
+ Container container = CraftEventFactory.callInventoryOpenEvent(this, new ContainerHorseInventory(this.inventory, p_110298_2_, p_110298_1_));
+
+ if (container == null)
+ {
+ p_110298_2_.closeInventory(); // Cauldron - prevent chests from being stuck in open state on clients
+ return;
+ }
+
+ // CraftBukkit end
+
if (this.openContainer != this.inventoryContainer)
{
this.closeScreen();
@@ -745,7 +1050,7 @@
this.getNextWindowId();
this.playerNetServerHandler.sendPacket(new S2DPacketOpenWindow(this.currentWindowId, 11, p_110298_2_.getInventoryName(), p_110298_2_.getSizeInventory(), p_110298_2_.hasCustomInventoryName(), p_110298_1_.getEntityId()));
- this.openContainer = new ContainerHorseInventory(this.inventory, p_110298_2_, p_110298_1_);
+ this.openContainer = container; // CraftBukkit - Use container we passed to event
this.openContainer.windowId = this.currentWindowId;
this.openContainer.addCraftingToCrafters(this);
}
@@ -770,6 +1075,15 @@
{
this.playerNetServerHandler.sendPacket(new S30PacketWindowItems(p_71110_1_.windowId, p_71110_2_));
this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(-1, -1, this.inventory.getItemStack()));
+
+ if (p_71110_1_.getBukkitView() == null) return; // Cauldron - allow vanilla mods to bypass
+ // CraftBukkit start - Send a Set Slot to update the crafting result slot
+ if (java.util.EnumSet.of(InventoryType.CRAFTING, InventoryType.WORKBENCH).contains(p_71110_1_.getBukkitView().getType()))
+ {
+ this.playerNetServerHandler.sendPacket(new S2FPacketSetSlot(p_71110_1_.windowId, 0, p_71110_1_.getSlot(0).getStack()));
+ }
+
+ // CraftBukkit end
}
public void sendProgressBarUpdate(Container p_71112_1_, int p_71112_2_, int p_71112_3_)
@@ -779,6 +1093,7 @@
public void closeScreen()
{
+ CraftEventFactory.handleInventoryCloseEvent(this); // CraftBukkit
this.playerNetServerHandler.sendPacket(new S2EPacketCloseWindow(this.openContainer.windowId));
this.closeContainer();
}
@@ -853,8 +1168,19 @@
public void setPlayerHealthUpdated()
{
this.lastHealth = -1.0E8F;
+ this.lastExperience = -1; // CraftBukkit - Added to reset
}
+ // CraftBukkit start - Support multi-line messages
+ public void sendMessage(IChatComponent[] ichatcomponent)
+ {
+ for (IChatComponent component : ichatcomponent)
+ {
+ this.addChatComponentMessage(component);
+ }
+ }
+ // CraftBukkit end
+
public void addChatComponentMessage(IChatComponent p_146105_1_)
{
this.playerNetServerHandler.sendPacket(new S02PacketChat(p_146105_1_));
@@ -1037,6 +1363,114 @@
return this.field_143005_bX;
}
+ // CraftBukkit start
+ public long timeOffset = 0;
+ public boolean relativeTime = true;
+
+ public long getPlayerTime()
+ {
+ if (this.relativeTime)
+ {
+ // Adds timeOffset to the current server time.
+ return this.worldObj.getWorldTime() + this.timeOffset;
+ }
+ else
+ {
+ // Adds timeOffset to the beginning of this day.
+ return this.worldObj.getWorldTime() - (this.worldObj.getWorldTime() % 24000) + this.timeOffset;
+ }
+ }
+
+ public WeatherType weather = null;
+
+ public WeatherType getPlayerWeather()
+ {
+ return this.weather;
+ }
+
+ public void setPlayerWeather(WeatherType type, boolean plugin)
+ {
+ if (!plugin && this.weather != null)
+ {
+ return;
+ }
+
+ if (plugin)
+ {
+ this.weather = type;
+ }
+
+ if (type == WeatherType.DOWNFALL)
+ {
+ this.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(2, 0));
+ // this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(7, this.world.j(1.0F)));
+ // this.playerConnection.sendPacket(new PacketPlayOutGameStateChange(8, this.world.h(1.0F)));
+ }
+ else
+ {
+ this.playerNetServerHandler.sendPacket(new S2BPacketChangeGameState(1, 0));
+ }
+ }
+
+ public void resetPlayerWeather()
+ {
+ this.weather = null;
+ this.setPlayerWeather(this.worldObj.getWorldInfo().isRaining() ? WeatherType.DOWNFALL : WeatherType.CLEAR, false);
+ }
+
+ @Override
+ public String toString()
+ {
+ return super.toString() + "(" + this.getCommandSenderName() + " at " + this.posX + "," + this.posY + "," + this.posZ + ")";
+ }
+
+ public void reset()
+ {
+ float exp = 0;
+ boolean keepInventory = this.worldObj.getGameRules().getGameRuleBooleanValue("keepInventory");
+
+ if (this.keepLevel || keepInventory)
+ {
+ exp = this.experience;
+ this.newTotalExp = this.experienceTotal;
+ this.newLevel = this.experienceLevel;
+ }
+
+ this.setHealth(this.getMaxHealth());
+ this.fire = 0;
+ this.fallDistance = 0;
+ this.foodStats = new FoodStats(this);
+ this.experienceLevel = this.newLevel;
+ this.experienceTotal = this.newTotalExp;
+ this.experience = 0;
+ this.deathTime = 0;
+ this.clearActivePotions(); // Should be remapped: removeAllEffects should be remapped to this.
+ super.potionsNeedUpdate = true; // Cauldron - change to super to temporarily workaround remapping bug with SpecialSource
+ this.openContainer = this.inventoryContainer;
+ this.attackingPlayer = null;
+ this.entityLivingToAttack = null;
+ this._combatTracker = new CombatTracker(this);
+ this.lastExperience = -1;
+
+ if (this.keepLevel || keepInventory)
+ {
+ this.experience = exp;
+ }
+ else
+ {
+ this.addExperience(this.newExp);
+ }
+
+ this.keepLevel = false;
+ }
+
+ @Override
+ public CraftPlayer getBukkitEntity()
+ {
+ return (CraftPlayer) super.getBukkitEntity();
+ }
+ // CraftBukkit end
+
/* ===================================== FORGE START =====================================*/
/**
* Returns the default eye height of the player

View File

@ -0,0 +1,140 @@
--- ../src-base/minecraft/net/minecraft/entity/player/InventoryPlayer.java
+++ ../src-work/minecraft/net/minecraft/entity/player/InventoryPlayer.java
@@ -2,7 +2,9 @@
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
+
import java.util.concurrent.Callable;
+
import net.minecraft.block.Block;
import net.minecraft.crash.CrashReport;
import net.minecraft.crash.CrashReportCategory;
@@ -13,7 +15,13 @@
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.util.ReportedException;
+// CraftBukkit start
+import java.util.List;
+import org.bukkit.craftbukkit.entity.CraftHumanEntity;
+import org.bukkit.entity.HumanEntity;
+// CraftBukkit end
+
public class InventoryPlayer implements IInventory
{
public ItemStack[] mainInventory = new ItemStack[36];
@@ -25,7 +33,46 @@
private ItemStack itemStack;
public boolean inventoryChanged;
private static final String __OBFID = "CL_00001709";
+ // CraftBukkit start
+ public List<HumanEntity> transaction = new java.util.ArrayList<HumanEntity>();
+ private int maxStack = MAX_STACK;
+ public ItemStack[] getContents()
+ {
+ return this.mainInventory;
+ }
+
+ public ItemStack[] getArmorContents()
+ {
+ return this.armorInventory;
+ }
+
+ public void onOpen(CraftHumanEntity who)
+ {
+ transaction.add(who);
+ }
+
+ public void onClose(CraftHumanEntity who)
+ {
+ transaction.remove(who);
+ }
+
+ public List<HumanEntity> getViewers()
+ {
+ return transaction;
+ }
+
+ public org.bukkit.inventory.InventoryHolder getOwner()
+ {
+ return this.player.getBukkitEntity();
+ }
+
+ public void setMaxStackSize(int size)
+ {
+ maxStack = size;
+ }
+ // CraftBukkit end
+
public InventoryPlayer(EntityPlayer p_i1750_1_)
{
this.player = p_i1750_1_;
@@ -81,6 +128,34 @@
return -1;
}
+ // CraftBukkit start - Watch method above! :D
+ public int canHold(ItemStack itemstack)
+ {
+ int remains = itemstack.stackSize;
+
+ for (int i = 0; i < this.mainInventory.length; ++i)
+ {
+ if (this.mainInventory[i] == null)
+ {
+ return itemstack.stackSize;
+ }
+
+ // Taken from firstPartial(ItemStack)
+ if (this.mainInventory[i] != null && this.mainInventory[i].getItem() == itemstack.getItem() && this.mainInventory[i].isStackable() && this.mainInventory[i].stackSize < this.mainInventory[i].getMaxStackSize() && this.mainInventory[i].stackSize < this.getInventoryStackLimit() && (!this.mainInventory[i].getHasSubtypes() || this.mainInventory[i].getItemDamage() == itemstack.getItemDamage()) && ItemStack.areItemStackTagsEqual(this.mainInventory[i], itemstack))
+ {
+ remains -= (this.mainInventory[i].getMaxStackSize() < this.getInventoryStackLimit() ? this.mainInventory[i].getMaxStackSize() : this.getInventoryStackLimit()) - this.mainInventory[i].stackSize;
+ }
+
+ if (remains <= 0)
+ {
+ return itemstack.stackSize;
+ }
+ }
+
+ return itemstack.stackSize - remains;
+ }
+ // CraftBukkit end
+
public int getFirstEmptyStack()
{
for (int i = 0; i < this.mainInventory.length; ++i)
@@ -658,7 +733,7 @@
if (this.mainInventory[i] != null)
{
this.player.func_146097_a(this.mainInventory[i], true, false);
- this.mainInventory[i] = null;
+ //this.mainInventory[i] = null; // Cauldron - we clear this in EntityPlayerMP.onDeath after PlayerDeathEvent
}
}
@@ -667,7 +742,7 @@
if (this.armorInventory[i] != null)
{
this.player.func_146097_a(this.armorInventory[i], true, false);
- this.armorInventory[i] = null;
+ //this.armorInventory[i] = null; // Cauldron - we clear this in EntityPlayerMP.onDeath after PlayerDeathEvent
}
}
}
@@ -684,6 +759,13 @@
public ItemStack getItemStack()
{
+ // CraftBukkit start
+ if (this.itemStack != null && this.itemStack.stackSize == 0)
+ {
+ this.setItemStack(null);
+ }
+
+ // CraftBukkit end
return this.itemStack;
}

View File

@ -0,0 +1,13 @@
--- ../src-base/minecraft/net/minecraft/entity/player/PlayerCapabilities.java
+++ ../src-work/minecraft/net/minecraft/entity/player/PlayerCapabilities.java
@@ -11,8 +11,8 @@
public boolean allowFlying;
public boolean isCreativeMode;
public boolean allowEdit = true;
- private float flySpeed = 0.05F;
- private float walkSpeed = 0.1F;
+ public float flySpeed = 0.05F; // CraftBukkit private -> public
+ public float walkSpeed = 0.1F; // CraftBukkit private -> public
private static final String __OBFID = "CL_00001708";
public void writeCapabilitiesToNBT(NBTTagCompound p_75091_1_)

View File

@ -0,0 +1,141 @@
--- ../src-base/minecraft/net/minecraft/entity/projectile/EntityArrow.java
+++ ../src-work/minecraft/net/minecraft/entity/projectile/EntityArrow.java
@@ -23,6 +23,13 @@
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
+// CraftBukkit start
+import net.minecraft.entity.item.EntityItem;
+import org.bukkit.entity.LivingEntity;
+import org.bukkit.event.entity.EntityCombustByEntityEvent;
+import org.bukkit.event.player.PlayerPickupItemEvent;
+// CraftBukkit end
+
public class EntityArrow extends Entity implements IProjectile
{
private int field_145791_d = -1;
@@ -30,14 +37,14 @@
private int field_145789_f = -1;
private Block field_145790_g;
private int inData;
- private boolean inGround;
+ public boolean inGround = false; // Spigot - private -> public
public int canBePickedUp;
public int arrowShake;
public Entity shootingEntity;
private int ticksInGround;
private int ticksInAir;
private double damage = 2.0D;
- private int knockbackStrength;
+ public int knockbackStrength; // CraftBukkit - private -> public
private static final String __OBFID = "CL_00001715";
public EntityArrow(World p_i1753_1_)
@@ -61,6 +68,7 @@
super(p_i1755_1_);
this.renderDistanceWeight = 10.0D;
this.shootingEntity = p_i1755_2_;
+ this.projectileSource = (LivingEntity) p_i1755_2_.getBukkitEntity(); // CraftBukkit
if (p_i1755_2_ instanceof EntityPlayer)
{
@@ -91,6 +99,7 @@
super(p_i1756_1_);
this.renderDistanceWeight = 10.0D;
this.shootingEntity = p_i1756_2_;
+ this.projectileSource = (LivingEntity) p_i1756_2_.getBukkitEntity(); // CraftBukkit
if (p_i1756_2_ instanceof EntityPlayer)
{
@@ -199,7 +208,7 @@
{
++this.ticksInGround;
- if (this.ticksInGround == 1200)
+ if (this.ticksInGround == worldObj.getSpigotConfig().arrowDespawnRate) // Spigot // Cauldron
{
this.setDead();
}
@@ -246,7 +255,7 @@
if (movingobjectposition1 != null)
{
- double d1 = vec31.distanceTo(movingobjectposition1.hitVec);
+ double d1 = vec31.squareDistanceTo(movingobjectposition1.hitVec); // CraftBukkit - distance efficiency
if (d1 < d0 || d0 == 0.0D)
{
@@ -277,6 +286,8 @@
if (movingobjectposition != null)
{
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // CraftBukkit - Call event
+
if (movingobjectposition.entityHit != null)
{
f2 = MathHelper.sqrt_double(this.motionX * this.motionX + this.motionY * this.motionY + this.motionZ * this.motionZ);
@@ -298,13 +309,23 @@
damagesource = DamageSource.causeArrowDamage(this, this.shootingEntity);
}
- if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman))
+ // CraftBukkit start - Moved damage call
+ if (movingobjectposition.entityHit.attackEntityFrom(damagesource, k))
{
- movingobjectposition.entityHit.setFire(5);
- }
+ if (this.isBurning() && !(movingobjectposition.entityHit instanceof EntityEnderman) && (!(movingobjectposition.entityHit instanceof EntityPlayerMP) || !(this.shootingEntity instanceof EntityPlayerMP) || this.worldObj.pvpMode)) // CraftBukkit - abide by pvp setting if destination is a player
+ {
+ EntityCombustByEntityEvent combustEvent = new EntityCombustByEntityEvent(this.getBukkitEntity(), entity.getBukkitEntity(), 5);
+ org.bukkit.Bukkit.getPluginManager().callEvent(combustEvent);
- if (movingobjectposition.entityHit.attackEntityFrom(damagesource, (float)k))
- {
+ if (!combustEvent.isCancelled())
+ {
+ movingobjectposition.entityHit.setFire(combustEvent.getDuration());
+ }
+
+ // CraftBukkit end
+ }
+
+ // if (movingobjectposition.entityHit.attackEntityFrom(damagesource, (float)k)) { // CraftBukkit - moved up
if (movingobjectposition.entityHit instanceof EntityLivingBase)
{
EntityLivingBase entitylivingbase = (EntityLivingBase)movingobjectposition.entityHit;
@@ -487,6 +508,23 @@
{
if (!this.worldObj.isRemote && this.inGround && this.arrowShake <= 0)
{
+ // CraftBukkit start
+ ItemStack itemstack = new ItemStack(Items.arrow);
+
+ if (this.canBePickedUp == 1 && p_70100_1_.inventory.canHold(itemstack) > 0)
+ {
+ EntityItem item = new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, itemstack);
+ PlayerPickupItemEvent event = new PlayerPickupItemEvent((org.bukkit.entity.Player) p_70100_1_.getBukkitEntity(), new org.bukkit.craftbukkit.entity.CraftItem(this.worldObj.getServer(), this, item), 0);
+ // event.setCancelled(!entityplayer.canPickUpLoot); TODO
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (event.isCancelled())
+ {
+ return;
+ }
+ }
+
+ // CraftBukkit end
boolean flag = this.canBePickedUp == 1 || this.canBePickedUp == 2 && p_70100_1_.capabilities.isCreativeMode;
if (this.canBePickedUp == 1 && !p_70100_1_.inventory.addItemStackToInventory(new ItemStack(Items.arrow, 1)))
@@ -553,4 +591,11 @@
byte b0 = this.dataWatcher.getWatchableObjectByte(16);
return (b0 & 1) != 0;
}
+
+ // CraftBukkit start
+ public boolean isInGround()
+ {
+ return inGround;
+ }
+ // CraftBukkit end
}

View File

@ -0,0 +1,73 @@
--- ../src-base/minecraft/net/minecraft/entity/projectile/EntityEgg.java
+++ ../src-work/minecraft/net/minecraft/entity/projectile/EntityEgg.java
@@ -6,6 +6,15 @@
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
+// CraftBukkit start
+import net.minecraft.entity.player.EntityPlayerMP;
+import org.bukkit.entity.Ageable;
+import org.bukkit.entity.EntityType;
+import org.bukkit.entity.Player;
+import org.bukkit.event.player.PlayerEggThrowEvent;
+import net.minecraft.entity.Entity;
+// CraftBukkit end
+
public class EntityEgg extends EntityThrowable
{
private static final String __OBFID = "CL_00001724";
@@ -32,24 +41,43 @@
p_70184_1_.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.getThrower()), 0.0F);
}
- if (!this.worldObj.isRemote && this.rand.nextInt(8) == 0)
+ // CraftBukkit start
+ boolean hatching = !this.worldObj.isRemote && this.rand.nextInt(8) == 0;
+ int numHatching = (this.rand.nextInt(32) == 0) ? 4 : 1;
+
+ if (!hatching)
{
- byte b0 = 1;
+ numHatching = 0;
+ }
- if (this.rand.nextInt(32) == 0)
- {
- b0 = 4;
- }
+ EntityType hatchingType = EntityType.CHICKEN;
+ Entity shooter = this.getThrower();
- for (int i = 0; i < b0; ++i)
+ if (shooter instanceof EntityPlayerMP)
+ {
+ Player player = (shooter == null) ? null : (Player) shooter.getBukkitEntity();
+ PlayerEggThrowEvent event = new PlayerEggThrowEvent(player, (org.bukkit.entity.Egg) this.getBukkitEntity(), hatching, (byte) numHatching, hatchingType);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+ hatching = event.isHatching();
+ numHatching = event.getNumHatches();
+ hatchingType = event.getHatchingType();
+ }
+
+ if (hatching)
+ {
+ for (int k = 0; k < numHatching; k++)
{
- EntityChicken entitychicken = new EntityChicken(this.worldObj);
- entitychicken.setGrowingAge(-24000);
- entitychicken.setLocationAndAngles(this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F);
- this.worldObj.spawnEntityInWorld(entitychicken);
+ org.bukkit.entity.Entity entity = worldObj.getWorld().spawn(new org.bukkit.Location(worldObj.getWorld(), this.posX, this.posY, this.posZ, this.rotationYaw, 0.0F), hatchingType.getEntityClass(), org.bukkit.event.entity.CreatureSpawnEvent.SpawnReason.EGG);
+
+ if (entity instanceof Ageable)
+ {
+ ((Ageable) entity).setBaby();
+ }
}
}
+ // CraftBukkit end
+
for (int j = 0; j < 8; ++j)
{
this.worldObj.spawnParticle("snowballpoof", this.posX, this.posY, this.posZ, 0.0D, 0.0D, 0.0D);

View File

@ -0,0 +1,122 @@
--- ../src-base/minecraft/net/minecraft/entity/projectile/EntityFireball.java
+++ ../src-work/minecraft/net/minecraft/entity/projectile/EntityFireball.java
@@ -3,6 +3,7 @@
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
+
import net.minecraft.block.Block;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
@@ -15,6 +16,8 @@
import net.minecraft.util.Vec3;
import net.minecraft.world.World;
+import org.bukkit.craftbukkit.event.CraftEventFactory; // CraftBukkit
+
public abstract class EntityFireball extends Entity
{
private int field_145795_e = -1;
@@ -28,6 +31,8 @@
public double accelerationX;
public double accelerationY;
public double accelerationZ;
+ public float bukkitYield = 1; // CraftBukkit
+ public boolean isIncendiary = true; // CraftBukkit
private static final String __OBFID = "CL_00001717";
public EntityFireball(World p_i1759_1_)
@@ -62,11 +67,19 @@
{
super(p_i1761_1_);
this.shootingEntity = p_i1761_2_;
+ this.projectileSource = (org.bukkit.entity.LivingEntity) p_i1761_2_.getBukkitEntity(); // CraftBukkit
this.setSize(1.0F, 1.0F);
this.setLocationAndAngles(p_i1761_2_.posX, p_i1761_2_.posY, p_i1761_2_.posZ, p_i1761_2_.rotationYaw, p_i1761_2_.rotationPitch);
this.setPosition(this.posX, this.posY, this.posZ);
this.yOffset = 0.0F;
this.motionX = this.motionY = this.motionZ = 0.0D;
+ // CraftBukkit start - Added setDirection method
+ this.setDirection(p_i1761_3_, p_i1761_5_, p_i1761_7_);
+ }
+
+ public void setDirection(double p_i1761_3_, double p_i1761_5_, double p_i1761_7_)
+ {
+ // CraftBukkit end
p_i1761_3_ += this.rand.nextGaussian() * 0.4D;
p_i1761_5_ += this.rand.nextGaussian() * 0.4D;
p_i1761_7_ += this.rand.nextGaussian() * 0.4D;
@@ -140,7 +153,7 @@
if (movingobjectposition1 != null)
{
- double d1 = vec3.distanceTo(movingobjectposition1.hitVec);
+ double d1 = vec3.squareDistanceTo(movingobjectposition1.hitVec); // CraftBukkit - distance efficiency
if (d1 < d0 || d0 == 0.0D)
{
@@ -159,6 +172,14 @@
if (movingobjectposition != null)
{
this.onImpact(movingobjectposition);
+
+ // CraftBukkit start
+ if (this.isDead)
+ {
+ CraftEventFactory.callProjectileHitEvent(this);
+ }
+
+ // CraftBukkit end
}
this.posX += this.motionX;
@@ -227,6 +248,8 @@
p_70014_1_.setShort("zTile", (short)this.field_145794_g);
p_70014_1_.setByte("inTile", (byte)Block.getIdFromBlock(this.field_145796_h));
p_70014_1_.setByte("inGround", (byte)(this.inGround ? 1 : 0));
+ // CraftBukkit - Fix direction being mismapped to invalid variables
+ p_70014_1_.setTag("power", this.newDoubleNBTList(new double[] { this.accelerationX, this.accelerationY, this.accelerationZ}));
p_70014_1_.setTag("direction", this.newDoubleNBTList(new double[] {this.motionX, this.motionY, this.motionZ}));
}
@@ -238,8 +261,17 @@
this.field_145796_h = Block.getBlockById(p_70037_1_.getByte("inTile") & 255);
this.inGround = p_70037_1_.getByte("inGround") == 1;
- if (p_70037_1_.hasKey("direction", 9))
+ // CraftBukkit start - direction -> power
+ if (p_70037_1_.hasKey("power", 9))
{
+ NBTTagList nbttaglist = p_70037_1_.getTagList("power", 6);
+ this.accelerationX = nbttaglist.func_150309_d(0);
+ this.accelerationY = nbttaglist.func_150309_d(1);
+ this.accelerationZ = nbttaglist.func_150309_d(2);
+ // CraftBukkit end
+ }
+ else if (p_70037_1_.hasKey("direction", 9))
+ {
NBTTagList nbttaglist = p_70037_1_.getTagList("direction", 6);
this.motionX = nbttaglist.func_150309_d(0);
this.motionY = nbttaglist.func_150309_d(1);
@@ -273,6 +305,13 @@
if (p_70097_1_.getEntity() != null)
{
+ // CraftBukkit start
+ if (CraftEventFactory.handleNonLivingEntityDamageEvent(this, p_70097_1_, p_70097_2_))
+ {
+ return false;
+ }
+
+ // CraftBukkit end
Vec3 vec3 = p_70097_1_.getEntity().getLookVec();
if (vec3 != null)
@@ -288,6 +327,7 @@
if (p_70097_1_.getEntity() instanceof EntityLivingBase)
{
this.shootingEntity = (EntityLivingBase)p_70097_1_.getEntity();
+ this.projectileSource = (org.bukkit.projectiles.ProjectileSource) this.shootingEntity.getBukkitEntity(); // CraftBukkit
}
return true;

View File

@ -0,0 +1,119 @@
--- ../src-base/minecraft/net/minecraft/entity/projectile/EntityFishHook.java
+++ ../src-work/minecraft/net/minecraft/entity/projectile/EntityFishHook.java
@@ -27,6 +27,12 @@
import net.minecraft.world.World;
import net.minecraft.world.WorldServer;
+// CraftBukkit start
+import org.bukkit.entity.Player;
+import org.bukkit.entity.Fish;
+import org.bukkit.event.player.PlayerFishEvent;
+// CraftBukkit end
+
public class EntityFishHook extends Entity
{
public static final List field_146039_d = Arrays.asList(new WeightedRandomFishable[] {(new WeightedRandomFishable(new ItemStack(Items.leather_boots), 10)).func_150709_a(0.9F), new WeightedRandomFishable(new ItemStack(Items.leather), 10), new WeightedRandomFishable(new ItemStack(Items.bone), 10), new WeightedRandomFishable(new ItemStack(Items.potionitem), 10), new WeightedRandomFishable(new ItemStack(Items.string), 5), (new WeightedRandomFishable(new ItemStack(Items.fishing_rod), 2)).func_150709_a(0.9F), new WeightedRandomFishable(new ItemStack(Items.bowl), 10), new WeightedRandomFishable(new ItemStack(Items.stick), 5), new WeightedRandomFishable(new ItemStack(Items.dye, 10, 0), 1), new WeightedRandomFishable(new ItemStack(Blocks.tripwire_hook), 10), new WeightedRandomFishable(new ItemStack(Items.rotten_flesh), 10)});
@@ -258,7 +264,7 @@
if (movingobjectposition1 != null)
{
- d2 = vec31.distanceTo(movingobjectposition1.hitVec);
+ d2 = vec31.squareDistanceTo(movingobjectposition1.hitVec); // CraftBukkit - distance efficiency
if (d2 < d0 || d0 == 0.0D)
{
@@ -276,6 +282,8 @@
if (movingobjectposition != null)
{
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this); // Craftbukkit - Call event
+
if (movingobjectposition.entityHit != null)
{
if (movingobjectposition.entityHit.attackEntityFrom(DamageSource.causeThrownDamage(this, this.field_146042_b), 0.0F))
@@ -509,6 +517,18 @@
if (this.field_146043_c != null)
{
+ // CraftBukkit start
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.field_146042_b.getBukkitEntity(), this.field_146043_c.getBukkitEntity(), (Fish) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_ENTITY);
+ this.worldObj.getServer().getPluginManager().callEvent(playerFishEvent);
+
+ if (playerFishEvent.isCancelled())
+ {
+ this.setDead();
+ this.field_146042_b.fishEntity = null;
+ return 0;
+ }
+
+ // CraftBukkit end
double d0 = this.field_146042_b.posX - this.posX;
double d2 = this.field_146042_b.posY - this.posY;
double d4 = this.field_146042_b.posZ - this.posZ;
@@ -522,6 +542,19 @@
else if (this.field_146045_ax > 0)
{
EntityItem entityitem = new EntityItem(this.worldObj, this.posX, this.posY, this.posZ, this.func_146033_f());
+ // CraftBukkit start
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.field_146042_b.getBukkitEntity(), entityitem.getBukkitEntity(), (Fish) this.getBukkitEntity(), PlayerFishEvent.State.CAUGHT_FISH);
+ playerFishEvent.setExpToDrop(this.rand.nextInt(6) + 1);
+ this.worldObj.getServer().getPluginManager().callEvent(playerFishEvent);
+
+ if (playerFishEvent.isCancelled())
+ {
+ this.setDead();
+ this.field_146042_b.fishEntity = null;
+ return 0;
+ }
+
+ // CraftBukkit end
double d1 = this.field_146042_b.posX - this.posX;
double d3 = this.field_146042_b.posY - this.posY;
double d5 = this.field_146042_b.posZ - this.posZ;
@@ -531,15 +564,36 @@
entityitem.motionY = d3 * d9 + (double)MathHelper.sqrt_double(d7) * 0.08D;
entityitem.motionZ = d5 * d9;
this.worldObj.spawnEntityInWorld(entityitem);
- this.field_146042_b.worldObj.spawnEntityInWorld(new EntityXPOrb(this.field_146042_b.worldObj, this.field_146042_b.posX, this.field_146042_b.posY + 0.5D, this.field_146042_b.posZ + 0.5D, this.rand.nextInt(6) + 1));
+ // CraftBukkit - this.random.nextInt(6) + 1 -> playerFishEvent.getExpToDrop()
+ this.field_146042_b.worldObj.spawnEntityInWorld(new EntityXPOrb(this.field_146042_b.worldObj, this.field_146042_b.posX, this.field_146042_b.posY + 0.5D, this.field_146042_b.posZ + 0.5D, playerFishEvent.getExpToDrop()));
b0 = 1;
}
if (this.field_146051_au)
{
+ // CraftBukkit start
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.field_146042_b.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.IN_GROUND);
+ this.worldObj.getServer().getPluginManager().callEvent(playerFishEvent);
+
+ if (playerFishEvent.isCancelled())
+ {
+ this.setDead();
+ this.field_146042_b.fishEntity = null;
+ return 0;
+ }
+
+ // CraftBukkit end
b0 = 2;
}
+ // CraftBukkit start
+ if (b0 == 0)
+ {
+ PlayerFishEvent playerFishEvent = new PlayerFishEvent((Player) this.field_146042_b.getBukkitEntity(), null, (Fish) this.getBukkitEntity(), PlayerFishEvent.State.FAILED_ATTEMPT);
+ this.worldObj.getServer().getPluginManager().callEvent(playerFishEvent);
+ }
+
+ // CraftBukkit end
this.setDead();
this.field_146042_b.fishEntity = null;
return b0;
@@ -580,7 +634,7 @@
{
float f3 = f - f2;
this.field_146042_b.addStat(StatList.fishCaughtStat, 1);
- return ((WeightedRandomFishable)WeightedRandom.getRandomItem(this.rand, field_146036_f)).func_150708_a(this.rand);
+ return ((WeightedRandomFishable) WeightedRandom.getRandomItem(this.rand, EntityFishHook.field_146036_f)).func_150708_a(this.rand); // CraftBukkit - fix static reference to fish list
}
}
}

View File

@ -0,0 +1,40 @@
--- ../src-base/minecraft/net/minecraft/entity/projectile/EntityLargeFireball.java
+++ ../src-work/minecraft/net/minecraft/entity/projectile/EntityLargeFireball.java
@@ -9,6 +9,8 @@
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
+import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit
+
public class EntityLargeFireball extends EntityFireball
{
public int field_92057_e = 1;
@@ -39,7 +41,17 @@
p_70227_1_.entityHit.attackEntityFrom(DamageSource.causeFireballDamage(this, this.shootingEntity), 6.0F);
}
- this.worldObj.newExplosion((Entity)null, this.posX, this.posY, this.posZ, (float)this.field_92057_e, true, this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing"));
+ // CraftBukkit start
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent((org.bukkit.entity.Explosive) org.bukkit.craftbukkit.entity.CraftEntity.getEntity(this.worldObj.getServer(), this));
+ this.worldObj.getServer().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(), this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing"));
+ }
+
+ // CraftBukkit end
this.setDead();
}
}
@@ -56,7 +68,8 @@
if (p_70037_1_.hasKey("ExplosionPower", 99))
{
- this.field_92057_e = p_70037_1_.getInteger("ExplosionPower");
+ // CraftBukkit - set bukkitYield when setting explosionpower
+ this.bukkitYield = this.field_92057_e = p_70037_1_.getInteger("ExplosionPower");
}
}
}

View File

@ -0,0 +1,89 @@
--- ../src-base/minecraft/net/minecraft/entity/projectile/EntityPotion.java
+++ ../src-work/minecraft/net/minecraft/entity/projectile/EntityPotion.java
@@ -14,9 +14,16 @@
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
+// CraftBukkit start
+import java.util.HashMap;
+import net.minecraft.entity.player.EntityPlayerMP;
+import org.bukkit.craftbukkit.entity.CraftLivingEntity;
+import org.bukkit.entity.LivingEntity;
+// CraftBukkit end
+
public class EntityPotion extends EntityThrowable
{
- private ItemStack potionDamage;
+ public ItemStack potionDamage; // CraftBukkit private --> public
private static final String __OBFID = "CL_00001727";
public EntityPotion(World p_i1788_1_)
@@ -88,14 +95,16 @@
{
List list = Items.potionitem.getEffects(this.potionDamage);
- if (list != null && !list.isEmpty())
+ if (true || list != null && !list.isEmpty()) // CraftBukkit - Call event even if no effects to apply
{
AxisAlignedBB axisalignedbb = this.boundingBox.expand(4.0D, 2.0D, 4.0D);
List list1 = this.worldObj.getEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb);
- if (list1 != null && !list1.isEmpty())
+ if (list1 != null) // CraftBukkit - Run code even if there are no entities around
{
Iterator iterator = list1.iterator();
+ // CraftBukkit
+ HashMap<LivingEntity, Double> affected = new HashMap<LivingEntity, Double>();
while (iterator.hasNext())
{
@@ -111,6 +120,25 @@
d1 = 1.0D;
}
+ // CraftBukkit start
+ affected.put((LivingEntity) entitylivingbase.getBukkitEntity(), d1);
+ }
+ }
+
+ org.bukkit.event.entity.PotionSplashEvent event = org.bukkit.craftbukkit.event.CraftEventFactory.callPotionSplashEvent(this, affected);
+
+ if (!event.isCancelled() && list != null && !list.isEmpty()) // do not process effects if there are no effects to process
+ {
+ for (LivingEntity victim : event.getAffectedEntities())
+ {
+ if (!(victim instanceof CraftLivingEntity))
+ {
+ continue;
+ }
+
+ EntityLivingBase entitylivingbase = ((CraftLivingEntity) victim).getHandle();
+ double d1 = event.getIntensity(victim);
+ // CraftBukkit end
Iterator iterator1 = list.iterator();
while (iterator1.hasNext())
@@ -118,9 +146,22 @@
PotionEffect potioneffect = (PotionEffect)iterator1.next();
int i = potioneffect.getPotionID();
+ // CraftBukkit start - Abide by PVP settings - for players only!
+ if (!this.worldObj.pvpMode && this.getThrower() instanceof EntityPlayerMP && entitylivingbase instanceof EntityPlayerMP && entitylivingbase != this.getThrower())
+ {
+ // Block SLOWER_MOVEMENT, SLOWER_DIG, HARM, BLINDNESS, HUNGER, WEAKNESS and POISON potions
+ if (i == 2 || i == 4 || i == 7 || i == 15 || i == 17 || i == 18 || i == 19)
+ {
+ continue;
+ }
+ }
+
+ // CraftBukkit end
+
if (Potion.potionTypes[i].isInstant())
{
- Potion.potionTypes[i].affectEntity(this.getThrower(), entitylivingbase, potioneffect.getAmplifier(), d1);
+ // CraftBukkit - Added 'this'
+ Potion.potionTypes[i].applyInstantEffect(this.getThrower(), entitylivingbase, potioneffect.getAmplifier(), d1, this);
}
else
{

View File

@ -0,0 +1,44 @@
--- ../src-base/minecraft/net/minecraft/entity/projectile/EntitySmallFireball.java
+++ ../src-work/minecraft/net/minecraft/entity/projectile/EntitySmallFireball.java
@@ -6,6 +6,8 @@
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
+import org.bukkit.event.entity.EntityCombustByEntityEvent; // CraftBukkit
+
public class EntitySmallFireball extends EntityFireball
{
private static final String __OBFID = "CL_00001721";
@@ -36,7 +38,16 @@
{
if (!p_70227_1_.entityHit.isImmuneToFire() && p_70227_1_.entityHit.attackEntityFrom(DamageSource.causeFireballDamage(this, this.shootingEntity), 5.0F))
{
- p_70227_1_.entityHit.setFire(5);
+ // CraftBukkit start - Entity damage by entity event + combust event
+ EntityCombustByEntityEvent event = new EntityCombustByEntityEvent((org.bukkit.entity.Projectile) this.getBukkitEntity(), p_70227_1_.entityHit.getBukkitEntity(), 5);
+ p_70227_1_.entityHit.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ p_70227_1_.entityHit.setFire(event.getDuration());
+ }
+
+ // CraftBukkit end
}
}
else
@@ -68,7 +79,13 @@
if (this.worldObj.isAirBlock(i, j, k))
{
- this.worldObj.setBlock(i, j, k, Blocks.fire);
+ // CraftBukkit start
+ if (!org.bukkit.craftbukkit.event.CraftEventFactory.callBlockIgniteEvent(worldObj, i, j, k, this).isCancelled())
+ {
+ this.worldObj.setBlock(i, j, k, Blocks.fire);
+ }
+
+ // CraftBukkit end
}
}

View File

@ -0,0 +1,45 @@
--- ../src-base/minecraft/net/minecraft/entity/projectile/EntityThrowable.java
+++ ../src-work/minecraft/net/minecraft/entity/projectile/EntityThrowable.java
@@ -24,8 +24,8 @@
private Block field_145785_f;
protected boolean inGround;
public int throwableShake;
- private EntityLivingBase thrower;
- private String throwerName;
+ public EntityLivingBase thrower; // CraftBukkit - private -> public
+ public String throwerName; // CraftBukkit - private -> public
private int ticksInGround;
private int ticksInAir;
private static final String __OBFID = "CL_00001723";
@@ -50,6 +50,7 @@
{
super(p_i1777_1_);
this.thrower = p_i1777_2_;
+ this.projectileSource = (org.bukkit.entity.LivingEntity) p_i1777_2_.getBukkitEntity(); // CraftBukkit
this.setSize(0.25F, 0.25F);
this.setLocationAndAngles(p_i1777_2_.posX, p_i1777_2_.posY + (double)p_i1777_2_.getEyeHeight(), p_i1777_2_.posZ, p_i1777_2_.rotationYaw, p_i1777_2_.rotationPitch);
this.posX -= (double)(MathHelper.cos(this.rotationYaw / 180.0F * (float)Math.PI) * 0.16F);
@@ -187,7 +188,7 @@
if (movingobjectposition1 != null)
{
- double d1 = vec3.distanceTo(movingobjectposition1.hitVec);
+ double d1 = vec3.squareDistanceTo(movingobjectposition1.hitVec); // CraftBukkit - distance efficiency
if (d1 < d0 || d0 == 0.0D)
{
@@ -213,6 +214,14 @@
else
{
this.onImpact(movingobjectposition);
+
+ // CraftBukkit start
+ if (this.isDead)
+ {
+ org.bukkit.craftbukkit.event.CraftEventFactory.callProjectileHitEvent(this);
+ }
+
+ // CraftBukkit end
}
}

View File

@ -0,0 +1,38 @@
--- ../src-base/minecraft/net/minecraft/entity/projectile/EntityWitherSkull.java
+++ ../src-work/minecraft/net/minecraft/entity/projectile/EntityWitherSkull.java
@@ -13,6 +13,8 @@
import net.minecraft.world.Explosion;
import net.minecraft.world.World;
+import org.bukkit.event.entity.ExplosionPrimeEvent; // CraftBukkit
+
public class EntityWitherSkull extends EntityFireball
{
private static final String __OBFID = "CL_00001728";
@@ -68,7 +70,7 @@
{
if (p_70227_1_.entityHit.attackEntityFrom(DamageSource.causeMobDamage(this.shootingEntity), 8.0F) && !p_70227_1_.entityHit.isEntityAlive())
{
- this.shootingEntity.heal(5.0F);
+ this.shootingEntity.heal(5.0F, org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason.WITHER); // CraftBukkit
}
}
else
@@ -96,7 +98,16 @@
}
}
- this.worldObj.newExplosion(this, this.posX, this.posY, this.posZ, 1.0F, false, this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing"));
+ // CraftBukkit start
+ ExplosionPrimeEvent event = new ExplosionPrimeEvent(this.getBukkitEntity(), 1.0F, false);
+ this.worldObj.getServer().getPluginManager().callEvent(event);
+
+ if (!event.isCancelled())
+ {
+ this.worldObj.newExplosion(this, this.posX, this.posY, this.posZ, event.getRadius(), event.getFire(), this.worldObj.getGameRules().getGameRuleBooleanValue("mobGriefing"));
+ }
+
+ // CraftBukkit end
this.setDead();
}
}