Minor Living Armor cleanup

This commit is contained in:
Nick 2016-01-28 22:37:19 -08:00
parent 3da5734225
commit e0fcf10a1b
10 changed files with 41 additions and 94 deletions

View file

@ -5,6 +5,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map.Entry;
import WayofTime.bloodmagic.item.armour.ItemLivingArmour;
import net.minecraft.entity.ai.attributes.AttributeModifier;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
@ -238,4 +239,13 @@ public class LivingArmour implements ILivingArmour
{
writeToNBT(tag, true);
}
public static boolean hasFullSet(EntityPlayer player) {
for (int slot = 0; slot < player.inventory.armorInventory.length; slot++) {
if (!(player.inventory.armorItemInSlot(slot).getItem() instanceof ItemLivingArmour))
return false;
}
return true;
}
}

View file

@ -73,7 +73,6 @@ public class StatTrackerArrowShot extends StatTracker
@Override
public List<LivingArmourUpgrade> getUpgrades()
{
// TODO Auto-generated method stub
List<LivingArmourUpgrade> upgradeList = new ArrayList<LivingArmourUpgrade>();
for (int i = 0; i < 5; i++)

View file

@ -73,7 +73,6 @@ public class StatTrackerDigging extends StatTracker
@Override
public List<LivingArmourUpgrade> getUpgrades()
{
// TODO Auto-generated method stub
List<LivingArmourUpgrade> upgradeList = new ArrayList<LivingArmourUpgrade>();
for (int i = 0; i < 5; i++)

View file

@ -75,7 +75,6 @@ public class StatTrackerFood extends StatTracker
@Override
public List<LivingArmourUpgrade> getUpgrades()
{
// TODO Auto-generated method stub
List<LivingArmourUpgrade> upgradeList = new ArrayList<LivingArmourUpgrade>();
for (int i = 0; i < foodRequired.length; i++)

View file

@ -73,7 +73,6 @@ public class StatTrackerHealthboost extends StatTracker
@Override
public List<LivingArmourUpgrade> getUpgrades()
{
// TODO Auto-generated method stub
List<LivingArmourUpgrade> upgradeList = new ArrayList<LivingArmourUpgrade>();
for (int i = 0; i < 10; i++)

View file

@ -73,7 +73,6 @@ public class StatTrackerMeleeDamage extends StatTracker
@Override
public List<LivingArmourUpgrade> getUpgrades()
{
// TODO Auto-generated method stub
List<LivingArmourUpgrade> upgradeList = new ArrayList<LivingArmourUpgrade>();
for (int i = 0; i < 10; i++)

View file

@ -86,7 +86,6 @@ public class StatTrackerMovement extends StatTracker
@Override
public List<LivingArmourUpgrade> getUpgrades()
{
// TODO Auto-generated method stub
List<LivingArmourUpgrade> upgradeList = new ArrayList<LivingArmourUpgrade>();
for (int i = 0; i < 10; i++)

View file

@ -73,7 +73,6 @@ public class StatTrackerPhysicalProtect extends StatTracker
@Override
public List<LivingArmourUpgrade> getUpgrades()
{
// TODO Auto-generated method stub
List<LivingArmourUpgrade> upgradeList = new ArrayList<LivingArmourUpgrade>();
for (int i = 0; i < 1; i++)

View file

@ -59,7 +59,6 @@ public class StatTrackerPoison extends StatTracker
@Override
public List<LivingArmourUpgrade> getUpgrades()
{
// TODO Auto-generated method stub
List<LivingArmourUpgrade> upgradeList = new ArrayList<LivingArmourUpgrade>();
for (int i = 0; i < 3; i++)

View file

@ -148,24 +148,18 @@ public class EventHandler
EntityPlayer player = event.getPlayer();
if (player != null)
{
for (int i = 0; i < 4; i++)
if (LivingArmour.hasFullSet(player))
{
ItemStack stack = player.getCurrentArmor(i);
if (stack == null || !(stack.getItem() instanceof ItemLivingArmour))
ItemStack chestStack = player.getCurrentArmor(2);
if (chestStack != null && chestStack.getItem() instanceof ItemLivingArmour)
{
return;
}
}
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
ItemStack chestStack = player.getCurrentArmor(2);
if (chestStack != null && chestStack.getItem() instanceof ItemLivingArmour)
{
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
if (armour != null)
{
StatTrackerDigging.incrementCounter(armour);
LivingArmourUpgradeDigging.hasDug(armour);
if (armour != null)
{
StatTrackerDigging.incrementCounter(armour);
LivingArmourUpgradeDigging.hasDug(armour);
}
}
}
}
@ -176,27 +170,21 @@ public class EventHandler
{
EntityPlayer player = event.player;
for (int i = 0; i < 4; i++)
if (LivingArmour.hasFullSet(player))
{
ItemStack stack = player.getCurrentArmor(i);
if (stack == null || !(stack.getItem() instanceof ItemLivingArmour))
ItemStack chestStack = player.getCurrentArmor(2);
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
if (armour != null)
{
return;
}
}
StatTrackerSelfSacrifice.incrementCounter(armour);
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(Constants.Mod.MODID + ".upgrade.selfSacrifice", chestStack);
ItemStack chestStack = player.getCurrentArmor(2);
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
if (armour != null)
{
StatTrackerSelfSacrifice.incrementCounter(armour);
LivingArmourUpgrade upgrade = ItemLivingArmour.getUpgrade(Constants.Mod.MODID + ".upgrade.selfSacrifice", chestStack);
if (upgrade instanceof LivingArmourUpgradeSelfSacrifice)
{
double modifier = ((LivingArmourUpgradeSelfSacrifice) upgrade).getSacrificeModifier();
if (upgrade instanceof LivingArmourUpgradeSelfSacrifice)
{
double modifier = ((LivingArmourUpgradeSelfSacrifice) upgrade).getSacrificeModifier();
event.lpAdded = (int) (event.lpAdded * (1 + modifier));
event.lpAdded = (int) (event.lpAdded * (1 + modifier));
}
}
}
}
@ -212,20 +200,12 @@ public class EventHandler
EntityPlayer player = (EntityPlayer) healedEntity;
for (int i = 0; i < 4; i++)
if (LivingArmour.hasFullSet(player))
{
ItemStack stack = player.getCurrentArmor(i);
if (stack == null || !(stack.getItem() instanceof ItemLivingArmour))
{
return;
}
}
ItemStack chestStack = player.getCurrentArmor(2);
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
if (armour != null)
{
StatTrackerHealthboost.incrementCounter(armour, event.amount);
ItemStack chestStack = player.getCurrentArmor(2);
LivingArmour armour = ItemLivingArmour.armourMap.get(chestStack);
if (armour != null)
StatTrackerHealthboost.incrementCounter(armour, event.amount);
}
}
@ -245,20 +225,8 @@ public class EventHandler
{
EntityPlayer attackedPlayer = (EntityPlayer) attackedEntity;
// Living Armour handling
boolean hasFullSet = true;
for (int i = 0; i < 4; i++)
{
ItemStack stack = attackedPlayer.getCurrentArmor(i);
if (stack == null || !(stack.getItem() instanceof ItemLivingArmour))
{
hasFullSet = false;
break;
}
}
if (hasFullSet)
// Living Armor Handling
if (LivingArmour.hasFullSet(attackedPlayer))
{
float amount = Math.min(Utils.getModifiedDamage(attackedPlayer, event.source, event.ammount), attackedPlayer.getHealth());
ItemStack chestStack = attackedPlayer.getCurrentArmor(2);
@ -284,27 +252,15 @@ public class EventHandler
{
EntityPlayer player = (EntityPlayer) sourceEntity;
// Living Armour handling
boolean hasFullSet = true;
for (int i = 0; i < 4; i++)
{
ItemStack stack = player.getCurrentArmor(i);
if (stack == null || !(stack.getItem() instanceof ItemLivingArmour))
{
hasFullSet = false;
break;
}
}
if (hasFullSet)
// Living Armor Handling
if (LivingArmour.hasFullSet(player))
{
float amount = Math.min(Utils.getModifiedDamage(attackedEntity, event.source, event.ammount), attackedEntity.getHealth());
ItemStack chestStack = player.getCurrentArmor(2);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
if (armour != null)
{
if (sourceEntity != null && !source.isProjectile())
if (!source.isProjectile())
{
StatTrackerMeleeDamage.incrementCounter(armour, amount);
}
@ -320,18 +276,7 @@ public class EventHandler
ItemStack stack = event.bow;
EntityPlayer player = event.entityPlayer;
boolean hasFullSet = true;
for (int i = 0; i < 4; i++)
{
ItemStack armourStack = player.getCurrentArmor(i);
if (armourStack == null || !(armourStack.getItem() instanceof ItemLivingArmour))
{
hasFullSet = false;
break;
}
}
if (hasFullSet)
if (LivingArmour.hasFullSet(player))
{
ItemStack chestStack = player.getCurrentArmor(2);
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);