1
0
forked from xjboss/KCauldronX

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