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