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

Implemented LivingKnockBackEvent event and hook #4503

Merged
merged 10 commits into from
Dec 17, 2017
107 changes: 78 additions & 29 deletions patches/minecraft/net/minecraft/entity/EntityLivingBase.java.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,47 @@
--- ../src-base/minecraft/net/minecraft/entity/EntityLivingBase.java
+++ ../src-work/minecraft/net/minecraft/entity/EntityLivingBase.java
@@ -201,10 +201,11 @@
@@ -1,7 +1,5 @@
package net.minecraft.entity;

-import com.google.common.base.Objects;
-import com.google.common.collect.Maps;
import java.util.Collection;
import java.util.ConcurrentModificationException;
import java.util.Iterator;
@@ -9,7 +7,15 @@
import java.util.Map;
import java.util.Random;
import java.util.UUID;
+
import javax.annotation.Nullable;
+
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have unused imports

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a patch, no touchy imports.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So do I have to remove the unused imports or not?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In Minecraft vanilla files do not ever touch imports, ever ever ever. You have added several, REMOVE THEM.

+
+import com.google.common.base.Objects;
+import com.google.common.collect.Maps;
+
import net.minecraft.advancements.CriteriaTriggers;
import net.minecraft.block.Block;
import net.minecraft.block.BlockLadder;
@@ -28,7 +34,6 @@
import net.minecraft.entity.item.EntityItem;
import net.minecraft.entity.item.EntityXPOrb;
import net.minecraft.entity.passive.AbstractHorse;
-import net.minecraft.entity.passive.EntityWolf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.entity.projectile.EntityArrow;
@@ -74,8 +79,6 @@
import net.minecraft.world.WorldServer;
import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
-import org.apache.logging.log4j.LogManager;
-import org.apache.logging.log4j.Logger;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't change imports in patches.


public abstract class EntityLivingBase extends Entity
{
@@ -201,10 +204,11 @@
{
float f = (float)MathHelper.func_76123_f(this.field_70143_R - 3.0F);

Expand All @@ -13,7 +54,7 @@
((WorldServer)this.field_70170_p).func_175739_a(EnumParticleTypes.BLOCK_DUST, this.field_70165_t, this.field_70163_u, this.field_70161_v, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, Block.func_176210_f(p_184231_4_));
}
}
@@ -281,7 +282,7 @@
@@ -281,7 +285,7 @@
}
}

Expand All @@ -22,7 +63,7 @@
{
this.func_184210_p();
}
@@ -380,7 +381,7 @@
@@ -380,7 +384,7 @@
if (!this.field_70170_p.field_72995_K && (this.func_70684_aJ() || this.field_70718_bc > 0 && this.func_146066_aG() && this.field_70170_p.func_82736_K().func_82766_b("doMobLoot")))
{
int i = this.func_70693_a(this.field_70717_bb);
Expand All @@ -31,15 +72,15 @@
while (i > 0)
{
int j = EntityXPOrb.func_70527_a(i);
@@ -442,6 +443,7 @@
@@ -442,6 +446,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()
@@ -670,8 +672,10 @@
@@ -670,8 +675,10 @@
else
{
Collection<PotionEffect> collection = this.field_70713_bf.values();
Expand All @@ -52,7 +93,7 @@
this.func_82142_c(this.func_70644_a(MobEffects.field_76441_p));
}
}
@@ -819,6 +823,8 @@
@@ -819,6 +826,8 @@

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

if (f > 0.0F)
@@ -839,6 +845,7 @@
@@ -839,6 +848,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 +934,9 @@
@@ -927,9 +937,9 @@
this.field_70718_bc = 100;
this.field_70717_bb = (EntityPlayer)entity1;
}
Expand All @@ -81,7 +122,7 @@

