Fixed the LivingArmourHandler for defense so it no longer ate armour.
This commit is contained in:
parent
b70c71f7be
commit
e888907350
|
@ -1,3 +1,8 @@
|
||||||
|
------------------------------------------------------
|
||||||
|
Version 2.0.0-6
|
||||||
|
------------------------------------------------------
|
||||||
|
- Fixed the LivingArmourTracker for defense so that it no longer ate up armour (om nom nom nom)
|
||||||
|
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
Version 2.0.0-5
|
Version 2.0.0-5
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
|
|
|
@ -50,10 +50,16 @@ public class TileInputRoutingNode extends TileFilteredRoutingNode implements IIn
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
filteredList.add(GhostItemHelper.getStackFromGhost(stack));
|
ItemStack ghostResult = GhostItemHelper.getStackFromGhost(stack);
|
||||||
|
// if (ghostResult.stackSize == 0)
|
||||||
|
// {
|
||||||
|
// ghostResult.stackSize = Int.MaxValue();
|
||||||
|
// }
|
||||||
|
|
||||||
|
filteredList.add(ghostResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
testFilter.initializeFilter(filteredList, (IInventory) tile, side, false);
|
testFilter.initializeFilter(filteredList, (IInventory) tile, side.getOpposite(), false);
|
||||||
|
|
||||||
return testFilter;
|
return testFilter;
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,7 +52,6 @@ public class TileMasterRoutingNode extends TileEntity implements IMasterRoutingN
|
||||||
{
|
{
|
||||||
if (!outputNode.isInventoryConnectedToSide(facing) || !outputNode.isOutput(facing))
|
if (!outputNode.isInventoryConnectedToSide(facing) || !outputNode.isOutput(facing))
|
||||||
{
|
{
|
||||||
System.out.println("Hello");
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,7 @@ package WayofTime.bloodmagic.tile.routing;
|
||||||
import java.util.LinkedList;
|
import java.util.LinkedList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import scala.Int;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.tileentity.TileEntity;
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
@ -50,10 +51,16 @@ public class TileOutputRoutingNode extends TileFilteredRoutingNode implements IO
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
filteredList.add(GhostItemHelper.getStackFromGhost(stack));
|
ItemStack ghostStack = GhostItemHelper.getStackFromGhost(stack);
|
||||||
|
if (ghostStack.stackSize == 0)
|
||||||
|
{
|
||||||
|
ghostStack.stackSize = Int.MaxValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
testFilter.initializeFilter(filteredList, (IInventory) tile, side, true);
|
filteredList.add(ghostStack);
|
||||||
|
}
|
||||||
|
|
||||||
|
testFilter.initializeFilter(filteredList, (IInventory) tile, side.getOpposite(), true);
|
||||||
|
|
||||||
return testFilter;
|
return testFilter;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
package WayofTime.bloodmagic.util;
|
package WayofTime.bloodmagic.util;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import net.minecraft.block.Block;
|
import net.minecraft.block.Block;
|
||||||
import net.minecraft.enchantment.EnchantmentHelper;
|
import net.minecraft.enchantment.EnchantmentHelper;
|
||||||
import net.minecraft.entity.EntityLivingBase;
|
import net.minecraft.entity.EntityLivingBase;
|
||||||
|
@ -8,6 +10,7 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||||
import net.minecraft.init.Blocks;
|
import net.minecraft.init.Blocks;
|
||||||
import net.minecraft.inventory.IInventory;
|
import net.minecraft.inventory.IInventory;
|
||||||
import net.minecraft.inventory.ISidedInventory;
|
import net.minecraft.inventory.ISidedInventory;
|
||||||
|
import net.minecraft.item.ItemArmor;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.potion.Potion;
|
import net.minecraft.potion.Potion;
|
||||||
import net.minecraft.util.DamageSource;
|
import net.minecraft.util.DamageSource;
|
||||||
|
@ -15,6 +18,8 @@ import net.minecraft.util.EnumFacing;
|
||||||
import WayofTime.bloodmagic.api.altar.EnumAltarComponent;
|
import WayofTime.bloodmagic.api.altar.EnumAltarComponent;
|
||||||
import WayofTime.bloodmagic.registry.ModBlocks;
|
import WayofTime.bloodmagic.registry.ModBlocks;
|
||||||
import WayofTime.bloodmagic.tile.TileInventory;
|
import WayofTime.bloodmagic.tile.TileInventory;
|
||||||
|
import net.minecraftforge.common.ISpecialArmor;
|
||||||
|
import net.minecraftforge.common.ISpecialArmor.ArmorProperties;
|
||||||
import net.minecraftforge.fluids.IFluidBlock;
|
import net.minecraftforge.fluids.IFluidBlock;
|
||||||
|
|
||||||
public class Utils
|
public class Utils
|
||||||
|
@ -126,7 +131,7 @@ public class Utils
|
||||||
if (amount <= 0)
|
if (amount <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
amount = net.minecraftforge.common.ISpecialArmor.ArmorProperties.applyArmor(attackedEntity, attackedEntity.getInventory(), source, amount);
|
amount = applyArmor(attackedEntity, attackedEntity.getInventory(), source, amount);
|
||||||
if (amount <= 0)
|
if (amount <= 0)
|
||||||
return 0;
|
return 0;
|
||||||
amount = applyPotionDamageCalculations(attackedEntity, source, amount);
|
amount = applyPotionDamageCalculations(attackedEntity, source, amount);
|
||||||
|
@ -137,6 +142,55 @@ public class Utils
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float applyArmor(EntityLivingBase entity, ItemStack[] inventory, DamageSource source, double damage)
|
||||||
|
{
|
||||||
|
damage *= 25;
|
||||||
|
ArrayList<ArmorProperties> dmgVals = new ArrayList<ArmorProperties>();
|
||||||
|
for (int x = 0; x < inventory.length; x++)
|
||||||
|
{
|
||||||
|
ItemStack stack = inventory[x];
|
||||||
|
if (stack == null)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
ArmorProperties prop = null;
|
||||||
|
if (stack.getItem() instanceof ISpecialArmor)
|
||||||
|
{
|
||||||
|
ISpecialArmor armor = (ISpecialArmor) stack.getItem();
|
||||||
|
prop = armor.getProperties(entity, stack, source, damage / 25D, x).copy();
|
||||||
|
} else if (stack.getItem() instanceof ItemArmor && !source.isUnblockable())
|
||||||
|
{
|
||||||
|
ItemArmor armor = (ItemArmor) stack.getItem();
|
||||||
|
prop = new ArmorProperties(0, armor.damageReduceAmount / 25D, Integer.MAX_VALUE);
|
||||||
|
}
|
||||||
|
if (prop != null)
|
||||||
|
{
|
||||||
|
prop.Slot = x;
|
||||||
|
dmgVals.add(prop);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (dmgVals.size() > 0)
|
||||||
|
{
|
||||||
|
ArmorProperties[] props = dmgVals.toArray(new ArmorProperties[dmgVals.size()]);
|
||||||
|
int level = props[0].Priority;
|
||||||
|
double ratio = 0;
|
||||||
|
for (ArmorProperties prop : props)
|
||||||
|
{
|
||||||
|
if (level != prop.Priority)
|
||||||
|
{
|
||||||
|
damage -= (damage * ratio);
|
||||||
|
ratio = 0;
|
||||||
|
level = prop.Priority;
|
||||||
|
}
|
||||||
|
ratio += prop.AbsorbRatio;
|
||||||
|
|
||||||
|
}
|
||||||
|
damage -= (damage * ratio);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (float) (damage / 25.0F);
|
||||||
|
}
|
||||||
|
|
||||||
public static float applyPotionDamageCalculations(EntityLivingBase attackedEntity, DamageSource source, float damage)
|
public static float applyPotionDamageCalculations(EntityLivingBase attackedEntity, DamageSource source, float damage)
|
||||||
{
|
{
|
||||||
if (source.isDamageAbsolute())
|
if (source.isDamageAbsolute())
|
||||||
|
|
|
@ -255,10 +255,9 @@ public class EventHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float amount = Math.min(Utils.getModifiedDamage(attackedPlayer, event.source, event.ammount), attackedPlayer.getHealth());
|
|
||||||
|
|
||||||
if (hasFullSet)
|
if (hasFullSet)
|
||||||
{
|
{
|
||||||
|
float amount = Math.min(Utils.getModifiedDamage(attackedPlayer, event.source, event.ammount), attackedPlayer.getHealth());
|
||||||
ItemStack chestStack = attackedPlayer.getCurrentArmor(2);
|
ItemStack chestStack = attackedPlayer.getCurrentArmor(2);
|
||||||
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
||||||
if (armour != null)
|
if (armour != null)
|
||||||
|
@ -295,10 +294,9 @@ public class EventHandler
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float amount = Math.min(Utils.getModifiedDamage(attackedEntity, event.source, event.ammount), attackedEntity.getHealth());
|
|
||||||
|
|
||||||
if (hasFullSet)
|
if (hasFullSet)
|
||||||
{
|
{
|
||||||
|
float amount = Math.min(Utils.getModifiedDamage(attackedEntity, event.source, event.ammount), attackedEntity.getHealth());
|
||||||
ItemStack chestStack = player.getCurrentArmor(2);
|
ItemStack chestStack = player.getCurrentArmor(2);
|
||||||
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
LivingArmour armour = ItemLivingArmour.getLivingArmour(chestStack);
|
||||||
if (armour != null)
|
if (armour != null)
|
||||||
|
|
Loading…
Reference in a new issue