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

463 lines
25 KiB
Diff
Raw Normal View History

2019-05-23 23:02:15 +00:00
--- a/net/minecraft/entity/LivingEntity.java
+++ b/net/minecraft/entity/LivingEntity.java
@@ -104,6 +104,8 @@
public abstract class LivingEntity extends Entity {
2018-12-05 09:16:33 +00:00
private static final UUID field_110156_b = UUID.fromString("662A6B8D-DA3E-4C1C-8813-96EA6097278D");
2019-05-23 23:02:15 +00:00
private static final AttributeModifier field_110157_c = (new AttributeModifier(field_110156_b, "Sprinting speed boost", (double)0.3F, AttributeModifier.Operation.MULTIPLY_TOTAL)).func_111168_a(false);
2018-12-05 09:16:33 +00:00
+ public static final net.minecraft.entity.ai.attributes.IAttribute SWIM_SPEED = new net.minecraft.entity.ai.attributes.RangedAttribute(null, "forge.swimSpeed", 1.0D, 0.0D, 1024.0D).func_111112_a(true);
2018-12-21 22:45:35 +00:00
+ public static final net.minecraft.entity.ai.attributes.IAttribute NAMETAG_DISTANCE = new net.minecraft.entity.ai.attributes.RangedAttribute(null, "forge.nameTagDistance", 64.0D, 0.0D, Float.MAX_VALUE).func_111112_a(true);
2019-05-23 23:02:15 +00:00
protected static final DataParameter<Byte> field_184621_as = EntityDataManager.func_187226_a(LivingEntity.class, DataSerializers.field_187191_a);
private static final DataParameter<Float> field_184632_c = EntityDataManager.func_187226_a(LivingEntity.class, DataSerializers.field_187193_c);
private static final DataParameter<Integer> field_184633_f = EntityDataManager.func_187226_a(LivingEntity.class, DataSerializers.field_187192_b);
@@ -227,6 +229,8 @@
2018-12-05 09:16:33 +00:00
this.func_110140_aT().func_111150_b(SharedMonsterAttributes.field_111263_d);
this.func_110140_aT().func_111150_b(SharedMonsterAttributes.field_188791_g);
this.func_110140_aT().func_111150_b(SharedMonsterAttributes.field_189429_h);
+ this.func_110140_aT().func_111150_b(SWIM_SPEED);
2018-12-21 22:45:35 +00:00
+ this.func_110140_aT().func_111150_b(NAMETAG_DISTANCE);
2018-12-05 09:16:33 +00:00
}
2019-05-23 23:02:15 +00:00
protected void func_184231_a(double p_184231_1_, boolean p_184231_3_, BlockState p_184231_4_, BlockPos p_184231_5_) {
@@ -236,9 +240,10 @@
2018-12-05 09:16:33 +00:00
if (!this.field_70170_p.field_72995_K && this.field_70143_R > 3.0F && p_184231_3_) {
float f = (float)MathHelper.func_76123_f(this.field_70143_R - 3.0F);
- if (!p_184231_4_.func_196958_f()) {
+ if (!p_184231_4_.isAir(field_70170_p, p_184231_5_)) {
double d0 = Math.min((double)(0.2F + f / 15.0F), 2.5D);
int i = (int)(150.0D * d0);
2019-05-23 23:02:15 +00:00
+ if (!p_184231_4_.addLandingEffects((ServerWorld)this.field_70170_p, p_184231_5_, p_184231_4_, this, i))
((ServerWorld)this.field_70170_p).func_195598_a(new BlockParticleData(ParticleTypes.field_197611_d, p_184231_4_), this.field_70165_t, this.field_70163_u, this.field_70161_v, i, 0.0D, 0.0D, 0.0D, (double)0.15F);
2018-12-05 09:16:33 +00:00
}
}
2019-05-23 23:02:15 +00:00
@@ -302,7 +307,7 @@
2018-12-05 09:16:33 +00:00
}
}
- if (!this.field_70170_p.field_72995_K && this.func_184218_aH() && this.func_184187_bx() != null && !this.func_184187_bx().func_205710_ba()) {
+ if (!this.field_70170_p.field_72995_K && this.func_184218_aH() && this.func_184187_bx() != null && !this.func_184187_bx().canBeRiddenInWater(this)) {
this.func_184210_p();
}
} else if (this.func_70086_ai() < this.func_205010_bg()) {
2019-05-23 23:02:15 +00:00
@@ -387,6 +392,7 @@
2018-12-05 09:16:33 +00:00
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);
+ i = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.field_70717_bb, i);
while(i > 0) {
2019-05-23 23:02:15 +00:00
int j = ExperienceOrbEntity.func_70527_a(i);
2018-12-05 09:16:33 +00:00
i -= j;
2019-05-23 23:02:15 +00:00
@@ -589,7 +595,7 @@
Effect effect = iterator.next();
EffectInstance effectinstance = this.field_70713_bf.get(effect);
if (!effectinstance.func_76455_a(this)) {
- if (!this.field_70170_p.field_72995_K) {
2019-05-23 23:02:15 +00:00
+ if (!this.field_70170_p.field_72995_K && !net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.PotionEvent.PotionExpiryEvent(this, effectinstance))) {
iterator.remove();
2019-05-23 23:02:15 +00:00
this.func_70688_c(effectinstance);
}
2019-05-23 23:02:15 +00:00
@@ -639,8 +645,10 @@
2018-12-05 09:16:33 +00:00
this.func_82142_c(false);
} else {
2019-05-23 23:02:15 +00:00
Collection<EffectInstance> collection = this.field_70713_bf.values();
2018-12-05 09:16:33 +00:00
- this.field_70180_af.func_187227_b(field_184634_g, func_184593_a(collection));
- this.field_70180_af.func_187227_b(field_184633_f, PotionUtils.func_185181_a(collection));
+ net.minecraftforge.event.entity.living.PotionColorCalculationEvent event = new net.minecraftforge.event.entity.living.PotionColorCalculationEvent(this, PotionUtils.func_185181_a(collection), func_184593_a(collection), collection);
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(event);
+ this.field_70180_af.func_187227_b(field_184634_g, event.areParticlesHidden());
+ this.field_70180_af.func_187227_b(field_184633_f, event.getColor());
2019-05-23 23:02:15 +00:00
this.func_82142_c(this.func_70644_a(Effects.field_76441_p));
2018-12-05 09:16:33 +00:00
}
2019-05-23 23:02:15 +00:00
@@ -704,7 +712,10 @@
boolean flag;
for(flag = false; iterator.hasNext(); flag = true) {
- this.func_70688_c(iterator.next());
2019-05-23 23:02:15 +00:00
+ EffectInstance effect = iterator.next();
+ if(net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.PotionEvent.PotionRemoveEvent(this, effect))) continue;
+
+ this.func_70688_c(effect);
iterator.remove();
}
2019-05-23 23:02:15 +00:00
@@ -734,6 +745,7 @@
return false;
} else {
2019-05-23 23:02:15 +00:00
EffectInstance effectinstance = this.field_70713_bf.get(p_195064_1_.func_188419_a());
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.PotionEvent.PotionAddedEvent(this, effectinstance, p_195064_1_));
if (effectinstance == null) {
this.field_70713_bf.put(p_195064_1_.func_188419_a(), p_195064_1_);
this.func_70670_a(p_195064_1_);
2019-05-23 23:02:15 +00:00
@@ -748,6 +760,9 @@
}
2019-05-23 23:02:15 +00:00
public boolean func_70687_e(EffectInstance 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.eventbus.api.Event.Result.DEFAULT) return event.getResult() == net.minecraftforge.eventbus.api.Event.Result.ALLOW;
if (this.func_70668_bt() == CreatureAttribute.UNDEAD) {
2019-05-23 23:02:15 +00:00
Effect effect = p_70687_1_.func_188419_a();
if (effect == Effects.field_76428_l || effect == Effects.field_76436_u) {
@@ -768,6 +783,7 @@
}
2019-05-23 23:02:15 +00:00
public boolean func_195063_d(Effect p_195063_1_) {
+ if(net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.PotionEvent.PotionRemoveEvent(this, p_195063_1_))) return false;
2019-05-23 23:02:15 +00:00
EffectInstance effectinstance = this.func_184596_c(p_195063_1_);
if (effectinstance != null) {
this.func_70688_c(effectinstance);
@@ -804,6 +820,8 @@
2018-12-05 09:16:33 +00:00
}
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 f = this.func_110143_aJ();
if (f > 0.0F) {
this.func_70606_j(f + p_70691_1_);
2019-05-23 23:02:15 +00:00
@@ -820,6 +838,7 @@
2018-12-05 09:16:33 +00:00
}
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;
} else if (this.field_70170_p.field_72995_K) {
2019-05-23 23:02:15 +00:00
@@ -886,8 +905,8 @@
if (entity1 instanceof PlayerEntity) {
this.field_70718_bc = 100;
2019-05-23 23:02:15 +00:00
this.field_70717_bb = (PlayerEntity)entity1;
- } else if (entity1 instanceof WolfEntity) {
- WolfEntity wolfentity = (WolfEntity)entity1;
+ } else if (entity1 instanceof net.minecraft.entity.passive.TameableEntity) {
+ net.minecraft.entity.passive.TameableEntity wolfentity = (net.minecraft.entity.passive.TameableEntity)entity1;
if (wolfentity.func_70909_n()) {
2018-12-05 09:16:33 +00:00
this.field_70718_bc = 100;
2019-05-23 23:02:15 +00:00
LivingEntity livingentity = wolfentity.func_70902_q();
@@ -1069,6 +1088,7 @@
2018-12-05 09:16:33 +00:00
}
public void func_70645_a(DamageSource p_70645_1_) {
+ if (net.minecraftforge.common.ForgeHooks.onLivingDeath(this, p_70645_1_)) return;
if (!this.field_70729_aU) {
Entity entity = p_70645_1_.func_76346_g();
2019-05-23 23:02:15 +00:00
LivingEntity livingentity = this.func_94060_bK();
@@ -1113,13 +1133,10 @@
protected void func_213345_d(DamageSource p_213345_1_) {
Entity entity = p_213345_1_.func_76346_g();
- int i;
- if (entity instanceof PlayerEntity) {
- i = EnchantmentHelper.func_185283_h((LivingEntity)entity);
- } else {
- i = 0;
- }
+ int i = net.minecraftforge.common.ForgeHooks.getLootingLevel(this, entity, p_213345_1_);
+ this.captureDrops(new java.util.ArrayList<>());
+
boolean flag = this.field_70718_bc > 0;
if (this.func_146066_aG() && this.field_70170_p.func_82736_K().func_82766_b("doMobLoot")) {
this.func_213354_a(p_213345_1_, flag);
@@ -1127,6 +1144,10 @@
}
this.func_213337_cE();
+
+ Collection<ItemEntity> drops = captureDrops(null);
+ if (!net.minecraftforge.common.ForgeHooks.onLivingDrops(this, p_213345_1_, drops, i, field_70718_bc > 0))
+ drops.forEach(e -> field_70170_p.func_217376_c(e));
}
2018-12-05 09:16:33 +00:00
2019-05-23 23:02:15 +00:00
protected void func_213337_cE() {
@@ -1156,6 +1177,9 @@
2018-12-05 09:16:33 +00:00
}
public void func_70653_a(Entity p_70653_1_, float p_70653_2_, double p_70653_3_, double p_70653_5_) {
+ net.minecraftforge.event.entity.living.LivingKnockBackEvent event = net.minecraftforge.common.ForgeHooks.onLivingKnockBack(this, p_70653_1_, p_70653_2_, p_70653_3_, p_70653_5_);
+ if(event.isCanceled()) return;
+ p_70653_2_ = event.getStrength(); p_70653_3_ = event.getRatioX(); p_70653_5_ = event.getRatioZ();
if (!(this.field_70146_Z.nextDouble() < this.func_110148_a(SharedMonsterAttributes.field_111266_c).func_111126_e())) {
this.field_70160_al = true;
2019-05-23 23:02:15 +00:00
Vec3d vec3d = this.func_213322_ci();
@@ -1191,12 +1215,7 @@
return false;
2018-12-05 09:16:33 +00:00
} else {
2019-05-23 23:02:15 +00:00
BlockState blockstate = this.func_213339_cH();
- Block block = blockstate.func_177230_c();
- if (block != Blocks.field_150468_ap && block != Blocks.field_150395_bd && block != Blocks.field_222420_lI) {
- return block instanceof TrapDoorBlock && this.func_184604_a(new BlockPos(this), blockstate);
2018-12-05 09:16:33 +00:00
- } else {
- return true;
- }
2019-05-23 23:02:15 +00:00
+ return net.minecraftforge.common.ForgeHooks.isLivingOnLadder(blockstate, field_70170_p, new BlockPos(this), this);
2018-12-05 09:16:33 +00:00
}
}
2019-05-23 23:02:15 +00:00
@@ -1220,6 +1239,9 @@
2018-12-05 09:16:33 +00:00
}
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_);
2019-05-23 23:02:15 +00:00
EffectInstance effectinstance = this.func_70660_b(Effects.field_76430_j);
float f = effectinstance == null ? 0.0F : (float)(effectinstance.func_76458_c() + 1);
@@ -1232,7 +1254,7 @@
2018-12-05 09:16:33 +00:00
int l = MathHelper.func_76128_c(this.field_70161_v);
2019-05-23 23:02:15 +00:00
BlockState blockstate = this.field_70170_p.func_180495_p(new BlockPos(j, k, l));
if (!blockstate.func_196958_f()) {
- SoundType soundtype = blockstate.func_215695_r();
+ SoundType soundtype = blockstate.getSoundType(field_70170_p, new BlockPos(j, k, l), this);
2018-12-05 09:16:33 +00:00
this.func_184185_a(soundtype.func_185842_g(), soundtype.func_185843_a() * 0.5F, soundtype.func_185847_b() * 0.75F);
}
}
2019-05-23 23:02:15 +00:00
@@ -1301,6 +1323,8 @@
2018-12-05 09:16:33 +00:00
protected void func_70665_d(DamageSource p_70665_1_, float p_70665_2_) {
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 f = p_70665_2_;
2019-05-23 23:02:15 +00:00
@@ -1311,10 +1335,11 @@
((ServerPlayerEntity)p_70665_1_.func_76346_g()).func_195067_a(Stats.field_212735_F, Math.round(f1 * 10.0F));
}
2018-12-05 09:16:33 +00:00
+ p_70665_2_ = net.minecraftforge.common.ForgeHooks.onLivingDamage(this, p_70665_1_, p_70665_2_);
if (p_70665_2_ != 0.0F) {
float f2 = this.func_110143_aJ();
- this.func_70606_j(f2 - p_70665_2_);
this.func_110142_aN().func_94547_a(p_70665_1_, f2, p_70665_2_);
+ this.func_70606_j(f2 - p_70665_2_); // Forge: moved to fix MC-121048
2018-12-05 09:16:33 +00:00
this.func_110149_m(this.func_110139_bj() - p_70665_2_);
}
}
2019-05-23 23:02:15 +00:00
@@ -1356,6 +1381,8 @@
2018-12-05 09:16:33 +00:00
}
2019-05-23 23:02:15 +00:00
public void func_184609_a(Hand p_184609_1_) {
2018-12-05 09:16:33 +00:00
+ ItemStack stack = this.func_184586_b(p_184609_1_);
+ if (!stack.func_190926_b() && stack.onEntitySwing(this)) 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;
this.field_82175_bq = true;
2019-05-23 23:02:15 +00:00
@@ -1714,15 +1741,16 @@
2018-12-05 09:16:33 +00:00
}
this.field_70160_al = true;
+ net.minecraftforge.common.ForgeHooks.onLivingJump(this);
}
@OnlyIn(Dist.CLIENT)
protected void func_203010_cG() {
2019-05-23 23:02:15 +00:00
- this.func_213317_d(this.func_213322_ci().func_72441_c(0.0D, (double)-0.04F, 0.0D));
+ this.func_213317_d(this.func_213322_ci().func_72441_c(0.0D, (double)-0.04F * this.func_110148_a(SWIM_SPEED).func_111126_e(), 0.0D));
2018-12-05 09:16:33 +00:00
}
protected void func_180466_bG(Tag<Fluid> p_180466_1_) {
2019-05-23 23:02:15 +00:00
- this.func_213317_d(this.func_213322_ci().func_72441_c(0.0D, (double)0.04F, 0.0D));
+ this.func_213317_d(this.func_213322_ci().func_72441_c(0.0D, (double)0.04F * this.func_110148_a(SWIM_SPEED).func_111126_e(), 0.0D));
2018-12-05 09:16:33 +00:00
}
protected float func_189749_co() {
2019-05-23 23:02:15 +00:00
@@ -1785,7 +1813,7 @@
}
} else {
BlockPos blockpos = new BlockPos(this.field_70165_t, this.func_174813_aQ().field_72338_b - 1.0D, this.field_70161_v);
- float f5 = this.field_70170_p.func_180495_p(blockpos).func_177230_c().func_208618_m();
+ float f5 = this.field_70170_p.func_180495_p(blockpos).getSlipperiness(field_70170_p, blockpos, this);
float f7 = this.field_70122_E ? f5 * 0.91F : 0.91F;
this.func_213309_a(this.func_213335_r(f5), p_213352_1_);
this.func_213317_d(this.func_213362_f(this.func_213322_ci()));
@@ -1847,6 +1875,7 @@
f = 0.96F;
}
+ f1 *= (float)this.func_110148_a(SWIM_SPEED).func_111126_e();
this.func_213309_a(f1, p_213352_1_);
this.func_213315_a(MoverType.SELF, this.func_213322_ci());
Vec3d vec3d1 = this.func_213322_ci();
@@ -1922,6 +1951,7 @@
2018-12-05 09:16:33 +00:00
}
public void func_70071_h_() {
+ if (net.minecraftforge.common.ForgeHooks.onLivingUpdate(this)) return;
super.func_70071_h_();
this.func_184608_ct();
this.func_205014_p();
2019-05-23 23:02:15 +00:00
@@ -1953,7 +1983,9 @@
2018-12-05 09:16:33 +00:00
2019-05-23 23:02:15 +00:00
ItemStack itemstack1 = this.func_184582_a(equipmentslottype);
2018-12-05 09:16:33 +00:00
if (!ItemStack.func_77989_b(itemstack1, itemstack)) {
+ if (!itemstack1.equals(itemstack, true))
2019-05-23 23:02:15 +00:00
((ServerWorld)this.field_70170_p).func_72863_F().func_217218_b(this, new SEntityEquipmentPacket(this.func_145782_y(), equipmentslottype, itemstack1));
+ net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.LivingEquipmentChangeEvent(this, equipmentslottype, itemstack, itemstack1));
2018-12-05 09:16:33 +00:00
if (!itemstack.func_190926_b()) {
2019-05-23 23:02:15 +00:00
this.func_110140_aT().func_111148_a(itemstack.func_111283_C(equipmentslottype));
2018-12-05 09:16:33 +00:00
}
2019-05-23 23:02:15 +00:00
@@ -2402,13 +2434,22 @@
2018-12-05 09:16:33 +00:00
protected void func_184608_ct() {
if (this.func_184587_cr()) {
- if (this.func_184586_b(this.func_184600_cs()) == this.field_184627_bm) {
+ ItemStack itemstack = this.func_184586_b(this.func_184600_cs());
+ if (net.minecraftforge.common.ForgeHooks.canContinueUsing(this.field_184627_bm, itemstack)) this.field_184627_bm = itemstack;
+ if (itemstack == this.field_184627_bm) {
2018-12-05 09:16:33 +00:00
+
+ if (!this.field_184627_bm.func_190926_b()) {
+ field_184628_bn = net.minecraftforge.event.ForgeEventFactory.onItemUseTick(this, field_184627_bm, field_184628_bn);
+ if (field_184628_bn > 0)
+ field_184627_bm.onUsingTick(this, field_184628_bn);
+ }
+
2019-05-23 23:02:15 +00:00
this.field_184627_bm.func_222121_b(this.field_70170_p, this, this.func_184605_cv());
2018-12-05 09:16:33 +00:00
if (this.func_184605_cv() <= 25 && this.func_184605_cv() % 4 == 0) {
this.func_184584_a(this.field_184627_bm, 5);
}
2019-05-23 23:02:15 +00:00
- if (--this.field_184628_bn == 0 && !this.field_70170_p.field_72995_K && !this.field_184627_bm.func_222122_m()) {
+ if (--this.field_184628_bn <= 0 && !this.field_70170_p.field_72995_K && !this.field_184627_bm.func_222122_m()) {
2018-12-05 09:16:33 +00:00
this.func_71036_o();
}
} else {
2019-05-23 23:02:15 +00:00
@@ -2442,8 +2483,10 @@
public void func_184598_c(Hand p_184598_1_) {
2018-12-05 09:16:33 +00:00
ItemStack itemstack = this.func_184586_b(p_184598_1_);
if (!itemstack.func_190926_b() && !this.func_184587_cr()) {
+ int duration = net.minecraftforge.event.ForgeEventFactory.onItemUseStart(this, itemstack, itemstack.func_77988_m());
+ if (duration <= 0) return;
this.field_184627_bm = itemstack;
- this.field_184628_bn = itemstack.func_77988_m();
+ this.field_184628_bn = duration;
if (!this.field_70170_p.field_72995_K) {
this.func_204802_c(1, true);
2019-05-23 23:02:15 +00:00
this.func_204802_c(2, p_184598_1_ == Hand.OFF_HAND);
@@ -2503,6 +2546,9 @@
2018-12-05 09:16:33 +00:00
vec3d1 = vec3d1.func_178789_a(-this.field_70125_A * ((float)Math.PI / 180F));
vec3d1 = vec3d1.func_178785_b(-this.field_70177_z * ((float)Math.PI / 180F));
vec3d1 = vec3d1.func_72441_c(this.field_70165_t, this.field_70163_u + (double)this.func_70047_e(), this.field_70161_v);
2019-05-23 23:02:15 +00:00
+ if (this.field_70170_p instanceof ServerWorld) //Forge: Fix MC-2518 spawnParticle is nooped on server, need to use server specific variant
+ ((ServerWorld)this.field_70170_p).func_195598_a(new ItemParticleData(ParticleTypes.field_197591_B, p_195062_1_), vec3d1.field_72450_a, vec3d1.field_72448_b, vec3d1.field_72449_c, 1, vec3d.field_72450_a, vec3d.field_72448_b + 0.05D, vec3d.field_72449_c, 0.0D);
2018-12-05 09:16:33 +00:00
+ else
2019-05-23 23:02:15 +00:00
this.field_70170_p.func_195594_a(new ItemParticleData(ParticleTypes.field_197591_B, p_195062_1_), vec3d1.field_72450_a, vec3d1.field_72448_b, vec3d1.field_72449_c, vec3d.field_72450_a, vec3d.field_72448_b + 0.05D, vec3d.field_72449_c);
2018-12-05 09:16:33 +00:00
}
2019-05-23 23:02:15 +00:00
@@ -2511,7 +2557,9 @@
2018-12-05 09:16:33 +00:00
protected void func_71036_o() {
if (!this.field_184627_bm.func_190926_b() && this.func_184587_cr()) {
this.func_184584_a(this.field_184627_bm, 16);
- this.func_184611_a(this.func_184600_cs(), this.field_184627_bm.func_77950_b(this.field_70170_p, this));
+ ItemStack copy = this.field_184627_bm.func_77946_l();
+ ItemStack stack = net.minecraftforge.event.ForgeEventFactory.onItemUseFinish(this, copy, func_184605_cv(), this.field_184627_bm.func_77950_b(this.field_70170_p, this));
+ this.func_184611_a(this.func_184600_cs(), stack);
this.func_184602_cy();
}
2019-05-23 23:02:15 +00:00
@@ -2531,6 +2579,7 @@
2018-12-05 09:16:33 +00:00
public void func_184597_cx() {
if (!this.field_184627_bm.func_190926_b()) {
+ if (!net.minecraftforge.event.ForgeEventFactory.onUseItemStop(this, field_184627_bm, this.func_184605_cv()))
this.field_184627_bm.func_77974_b(this.field_70170_p, this, this.func_184605_cv());
2019-05-23 23:02:15 +00:00
if (this.field_184627_bm.func_222122_m()) {
this.func_184608_ct();
@@ -2686,16 +2735,16 @@
private boolean func_213359_p() {
return this.func_213374_dv().map((p_213347_1_) -> {
- return this.field_70170_p.func_180495_p(p_213347_1_).func_177230_c() instanceof BedBlock;
+ return net.minecraftforge.event.ForgeEventFactory.fireSleepingLocationCheck(this, p_213347_1_);
}).orElse(false);
}
2018-12-05 09:16:33 +00:00
2019-05-23 23:02:15 +00:00
public void func_213366_dy() {
this.func_213374_dv().filter(this.field_70170_p::func_175667_e).ifPresent((p_213368_1_) -> {
BlockState blockstate = this.field_70170_p.func_180495_p(p_213368_1_);
- if (blockstate.func_177230_c() instanceof BedBlock) {
- this.field_70170_p.func_180501_a(p_213368_1_, blockstate.func_206870_a(BedBlock.field_176471_b, Boolean.valueOf(false)), 3);
- Vec3d vec3d = BedBlock.func_220172_a(this.func_200600_R(), this.field_70170_p, p_213368_1_, 0).orElseGet(() -> {
+ if (blockstate.isBed(this.field_70170_p, p_213368_1_, this)) {
+ blockstate.setBedOccupied(field_70170_p, p_213368_1_, this, false);
+ Vec3d vec3d = blockstate.getBedSpawnPosition(this.func_200600_R(), field_70170_p, p_213368_1_, this).orElseGet(()-> {
BlockPos blockpos = p_213368_1_.func_177984_a();
return new Vec3d((double)blockpos.func_177958_n() + 0.5D, (double)blockpos.func_177956_o() + 0.1D, (double)blockpos.func_177952_p() + 0.5D);
});
@@ -2710,8 +2759,13 @@
@Nullable
2018-12-05 09:16:33 +00:00
@OnlyIn(Dist.CLIENT)
2019-05-23 23:02:15 +00:00
public Direction func_213376_dz() {
+// this.getBedPosition().map(pos->{ // This is apparently an "optimization" by Mojang, so we'll copy their lead here for now
2019-05-23 23:02:15 +00:00
+// BlockState state = this.world.getBlockState(pos);
+// return !state.isBed(world, pos, this) ? Direction.UP : state.getBedDirection(world, pos);
+// });
BlockPos blockpos = this.func_213374_dv().orElse((BlockPos)null);
- return blockpos != null ? BedBlock.func_220174_a(this.field_70170_p, blockpos) : null;
+ BlockState state = this.field_70170_p.func_180495_p(blockpos);
+ return !state.isBed(field_70170_p, blockpos, this) ? Direction.UP : state.getBedDirection(field_70170_p, blockpos);
}
public boolean func_70094_T() {
@@ -2778,4 +2832,58 @@
public void func_213334_d(Hand p_213334_1_) {
this.func_213361_c(p_213334_1_ == Hand.MAIN_HAND ? EquipmentSlotType.MAINHAND : EquipmentSlotType.OFFHAND);
2018-12-05 09:16:33 +00:00
}
+
2019-05-23 23:02:15 +00:00
+ /* ==== FORGE START ==== */
+ /***
+ * 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 boolean curePotionEffects(ItemStack curativeItem) {
+ if (this.field_70170_p.field_72995_K)
+ return false;
+ boolean ret = false;
+ Iterator<EffectInstance> itr = this.field_70713_bf.values().iterator();
+ while (itr.hasNext()) {
+ EffectInstance effect = itr.next();
+ if (effect.isCurativeItem(curativeItem) && !net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(new net.minecraftforge.event.entity.living.PotionEvent.PotionRemoveEvent(this, effect))) {
+ this.func_70688_c(effect);
+ itr.remove();
+ ret = true;
+ this.field_70752_e = true;
+ }
+ }
+ return ret;
+ }
+
2018-12-05 09:16:33 +00:00
+ /**
+ * 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.
+ */
2019-05-23 23:02:15 +00:00
+ public boolean shouldRiderFaceForward(PlayerEntity player) {
+ return this instanceof net.minecraft.entity.passive.PigEntity;
2018-12-05 09:16:33 +00:00
+ }
+
+ private final net.minecraftforge.common.util.LazyOptional<?>[] handlers = net.minecraftforge.items.wrapper.EntityEquipmentInvWrapper.create(this);
2018-12-05 09:16:33 +00:00
+
+ @Override
2019-05-23 23:02:15 +00:00
+ public <T> net.minecraftforge.common.util.LazyOptional<T> getCapability(net.minecraftforge.common.capabilities.Capability<T> capability, @Nullable Direction facing) {
+ if (this.func_70089_S() && capability == net.minecraftforge.items.CapabilityItemHandler.ITEM_HANDLER_CAPABILITY) {
2018-12-05 09:16:33 +00:00
+ if (facing == null) return handlers[2].cast();
+ else if (facing.func_176740_k().func_200128_b()) return handlers[0].cast();
+ else if (facing.func_176740_k().func_176722_c()) return handlers[1].cast();
+ }
+ return super.getCapability(capability, facing);
+ }
+
+ @Override
+ public void remove(boolean keepData) {
+ super.remove(keepData);
+ if (!keepData) {
+ for (int x = 0; x < handlers.length; x++)
+ handlers[x].invalidate();
+ }
2018-12-05 09:16:33 +00:00
+ }
}