if (entitywolf.func_70909_n())
{
@@ -1127,7 +1134,7 @@
@@ -1127,7 +1137,7 @@

public void func_70669_a(ItemStack p_70669_1_)
{
Expand All @@ -90,7 +131,7 @@

for (int i = 0; i < 5; ++i)
{
@@ -1139,12 +1146,17 @@
@@ -1139,12 +1149,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 @@ -109,7 +150,7 @@
if (!this.field_70729_aU)
{
Entity entity = p_70645_1_.func_76346_g();
@@ -1165,18 +1177,26 @@
@@ -1165,18 +1180,26 @@

if (!this.field_70170_p.field_72995_K)
{
Expand Down Expand Up @@ -141,7 +182,15 @@
}

this.field_70170_p.func_72960_a(this, (byte)3);
@@ -1253,15 +1273,7 @@
@@ -1195,6 +1218,7 @@

public void func_70653_a(Entity p_70653_1_, float p_70653_2_, double p_70653_3_, double p_70653_5_)
{
+ if (!net.minecraftforge.common.ForgeHooks.onLivingKnockBack(this, p_70653_1_, p_70653_2_, p_70653_3_, p_70653_5_)) return;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The formatting here doesn't match, check spaces are being used.

if (this.field_70146_Z.nextDouble() >= this.func_110148_a(SharedMonsterAttributes.field_111266_c).func_111126_e())
{
this.field_70160_al = true;
@@ -1253,15 +1277,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 @@ -158,7 +207,7 @@
}
}

@@ -1287,6 +1299,9 @@
@@ -1287,6 +1303,9 @@

public void func_180430_e(float p_180430_1_, float p_180430_2_)
{
Expand All @@ -168,7 +217,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 +1318,7 @@
@@ -1303,7 +1322,7 @@

if (iblockstate.func_185904_a() != Material.field_151579_a)
{
Expand All @@ -177,7 +226,7 @@
this.func_184185_a(soundtype.func_185842_g(), soundtype.func_185843_a() * 0.5F, soundtype.func_185847_b() * 0.75F);
}
}
@@ -1380,17 +1395,20 @@
@@ -1380,17 +1399,20 @@
{
if (!this.func_180431_b(p_70665_1_))
{
Expand All @@ -199,7 +248,7 @@
this.func_110149_m(this.func_110139_bj() - p_70665_2_);
}
}
@@ -1447,6 +1465,11 @@
@@ -1447,6 +1469,11 @@

public void func_184609_a(EnumHand p_184609_1_)
{
Expand All @@ -211,7 +260,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 +1717,7 @@
@@ -1694,7 +1721,7 @@

if (!this.field_70170_p.func_184143_b(axisalignedbb1))
{
Expand All @@ -220,7 +269,7 @@
{
this.func_70634_a(d11, this.field_70163_u + 1.0D, d12);
return;
@@ -1702,14 +1725,14 @@
@@ -1702,14 +1729,14 @@

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

Expand All @@ -237,15 +286,15 @@
{
d1 = d11;
d13 = this.field_70163_u + 2.0D;
@@ -1781,6 +1804,7 @@
@@ -1781,6 +1808,7 @@
}

this.field_70160_al = true;
+ net.minecraftforge.common.ForgeHooks.onLivingJump(this);
}

protected void func_70629_bd()
@@ -1874,7 +1898,8 @@
@@ -1874,7 +1902,8 @@

if (this.field_70122_E)
{
Expand All @@ -255,7 +304,7 @@
}

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

if (this.field_70122_E)
{
Expand All @@ -265,15 +314,15 @@
}

if (this.func_70617_f_())
@@ -2054,6 +2080,7 @@
@@ -2054,6 +2084,7 @@

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

@@ -2096,7 +2123,9 @@
@@ -2096,7 +2127,9 @@

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

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

Expand Down Expand Up @@ -324,7 +373,7 @@
public abstract EnumHandSide func_184591_cq();

public boolean func_184587_cr()
@@ -2595,12 +2658,19 @@
@@ -2595,12 +2662,19 @@

if (itemstack == this.field_184627_bm)
{
Expand All @@ -345,7 +394,7 @@
{
this.func_71036_o();
}
@@ -2618,8 +2688,10 @@
@@ -2618,8 +2692,10 @@

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

if (!this.field_70170_p.field_72995_K)
{
@@ -2700,7 +2772,9 @@
@@ -2700,7 +2776,9 @@
if (!this.field_184627_bm.func_190926_b() && this.func_184587_cr())
{
this.func_184584_a(this.field_184627_bm, 16);
Expand All @@ -368,7 +417,7 @@
this.func_184602_cy();
}
}
@@ -2724,7 +2798,8 @@
@@ -2724,7 +2802,8 @@
{
if (!this.field_184627_bm.func_190926_b())
{
Expand All @@ -378,7 +427,7 @@
}

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

Expand Down
8 changes: 4 additions & 4 deletions patches/minecraft/net/minecraft/item/Item.java.patch
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
CreativeTabs creativetabs = this.func_77640_w();
return creativetabs != null && (p_194125_1_ == CreativeTabs.field_78027_g || p_194125_1_ == creativetabs);
}
@@ -435,11 +445,704 @@
@@ -435,11 +441,704 @@
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You aren't really changing the contents of this file, so leave it out of the PR.

return false;
}

Expand Down Expand Up @@ -773,7 +773,7 @@
public static void func_150900_l()
{
func_179214_a(Blocks.field_150350_a, new ItemAir(Blocks.field_150350_a));
@@ -999,6 +1702,8 @@
@@ -999,6 +1698,8 @@
private final float field_78010_h;
private final float field_78011_i;
private final int field_78008_j;
Expand All @@ -782,15 +782,15 @@

private ToolMaterial(int p_i1874_3_, int p_i1874_4_, float p_i1874_5_, float p_i1874_6_, int p_i1874_7_)
{
@@ -1034,6 +1739,7 @@
@@ -1034,6 +1735,7 @@
return this.field_78008_j;
}

+ @Deprecated // Use getRepairItemStack below
public Item func_150995_f()
{
if (this == WOOD)
@@ -1057,5 +1763,21 @@
@@ -1057,5 +1759,21 @@
return this == DIAMOND ? Items.field_151045_i : null;
}
}
Expand Down