no invuln temp fix

This commit is contained in:
Sen 2025-04-01 01:32:19 +02:00
parent cb3787349b
commit eea23233f4
19 changed files with 220 additions and 217 deletions

View file

@ -1316,15 +1316,15 @@ public abstract class Entity
*/ */
public boolean attackEntityFrom(DamageSource source, int amount) public boolean attackEntityFrom(DamageSource source, int amount)
{ {
if (this.isEntityInvulnerable(source)) // if (this.isEntityInvulnerable(source))
{ // {
return false; // return false;
} // }
else // else
{ // {
this.setBeenAttacked(); this.setBeenAttacked();
return false; return false;
} // }
} }
/** /**
@ -2333,10 +2333,10 @@ public abstract class Entity
// return String.format("%s[\'%s\'/%d, l=\'%s\', x=%.2f, y=%.2f, z=%.2f]", this.getClass().getSimpleName(), this.getName(), this.eid, this.worldObj == null ? "~NULL~" : this.worldObj.dimension.getDimensionId(), this.posX, this.posY, this.posZ); // return String.format("%s[\'%s\'/%d, l=\'%s\', x=%.2f, y=%.2f, z=%.2f]", this.getClass().getSimpleName(), this.getName(), this.eid, this.worldObj == null ? "~NULL~" : this.worldObj.dimension.getDimensionId(), this.posX, this.posY, this.posZ);
// } // }
public final boolean isEntityInvulnerable(DamageSource source) // public final boolean isEntityInvulnerable(DamageSource source)
{ // {
return false; // this.invulnerable && source != DamageSource.outOfWorld; // && !source.isCreativePlayer(); // return false; // this.invulnerable && source != DamageSource.outOfWorld; // && !source.isCreativePlayer();
} // }
/** /**
* Sets this entity's location and angles to the location and angles of the passed in entity. * Sets this entity's location and angles to the location and angles of the passed in entity.

View file

@ -230,19 +230,19 @@ public class EntityBat extends EntityLiving
*/ */
public boolean attackEntityFrom(DamageSource source, int amount) public boolean attackEntityFrom(DamageSource source, int amount)
{ {
if (this.isEntityInvulnerable(source)) // if (this.isEntityInvulnerable(source))
// {
// return false;
// }
// else
// {
if (!this.worldObj.client && this.getIsBatHanging())
{ {
return false; this.setIsBatHanging(false);
} }
else
{
if (!this.worldObj.client && this.getIsBatHanging())
{
this.setIsBatHanging(false);
}
return super.attackEntityFrom(source, amount); return super.attackEntityFrom(source, amount);
} // }
} }
/** /**

View file

@ -51,7 +51,7 @@ public class EntityDragonPart extends Entity
*/ */
public boolean attackEntityFrom(DamageSource source, int amount) public boolean attackEntityFrom(DamageSource source, int amount)
{ {
return this.isEntityInvulnerable(source) ? false : this.entityDragonObj.attackEntityFromPart(this, source, amount); return /* this.isEntityInvulnerable(source) ? false : */ this.entityDragonObj.attackEntityFromPart(this, source, amount);
} }
/** /**

View file

@ -187,15 +187,15 @@ public class EntityOcelot extends EntityTameable
*/ */
public boolean attackEntityFrom(DamageSource source, int amount) public boolean attackEntityFrom(DamageSource source, int amount)
{ {
if (this.isEntityInvulnerable(source)) // if (this.isEntityInvulnerable(source))
{ // {
return false; // return false;
} // }
else // else
{ // {
this.aiSit.setSitting(false); this.aiSit.setSitting(false);
return super.attackEntityFrom(source, amount); return super.attackEntityFrom(source, amount);
} // }
} }
/** /**

View file

@ -242,9 +242,9 @@ public class EntityRabbit extends EntityAnimal {
return this.getRabbitType() == 99 ? 8 : super.getTotalArmorValue(); return this.getRabbitType() == 99 ? 8 : super.getTotalArmorValue();
} }
public boolean attackEntityFrom(DamageSource source, int amount) { // public boolean attackEntityFrom(DamageSource source, int amount) {
return this.isEntityInvulnerable(source) ? false : super.attackEntityFrom(source, amount); // return this.isEntityInvulnerable(source) ? false : super.attackEntityFrom(source, amount);
} // }
// protected void addRandomDrop() { // protected void addRandomDrop() {
// this.entityDropItem(new ItemStack(Items.rabbit_foot, 1), 0.0F); // this.entityDropItem(new ItemStack(Items.rabbit_foot, 1), 0.0F);

View file

@ -332,22 +332,22 @@ public class EntityWolf extends EntityTameable
*/ */
public boolean attackEntityFrom(DamageSource source, int amount) public boolean attackEntityFrom(DamageSource source, int amount)
{ {
if (this.isEntityInvulnerable(source)) // if (this.isEntityInvulnerable(source))
{ // {
return false; // return false;
} // }
else // else
{ // {
// Entity entity = source.getEntity(); // Entity entity = source.getEntity();
this.aiSit.setSitting(false); this.aiSit.setSitting(false);
// if (entity != null && !(entity.isPlayer()) && !(entity instanceof EntityArrow)) // if (entity != null && !(entity.isPlayer()) && !(entity instanceof EntityArrow))
// { // {
// amount = (amount + 1) / 2; // amount = (amount + 1) / 2;
// } // }
return super.attackEntityFrom(source, amount); return super.attackEntityFrom(source, amount);
} // }
} }
public boolean attackEntityAsMob(Entity entityIn) public boolean attackEntityAsMob(Entity entityIn)

