Reorganized SpecialArmor code to work properly.
This commit is contained in:
parent
92b2a3666e
commit
7a6193e8f5
2 changed files with 33 additions and 30 deletions
|
@ -93,35 +93,36 @@
|
||||||
public boolean canHarvestBlock(Block block)
|
public boolean canHarvestBlock(Block block)
|
||||||
{
|
{
|
||||||
return inventory.canHarvestBlock(block);
|
return inventory.canHarvestBlock(block);
|
||||||
@@ -764,6 +820,27 @@
|
@@ -768,8 +824,26 @@
|
||||||
|
{
|
||||||
protected void damageEntity(DamageSource damagesource, int i)
|
i = 1 + i >> 1;
|
||||||
{
|
}
|
||||||
+ boolean doRegularComputation = true;
|
- i = applyArmorCalculations(damagesource, i);
|
||||||
|
- i = applyPotionDamageCalculations(damagesource, i);
|
||||||
|
+
|
||||||
|
+ boolean doRegularComputation = true;
|
||||||
+ int initialDamage = i;
|
+ int initialDamage = i;
|
||||||
+
|
+
|
||||||
+ for (ItemStack stack : inventory.armorInventory)
|
+ for (ItemStack stack : inventory.armorInventory)
|
||||||
+ {
|
+ {
|
||||||
+ if (stack != null && stack.getItem() instanceof ISpecialArmor)
|
+ if (stack != null && stack.getItem() instanceof ISpecialArmor)
|
||||||
+ {
|
+ {
|
||||||
+ ISpecialArmor armor = (ISpecialArmor) stack.getItem();
|
+ ISpecialArmor armor = (ISpecialArmor)stack.getItem();
|
||||||
+
|
|
||||||
+ ArmorProperties props = armor.getProperties(this, initialDamage, i);
|
+ ArmorProperties props = armor.getProperties(this, initialDamage, i);
|
||||||
+ i = i - props.damageRemove;
|
+ i = i - props.damageRemove;
|
||||||
+ doRegularComputation = doRegularComputation && props.allowRegularComputation;
|
+ doRegularComputation = doRegularComputation && props.allowRegularComputation;
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ if (!doRegularComputation)
|
+ if (doRegularComputation)
|
||||||
+ {
|
+ {
|
||||||
+ super.damageEntity(damagesource, i);
|
+ i = applyArmorCalculations(damagesource, i);
|
||||||
+ return;
|
+ i = applyPotionDamageCalculations(damagesource, i);
|
||||||
+ }
|
+ }
|
||||||
+
|
addExhaustion(damagesource.getHungerDamage());
|
||||||
if (!damagesource.isUnblockable() && isBlocking())
|
health -= i;
|
||||||
{
|
}
|
||||||
i = 1 + i >> 1;
|
@@ -815,7 +889,9 @@
|
||||||
@@ -815,7 +892,9 @@
|
|
||||||
|
|
||||||
public void destroyCurrentEquippedItem()
|
public void destroyCurrentEquippedItem()
|
||||||
{
|
{
|
||||||
|
@ -131,7 +132,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getYOffset()
|
public double getYOffset()
|
||||||
@@ -947,6 +1026,11 @@
|
@@ -947,6 +1023,11 @@
|
||||||
|
|
||||||
public EnumStatus sleepInBedAt(int i, int j, int k)
|
public EnumStatus sleepInBedAt(int i, int j, int k)
|
||||||
{
|
{
|
||||||
|
|
|
@ -103,10 +103,13 @@
|
||||||
public boolean canHarvestBlock(Block block)
|
public boolean canHarvestBlock(Block block)
|
||||||
{
|
{
|
||||||
return inventory.canHarvestBlock(block);
|
return inventory.canHarvestBlock(block);
|
||||||
@@ -707,6 +766,26 @@
|
@@ -711,8 +770,26 @@
|
||||||
|
{
|
||||||
protected void damageEntity(DamageSource damagesource, int i)
|
i = 1 + i >> 1;
|
||||||
{
|
}
|
||||||
|
- i = applyArmorCalculations(damagesource, i);
|
||||||
|
- i = applyPotionDamageCalculations(damagesource, i);
|
||||||
|
+
|
||||||
+ boolean doRegularComputation = true;
|
+ boolean doRegularComputation = true;
|
||||||
+ int initialDamage = i;
|
+ int initialDamage = i;
|
||||||
+
|
+
|
||||||
|
@ -114,23 +117,22 @@
|
||||||
+ {
|
+ {
|
||||||
+ if (stack != null && stack.getItem() instanceof ISpecialArmor)
|
+ if (stack != null && stack.getItem() instanceof ISpecialArmor)
|
||||||
+ {
|
+ {
|
||||||
+ ISpecialArmor armor = (ISpecialArmor) stack.getItem();
|
+ ISpecialArmor armor = (ISpecialArmor)stack.getItem();
|
||||||
+ ArmorProperties props = armor.getProperties(this, initialDamage, i);
|
+ ArmorProperties props = armor.getProperties(this, initialDamage, i);
|
||||||
+ i = i - props.damageRemove;
|
+ i = i - props.damageRemove;
|
||||||
+ doRegularComputation = doRegularComputation && props.allowRegularComputation;
|
+ doRegularComputation = doRegularComputation && props.allowRegularComputation;
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
+
|
+
|
||||||
+ if (!doRegularComputation)
|
+ if (doRegularComputation)
|
||||||
+ {
|
+ {
|
||||||
+ super.damageEntity(damagesource, i);
|
+ i = applyArmorCalculations(damagesource, i);
|
||||||
+ return;
|
+ i = applyPotionDamageCalculations(damagesource, i);
|
||||||
+ }
|
+ }
|
||||||
+
|
addExhaustion(damagesource.getHungerDamage());
|
||||||
if (!damagesource.isUnblockable() && isBlocking())
|
health -= i;
|
||||||
{
|
}
|
||||||
i = 1 + i >> 1;
|
@@ -758,7 +835,9 @@
|
||||||
@@ -758,7 +837,9 @@
|
|
||||||
|
|
||||||
public void destroyCurrentEquippedItem()
|
public void destroyCurrentEquippedItem()
|
||||||
{
|
{
|
||||||
|
@ -140,7 +142,7 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getYOffset()
|
public double getYOffset()
|
||||||
@@ -884,6 +965,11 @@
|
@@ -884,6 +963,11 @@
|
||||||
|
|
||||||
public EnumStatus sleepInBedAt(int i, int j, int k)
|
public EnumStatus sleepInBedAt(int i, int j, int k)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue