Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added PotionHooks, closes #3867, #4375 #4614

Merged
merged 5 commits into from Dec 2, 2018
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
78 changes: 52 additions & 26 deletions patches/minecraft/net/minecraft/entity/EntityLivingBase.java.patch
Expand Up @@ -68,7 +68,33 @@
this.func_82142_c(this.func_70644_a(MobEffects.field_76441_p));
}
}
@@ -819,6 +825,8 @@
@@ -736,6 +742,7 @@
{
PotionEffect potioneffect = this.field_70713_bf.get(p_70690_1_.func_188419_a());

+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.PotionEvent.PotionAddedEvent(this, potioneffect, p_70690_1_));
if (potioneffect == null)
{
this.field_70713_bf.put(p_70690_1_.func_188419_a(), p_70690_1_);
@@ -751,6 +758,9 @@

public boolean func_70687_e(PotionEffect p_70687_1_)
{
+ net.minecraftforge.event.entity.living.PotionEvent.PotionApplicableEvent event = new net.minecraftforge.event.entity.living.PotionEvent.PotionApplicableEvent(this, p_70687_1_);
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event);
+ if (event.getResult()!=net.minecraftforge.fml.common.eventhandler.Event.Result.DEFAULT) return event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.ALLOW;
mcenderdragon marked this conversation as resolved.
Show resolved Hide resolved
if (this.func_70668_bt() == EnumCreatureAttribute.UNDEAD)
{
Potion potion = p_70687_1_.func_188419_a();
@@ -777,6 +787,7 @@

public void func_184589_d(Potion p_184589_1_)
{
+ if(net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.PotionEvent.PotionRemoveEvent(this, p_184589_1_))) return;
PotionEffect potioneffect = this.func_184596_c(p_184589_1_);

if (potioneffect != null)
@@ -819,6 +830,8 @@

public void func_70691_i(float p_70691_1_)
{
Expand All @@ -77,15 +103,15 @@
float f = this.func_110143_aJ();

if (f > 0.0F)
@@ -839,6 +847,7 @@
@@ -839,6 +852,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;
@@ -927,9 +936,9 @@
@@ -927,9 +941,9 @@
this.field_70718_bc = 100;
this.field_70717_bb = (EntityPlayer)entity1;
}
Expand All @@ -97,7 +123,7 @@

if (entitywolf.func_70909_n())
{
@@ -1127,7 +1136,7 @@
@@ -1127,7 +1141,7 @@

public void func_70669_a(ItemStack p_70669_1_)
{
Expand All @@ -106,7 +132,7 @@

for (int i = 0; i < 5; ++i)
{
@@ -1139,12 +1148,17 @@
@@ -1139,12 +1153,17 @@
vec3d1 = vec3d1.func_178789_a(-this.field_70125_A * 0.017453292F);
vec3d1 = vec3d1.func_178785_b(-this.field_70177_z * 0.017453292F);
vec3d1 = vec3d1.func_72441_c(this.field_70165_t, this.field_70163_u + (double)this.func_70047_e(), this.field_70161_v);
Expand All @@ -125,7 +151,7 @@
if (!this.field_70729_aU)
{
Entity entity = p_70645_1_.func_76346_g();
@@ -1165,18 +1179,26 @@
@@ -1165,18 +1184,26 @@

if (!this.field_70170_p.field_72995_K)
{
Expand Down Expand Up @@ -157,7 +183,7 @@
}

this.field_70170_p.func_72960_a(this, (byte)3);
@@ -1195,6 +1217,9 @@
@@ -1195,6 +1222,9 @@

public void func_70653_a(Entity p_70653_1_, float p_70653_2_, double p_70653_3_, double p_70653_5_)
{
Expand All @@ -167,7 +193,7 @@
if (this.field_70146_Z.nextDouble() >= this.func_110148_a(SharedMonsterAttributes.field_111266_c).func_111126_e())
{
this.field_70160_al = true;
@@ -1253,15 +1278,7 @@
@@ -1253,15 +1283,7 @@
BlockPos blockpos = new BlockPos(i, j, k);
IBlockState iblockstate = this.field_70170_p.func_180495_p(blockpos);
Block block = iblockstate.func_177230_c();
Expand All @@ -184,7 +210,7 @@
}
}

@@ -1287,6 +1304,9 @@
@@ -1287,6 +1309,9 @@

public void func_180430_e(float p_180430_1_, float p_180430_2_)
{
Expand All @@ -194,7 +220,7 @@
super.func_180430_e(p_180430_1_, p_180430_2_);
PotionEffect potioneffect = this.func_70660_b(MobEffects.field_76430_j);
float f = potioneffect == null ? 0.0F : (float)(potioneffect.func_76458_c() + 1);
@@ -1303,7 +1323,7 @@
@@ -1303,7 +1328,7 @@

if (iblockstate.func_185904_a() != Material.field_151579_a)
{
Expand All @@ -203,7 +229,7 @@
this.func_184185_a(soundtype.func_185842_g(), soundtype.func_185843_a() * 0.5F, soundtype.func_185847_b() * 0.75F);
}
}
@@ -1380,17 +1400,20 @@
@@ -1380,17 +1405,20 @@
{
if (!this.func_180431_b(p_70665_1_))
{
Expand All @@ -225,7 +251,7 @@
this.func_110149_m(this.func_110139_bj() - p_70665_2_);
}
}
@@ -1447,6 +1470,11 @@
@@ -1447,6 +1475,11 @@

public void func_184609_a(EnumHand p_184609_1_)
{
Expand All @@ -237,7 +263,7 @@
if (!this.field_82175_bq || this.field_110158_av >= this.func_82166_i() / 2 || this.field_110158_av < 0)
{
this.field_110158_av = -1;
@@ -1694,7 +1722,7 @@
@@ -1694,7 +1727,7 @@

if (!this.field_70170_p.func_184143_b(axisalignedbb1))
{
Expand All @@ -246,7 +272,7 @@
{
this.func_70634_a(d11, this.field_70163_u + 1.0D, d12);
return;
@@ -1702,14 +1730,14 @@
@@ -1702,14 +1735,14 @@

BlockPos blockpos = new BlockPos(d11, this.field_70163_u - 1.0D, d12);

Expand All @@ -263,7 +289,7 @@
{
d1 = d11;
d13 = this.field_70163_u + 2.0D;
@@ -1781,16 +1809,17 @@
@@ -1781,16 +1814,17 @@
}

this.field_70160_al = true;
Expand All @@ -283,7 +309,7 @@
}

protected float func_189749_co()
@@ -1874,7 +1903,8 @@
@@ -1874,7 +1908,8 @@

if (this.field_70122_E)
{
Expand All @@ -293,7 +319,7 @@
}

float f7 = 0.16277136F / (f6 * f6 * f6);
@@ -1894,7 +1924,8 @@
@@ -1894,7 +1929,8 @@

if (this.field_70122_E)
{
Expand All @@ -303,15 +329,15 @@
}

if (this.func_70617_f_())
@@ -2054,6 +2085,7 @@
@@ -2054,6 +2090,7 @@

public void func_70071_h_()
{
+ if (net.minecraftforge.common.ForgeHooks.onLivingUpdate(this)) return;
super.func_70071_h_();
this.func_184608_ct();

@@ -2096,7 +2128,9 @@
@@ -2096,7 +2133,9 @@

if (!ItemStack.func_77989_b(itemstack1, itemstack))
{
Expand All @@ -321,7 +347,7 @@

if (!itemstack.func_190926_b())
{
@@ -2575,6 +2609,40 @@
@@ -2575,6 +2614,40 @@
this.field_70752_e = true;
}

Expand Down Expand Up @@ -362,7 +388,7 @@
public abstract EnumHandSide func_184591_cq();

public boolean func_184587_cr()
@@ -2595,12 +2663,19 @@
@@ -2595,12 +2668,19 @@

if (itemstack == this.field_184627_bm)
{
Expand All @@ -383,7 +409,7 @@
{
this.func_71036_o();
}
@@ -2618,8 +2693,10 @@
@@ -2618,8 +2698,10 @@

if (!itemstack.func_190926_b() && !this.func_184587_cr())
{
Expand All @@ -395,7 +421,7 @@

if (!this.field_70170_p.field_72995_K)
{
@@ -2700,7 +2777,10 @@
@@ -2700,7 +2782,10 @@
if (!this.field_184627_bm.func_190926_b() && this.func_184587_cr())
{
this.func_184584_a(this.field_184627_bm, 16);
Expand All @@ -407,7 +433,7 @@
this.func_184602_cy();
}
}
@@ -2724,7 +2804,8 @@
@@ -2724,7 +2809,8 @@
{
if (!this.field_184627_bm.func_190926_b())
{
Expand All @@ -417,7 +443,7 @@
}

this.func_184602_cy();
@@ -2852,6 +2933,31 @@
@@ -2852,6 +2938,31 @@
return true;
}

Expand Down Expand Up @@ -449,7 +475,7 @@
public boolean func_190631_cK()
{
return true;
@@ -2861,4 +2967,30 @@
@@ -2861,4 +2972,30 @@
public void func_191987_a(BlockPos p_191987_1_, boolean p_191987_2_)
{
}
Expand Down
@@ -0,0 +1,17 @@
--- ../src-base/minecraft/net/minecraft/entity/monster/EntitySpider.java
+++ ../src-work/minecraft/net/minecraft/entity/monster/EntitySpider.java
@@ -139,7 +139,13 @@

public boolean func_70687_e(PotionEffect p_70687_1_)
{
- return p_70687_1_.func_188419_a() == MobEffects.field_76436_u ? false : super.func_70687_e(p_70687_1_);
+ if(p_70687_1_.func_188419_a() == MobEffects.field_76436_u)
+ {
+ net.minecraftforge.event.entity.living.PotionEvent.PotionApplicableEvent event = new net.minecraftforge.event.entity.living.PotionEvent.PotionApplicableEvent(this, p_70687_1_);
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event);
+ return event.getResult() == net.minecraftforge.fml.common.eventhandler.Event.Result.ALLOW;
+ }
+ return super.func_70687_e(p_70687_1_);
}

public boolean func_70841_p()