View file

@ -111,11 +111,12 @@ public class EntityBoat extends Entity
*/ */
public boolean attackEntityFrom(DamageSource source, int amount) public boolean attackEntityFrom(DamageSource source, int amount)
{ {
if (this.isEntityInvulnerable(source)) // if (this.isEntityInvulnerable(source))
{ // {
return false; // return false;
} // }
else if (!this.worldObj.client && !this.dead) // else
if (!this.worldObj.client && !this.dead)
{ {
if (this.passenger != null && this.passenger == source.getEntity() && source instanceof EntityDamageSourceIndirect) if (this.passenger != null && this.passenger == source.getEntity() && source instanceof EntityDamageSourceIndirect)
{ {

View file

@ -146,24 +146,24 @@ public abstract class EntityCart extends Entity implements IWorldNameable
{ {
if (!this.worldObj.client && !this.dead) if (!this.worldObj.client && !this.dead)
{ {
if (this.isEntityInvulnerable(source)) // if (this.isEntityInvulnerable(source))
{ // {
return false; // return false;
} // }
else // else
{ // {
this.setRollingDirection(-this.getRollingDirection()); this.setRollingDirection(-this.getRollingDirection());
this.setRollingAmplitude(10); this.setRollingAmplitude(10);
this.setBeenAttacked(); this.setBeenAttacked();
this.setDamage(this.getDamage() + (int)amount * 10); this.setDamage(this.getDamage() + (int)amount * 10);
// boolean flag = source.getEntity().isPlayer() && ((EntityNPC)source.getEntity()).creative; // boolean flag = source.getEntity().isPlayer() && ((EntityNPC)source.getEntity()).creative;
if (/* flag || */ this.getDamage() > 40) if (/* flag || */ this.getDamage() > 40)
{
if (this.passenger != null)
{ {
if (this.passenger != null) this.passenger.mountEntity((Entity)null);
{ }
this.passenger.mountEntity((Entity)null);
}
// if (flag && !this.hasCustomName()) // if (flag && !this.hasCustomName())
// { // {
@ -171,12 +171,12 @@ public abstract class EntityCart extends Entity implements IWorldNameable
// } // }
// else // else
// { // {
this.killMinecart(source); this.killMinecart(source);
// } // }
}
return true;
} }
return true;
// }
} }
else else
{ {

View file

@ -87,29 +87,29 @@ public class EntityCrystal extends Entity
*/ */
public boolean attackEntityFrom(DamageSource source, int amount) public boolean attackEntityFrom(DamageSource source, int amount)
{ {
if (this.isEntityInvulnerable(source)) // if (this.isEntityInvulnerable(source))
// {
// return false;
// }
// else
// {
if (!this.dead && !this.worldObj.client)
{ {
return false;
}
else
{
if (!this.dead && !this.worldObj.client)
{
// this.health = 0; // this.health = 0;
// //
// if (this.health <= 0) // if (this.health <= 0)
// { // {
this.setDead(); this.setDead();
// if (!this.worldObj.client) // if (!this.worldObj.client)
// { // {
this.worldObj.createExplosion(null, this.posX, this.posY, this.posZ, 6.0F, true); this.worldObj.createExplosion(null, this.posX, this.posY, this.posZ, 6.0F, true);
// } // }
// } // }
}
return true;
} }
return true;
// }
} }
public int getTrackingRange() { public int getTrackingRange() {

View file

@ -317,26 +317,26 @@ public class EntityItem extends Entity
*/ */
public boolean attackEntityFrom(DamageSource source, int amount) public boolean attackEntityFrom(DamageSource source, int amount)
{ {
if (this.isEntityInvulnerable(source)) // if (this.isEntityInvulnerable(source))
{
return false;
}
// else if (this.getEntityItem() != null && this.getEntityItem().getItem() == Items.nether_star && source.isExplosion())
// { // {
// return false; // return false;
// } // }
else //// else if (this.getEntityItem() != null && this.getEntityItem().getItem() == Items.nether_star && source.isExplosion())
//// {
//// return false;
//// }
// else
// {
this.setBeenAttacked();
this.health = this.health - (int)amount;
if (this.health <= 0)
{ {
this.setBeenAttacked(); this.setDead();
this.health = this.health - (int)amount;
if (this.health <= 0)
{
this.setDead();
}
return false;
} }
return false;
// }
} }
/** /**

View file

@ -201,21 +201,21 @@ public class EntityLeashKnot extends Entity
*/ */
public boolean attackEntityFrom(DamageSource source, int amount) public boolean attackEntityFrom(DamageSource source, int amount)
{ {
if (this.isEntityInvulnerable(source)) // if (this.isEntityInvulnerable(source))
// {
// return false;
// }
// else
// {
if (!this.dead && !this.worldObj.client)
{ {
return false; this.setDead();
} this.setBeenAttacked();
else
{
if (!this.dead && !this.worldObj.client)
{
this.setDead();
this.setBeenAttacked();
// this.onBroken(source.getEntity()); // this.onBroken(source.getEntity());
}
return true;
} }
return true;
// }
} }
/** /**

View file

@ -272,22 +272,22 @@ public class EntityXp extends Entity implements IObjectData
*/ */
public boolean attackEntityFrom(DamageSource source, int amount) public boolean attackEntityFrom(DamageSource source, int amount)
{ {
if (this.isEntityInvulnerable(source)) // if (this.isEntityInvulnerable(source))
{ // {
return false; // return false;
} // }
else // else
{ // {
this.setBeenAttacked(); this.setBeenAttacked();
this.xpOrbHealth = this.xpOrbHealth - (int)amount; this.xpOrbHealth = this.xpOrbHealth - (int)amount;
if (this.xpOrbHealth <= 0) if (this.xpOrbHealth <= 0)
{ {
this.setDead(); this.setDead();
}
return false;
} }
return false;
// }
} }
/** /**

View file

@ -147,11 +147,12 @@ public class EntityGargoyle extends EntityFlyingNPC
public boolean attackEntityFrom(DamageSource source, int amount) public boolean attackEntityFrom(DamageSource source, int amount)
{ {
if (this.isEntityInvulnerable(source)) // if (this.isEntityInvulnerable(source))
{ // {
return false; // return false;
} // }
else if (this.getInvulTime() > 0 && source != DamageSource.outOfWorld) // else
if (this.getInvulTime() > 0 && source != DamageSource.outOfWorld)
{ {
return false; return false;
} }

View file

@ -150,21 +150,21 @@ public abstract class EntityMobNPC extends EntityNPC
*/ */
public boolean attackEntityFrom(DamageSource source, int amount) public boolean attackEntityFrom(DamageSource source, int amount)
{ {
if (this.isEntityInvulnerable(source)) // if (this.isEntityInvulnerable(source))
{ // {
return false; // return false;
} // }
else // else
{ // {
Entity entity = source.getEntity(); Entity entity = source.getEntity();
if (entity != null && entity instanceof EntityNPC) if (entity != null && entity instanceof EntityNPC)
{ {
this.becomeAngryAt(entity); this.becomeAngryAt(entity);
}
return super.attackEntityFrom(source, amount);
} }
return super.attackEntityFrom(source, amount);
// }
} }
/** /**

View file

@ -1762,8 +1762,8 @@ public abstract class EntityNPC extends EntityLiving
{ {
if(this.gm != null) if(this.gm != null)
return this.sendQueue == null; return this.sendQueue == null;
if(this.isEntityInvulnerable(source)) // if(this.isEntityInvulnerable(source))
return false; // return false;
if(this.connection != null) { if(this.connection != null) {
if(this.getHealth() <= 0) if(this.getHealth() <= 0)
return false; return false;
@ -2030,8 +2030,8 @@ public abstract class EntityNPC extends EntityLiving
protected void damageEntity(DamageSource damageSrc, int damageAmount) protected void damageEntity(DamageSource damageSrc, int damageAmount)
{ {
if(this.sendQueue != null) { if(this.sendQueue != null) {
if(!this.isEntityInvulnerable(damageSrc)) // if(!this.isEntityInvulnerable(damageSrc))
this.setHealth(this.getHealth() - damageAmount); this.setHealth(this.getHealth() - damageAmount);
return; return;
} }
if(!this.isPlayer()) { if(!this.isPlayer()) {
@ -2039,32 +2039,32 @@ public abstract class EntityNPC extends EntityLiving
return; return;
} }
if (!this.isEntityInvulnerable(damageSrc)) // if (!this.isEntityInvulnerable(damageSrc))
// {
if (!damageSrc.isUnblockable() && this.isBlocking() && damageAmount > 0)
{ {
if (!damageSrc.isUnblockable() && this.isBlocking() && damageAmount > 0) damageAmount = (1 + damageAmount) / 2;
{ }
damageAmount = (1 + damageAmount) / 2;
}
damageAmount = this.applyArmorCalculations(damageSrc, damageAmount); damageAmount = this.applyArmorCalculations(damageSrc, damageAmount);
damageAmount = this.applyPotionDamageCalculations(damageSrc, damageAmount); damageAmount = this.applyPotionDamageCalculations(damageSrc, damageAmount);
int f = damageAmount; int f = damageAmount;
damageAmount = Math.max(damageAmount - this.getAbsorptionAmount(), 0); damageAmount = Math.max(damageAmount - this.getAbsorptionAmount(), 0);
this.setAbsorptionAmount(this.getAbsorptionAmount() - (f - damageAmount)); this.setAbsorptionAmount(this.getAbsorptionAmount() - (f - damageAmount));
if (damageAmount != 0) if (damageAmount != 0)
{ {
// float f1 = this.getHealth(); // float f1 = this.getHealth();
this.setHealth(this.getHealth() - damageAmount); this.setHealth(this.getHealth() - damageAmount);
this.trackDamage(damageSrc, damageAmount); this.trackDamage(damageSrc, damageAmount);
// if ((float)damageAmount < 3.4028235E37F) // if ((float)damageAmount < 3.4028235E37F)
// { // {
// if(damageAmount < Integer.MAX_VALUE) // if(damageAmount < Integer.MAX_VALUE)
// this.addStat(StatRegistry.damageTakenStat, damageAmount); // this.addStat(StatRegistry.damageTakenStat, damageAmount);
// } // }
}
} }
// }
} }
/** /**

View file

@ -146,8 +146,8 @@ public class EntityDie extends EntityThrowable implements IObjectData
public boolean attackEntityFrom(DamageSource source, int amount) public boolean attackEntityFrom(DamageSource source, int amount)
{ {
if(this.isEntityInvulnerable(source)) // if(this.isEntityInvulnerable(source))
return false; // return false;
if(!this.worldObj.client && !this.dead) { if(!this.worldObj.client && !this.dead) {
if(!this.noPickup) if(!this.noPickup)
this.entityDropItem(this.getStack(), 0.0f); this.entityDropItem(this.getStack(), 0.0f);

View file

@ -318,40 +318,40 @@ public abstract class EntityProjectile extends Entity
*/ */
public boolean attackEntityFrom(DamageSource source, int amount) public boolean attackEntityFrom(DamageSource source, int amount)
{ {
if (this.isEntityInvulnerable(source)) // if (this.isEntityInvulnerable(source))
// {
// return false;
// }
// else
// {
this.setBeenAttacked();
if (source.getEntity() != null)
{ {
return false; Vec3 vec3 = source.getEntity().getLookVec();
if (vec3 != null)
{
this.motionX = vec3.xCoord;
this.motionY = vec3.yCoord;
this.motionZ = vec3.zCoord;
this.accelerationX = this.motionX * 0.1D;
this.accelerationY = this.motionY * 0.1D;
this.accelerationZ = this.motionZ * 0.1D;
}
if (source.getEntity() instanceof EntityLiving)
{
this.shootingEntity = (EntityLiving)source.getEntity();
}
return true;
} }
else else
{ {
this.setBeenAttacked(); return false;
if (source.getEntity() != null)
{
Vec3 vec3 = source.getEntity().getLookVec();
if (vec3 != null)
{
this.motionX = vec3.xCoord;
this.motionY = vec3.yCoord;
this.motionZ = vec3.zCoord;
this.accelerationX = this.motionX * 0.1D;
this.accelerationY = this.motionY * 0.1D;
this.accelerationZ = this.motionZ * 0.1D;
}
if (source.getEntity() instanceof EntityLiving)
{
this.shootingEntity = (EntityLiving)source.getEntity();
}
return true;
}
else
{
return false;
}
} }
// }
} }
/** /**

View file

@ -82,15 +82,15 @@ public abstract class EntityAnimal extends EntityLiving
*/ */
public boolean attackEntityFrom(DamageSource source, int amount) public boolean attackEntityFrom(DamageSource source, int amount)
{ {
if (this.isEntityInvulnerable(source)) // if (this.isEntityInvulnerable(source))
{ // {
return false; // return false;
} // }
else // else
{ // {
this.resetInLove(); this.resetInLove();
return super.attackEntityFrom(source, amount); return super.attackEntityFrom(source, amount);
} // }
} }
public float getBlockPathWeight(BlockPos pos) public float getBlockPathWeight(BlockPos pos)

View file

@ -940,11 +940,12 @@ public abstract class EntityLiving extends Entity
*/ */
public boolean attackEntityFrom(DamageSource source, int amount) public boolean attackEntityFrom(DamageSource source, int amount)
{ {
if (this.isEntityInvulnerable(source)) // if (this.isEntityInvulnerable(source))
{ // {
return false; // return false;
} // }
else if (this.worldObj.client) // else
if (this.worldObj.client)
{ {
return false; return false;
} }
@ -1356,22 +1357,22 @@ public abstract class EntityLiving extends Entity
*/ */
protected void damageEntity(DamageSource damageSrc, int damageAmount) protected void damageEntity(DamageSource damageSrc, int damageAmount)
{ {
if (!this.isEntityInvulnerable(damageSrc)) // if (!this.isEntityInvulnerable(damageSrc))
{ // {
damageAmount = this.applyArmorCalculations(damageSrc, damageAmount); damageAmount = this.applyArmorCalculations(damageSrc, damageAmount);
damageAmount = this.applyPotionDamageCalculations(damageSrc, damageAmount); damageAmount = this.applyPotionDamageCalculations(damageSrc, damageAmount);
int f = damageAmount; int f = damageAmount;
damageAmount = Math.max(damageAmount - this.getAbsorptionAmount(), 0); damageAmount = Math.max(damageAmount - this.getAbsorptionAmount(), 0);
this.setAbsorptionAmount(this.getAbsorptionAmount() - (f - damageAmount)); this.setAbsorptionAmount(this.getAbsorptionAmount() - (f - damageAmount));
if (damageAmount != 0) if (damageAmount != 0)
{ {
// float f1 = this.getHealth(); // float f1 = this.getHealth();
this.setHealth(this.getHealth() - damageAmount); this.setHealth(this.getHealth() - damageAmount);
this.trackDamage(damageSrc, damageAmount); this.trackDamage(damageSrc, damageAmount);
this.setAbsorptionAmount(this.getAbsorptionAmount() - damageAmount); this.setAbsorptionAmount(this.getAbsorptionAmount() - damageAmount);
}
} }
// }
} }
public EntityLiving getAttackingEntity() public EntityLiving getAttackingEntity()