mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-23 21:49:45 +00:00
Fix JABBA-related issues with crafting station slots (#54)
* Fix shift-merging tools voiding items fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/11392> * Change 0-sized ItemStacks into null stacks in crafting station attached slots Fixes <https://github.com/GTNewHorizons/GT-New-Horizons-Modpack/issues/10425> * Update buildscript * spotlessApply
This commit is contained in:
1 parent
18bfeaff32
commit
39be06c23b
571 files changed
+25959
-28223
No files matched your search
@@ -20,8 +20,7 @@ import tconstruct.library.modifier.*;
|
||||
import tconstruct.library.tools.ToolCore;
|
||||
import tconstruct.tools.entity.FancyEntityItem;
|
||||
|
||||
public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IModifyable
|
||||
{
|
||||
public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IModifyable {
|
||||
public final ArmorPart armorPart;
|
||||
private static final IBehaviorDispenseItem dispenserBehavior = new BehaviorDispenseArmorCopy();
|
||||
public final int baseProtection;
|
||||
@@ -29,8 +28,7 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
protected final String textureFolder;
|
||||
protected final String textureName;
|
||||
|
||||
public ArmorCore(int baseProtection, ArmorPart part, String type, String textureFolder, String textureName)
|
||||
{
|
||||
public ArmorCore(int baseProtection, ArmorPart part, String type, String textureFolder, String textureName) {
|
||||
super(ArmorMaterial.CHAIN, 0, part.getPartId());
|
||||
this.maxStackSize = 1;
|
||||
this.setMaxDamage(100);
|
||||
@@ -43,46 +41,42 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
this.setCreativeTab(TConstructRegistry.equipableTab);
|
||||
}
|
||||
|
||||
public ArmorCore(int baseProtection, ArmorPart part, String type, String textureName)
|
||||
{
|
||||
public ArmorCore(int baseProtection, ArmorPart part, String type, String textureName) {
|
||||
this(baseProtection, part, type, "armor", textureName);
|
||||
}
|
||||
|
||||
//Temporary?
|
||||
public abstract ItemStack getRepairMaterial (ItemStack input);
|
||||
// Temporary?
|
||||
public abstract ItemStack getRepairMaterial(ItemStack input);
|
||||
|
||||
public String getArmorName ()
|
||||
{
|
||||
public String getArmorName() {
|
||||
return this.getClass().getSimpleName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBaseTagName ()
|
||||
{
|
||||
public String getBaseTagName() {
|
||||
return "TinkerArmor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getModifyType ()
|
||||
{
|
||||
public String getModifyType() {
|
||||
return modifyType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getTraits ()
|
||||
{
|
||||
return new String[] { "armor" };
|
||||
public String[] getTraits() {
|
||||
return new String[] {"armor"};
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick (ItemStack stack, World world, EntityPlayer player)
|
||||
{
|
||||
public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
|
||||
int i = EntityLiving.getArmorPosition(stack) - 1;
|
||||
ItemStack itemstack1 = player.getCurrentArmor(i);
|
||||
|
||||
if (itemstack1 == null)
|
||||
{
|
||||
player.setCurrentItemOrArmor(i + 1, stack.copy()); //Forge: Vanilla bug fix associated with fixed setCurrentItemOrArmor indexs for players.
|
||||
if (itemstack1 == null) {
|
||||
player.setCurrentItemOrArmor(
|
||||
i + 1,
|
||||
stack.copy()); // Forge: Vanilla bug fix associated with fixed setCurrentItemOrArmor indexs for
|
||||
// players.
|
||||
stack.stackSize = 0;
|
||||
}
|
||||
|
||||
@@ -90,20 +84,16 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmorTick (World world, EntityPlayer player, ItemStack itemStack)
|
||||
{
|
||||
for (ActiveArmorMod mod : TConstructRegistry.activeArmorModifiers)
|
||||
{
|
||||
public void onArmorTick(World world, EntityPlayer player, ItemStack itemStack) {
|
||||
for (ActiveArmorMod mod : TConstructRegistry.activeArmorModifiers) {
|
||||
mod.onArmorTick(world, player, itemStack, this, this.armorPart);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getArmorTexture (ItemStack stack, Entity entity, int slot, String type)
|
||||
{
|
||||
if (slot == 2)
|
||||
return "tinker:textures/armor/" + textureName + "_" + 2 + ".png";
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
|
||||
if (slot == 2) return "tinker:textures/armor/" + textureName + "_" + 2 + ".png";
|
||||
return "tinker:textures/armor/" + textureName + "_" + 1 + ".png";
|
||||
}
|
||||
|
||||
@@ -112,31 +102,29 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons (IIconRegister iconRegister)
|
||||
{
|
||||
this.itemIcon = iconRegister.registerIcon("tinker:" + textureFolder + "/" + textureName + (this.armorType == 0 ? "helmet" : this.armorType == 1 ? "chestplate" : this.armorType == 2 ? "pants" : this.armorType == 3 ? "boots" : "helmet"));
|
||||
public void registerIcons(IIconRegister iconRegister) {
|
||||
this.itemIcon = iconRegister.registerIcon("tinker:" + textureFolder + "/" + textureName
|
||||
+ (this.armorType == 0
|
||||
? "helmet"
|
||||
: this.armorType == 1
|
||||
? "chestplate"
|
||||
: this.armorType == 2 ? "pants" : this.armorType == 3 ? "boots" : "helmet"));
|
||||
registerModifiers(iconRegister);
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public IIcon getIcon (ItemStack stack, int renderPass)
|
||||
{
|
||||
if (renderPass > 0)
|
||||
{
|
||||
if (stack.hasTagCompound())
|
||||
{
|
||||
public IIcon getIcon(ItemStack stack, int renderPass) {
|
||||
if (renderPass > 0) {
|
||||
if (stack.hasTagCompound()) {
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag(getBaseTagName());
|
||||
if (renderPass == 1 && tags.hasKey("Effect1"))
|
||||
{
|
||||
if (renderPass == 1 && tags.hasKey("Effect1")) {
|
||||
return modifiers[tags.getInteger("Effect1")];
|
||||
}
|
||||
if (renderPass == 2 && tags.hasKey("Effect2"))
|
||||
{
|
||||
if (renderPass == 2 && tags.hasKey("Effect2")) {
|
||||
return modifiers[tags.getInteger("Effect2")];
|
||||
}
|
||||
if (renderPass == 3 && tags.hasKey("Effect3"))
|
||||
{
|
||||
if (renderPass == 3 && tags.hasKey("Effect3")) {
|
||||
return modifiers[tags.getInteger("Effect3")];
|
||||
}
|
||||
}
|
||||
@@ -147,55 +135,46 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
protected void registerModifiers (IIconRegister iconRegister)
|
||||
{
|
||||
}
|
||||
protected void registerModifiers(IIconRegister iconRegister) {}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean requiresMultipleRenderPasses ()
|
||||
{
|
||||
public boolean requiresMultipleRenderPasses() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public int getRenderPasses (int metadata)
|
||||
{
|
||||
public int getRenderPasses(int metadata) {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean hasEffect (ItemStack par1ItemStack)
|
||||
{
|
||||
public boolean hasEffect(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//ISpecialArmor overrides
|
||||
// ISpecialArmor overrides
|
||||
@Override
|
||||
public ArmorProperties getProperties (EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot)
|
||||
{
|
||||
//Priority, absorbRatio, max
|
||||
if (!armor.hasTagCompound() || source.isUnblockable())
|
||||
return new ArmorProperties(0, 0, 0);
|
||||
public ArmorProperties getProperties(
|
||||
EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) {
|
||||
// Priority, absorbRatio, max
|
||||
if (!armor.hasTagCompound() || source.isUnblockable()) return new ArmorProperties(0, 0, 0);
|
||||
|
||||
NBTTagCompound tags = armor.getTagCompound().getCompoundTag(getBaseTagName());
|
||||
if (tags.getBoolean("Broken"))
|
||||
return new ArmorProperties(0, 0, 0);
|
||||
if (tags.getBoolean("Broken")) return new ArmorProperties(0, 0, 0);
|
||||
|
||||
double current = getProtection(tags);
|
||||
|
||||
return new ArmorProperties(0, current / 100, 100);
|
||||
}
|
||||
|
||||
public double getProtection(ItemStack stack)
|
||||
{
|
||||
public double getProtection(ItemStack stack) {
|
||||
return getProtection(stack.getTagCompound().getCompoundTag(getBaseTagName()));
|
||||
}
|
||||
|
||||
public double getProtection(NBTTagCompound tags)
|
||||
{
|
||||
public double getProtection(NBTTagCompound tags) {
|
||||
float maxDurability = tags.getInteger("TotalDurability");
|
||||
float currentDurability = maxDurability - tags.getInteger("Damage");
|
||||
float ratio = currentDurability / maxDurability;
|
||||
@@ -207,59 +186,46 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getArmorDisplay (EntityPlayer player, ItemStack armor, int slot)
|
||||
{
|
||||
if (slot != 1)
|
||||
{
|
||||
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
|
||||
if (slot != 1) {
|
||||
ItemStack stack = player.getCurrentArmor(1);
|
||||
if (stack != null && stack.getItem() instanceof ArmorCore)
|
||||
return 0;
|
||||
if (stack != null && stack.getItem() instanceof ArmorCore) return 0;
|
||||
return disconnectedArmorDisplay(player, armor, slot);
|
||||
}
|
||||
|
||||
return combinedArmorDisplay(player, armor);
|
||||
}
|
||||
|
||||
protected int disconnectedArmorDisplay (EntityPlayer player, ItemStack armor, int slot)
|
||||
{
|
||||
if (!armor.hasTagCompound())
|
||||
return 0;
|
||||
protected int disconnectedArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
|
||||
if (!armor.hasTagCompound()) return 0;
|
||||
|
||||
NBTTagCompound armorTag = armor.getTagCompound().getCompoundTag(getBaseTagName());
|
||||
if (armorTag.getBoolean("Broken"))
|
||||
return 0;
|
||||
if (armorTag.getBoolean("Broken")) return 0;
|
||||
|
||||
float max = armorTag.getInteger("TotalDurability");
|
||||
float current = max - armorTag.getInteger("Damage");
|
||||
float amount = current / max * 5 + 0.09F;
|
||||
if (slot == 2 && amount < 1)
|
||||
amount = 1;
|
||||
if (slot == 2 && amount < 1) amount = 1;
|
||||
return (int) amount;
|
||||
}
|
||||
|
||||
protected int combinedArmorDisplay (EntityPlayer player, ItemStack legs)
|
||||
{
|
||||
ItemStack[] armors = new ItemStack[] { player.getCurrentArmor(3), player.getCurrentArmor(2), legs, player.getCurrentArmor(0) };
|
||||
protected int combinedArmorDisplay(EntityPlayer player, ItemStack legs) {
|
||||
ItemStack[] armors =
|
||||
new ItemStack[] {player.getCurrentArmor(3), player.getCurrentArmor(2), legs, player.getCurrentArmor(0)};
|
||||
int types = 0;
|
||||
int max = 0;
|
||||
int damage = 0;
|
||||
boolean anyAlive = false;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
for (int i = 0; i < 4; i++) {
|
||||
ItemStack stack = armors[i];
|
||||
if (stack != null && stack.hasTagCompound())
|
||||
{
|
||||
if (stack != null && stack.hasTagCompound()) {
|
||||
NBTTagCompound armorTag = stack.getTagCompound().getCompoundTag(getBaseTagName());
|
||||
if (stack.getItem() instanceof ArmorCore)
|
||||
{
|
||||
if (stack.getItem() instanceof ArmorCore) {
|
||||
types++;
|
||||
max += armorTag.getInteger("TotalDurability");
|
||||
if (armorTag.getBoolean("Broken"))
|
||||
{
|
||||
if (armorTag.getBoolean("Broken")) {
|
||||
damage += armorTag.getInteger("TotalDurability");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
damage += armorTag.getInteger("Damage");
|
||||
anyAlive = true;
|
||||
}
|
||||
@@ -268,30 +234,23 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
}
|
||||
float ratio = ((float) max - (float) damage) / (float) max * (types * 5) + 0.1f;
|
||||
int minimum = anyAlive ? 1 : 0;
|
||||
if (ratio < minimum)
|
||||
ratio = minimum;
|
||||
if (ratio < minimum) ratio = minimum;
|
||||
return (int) ratio;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void damageArmor (EntityLivingBase entity, ItemStack armor, DamageSource source, int damage, int slot)
|
||||
{
|
||||
if (armor.hasTagCompound())
|
||||
{
|
||||
public void damageArmor(EntityLivingBase entity, ItemStack armor, DamageSource source, int damage, int slot) {
|
||||
if (armor.hasTagCompound()) {
|
||||
NBTTagCompound tags = armor.getTagCompound().getCompoundTag(getBaseTagName());
|
||||
if (!tags.getBoolean("Broken"))
|
||||
{
|
||||
if (!tags.getBoolean("Broken")) {
|
||||
int maxDurability = tags.getInteger("TotalDurability");
|
||||
int currentDurability = tags.getInteger("Damage");
|
||||
if (currentDurability + damage > maxDurability)
|
||||
{
|
||||
if (currentDurability + damage > maxDurability) {
|
||||
tags.setInteger("Damage", 0);
|
||||
tags.setBoolean("Broken", true);
|
||||
armor.setItemDamage(0);
|
||||
entity.worldObj.playSound(entity.posX, entity.posY, entity.posZ, "random.break", 1f, 1f, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
tags.setInteger("Damage", currentDurability + damage);
|
||||
armor.setItemDamage(currentDurability + damage);
|
||||
}
|
||||
@@ -301,13 +260,11 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void getSubItems (Item par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
public void getSubItems(Item par1, CreativeTabs par2CreativeTabs, List par3List) {
|
||||
par3List.add(getDefaultItem());
|
||||
}
|
||||
|
||||
public ItemStack getDefaultItem ()
|
||||
{
|
||||
public ItemStack getDefaultItem() {
|
||||
ItemStack gear = new ItemStack(this, 1, 0);
|
||||
NBTTagCompound baseTag = new NBTTagCompound();
|
||||
|
||||
@@ -322,11 +279,11 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
|
||||
int baseDurability = getDurability();
|
||||
|
||||
tag.setInteger("Damage", 0); //Damage is damage to the armor
|
||||
tag.setInteger("Damage", 0); // Damage is damage to the armor
|
||||
tag.setInteger("TotalDurability", baseDurability);
|
||||
tag.setInteger("BaseDurability", baseDurability);
|
||||
tag.setInteger("BonusDurability", 0); //Modifier
|
||||
tag.setFloat("ModDurability", 0f); //Modifier
|
||||
tag.setInteger("BonusDurability", 0); // Modifier
|
||||
tag.setFloat("ModDurability", 0f); // Modifier
|
||||
tag.setBoolean("Broken", false);
|
||||
tag.setBoolean("Built", true);
|
||||
|
||||
@@ -335,66 +292,55 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
return gear;
|
||||
}
|
||||
|
||||
protected double getFlatDefense ()
|
||||
{
|
||||
protected double getFlatDefense() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected abstract double getBaseDefense ();
|
||||
protected abstract double getBaseDefense();
|
||||
|
||||
protected abstract double getMaxDefense ();
|
||||
protected abstract double getMaxDefense();
|
||||
|
||||
protected abstract int getDurability ();
|
||||
protected abstract int getDurability();
|
||||
|
||||
// Vanilla overrides
|
||||
public boolean isItemTool (ItemStack par1ItemStack)
|
||||
{
|
||||
public boolean isItemTool(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable (ItemStack par1ItemStack, ItemStack par2ItemStack)
|
||||
{
|
||||
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isRepairable ()
|
||||
{
|
||||
public boolean isRepairable() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public int getItemEnchantability ()
|
||||
{
|
||||
public int getItemEnchantability() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean isFull3D ()
|
||||
{
|
||||
public boolean isFull3D() {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isValidArmor (ItemStack stack, int armorType, Entity entity)
|
||||
{
|
||||
public boolean isValidArmor(ItemStack stack, int armorType, Entity entity) {
|
||||
return this.armorPart.getPartId() == armorType;
|
||||
}
|
||||
|
||||
/* Proper stack damage */
|
||||
public int getItemMaxDamageFromStack (ItemStack stack)
|
||||
{
|
||||
public int getItemMaxDamageFromStack(ItemStack stack) {
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
if (tags == null)
|
||||
{
|
||||
if (tags == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return tags.getCompoundTag(getBaseTagName()).getInteger("TotalDurability");
|
||||
}
|
||||
|
||||
public int getItemMaxDamageFromStackForDisplay (ItemStack stack)
|
||||
{
|
||||
public int getItemMaxDamageFromStackForDisplay(ItemStack stack) {
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
if (tags == null)
|
||||
{
|
||||
if (tags == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -405,52 +351,43 @@ public abstract class ArmorCore extends ItemArmor implements ISpecialArmor, IMod
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation (ItemStack stack, EntityPlayer player, List list, boolean par4)
|
||||
{
|
||||
if (!stack.hasTagCompound())
|
||||
return;
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean par4) {
|
||||
if (!stack.hasTagCompound()) return;
|
||||
NBTTagCompound tags = stack.getTagCompound().getCompoundTag(getBaseTagName());
|
||||
double protection = 0;
|
||||
if (!tags.getBoolean("Broken"))
|
||||
{
|
||||
if (!tags.getBoolean("Broken")) {
|
||||
protection = getProtection(tags);
|
||||
}
|
||||
if (protection > 0)
|
||||
list.add("\u00a77" + StatCollector.translateToLocal("armor.core.protection") + df.format(protection) + "%");
|
||||
else
|
||||
list.add("\u00A7o" + StatCollector.translateToLocal("armor.core.broken"));
|
||||
else list.add("\u00A7o" + StatCollector.translateToLocal("armor.core.broken"));
|
||||
|
||||
boolean displayToolTips = true;
|
||||
int tipNum = 0;
|
||||
while (displayToolTips)
|
||||
{
|
||||
while (displayToolTips) {
|
||||
tipNum++;
|
||||
String tooltip = "Tooltip" + tipNum;
|
||||
if (tags.hasKey(tooltip))
|
||||
{
|
||||
if (tags.hasKey(tooltip)) {
|
||||
String tipName = tags.getString(tooltip);
|
||||
// let's see if we can translate it somehow
|
||||
// strip color information
|
||||
String locString = "modifier.tooltip." + EnumChatFormatting.getTextWithoutFormattingCodes(tipName);
|
||||
locString = locString.replace(" ", "");
|
||||
if(StatCollector.canTranslate(locString))
|
||||
tipName = tipName.replace(EnumChatFormatting.getTextWithoutFormattingCodes(tipName), StatCollector.translateToLocal(locString));
|
||||
if (!tipName.equals(""))
|
||||
list.add(tipName);
|
||||
}
|
||||
else
|
||||
displayToolTips = false;
|
||||
if (StatCollector.canTranslate(locString))
|
||||
tipName = tipName.replace(
|
||||
EnumChatFormatting.getTextWithoutFormattingCodes(tipName),
|
||||
StatCollector.translateToLocal(locString));
|
||||
if (!tipName.equals("")) list.add(tipName);
|
||||
} else displayToolTips = false;
|
||||
}
|
||||
}
|
||||
|
||||
/* Prevent armor from dying */
|
||||
public boolean hasCustomEntity (ItemStack stack)
|
||||
{
|
||||
public boolean hasCustomEntity(ItemStack stack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public Entity createEntity (World world, Entity location, ItemStack itemstack)
|
||||
{
|
||||
public Entity createEntity(World world, Entity location, ItemStack itemstack) {
|
||||
return new FancyEntityItem(world, location, itemstack);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,25 +5,20 @@ import net.minecraft.item.*;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import tconstruct.library.modifier.*;
|
||||
|
||||
public abstract class ArmorMod extends ItemModifier
|
||||
{
|
||||
public abstract class ArmorMod extends ItemModifier {
|
||||
protected final EnumSet<ArmorPart> armorTypes;
|
||||
|
||||
public ArmorMod(int effect, String dataKey, EnumSet<ArmorPart> armorTypes, ItemStack[] items)
|
||||
{
|
||||
public ArmorMod(int effect, String dataKey, EnumSet<ArmorPart> armorTypes, ItemStack[] items) {
|
||||
super(items, effect, dataKey);
|
||||
this.armorTypes = armorTypes;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean canModify (ItemStack armor, ItemStack[] input)
|
||||
{
|
||||
protected boolean canModify(ItemStack armor, ItemStack[] input) {
|
||||
Item i = armor.getItem();
|
||||
if (!(i instanceof ArmorCore))
|
||||
return false;
|
||||
if (!(i instanceof ArmorCore)) return false;
|
||||
ArmorCore item = (ArmorCore) armor.getItem();
|
||||
if (armorTypes.contains(item.armorPart))
|
||||
{
|
||||
if (armorTypes.contains(item.armorPart)) {
|
||||
NBTTagCompound tags = getModifierTag(armor);
|
||||
return tags.getInteger("Modifiers") > 0;
|
||||
}
|
||||
@@ -31,8 +26,7 @@ public abstract class ArmorMod extends ItemModifier
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validType (IModifyable type)
|
||||
{
|
||||
public boolean validType(IModifyable type) {
|
||||
return type.getModifyType().equals("Armor") || type.getModifyType().equals("Clothing");
|
||||
}
|
||||
}
|
||||
@@ -3,17 +3,16 @@ package tconstruct.library.armor;
|
||||
import java.util.*;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
public abstract class ArmorModTypeFilter extends ArmorMod
|
||||
{
|
||||
public abstract class ArmorModTypeFilter extends ArmorMod {
|
||||
public final List<Integer> increase;
|
||||
|
||||
public ArmorModTypeFilter(int effect, String dataKey, EnumSet<ArmorPart> armorTypes, ItemStack[] items, int[] values)
|
||||
{
|
||||
public ArmorModTypeFilter(
|
||||
int effect, String dataKey, EnumSet<ArmorPart> armorTypes, ItemStack[] items, int[] values) {
|
||||
super(effect, dataKey, armorTypes, items);
|
||||
assert items.length == values.length : "Itemstacks and their values for armor modifiers must be the same length";
|
||||
assert items.length == values.length
|
||||
: "Itemstacks and their values for armor modifiers must be the same length";
|
||||
this.increase = new ArrayList<Integer>();
|
||||
for (int i = 0; i < values.length; i++)
|
||||
{
|
||||
for (int i = 0; i < values.length; i++) {
|
||||
increase.add(values[i]);
|
||||
}
|
||||
}
|
||||
@@ -21,7 +20,7 @@ public abstract class ArmorModTypeFilter extends ArmorMod
|
||||
/**
|
||||
* Checks to see if the inputs match the stored items Note: Filters types,
|
||||
* doesn't care about amount
|
||||
*
|
||||
*
|
||||
* @param input
|
||||
* The ItemStacks to compare against
|
||||
* @param tool
|
||||
@@ -29,61 +28,40 @@ public abstract class ArmorModTypeFilter extends ArmorMod
|
||||
* @return Whether the recipe matches the input
|
||||
*/
|
||||
@Override
|
||||
public boolean matches (ItemStack[] input, ItemStack tool)
|
||||
{
|
||||
if (!canModify(tool, input))
|
||||
return false;
|
||||
public boolean matches(ItemStack[] input, ItemStack tool) {
|
||||
if (!canModify(tool, input)) return false;
|
||||
|
||||
boolean minimumMatch = false;
|
||||
for (ItemStack inputStack : input)
|
||||
{
|
||||
if (inputStack == null)
|
||||
continue;
|
||||
for (ItemStack inputStack : input) {
|
||||
if (inputStack == null) continue;
|
||||
|
||||
boolean match = false;
|
||||
for (Object check : stacks)
|
||||
{
|
||||
for (Object check : stacks) {
|
||||
ItemStack stack = (ItemStack) check;
|
||||
if (stack.getItemDamage() == Short.MAX_VALUE)
|
||||
{
|
||||
if (this.areItemsEquivalent(inputStack, stack))
|
||||
match = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.areItemStacksEquivalent(inputStack, stack))
|
||||
match = true;
|
||||
if (stack.getItemDamage() == Short.MAX_VALUE) {
|
||||
if (this.areItemsEquivalent(inputStack, stack)) match = true;
|
||||
} else {
|
||||
if (this.areItemStacksEquivalent(inputStack, stack)) match = true;
|
||||
}
|
||||
}
|
||||
if (!match)
|
||||
return false;
|
||||
if (!match) return false;
|
||||
|
||||
minimumMatch = true;
|
||||
}
|
||||
return minimumMatch;
|
||||
}
|
||||
|
||||
public int matchingAmount (ItemStack[] input)
|
||||
{
|
||||
public int matchingAmount(ItemStack[] input) {
|
||||
int amount = 0;
|
||||
for (ItemStack inputStack : input)
|
||||
{
|
||||
if (inputStack == null)
|
||||
continue;
|
||||
else
|
||||
{
|
||||
for (int iter = 0; iter < stacks.size(); iter++)
|
||||
{
|
||||
for (ItemStack inputStack : input) {
|
||||
if (inputStack == null) continue;
|
||||
else {
|
||||
for (int iter = 0; iter < stacks.size(); iter++) {
|
||||
ItemStack stack = (ItemStack) stacks.get(iter);
|
||||
if (stack.getItemDamage() == Short.MAX_VALUE)
|
||||
{
|
||||
if (this.areItemsEquivalent(inputStack, stack))
|
||||
amount += increase.get(iter);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.areItemStacksEquivalent(inputStack, stack))
|
||||
amount += increase.get(iter);
|
||||
if (stack.getItemDamage() == Short.MAX_VALUE) {
|
||||
if (this.areItemsEquivalent(inputStack, stack)) amount += increase.get(iter);
|
||||
} else {
|
||||
if (this.areItemStacksEquivalent(inputStack, stack)) amount += increase.get(iter);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -91,29 +69,26 @@ public abstract class ArmorModTypeFilter extends ArmorMod
|
||||
return amount;
|
||||
}
|
||||
|
||||
public int matchingItems (ItemStack[] input)
|
||||
{
|
||||
public int matchingItems(ItemStack[] input) {
|
||||
int amount = 0;
|
||||
for (ItemStack inputStack : input)
|
||||
{
|
||||
if (inputStack != null)
|
||||
amount++;
|
||||
for (ItemStack inputStack : input) {
|
||||
if (inputStack != null) amount++;
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a new itemstack to the list for increases
|
||||
*
|
||||
*
|
||||
* @param stack
|
||||
* ItemStack to compare against
|
||||
* @param amount
|
||||
* Amount to increase
|
||||
*/
|
||||
public void addStackToMatchList (ItemStack stack, int amount)
|
||||
{
|
||||
public void addStackToMatchList(ItemStack stack, int amount) {
|
||||
if (stack == null)
|
||||
throw new NullPointerException("ItemStack added to " + this.getClass().getSimpleName() + " cannot be null.");
|
||||
throw new NullPointerException(
|
||||
"ItemStack added to " + this.getClass().getSimpleName() + " cannot be null.");
|
||||
stacks.add(stack);
|
||||
increase.add(amount);
|
||||
}
|
||||
|
||||
@@ -1,19 +1,18 @@
|
||||
package tconstruct.library.armor;
|
||||
|
||||
public enum ArmorPart
|
||||
{
|
||||
|
||||
Head(0), Chest(1), Legs(2), Feet(3);
|
||||
public enum ArmorPart {
|
||||
Head(0),
|
||||
Chest(1),
|
||||
Legs(2),
|
||||
Feet(3);
|
||||
|
||||
private final int partID;
|
||||
|
||||
private ArmorPart(int partID)
|
||||
{
|
||||
private ArmorPart(int partID) {
|
||||
this.partID = partID;
|
||||
}
|
||||
|
||||
public int getPartId ()
|
||||
{
|
||||
public int getPartId() {
|
||||
return this.partID;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -9,52 +9,50 @@ import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.*;
|
||||
|
||||
final class BehaviorDispenseArmorCopy extends BehaviorDefaultDispenseItem
|
||||
{
|
||||
final class BehaviorDispenseArmorCopy extends BehaviorDefaultDispenseItem {
|
||||
/**
|
||||
* Dispense the specified stack, play the dispense sound and spawn
|
||||
* particles.
|
||||
*/
|
||||
@Override
|
||||
protected ItemStack dispenseStack (IBlockSource par1IBlockSource, ItemStack par2ItemStack)
|
||||
{
|
||||
protected ItemStack dispenseStack(IBlockSource par1IBlockSource, ItemStack par2ItemStack) {
|
||||
EnumFacing enumfacing = BlockDispenser.func_149937_b(par1IBlockSource.getBlockMetadata());
|
||||
int i = par1IBlockSource.getXInt() + enumfacing.getFrontOffsetX();
|
||||
int j = par1IBlockSource.getYInt() + enumfacing.getFrontOffsetY();
|
||||
int k = par1IBlockSource.getZInt() + enumfacing.getFrontOffsetZ();
|
||||
AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox((double) i, (double) j, (double) k, (double) (i + 1), (double) (j + 1), (double) (k + 1));
|
||||
List list = par1IBlockSource.getWorld().selectEntitiesWithinAABB(EntityLivingBase.class, axisalignedbb, new IEntitySelector.ArmoredMob(par2ItemStack));
|
||||
AxisAlignedBB axisalignedbb = AxisAlignedBB.getBoundingBox(
|
||||
(double) i, (double) j, (double) k, (double) (i + 1), (double) (j + 1), (double) (k + 1));
|
||||
List list = par1IBlockSource
|
||||
.getWorld()
|
||||
.selectEntitiesWithinAABB(
|
||||
EntityLivingBase.class, axisalignedbb, new IEntitySelector.ArmoredMob(par2ItemStack));
|
||||
|
||||
if (list.size() > 0)
|
||||
{
|
||||
if (list.size() > 0) {
|
||||
EntityLivingBase entitylivingbase = (EntityLivingBase) list.get(0);
|
||||
int l = entitylivingbase instanceof EntityPlayer ? 1 : 0;
|
||||
int i1 = EntityLiving.getArmorPosition(par2ItemStack);
|
||||
ItemStack itemstack1 = par2ItemStack.copy();
|
||||
itemstack1.stackSize = 1;
|
||||
entitylivingbase.setCurrentItemOrArmor(i1, itemstack1); // BUGFIX
|
||||
// Forge:
|
||||
// Vanilla
|
||||
// bug fix
|
||||
// associated
|
||||
// with
|
||||
// fixed
|
||||
// setCurrentItemOrArmor
|
||||
// indexs
|
||||
// for
|
||||
// players.
|
||||
// Forge:
|
||||
// Vanilla
|
||||
// bug fix
|
||||
// associated
|
||||
// with
|
||||
// fixed
|
||||
// setCurrentItemOrArmor
|
||||
// indexs
|
||||
// for
|
||||
// players.
|
||||
|
||||
if (entitylivingbase instanceof EntityLiving)
|
||||
{
|
||||
if (entitylivingbase instanceof EntityLiving) {
|
||||
((EntityLiving) entitylivingbase).setEquipmentDropChance(i1, 2.0F);
|
||||
}
|
||||
|
||||
--par2ItemStack.stackSize;
|
||||
return par2ItemStack;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
return super.dispenseStack(par1IBlockSource, par2ItemStack);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user