mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-19 11:59:25 +00:00
288 lines
12 KiB
Diff
288 lines
12 KiB
Diff
--- ../src-base/minecraft/net/minecraft/entity/EntityLivingBase.java
|
|
+++ ../src-work/minecraft/net/minecraft/entity/EntityLivingBase.java
|
|
@@ -190,9 +190,11 @@
|
|
float f = (float)MathHelper.ceiling_float_int(this.fallDistance - 3.0F);
|
|
|
|
if (p_184231_4_.func_185904_a() != Material.air)
|
|
+ if (p_184231_4_.getBlock().isAir(p_184231_4_, worldObj, p_184231_5_))
|
|
{
|
|
double d0 = Math.min((double)(0.2F + f / 15.0F), 2.5D);
|
|
int i = (int)(150.0D * d0);
|
|
+ if (!p_184231_4_.getBlock().addLandingEffects(p_184231_4_, (WorldServer)this.worldObj, p_184231_5_, p_184231_4_, this, i))
|
|
((WorldServer)this.worldObj).spawnParticle(EnumParticleTypes.BLOCK_DUST, this.posX, this.posY, this.posZ, i, 0.0D, 0.0D, 0.0D, 0.15000000596046448D, new int[] {Block.getStateId(p_184231_4_)});
|
|
}
|
|
}
|
|
@@ -264,7 +266,7 @@
|
|
}
|
|
}
|
|
|
|
- if (!this.worldObj.isRemote && this.func_184218_aH() && this.func_184187_bx() instanceof EntityLivingBase)
|
|
+ if (!this.worldObj.isRemote && this.func_184218_aH() && this.func_184187_bx() != null && this.func_184187_bx().shouldDismountInWater(this))
|
|
{
|
|
this.func_184210_p();
|
|
}
|
|
@@ -363,7 +365,7 @@
|
|
if (!this.worldObj.isRemote && (this.isPlayer() || this.recentlyHit > 0 && this.canDropLoot() && this.worldObj.getGameRules().getBoolean("doMobLoot")))
|
|
{
|
|
int i = this.getExperiencePoints(this.attackingPlayer);
|
|
-
|
|
+ i = net.minecraftforge.event.ForgeEventFactory.getExperienceDrop(this, this.attackingPlayer, i);
|
|
while (i > 0)
|
|
{
|
|
int j = EntityXPOrb.getXPSplit(i);
|
|
@@ -424,6 +426,7 @@
|
|
{
|
|
this.entityLivingToAttack = livingBase;
|
|
this.revengeTimer = this.ticksExisted;
|
|
+ net.minecraftforge.common.ForgeHooks.onLivingSetAttackTarget(this, livingBase);
|
|
}
|
|
|
|
public EntityLivingBase getLastAttacker()
|
|
@@ -775,6 +778,8 @@
|
|
|
|
public void heal(float healAmount)
|
|
{
|
|
+ healAmount = net.minecraftforge.event.ForgeEventFactory.onLivingHeal(this, healAmount);
|
|
+ if (healAmount <= 0) return;
|
|
float f = this.getHealth();
|
|
|
|
if (f > 0.0F)
|
|
@@ -795,6 +800,7 @@
|
|
|
|
public boolean attackEntityFrom(DamageSource source, float amount)
|
|
{
|
|
+ if (!net.minecraftforge.common.ForgeHooks.onLivingAttack(this, source, amount)) return false;
|
|
if (this.isEntityInvulnerable(source))
|
|
{
|
|
return false;
|
|
@@ -883,9 +889,9 @@
|
|
this.recentlyHit = 100;
|
|
this.attackingPlayer = (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.isTamed())
|
|
{
|
|
@@ -1007,6 +1013,7 @@
|
|
|
|
public void onDeath(DamageSource cause)
|
|
{
|
|
+ if (net.minecraftforge.common.ForgeHooks.onLivingDeath(this, cause)) return;
|
|
if (!this.dead)
|
|
{
|
|
Entity entity = cause.getEntity();
|
|
@@ -1034,11 +1041,24 @@
|
|
i = EnchantmentHelper.func_185283_h((EntityLivingBase)entity);
|
|
}
|
|
|
|
+ captureDrops = true;
|
|
+ capturedDrops.clear();
|
|
+
|
|
if (this.canDropLoot() && this.worldObj.getGameRules().getBoolean("doMobLoot"))
|
|
{
|
|
boolean flag = this.recentlyHit > 0;
|
|
this.func_184610_a(flag, i, cause);
|
|
}
|
|
+
|
|
+ captureDrops = false;
|
|
+
|
|
+ if (!net.minecraftforge.common.ForgeHooks.onLivingDrops(this, cause, capturedDrops, i, recentlyHit > 0))
|
|
+ {
|
|
+ for (EntityItem item : capturedDrops)
|
|
+ {
|
|
+ worldObj.spawnEntityInWorld(item);
|
|
+ }
|
|
+ }
|
|
}
|
|
|
|
this.worldObj.setEntityState(this, (byte)3);
|
|
@@ -1113,7 +1133,7 @@
|
|
BlockPos blockpos = new BlockPos(i, j, k);
|
|
IBlockState iblockstate = this.worldObj.getBlockState(blockpos);
|
|
Block block = iblockstate.getBlock();
|
|
- return block != Blocks.ladder && block != Blocks.vine ? block instanceof BlockTrapDoor && this.func_184604_a(blockpos, iblockstate) : true;
|
|
+ return net.minecraftforge.common.ForgeHooks.isLivingOnLadder(iblockstate, worldObj, new BlockPos(i, j, k), this);
|
|
}
|
|
}
|
|
|
|
@@ -1139,6 +1159,9 @@
|
|
|
|
public void fall(float distance, float damageMultiplier)
|
|
{
|
|
+ float[] ret = net.minecraftforge.common.ForgeHooks.onLivingFall(this, distance, damageMultiplier);
|
|
+ if (ret == null) return;
|
|
+ distance = ret[0]; damageMultiplier = ret[1];
|
|
super.fall(distance, damageMultiplier);
|
|
PotionEffect potioneffect = this.getActivePotionEffect(MobEffects.jump);
|
|
float f = potioneffect == null ? 0.0F : (float)(potioneffect.getAmplifier() + 1);
|
|
@@ -1231,6 +1254,8 @@
|
|
{
|
|
if (!this.isEntityInvulnerable(damageSrc))
|
|
{
|
|
+ damageAmount = net.minecraftforge.common.ForgeHooks.onLivingHurt(this, damageSrc, damageAmount);
|
|
+ if (damageAmount <= 0) return;
|
|
damageAmount = this.applyArmorCalculations(damageSrc, damageAmount);
|
|
damageAmount = this.applyPotionDamageCalculations(damageSrc, damageAmount);
|
|
float f = damageAmount;
|
|
@@ -1279,6 +1304,11 @@
|
|
|
|
public void func_184609_a(EnumHand p_184609_1_)
|
|
{
|
|
+ ItemStack stack = this.func_184586_b(p_184609_1_);
|
|
+ if (stack != null && stack.getItem() != null)
|
|
+ {
|
|
+ if (stack.getItem().onEntitySwing(this, stack)) return;
|
|
+ }
|
|
if (!this.isSwingInProgress || this.swingProgressInt >= this.getArmSwingAnimationEnd() / 2 || this.swingProgressInt < 0)
|
|
{
|
|
this.swingProgressInt = -1;
|
|
@@ -1476,6 +1506,7 @@
|
|
|
|
public void dismountEntity(Entity p_110145_1_)
|
|
{
|
|
+ if (!net.minecraftforge.event.ForgeEventFactory.canMountEntity(this, p_110145_1_, false)) return;
|
|
if (!(p_110145_1_ instanceof EntityBoat) && !(p_110145_1_ instanceof EntityHorse))
|
|
{
|
|
double d1 = p_110145_1_.posX;
|
|
@@ -1500,7 +1531,7 @@
|
|
|
|
if (!this.worldObj.func_184143_b(axisalignedbb1))
|
|
{
|
|
- if (this.worldObj.getBlockState(new BlockPos(d11, this.posY, d12)).func_185896_q())
|
|
+ if (this.worldObj.getBlockState(new BlockPos(d11, this.posY, d12)).isSideSolid(worldObj, new BlockPos(d11, this.posY, d12), EnumFacing.UP))
|
|
{
|
|
this.setPositionAndUpdate(d11, this.posY + 1.0D, d12);
|
|
return;
|
|
@@ -1508,14 +1539,14 @@
|
|
|
|
BlockPos blockpos = new BlockPos(d11, this.posY - 1.0D, d12);
|
|
|
|
- if (this.worldObj.getBlockState(blockpos).func_185896_q() || this.worldObj.getBlockState(blockpos).func_185904_a() == Material.water)
|
|
+ if (this.worldObj.getBlockState(blockpos).isSideSolid(worldObj, blockpos, EnumFacing.UP) || this.worldObj.getBlockState(blockpos).func_185904_a() == Material.water)
|
|
{
|
|
d1 = d11;
|
|
d13 = this.posY + 1.0D;
|
|
d14 = d12;
|
|
}
|
|
}
|
|
- else if (!this.worldObj.func_184143_b(axisalignedbb1.offset(0.0D, 1.0D, 0.0D)) && this.worldObj.getBlockState(new BlockPos(d11, this.posY + 1.0D, d12)).func_185896_q())
|
|
+ else if (!this.worldObj.func_184143_b(axisalignedbb1.offset(0.0D, 1.0D, 0.0D)) && this.worldObj.getBlockState(new BlockPos(d11, this.posY + 1.0D, d12)).isSideSolid(worldObj, new BlockPos(d11, this.posY + 1.0D, d12), EnumFacing.UP))
|
|
{
|
|
d1 = d11;
|
|
d13 = this.posY + 2.0D;
|
|
@@ -1586,6 +1617,7 @@
|
|
}
|
|
|
|
this.isAirBorne = true;
|
|
+ net.minecraftforge.common.ForgeHooks.onLivingJump(this);
|
|
}
|
|
|
|
protected void updateAITick()
|
|
@@ -1845,6 +1877,7 @@
|
|
|
|
public void onUpdate()
|
|
{
|
|
+ if (net.minecraftforge.common.ForgeHooks.onLivingUpdate(this)) return;
|
|
super.onUpdate();
|
|
this.func_184608_ct();
|
|
|
|
@@ -2351,6 +2384,41 @@
|
|
this.potionsNeedUpdate = 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 = activePotionsMap.keySet().iterator();
|
|
+ if (worldObj.isRemote) return;
|
|
+
|
|
+ while (potionKey.hasNext())
|
|
+ {
|
|
+ Integer key = potionKey.next();
|
|
+ PotionEffect effect = (PotionEffect)activePotionsMap.get(key);
|
|
+
|
|
+ if (effect.isCurativeItem(curativeItem))
|
|
+ {
|
|
+ potionKey.remove();
|
|
+ onFinishedPotionEffect(effect);
|
|
+ this.potionsNeedUpdate = 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;
|
|
+ }
|
|
+
|
|
public abstract EnumHandSide func_184591_cq();
|
|
|
|
public boolean func_184587_cr()
|
|
@@ -2371,6 +2439,14 @@
|
|
|
|
if (itemstack == this.field_184627_bm)
|
|
{
|
|
+ field_184628_bn = net.minecraftforge.event.ForgeEventFactory.onItemUseTick(this, field_184627_bm, field_184628_bn);
|
|
+ if (field_184628_bn <= 0)
|
|
+ {
|
|
+ this.onItemUseFinish();
|
|
+ }
|
|
+ else
|
|
+ { // Forge Keep unindented to lower patch
|
|
+ field_184627_bm.getItem().onUsingTick(field_184627_bm, this, field_184628_bn); //Forge Added
|
|
if (this.func_184605_cv() <= 25 && this.func_184605_cv() % 4 == 0)
|
|
{
|
|
this.func_184584_a(this.field_184627_bm, 5);
|
|
@@ -2380,6 +2456,7 @@
|
|
{
|
|
this.onItemUseFinish();
|
|
}
|
|
+ }
|
|
}
|
|
else
|
|
{
|
|
@@ -2394,8 +2471,10 @@
|
|
|
|
if (itemstack != null && !this.func_184587_cr())
|
|
{
|
|
+ int duration = net.minecraftforge.event.ForgeEventFactory.onItemUseStart(this, itemstack, itemstack.getMaxItemUseDuration());
|
|
+ if (duration <= 0) return;
|
|
this.field_184627_bm = itemstack;
|
|
- this.field_184628_bn = itemstack.getMaxItemUseDuration();
|
|
+ this.field_184628_bn = duration;
|
|
|
|
if (!this.worldObj.isRemote)
|
|
{
|
|
@@ -2478,6 +2557,8 @@
|
|
this.func_184584_a(this.field_184627_bm, 16);
|
|
ItemStack itemstack = this.field_184627_bm.onItemUseFinish(this.worldObj, this);
|
|
|
|
+ itemstack = net.minecraftforge.event.ForgeEventFactory.onItemUseFinish(this, field_184627_bm, func_184605_cv(), itemstack);
|
|
+
|
|
if (itemstack != null && itemstack.stackSize == 0)
|
|
{
|
|
itemstack = null;
|
|
@@ -2508,6 +2589,8 @@
|
|
if (this.field_184627_bm != null)
|
|
{
|
|
this.field_184627_bm.onPlayerStoppedUsing(this.worldObj, this, this.func_184605_cv());
|
|
+ if (!net.minecraftforge.event.ForgeEventFactory.onUseItemStop(this, field_184627_bm, this.func_184605_cv()))
|
|
+ this.field_184627_bm.onPlayerStoppedUsing(this.worldObj, this, this.func_184605_cv());
|
|
}
|
|
|
|
this.func_184602_cy();
|