ForgePatch/patches/minecraft/net/minecraft/entity/EntityLiving.java.patch
2018-12-05 01:16:33 -08:00

73 lines
4.2 KiB
Diff

--- a/net/minecraft/entity/EntityLiving.java
+++ b/net/minecraft/entity/EntityLiving.java
@@ -159,6 +159,7 @@
public void func_70624_b(@Nullable EntityLivingBase p_70624_1_) {
this.field_70696_bz = p_70624_1_;
+ net.minecraftforge.common.ForgeHooks.onLivingSetAttackTarget(this, p_70624_1_);
}
public boolean func_70686_a(Class<? extends EntityLivingBase> p_70686_1_) {
@@ -472,7 +473,7 @@
public void func_70636_d() {
super.func_70636_d();
this.field_70170_p.field_72984_F.func_76320_a("looting");
- if (!this.field_70170_p.field_72995_K && this.func_98052_bS() && !this.field_70729_aU && this.field_70170_p.func_82736_K().func_82766_b("mobGriefing")) {
+ if (!this.field_70170_p.field_72995_K && this.func_98052_bS() && !this.field_70729_aU && net.minecraftforge.event.ForgeEventFactory.getMobGriefingEvent(this.field_70170_p, this)) {
for(EntityItem entityitem : this.field_70170_p.func_72872_a(EntityItem.class, this.func_174813_aQ().func_72314_b(1.0D, 0.0D, 1.0D))) {
if (!entityitem.field_70128_L && !entityitem.func_92059_d().func_190926_b() && !entityitem.func_174874_s()) {
this.func_175445_a(entityitem);
@@ -556,8 +557,14 @@
}
protected void func_70623_bb() {
+ net.minecraftforge.eventbus.api.Event.Result result = null;
if (this.field_82179_bU) {
this.field_70708_bq = 0;
+ } else if ((this.field_70708_bq & 0x1F) == 0x1F && (result = net.minecraftforge.event.ForgeEventFactory.canEntityDespawn(this)) != net.minecraftforge.eventbus.api.Event.Result.DEFAULT) {
+ if (result == net.minecraftforge.eventbus.api.Event.Result.DENY)
+ this.field_70708_bq = 0;
+ else
+ this.func_70106_y();
} else {
Entity entity = this.field_70170_p.func_72890_a(this, -1.0D);
if (entity != null) {
@@ -675,7 +682,6 @@
return !p_205019_1_.func_72953_d(this.func_174813_aQ()) && p_205019_1_.func_195586_b(this, this.func_174813_aQ()) && p_205019_1_.func_195587_c(this, this.func_174813_aQ());
}
- @OnlyIn(Dist.CLIENT)
public float func_70603_bj() {
return 1.0F;
}
@@ -803,6 +809,8 @@
}
public static EntityEquipmentSlot func_184640_d(ItemStack p_184640_0_) {
+ final EntityEquipmentSlot slot = p_184640_0_.getEquipmentSlot();
+ if (slot != null) return slot; // FORGE: Allow modders to set a non-default equipment slot for a stack; e.g. a non-armor chestplate-slot item
Item item = p_184640_0_.func_77973_b();
if (item != Blocks.field_196625_cS.func_199767_j() && (!(item instanceof ItemBlock) || !(((ItemBlock)item).func_179223_d() instanceof BlockAbstractSkull))) {
if (item instanceof ItemArmor) {
@@ -810,7 +818,7 @@
} else if (item == Items.field_185160_cR) {
return EntityEquipmentSlot.CHEST;
} else {
- return item == Items.field_185159_cQ ? EntityEquipmentSlot.OFFHAND : EntityEquipmentSlot.MAINHAND;
+ return p_184640_0_.isShield(null) ? EntityEquipmentSlot.OFFHAND : EntityEquipmentSlot.MAINHAND;
}
} else {
return EntityEquipmentSlot.HEAD;
@@ -1133,10 +1141,10 @@
EntityPlayer entityplayer = (EntityPlayer)p_70652_1_;
ItemStack itemstack = this.func_184614_ca();
ItemStack itemstack1 = entityplayer.func_184587_cr() ? entityplayer.func_184607_cu() : ItemStack.field_190927_a;
- if (!itemstack.func_190926_b() && !itemstack1.func_190926_b() && itemstack.func_77973_b() instanceof ItemAxe && itemstack1.func_77973_b() == Items.field_185159_cQ) {
+ if (!itemstack.func_190926_b() && !itemstack1.func_190926_b() && itemstack.canDisableShield(itemstack1, entityplayer, this) && itemstack1.isShield(entityplayer)) {
float f1 = 0.25F + (float)EnchantmentHelper.func_185293_e(this) * 0.05F;
if (this.field_70146_Z.nextFloat() < f1) {
- entityplayer.func_184811_cZ().func_185145_a(Items.field_185159_cQ, 100);
+ entityplayer.func_184811_cZ().func_185145_a(itemstack1.func_77973_b(), 100);
this.field_70170_p.func_72960_a(entityplayer, (byte)30);
}
}