mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-23 21:49:45 +00:00
port in some fixes from 1.6.x
This commit is contained in:
1 parent
cd9e0f6452
commit
9fce66a827
15 files changed
+453
-59
No files matched your search
@@ -62,6 +62,10 @@ public abstract class ArmorCore extends ItemArmor implements IEnergyContainerIte
|
||||
@Override
|
||||
public ArmorProperties getProperties (EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot)
|
||||
{
|
||||
if (player.worldObj.isRemote)
|
||||
{
|
||||
return new ArmorProperties(0, 0, baseProtection);
|
||||
}
|
||||
NBTTagCompound tags = armor.getTagCompound();
|
||||
|
||||
if (tags == null)
|
||||
@@ -71,14 +75,28 @@ public abstract class ArmorCore extends ItemArmor implements IEnergyContainerIte
|
||||
|
||||
NBTTagCompound data = tags.getCompoundTag(SET_NAME);
|
||||
|
||||
return new ArmorProperties(0, data.getInteger("damageReduction") / damage, data.getInteger("maxAbsorb"));
|
||||
double amount = (data.getInteger("defense") / damage) + (data.getDouble("protection") / 100);
|
||||
if (source.isUnblockable())
|
||||
amount = 0;
|
||||
clamp_double(amount, 0, 1);
|
||||
return new ArmorProperties(0, amount, 100);
|
||||
}
|
||||
|
||||
public static double clamp_double (double par0, double par1, double par2)
|
||||
{
|
||||
return par0 < par1 ? par1 : (par0 > par2 ? par2 : par0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getArmorDisplay (EntityPlayer player, ItemStack armor, int slot)
|
||||
{
|
||||
return armor.getTagCompound() != null && armor.getTagCompound().getCompoundTag(SET_NAME) != null ? armor.getTagCompound().getCompoundTag(SET_NAME).getInteger("maxAbsorb")
|
||||
: this.baseProtection;
|
||||
if (!armor.hasTagCompound())
|
||||
return this.baseProtection;
|
||||
NBTTagCompound armorTag = armor.getTagCompound().getCompoundTag(SET_NAME);
|
||||
double amount = armorTag.getDouble("protection") / 4;
|
||||
if (amount > 0 && amount < 1)
|
||||
amount = 1;
|
||||
return (int) (Math.floor(amount));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -93,9 +111,7 @@ public abstract class ArmorCore extends ItemArmor implements IEnergyContainerIte
|
||||
stack.setTagCompound(tags);
|
||||
data = new NBTTagCompound();
|
||||
tags.setTag(SET_NAME, data);
|
||||
data.setInteger("damageReduction", baseProtection);
|
||||
data.setInteger("maxAbsorb", baseProtection);
|
||||
}
|
||||
data.setDouble("damageReduction", baseProtection); }
|
||||
|
||||
data = tags.getCompoundTag(SET_NAME);
|
||||
|
||||
@@ -114,7 +130,7 @@ public abstract class ArmorCore extends ItemArmor implements IEnergyContainerIte
|
||||
tags.setInteger("Energy", 0);
|
||||
int dmg = data.getInteger("Damage");
|
||||
dmg += damage;
|
||||
data.setInteger("Damage", dmg);
|
||||
data.setDouble("Damage", dmg);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -192,6 +208,7 @@ public abstract class ArmorCore extends ItemArmor implements IEnergyContainerIte
|
||||
}
|
||||
return tags.getInteger("Energy");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxEnergyStored (ItemStack container)
|
||||
{
|
||||
@@ -200,6 +217,7 @@ public abstract class ArmorCore extends ItemArmor implements IEnergyContainerIte
|
||||
return 0;
|
||||
return capacity;
|
||||
}
|
||||
|
||||
//end of TE support section
|
||||
|
||||
// Vanilla overrides
|
||||
|
||||
@@ -9,6 +9,7 @@ import net.minecraft.init.Items;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import cpw.mods.fml.common.event.*;
|
||||
import cpw.mods.fml.common.eventhandler.Event.Result;
|
||||
@@ -384,6 +385,8 @@ public class ToolBuilder
|
||||
public ItemStack modifyArmor (ItemStack input, ItemStack[] slots, String name)
|
||||
{
|
||||
ItemStack armor = input.copy();
|
||||
if (!armor.hasTagCompound())
|
||||
addArmorTag(input);
|
||||
NBTTagCompound tags = armor.getTagCompound().getCompoundTag("TinkerArmor");
|
||||
tags.removeTag("Built");
|
||||
|
||||
@@ -449,6 +452,18 @@ public class ToolBuilder
|
||||
return null;
|
||||
}
|
||||
|
||||
public void addArmorTag (ItemStack armor) //Not sure if temporary or not
|
||||
{
|
||||
NBTTagCompound baseTag = new NBTTagCompound();
|
||||
NBTTagList list = new NBTTagList();
|
||||
|
||||
NBTTagCompound armorTag = new NBTTagCompound();
|
||||
armorTag.setInteger("Modifiers", 30);
|
||||
baseTag.setTag("TinkerArmor", armorTag);
|
||||
|
||||
armor.setTagCompound(baseTag);
|
||||
}
|
||||
|
||||
int buildReinforced (TToolMaterial headMat, TToolMaterial handleMat, TToolMaterial accessoryMat, TToolMaterial extraMat)
|
||||
{
|
||||
int reinforced = 0;
|
||||
@@ -499,8 +514,8 @@ public class ToolBuilder
|
||||
throw new NullPointerException("Tool modifier cannot be null.");
|
||||
instance.toolMods.add(mod);
|
||||
}
|
||||
|
||||
public static void registerArmorMod(ArmorMod mod)
|
||||
|
||||
public static void registerArmorMod (ArmorMod mod)
|
||||
{
|
||||
if (mod == null)
|
||||
throw new NullPointerException("Armor modifier cannot be null.");
|
||||
|
||||
@@ -455,7 +455,7 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem, IBa
|
||||
}
|
||||
if (getPartAmount() >= 4)
|
||||
{
|
||||
current = extraMat.reinforced();
|
||||
current = extraMat.reinforced();
|
||||
if (current > 0 && current > reinforced)
|
||||
{
|
||||
style = extraMat.style();
|
||||
@@ -546,7 +546,7 @@ public abstract class ToolCore extends Item implements IEnergyContainerItem, IBa
|
||||
boolean supress = false;
|
||||
try
|
||||
{
|
||||
clazz = Class.forName(tconstruct.common.TContent.class.getName());
|
||||
clazz = Class.forName("tconstruct.common.TRepo"); //TODO: Make sure this is still working in 1.7.
|
||||
fld = clazz.getField("supressMissingToolLogs");
|
||||
supress = fld.getBoolean(fld);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user