mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-21 12:42:26 +00:00
206 lines
5.9 KiB
Diff
206 lines
5.9 KiB
Diff
--- ../src_base/minecraft/net/minecraft/entity/EntityLiving.java
|
|
+++ ../src_work/minecraft/net/minecraft/entity/EntityLiving.java
|
|
@@ -20,6 +20,7 @@
|
|
import net.minecraft.entity.item.EntityXPOrb;
|
|
import net.minecraft.entity.monster.EntityCreeper;
|
|
import net.minecraft.entity.monster.EntityGhast;
|
|
+import net.minecraft.entity.passive.EntityPig;
|
|
import net.minecraft.entity.passive.EntityWolf;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.entity.projectile.EntityArrow;
|
|
@@ -45,6 +46,11 @@
|
|
import net.minecraft.world.World;
|
|
import net.minecraft.world.WorldServer;
|
|
|
|
+import net.minecraftforge.common.ForgeHooks;
|
|
+import net.minecraftforge.common.MinecraftForge;
|
|
+import net.minecraftforge.event.entity.living.*;
|
|
+import static net.minecraftforge.event.entity.living.LivingEvent.*;
|
|
+
|
|
public abstract class EntityLiving extends Entity
|
|
{
|
|
/**
|
|
@@ -387,6 +393,7 @@
|
|
public void setAttackTarget(EntityLiving par1EntityLiving)
|
|
{
|
|
this.attackTarget = par1EntityLiving;
|
|
+ ForgeHooks.onLivingSetAttackTarget(this, par1EntityLiving);
|
|
}
|
|
|
|
/**
|
|
@@ -483,6 +490,7 @@
|
|
{
|
|
this.entityLivingToAttack = par1EntityLiving;
|
|
this.revengeTimer = this.entityLivingToAttack != null ? 60 : 0;
|
|
+ ForgeHooks.onLivingSetAttackTarget(this, par1EntityLiving);
|
|
}
|
|
|
|
protected void entityInit()
|
|
@@ -792,6 +800,11 @@
|
|
*/
|
|
public void onUpdate()
|
|
{
|
|
+ if (ForgeHooks.onLivingUpdate(this))
|
|
+ {
|
|
+ return;
|
|
+ }
|
|
+
|
|
super.onUpdate();
|
|
|
|
if (!this.worldObj.isRemote)
|
|
@@ -977,6 +990,11 @@
|
|
*/
|
|
public boolean attackEntityFrom(DamageSource par1DamageSource, int par2)
|
|
{
|
|
+ if (ForgeHooks.onLivingAttack(this, par1DamageSource, par2))
|
|
+ {
|
|
+ return false;
|
|
+ }
|
|
+
|
|
if (this.isEntityInvulnerable())
|
|
{
|
|
return false;
|
|
@@ -1188,6 +1206,11 @@
|
|
{
|
|
if (!this.isEntityInvulnerable())
|
|
{
|
|
+ par2 = ForgeHooks.onLivingHurt(this, par1DamageSource, par2);
|
|
+ if (par2 <= 0)
|
|
+ {
|
|
+ return;
|
|
+ }
|
|
par2 = this.applyArmorCalculations(par1DamageSource, par2);
|
|
par2 = this.applyPotionDamageCalculations(par1DamageSource, par2);
|
|
this.health -= par2;
|
|
@@ -1252,6 +1275,11 @@
|
|
*/
|
|
public void onDeath(DamageSource par1DamageSource)
|
|
{
|
|
+ if (ForgeHooks.onLivingDeath(this, par1DamageSource))
|
|
+ {
|
|
+ return;
|
|
+ }
|
|
+
|
|
Entity var2 = par1DamageSource.getEntity();
|
|
|
|
if (this.scoreValue >= 0 && var2 != null)
|
|
@@ -1274,6 +1302,10 @@
|
|
{
|
|
var3 = EnchantmentHelper.getLootingModifier((EntityLiving)var2);
|
|
}
|
|
+
|
|
+ captureDrops = true;
|
|
+ capturedDrops.clear();
|
|
+ int var4 = 0;
|
|
|
|
if (!this.isChild() && this.worldObj.getGameRules().getGameRuleBooleanValue("doMobLoot"))
|
|
{
|
|
@@ -1282,7 +1314,7 @@
|
|
|
|
if (this.recentlyHit > 0)
|
|
{
|
|
- int var4 = this.rand.nextInt(200) - var3;
|
|
+ var4 = this.rand.nextInt(200) - var3;
|
|
|
|
if (var4 < 5)
|
|
{
|
|
@@ -1290,6 +1322,16 @@
|
|
}
|
|
}
|
|
}
|
|
+
|
|
+ captureDrops = false;
|
|
+
|
|
+ if (!ForgeHooks.onLivingDrops(this, par1DamageSource, capturedDrops, var3, recentlyHit > 0, var4))
|
|
+ {
|
|
+ for (EntityItem item : capturedDrops)
|
|
+ {
|
|
+ worldObj.spawnEntityInWorld(item);
|
|
+ }
|
|
+ }
|
|
}
|
|
|
|
this.worldObj.setEntityState(this, (byte)3);
|
|
@@ -1334,6 +1376,12 @@
|
|
*/
|
|
protected void fall(float par1)
|
|
{
|
|
+ par1 = ForgeHooks.onLivingFall(this, par1);
|
|
+ if (par1 <= 0)
|
|
+ {
|
|
+ return;
|
|
+ }
|
|
+
|
|
super.fall(par1);
|
|
int var2 = MathHelper.ceiling_float_int(par1 - 3.0F);
|
|
|
|
@@ -1536,7 +1584,7 @@
|
|
int var2 = MathHelper.floor_double(this.boundingBox.minY);
|
|
int var3 = MathHelper.floor_double(this.posZ);
|
|
int var4 = this.worldObj.getBlockId(var1, var2, var3);
|
|
- return var4 == Block.ladder.blockID || var4 == Block.vine.blockID;
|
|
+ return ForgeHooks.isLivingOnLadder(Block.blocksList[var4], worldObj, var1, var2, var3);
|
|
}
|
|
|
|
/**
|
|
@@ -1949,6 +1997,7 @@
|
|
}
|
|
|
|
this.isAirBorne = true;
|
|
+ ForgeHooks.onLivingJump(this);
|
|
}
|
|
|
|
/**
|
|
@@ -2486,8 +2535,6 @@
|
|
return this.getCreatureAttribute() == EnumCreatureAttribute.UNDEAD;
|
|
}
|
|
|
|
- @SideOnly(Side.CLIENT)
|
|
-
|
|
/**
|
|
* Remove the speified potion effect from this entity.
|
|
*/
|
|
@@ -2944,4 +2991,42 @@
|
|
{
|
|
this.dataWatcher.updateObject(10, Byte.valueOf((byte)par1));
|
|
}
|
|
+
|
|
+ /***
|
|
+ * Removes all potion effects that have curativeItem as a curative item for its effect
|
|
+ * @param curativeItem The itemstack we are using to cure potion effects
|
|
+ */
|
|
+ public void curePotionEffects(ItemStack curativeItem)
|
|
+ {
|
|
+ Iterator<Integer> potionKey = activePotionsMap.keySet().iterator();
|
|
+
|
|
+ if (worldObj.isRemote)
|
|
+ {
|
|
+ return;
|
|
+ }
|
|
+
|
|
+ while (potionKey.hasNext())
|
|
+ {
|
|
+ Integer key = potionKey.next();
|
|
+ PotionEffect effect = (PotionEffect)activePotionsMap.get(key);
|
|
+
|
|
+ if (effect.isCurativeItem(curativeItem))
|
|
+ {
|
|
+ potionKey.remove();
|
|
+ onFinishedPotionEffect(effect);
|
|
+ }
|
|
+ }
|
|
+ }
|
|
+
|
|
+ /**
|
|
+ * Returns true if the entity's rider (EntityPlayer) should face forward when mounted.
|
|
+ * currently only used in vanilla code by pigs.
|
|
+ *
|
|
+ * @param player The player who is riding the entity.
|
|
+ * @return If the player should orient the same direction as this entity.
|
|
+ */
|
|
+ public boolean shouldRiderFaceForward(EntityPlayer player)
|
|
+ {
|
|
+ return this instanceof EntityPig;
|
|
+ }
|
|
}
|