ForgePatch/patches/minecraft/net/minecraft/entity/EntityLivingBase.java.patch

213 lines
8.1 KiB
Diff

--- ../src-base/minecraft/net/minecraft/entity/EntityLivingBase.java
+++ ../src-work/minecraft/net/minecraft/entity/EntityLivingBase.java
@@ -233,7 +233,7 @@
}
}
- if (!this.field_70170_p.field_72995_K && this.func_70115_ae() && this.field_70154_o instanceof EntityLivingBase)
+ if (!this.field_70170_p.field_72995_K && this.func_70115_ae() && this.field_70154_o != null && field_70154_o.shouldDismountInWater(this))
{
this.func_70078_a((Entity)null);
}
@@ -316,7 +316,7 @@
if (!this.field_70170_p.field_72995_K && (this.field_70718_bc > 0 || this.func_70684_aJ()) && this.func_146066_aG() && this.field_70170_p.func_82736_K().func_82766_b("doMobLoot"))
{
i = this.func_70693_a(this.field_70717_bb);
-
+ i = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.field_70717_bb, i);
while (i > 0)
{
int j = EntityXPOrb.func_70527_a(i);
@@ -377,6 +377,7 @@
{
this.field_70755_b = p_70604_1_;
this.field_70756_c = this.field_70173_aa;
+ net.minecraftforge.common.ForgeHooks.onLivingSetAttackTarget(this, p_70604_1_);
}
public EntityLivingBase func_110144_aD()
@@ -672,7 +673,6 @@
return this.func_70668_bt() == EnumCreatureAttribute.UNDEAD;
}
- @SideOnly(Side.CLIENT)
public void func_70618_n(int p_70618_1_)
{
this.field_70713_bf.remove(Integer.valueOf(p_70618_1_));
@@ -721,6 +721,8 @@
public void func_70691_i(float p_70691_1_)
{
+ p_70691_1_ = net.minecraftforge.event.ForgeEventFactory.onLivingHeal(this, p_70691_1_);
+ if (p_70691_1_ <= 0) return;
float f1 = this.func_110143_aJ();
if (f1 > 0.0F)
@@ -741,6 +743,7 @@
public boolean func_70097_a(DamageSource p_70097_1_, float p_70097_2_)
{
+ if (!net.minecraftforge.common.ForgeHooks.onLivingAttack(this, p_70097_1_, p_70097_2_)) return false;
if (this.func_180431_b(p_70097_1_))
{
return false;
@@ -806,9 +809,9 @@
this.field_70718_bc = 100;
this.field_70717_bb = (EntityPlayer)entity;
}
- else if (entity instanceof EntityWolf)
+ else if (entity instanceof net.minecraft.entity.passive.EntityTameable)
{
- EntityWolf entitywolf = (EntityWolf)entity;
+ net.minecraft.entity.passive.EntityTameable entitywolf = (net.minecraft.entity.passive.EntityTameable)entity;
if (entitywolf.func_70909_n())
{
@@ -894,6 +897,7 @@
public void func_70645_a(DamageSource p_70645_1_)
{
+ if (net.minecraftforge.common.ForgeHooks.onLivingDeath(this, p_70645_1_)) return;
Entity entity = p_70645_1_.func_76346_g();
EntityLivingBase entitylivingbase = this.func_94060_bK();
@@ -919,6 +923,9 @@
i = EnchantmentHelper.func_77519_f((EntityLivingBase)entity);
}
+ captureDrops = true;
+ capturedDrops.clear();
+
if (this.func_146066_aG() && this.field_70170_p.func_82736_K().func_82766_b("doMobLoot"))
{
this.func_70628_a(this.field_70718_bc > 0, i);
@@ -929,6 +936,16 @@
this.func_82164_bB();
}
}
+
+ captureDrops = false;
+
+ if (!net.minecraftforge.common.ForgeHooks.onLivingDrops(this, p_70645_1_, capturedDrops, i, field_70718_bc > 0))
+ {
+ for (EntityItem item : capturedDrops)
+ {
+ field_70170_p.func_72838_d(item);
+ }
+ }
}
this.field_70170_p.func_72960_a(this, (byte)3);
@@ -977,7 +994,7 @@
int j = MathHelper.func_76128_c(this.func_174813_aQ().field_72338_b);
int k = MathHelper.func_76128_c(this.field_70161_v);
Block block = this.field_70170_p.func_180495_p(new BlockPos(i, j, k)).func_177230_c();
- return (block == Blocks.field_150468_ap || block == Blocks.field_150395_bd) && (!(this instanceof EntityPlayer) || !((EntityPlayer)this).func_175149_v());
+ return net.minecraftforge.common.ForgeHooks.isLivingOnLadder(block, field_70170_p, new BlockPos(i, j, k), this);
}
public boolean func_70089_S()
@@ -987,6 +1004,9 @@
public void func_180430_e(float p_180430_1_, float p_180430_2_)
{
+ float[] ret = net.minecraftforge.common.ForgeHooks.onLivingFall(this, p_180430_1_, p_180430_2_);
+ if (ret == null) return;
+ p_180430_1_ = ret[0]; p_180430_2_ = ret[1];
super.func_180430_e(p_180430_1_, p_180430_2_);
PotionEffect potioneffect = this.func_70660_b(Potion.field_76430_j);
float f2 = potioneffect != null ? (float)(potioneffect.func_76458_c() + 1) : 0.0F;
@@ -1105,6 +1125,8 @@
{
if (!this.func_180431_b(p_70665_1_))
{
+ p_70665_2_ = net.minecraftforge.common.ForgeHooks.onLivingHurt(this, p_70665_1_, p_70665_2_);
+ if (p_70665_2_ <= 0) return;
p_70665_2_ = this.func_70655_b(p_70665_1_, p_70665_2_);
p_70665_2_ = this.func_70672_c(p_70665_1_, p_70665_2_);
float f1 = p_70665_2_;
@@ -1153,6 +1175,11 @@
public void func_71038_i()
{
+ ItemStack stack = this.func_70694_bm();
+ if (stack != null && stack.func_77973_b() != null)
+ {
+ if (stack.func_77973_b().onEntitySwing(this, stack)) return;
+ }
if (!this.field_82175_bq || this.field_110158_av >= this.func_82166_i() / 2 || this.field_110158_av < 0)
{
this.field_110158_av = -1;
@@ -1294,6 +1321,7 @@
public void func_110145_l(Entity p_110145_1_)
{
+ if(!net.minecraftforge.event.ForgeEventFactory.canMountEntity(this, p_110145_1_, false)){ return; }
double d0 = p_110145_1_.field_70165_t;
double d1 = p_110145_1_.func_174813_aQ().field_72338_b + (double)p_110145_1_.field_70131_O;
double d2 = p_110145_1_.field_70161_v;
@@ -1359,6 +1387,7 @@
}
this.field_70160_al = true;
+ net.minecraftforge.common.ForgeHooks.onLivingJump(this);
}
protected void func_70629_bd()
@@ -1545,6 +1574,7 @@
public void func_70071_h_()
{
+ if (net.minecraftforge.common.ForgeHooks.onLivingUpdate(this)) return;
super.func_70071_h_();
if (!this.field_70170_p.field_72995_K)
@@ -1828,6 +1858,7 @@
public void func_70078_a(Entity p_70078_1_)
{
+ if(!net.minecraftforge.event.ForgeEventFactory.canMountEntity(this, p_70078_1_, true)){ return; }
if (this.field_70154_o != null && p_70078_1_ == null)
{
if (!this.field_70170_p.field_72995_K)
@@ -2000,4 +2031,39 @@
{
this.field_70752_e = true;
}
+
+ /***
+ * 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 = field_70713_bf.keySet().iterator();
+ if (field_70170_p.field_72995_K) return;
+
+ while (potionKey.hasNext())
+ {
+ Integer key = potionKey.next();
+ PotionEffect effect = (PotionEffect)field_70713_bf.get(key);
+
+ if (effect.isCurativeItem(curativeItem))
+ {
+ potionKey.remove();
+ func_70688_c(effect);
+ this.field_70752_e = true;
+ }
+ }
+ }
+
+ /**
+ * 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 net.minecraft.entity.passive.EntityPig;
+ }
}