diff options
Diffstat (limited to 'src/main/java/gregtech/common/items/armor')
16 files changed, 2863 insertions, 0 deletions
diff --git a/src/main/java/gregtech/common/items/armor/ArmorCalculation.java b/src/main/java/gregtech/common/items/armor/ArmorCalculation.java new file mode 100644 index 0000000000..8915ce6f52 --- /dev/null +++ b/src/main/java/gregtech/common/items/armor/ArmorCalculation.java @@ -0,0 +1,413 @@ +package gregtech.common.items.armor; + +import java.util.List; + +import thaumcraft.api.nodes.IRevealer; +import cpw.mods.fml.common.Loader; +import gregtech.api.enums.ItemList; +import gregtech.api.enums.Materials; +import gregtech.api.enums.OrePrefixes; +import gregtech.api.objects.ItemData; +import gregtech.api.util.GT_ModHandler; +import gregtech.api.util.GT_OreDictUnificator; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidStack; + +public class ArmorCalculation { + public static float[] calculateArmor(ItemStack[] parts) { + float[] def = new float[32]; + def[0] = 0; // Weight + def[1] = 1; // physical Def + def[2] = 1; // projectileDef + def[3] = 1; // fireDef + def[4] = 1; // magicDef + def[5] = 1; // explosionDef + def[6] = 0; // radiationDef + def[7] = 0; // electricDef + def[8] = 0; // witherDef + def[9] = 0; // fallDef + def[10] = 0; // Thorns + def[11] = 0; // ItemMagnet + def[12] = 0; // ItemCharge + def[13] = 0; // Thaumcraft goggles + def[14] = 0; // Nightvision + def[15] = 0; // tankCap + def[16] = 0; // motorPower + def[17] = 0; // motorEU + def[18] = 0; // pistonPower + def[19] = 0; // pistonEU + def[20] = 0; // ElectrolyzerPower + def[21] = 0; // ElectrolyzerEU + def[22] = 0; // FieldEmmiterPower + def[23] = 0; // FieldEmmiterEU + def[24] = 0; // JetpackFuelPower + def[25] = 0; // FuelUsage + def[26] = 0; // JetpackEUPower + def[27] = 0; // JetpackEU + def[28] = 0; // AntiGravPower + def[29] = 0; // AntiGravEU + def[30] = 0; // ProcessingPower + def[31] = 0; // ProcessingPowerUsed + + if (parts != null) { + def[12] = 0.0f; + for (int i = 0; i < parts.length; i++) { + if (parts[i] != null) { + ItemData data = GT_OreDictUnificator.getItemData(parts[i]); + if (data != null && (data.mPrefix == OrePrefixes.plate || data.mPrefix == OrePrefixes.plateAlloy)) { + // Weight + def[0] = def[0] + Values.INSTANCE.getValues(data.mMaterial.mMaterial).weight; + if (data.mPrefix == OrePrefixes.plateAlloy && data.mMaterial.mMaterial == Materials.Iridium) { + def[0] = def[0] - 20; + } + // physicalDef + float tmp = Values.INSTANCE.getValues(data.mMaterial.mMaterial).physicalDef; + if (data.mPrefix == OrePrefixes.plateAlloy && data.mMaterial.mMaterial == Materials.Iridium) { + tmp = 0.27f; + } + if (tmp > 0.0f) { + def[1] = def[1] - (tmp * def[1]); + } + // projectileDef + tmp = Values.INSTANCE.getValues(data.mMaterial.mMaterial).projectileDef; + if (data.mPrefix == OrePrefixes.plateAlloy && data.mMaterial.mMaterial == Materials.Iridium) { + tmp = 0.27f; + } + if (tmp > 0.0f) { + def[2] = def[2] - (tmp * def[2]); + } + // fireDef + tmp = Values.INSTANCE.getValues(data.mMaterial.mMaterial).fireDef; + if (data.mPrefix == OrePrefixes.plateAlloy && data.mMaterial.mMaterial == Materials.Iridium) { + tmp = 0.25f; + } + if (tmp > 0.0f) { + def[3] = def[3] - (tmp * def[3]); + } + // magicDef + tmp = Values.INSTANCE.getValues(data.mMaterial.mMaterial).magicDef; + if (data.mPrefix == OrePrefixes.plateAlloy && data.mMaterial.mMaterial == Materials.Iridium) { + tmp = 0.25f; + } + if (tmp > 0.0f) { + def[4] = def[4] - (tmp * def[4]); + } + // explosionDef + tmp = Values.INSTANCE.getValues(data.mMaterial.mMaterial).explosionDef; + if (data.mPrefix == OrePrefixes.plateAlloy && data.mMaterial.mMaterial == Materials.Iridium) { + tmp = 0.27f; + } + if (tmp > 0.0f) { + def[5] = def[5] - (tmp * def[5]); + } + if (data.mPrefix == OrePrefixes.plate && data.mMaterial.mMaterial == Materials.Rubber) { + def[7] = def[7] + 0.25f; + def[9] = def[9] + 2.0f; + } + if (data.mPrefix == OrePrefixes.plate && data.mMaterial.mMaterial == Materials.Lead) { + def[6] = def[6] + 0.30f; + } + if (data.mPrefix == OrePrefixes.plate && data.mMaterial.mMaterial == Materials.Plastic) { + def[7] = def[7] + 0.25f; + } + if (data.mPrefix == OrePrefixes.plate && data.mMaterial.mMaterial == Materials.NeodymiumMagnetic) { + def[11] = def[11] + 2.0f; + } + if (data.mPrefix == OrePrefixes.plate && data.mMaterial.mMaterial == Materials.NetherStar) { + def[8] = def[8] + 0.20f; + } + if (data.mPrefix == OrePrefixes.plate && data.mMaterial.mMaterial == Materials.InfusedFire) { + def[10] = def[10] + 3.0f; + } + if (data.mPrefix == OrePrefixes.plate && data.mMaterial.mMaterial == Materials.InfusedEntropy) { + def[10] = def[10] + 4.0f; + } + } else if (GT_ModHandler.isChargerItem(parts[i])) { + def[12] = def[12] + (float) ic2.api.item.ElectricItem.manager.getCharge(parts[i]); + def[0] = (float) (def[0] + Math.pow(ic2.api.item.ElectricItem.manager.getCharge(parts[i]), 0.33f)); + } + else if (Loader.isModLoaded("Thaumcraft") && parts[i].getItem() instanceof IRevealer) { + def[13] = 1; + def[31] += 100; + } + else if (parts[i].getItem().getUnlocalizedName().equals("ic2.itemNightvisionGoggles")) { + def[14] = 1; + def[31] += 100; + } else if (parts[i].getItem().getUnlocalizedName().equals("gt.meta.spring")) {// Once readded: GT Motors + switch (parts[i].getItem().getDamage(parts[i])) { + case 8630: + def[16] += 200; // motorPower + def[17] += 50; + def[31] += 10; + break; + case 8631: + def[16] += 300; // motorPower + def[17] += 100; + def[31] += 20; + break; + case 8632: + def[16] += 400; // motorPower + def[17] += 200; + def[31] += 50; + break; + case 8633: + def[16] += 500; // motorPower + def[17] += 400; + def[31] += 100; + break; + case 8634: + def[16] += 600; // motorPower + def[17] += 800; + def[31] += 200; + break; + } + } else if (parts[i].getItem().getUnlocalizedName().equals("gt.meta.springSmall")) {// Once Readded: GT Electric Pistons + switch (parts[i].getItem().getDamage(parts[i])) { + case 8630: + def[18] += 3; + def[19] += 200; + def[31] += 10; + break; + case 8631: + def[18] += 4; + def[19] += 300; + def[31] += 20; + break; + case 8632: + def[18] += 5; + def[19] += 450; + def[31] += 50; + break; + case 8633: + def[18] += 6; + def[19] += 800; + def[31] += 100; + break; + case 8634: + def[18] += 7; + def[19] += 1600; + def[31] += 200; + break; + } + } else if (parts[i].getItem().getUnlocalizedName().equals("gt.meta.Electrolyzer")) {// Once Readded: GT Electrolyzer + switch (parts[i].getItem().getDamage(parts[i])) { + case 8630: + def[20] += 10; // ElectrolyzerPower + def[21] += 1; // ElectrolyzerEU + def[31] += 50; + break; + case 8631: + def[20] += 20; // ElectrolyzerPower + def[21] += 4; // ElectrolyzerEU + def[31] += 100; + break; + case 8632: + def[20] += 40; // ElectrolyzerPower + def[21] += 16; // ElectrolyzerEU + def[31] += 150; + break; + case 8633: + def[20] += 80; // ElectrolyzerPower + def[21] += 64; // ElectrolyzerEU + def[31] += 200; + break; + case 8634: + def[20] += 160; // ElectrolyzerPower + def[21] += 256; // ElectrolyzerEU + def[31] += 250; + break; + } + } else if (parts[i].getItem().equals(ItemList.Cell_Empty.getItem())) { + def[15] += 8000; + } else if (parts[i].getItem().getUnlocalizedName().equals("gt.meta.cell")) {// Once Readded: GT Fluid Cells (tank) + switch (parts[i].getItem().getDamage(parts[i])) { + case 8630: // steel fluid cell + def[15] += 16000; + break; + case 8631: // tungsten fluid cell + def[15] += 64000; + break; + } + } else if (parts[i].getItem().getUnlocalizedName().equals("gt.meta.emmiter")) {// Once Readded: GT Field Emmiter + switch (parts[i].getItem().getDamage(parts[i])) { + case 8630: + def[22] += 1; // FieldEmmiterPower + def[23] += 1; // FieldEmmiterEU + def[31] += 100; + break; + case 8631: + def[22] += 2; // FieldEmmiterPower + def[23] += 4; // FieldEmmiterEU + def[31] += 200; + break; + case 8632: + def[22] += 3; // FieldEmmiterPower + def[23] += 16; // FieldEmmiterEU + def[31] += 300; + break; + case 8633: + def[22] += 4; // FieldEmmiterPower + def[23] += 64; // FieldEmmiterEU + def[31] += 400; + break; + case 8634: + def[22] += 5; // FieldEmmiterPower + def[23] += 512; // FieldEmmiterEU + def[31] += 500; + break; + } + } else if (data !=null && data.mPrefix == OrePrefixes.circuit) {// processing power stuff + if (data.mMaterial.mMaterial == Materials.Basic) { + def[30] += 100; + } else if (data.mMaterial.mMaterial == Materials.Good) { + def[30] += 200; + } else if (data.mMaterial.mMaterial == Materials.Advanced) { + def[30] += 300; + } else if (data.mMaterial.mMaterial == Materials.Data) { + def[30] += 400; + } else if (data.mMaterial.mMaterial == Materials.Elite) { + def[30] += 500; + } else if (data.mMaterial.mMaterial == Materials.Master) { + def[30] += 600; + } + } else if (parts[i].getItem().getUnlocalizedName().equals("gte.meta.jetpack")) {// jeptack parts + switch (parts[i].getItem().getDamage(parts[i])) { + case 0: + def[24] += 50; // JetpackFuelPower + def[25] += 1; // FuelUsage + def[31] += 10; + break; + case 1: + def[24] += 75; // JetpackFuelPower + def[25] += 2; // FuelUsage + def[31] += 20; + break; + case 2: + def[24] += 100; // JetpackFuelPower + def[25] += 4; // FuelUsage + def[31] += 30; + break; + case 3: + def[24] += 125; // JetpackFuelPower + def[25] += 8; // FuelUsage + def[31] += 40; + break; + case 4: + def[24] += 150; // JetpackFuelPower + def[25] += 16; // FuelUsage + def[31] += 50; + break; + case 5: + def[26] += 20; // JetpackEUPower + def[27] += 8; // JetpackEU + def[31] += 30; + break; + case 6: + def[26] += 30; // JetpackEUPower + def[27] += 16; // JetpackEU + def[31] += 60; + break; + case 7: + def[26] += 40; // JetpackEUPower + def[27] += 32; // JetpackEU + def[31] += 90; + break; + case 8: + def[26] += 50; // JetpackEUPower + def[27] += 64; // JetpackEU + def[31] += 120; + break; + case 9: + def[26] += 60; // JetpackEUPower + def[27] += 128; // JetpackEU + def[31] += 150; + break; + case 10: + def[28] += 100; // AntiGravPower + def[29] += 32; // AntiGravEU + def[31] += 100; + break; + case 11: + def[28] += 133; // AntiGravPower + def[29] += 64; // AntiGravEU + def[31] += 200; + break; + case 12: + def[28] += 166; // AntiGravPower + def[29] += 128; // AntiGravEU + def[31] += 300; + break; + case 13: + def[28] += 200; // AntiGravPower + def[29] += 256; // AntiGravEU + def[31] += 400; + break; + case 14: + def[28] += 233; // AntiGravPower + def[29] += 512; // AntiGravEU + def[31] += 500; + break; + } + } else if (true) { + //System.out.println("Unknown Item: " + parts[i].getItem().getUnlocalizedName()); + } + } + } + } + def[1] = 1 - def[1]; + def[2] = 1 - def[2]; + def[3] = 1 - def[3]; + def[4] = 1 - def[4]; + def[5] = 1 - def[5]; + if (def[7] > 0.95) { + def[7] = 1.0f; + } + if (def[8] > 0.98) { + def[8] = 1.0f; + } + return def; + } + + public static int deChargeBatterys(ItemStack[] parts, int amount) { + // System.out.println("deCharge " + amount); + int decharged = 0; + for (int i = 0; decharged < amount && i < parts.length; i++) { + if (GT_ModHandler.isChargerItem(parts[i])) { + decharged = (int) (decharged + ic2.api.item.ElectricItem.manager.discharge(parts[i], amount - decharged, 10, false, false, false)); + } + } + return decharged; + } + + public static FluidStack getFluid(ItemStack[] parts, int tankCap) { + int fluidAmount; + if (parts.length > 12 && parts[12] != null) { + NBTTagCompound nbt = parts[12].getTagCompound(); + if (nbt != null) { + fluidAmount = (int) nbt.getLong("mFluidDisplayAmount"); + if (fluidAmount > tankCap) { + nbt.setLong("mFluidDisplayAmount", tankCap); + parts[12].setTagCompound(nbt); + fluidAmount = tankCap; + } + return new FluidStack(parts[12].getItemDamage(), fluidAmount); + } + + } + return null; + } + + public static void useFluid(ItemStack[] parts, int usedAmount) { + int fluidAmount; + if (parts.length > 12 && parts[12] != null) { + NBTTagCompound nbt = parts[12].getTagCompound(); + if (nbt != null) { + fluidAmount = (int) nbt.getLong("mFluidDisplayAmount"); + nbt.setLong("mFluidDisplayAmount", fluidAmount - usedAmount); + parts[12].setTagCompound(nbt); + } + } + } +} diff --git a/src/main/java/gregtech/common/items/armor/ArmorData.java b/src/main/java/gregtech/common/items/armor/ArmorData.java new file mode 100644 index 0000000000..79c6a20ffa --- /dev/null +++ b/src/main/java/gregtech/common/items/armor/ArmorData.java @@ -0,0 +1,345 @@ +package gregtech.common.items.armor; + +import java.text.DecimalFormat; +import java.text.DecimalFormatSymbols; +import java.text.NumberFormat; +import java.util.ArrayList; +import java.util.List; +import java.util.Locale; +import java.util.Random; + +import gregtech.api.damagesources.GT_DamageSources; +import gregtech.api.util.GT_LanguageManager; +import gregtech.api.util.GT_Utility; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.nbt.NBTTagList; +import net.minecraft.util.DamageSource; +import net.minecraftforge.fluids.Fluid; +import net.minecraftforge.fluids.FluidRegistry; +import net.minecraftforge.fluids.FluidStack; + +public class ArmorData { + + public int type; // 0 = helmet; 1 = chestplate; 2 = leggings; 3 = boots; + public int armorTier; // 0 = Basic Modular Armor; 1 = Modular Exoskeleton; 2= Modular Nanosuit; 3 = Heavy Power Armor + public List info; // needs Localization + public boolean isTopItem; + public int tooltipUpdate; + public boolean openGui; + + public ArmorData helmet; + public ArmorData chestplate; + public ArmorData leggings; + public ArmorData boots; + + public boolean fullArmor; + public boolean fullRadiationDef; + public boolean fullElectricDef; + + public float fallDef; + public float physicalDef; + public float projectileDef; + public float fireDef; + public float magicDef; + public float explosionDef; + public float radiationDef; + public float electricDef; + public float witherDef; + + public float thorns; + public float thornsSingle; + public int magnet; + public int magnetSingle; + + public int partsCharge; + public int maxCharge; + public int charge; + public boolean thaumicGoggles; + public boolean nightVision; + public boolean potionInjector; + public boolean autoFeeder; + + public FluidStack fluid; + public int tankCap; + + public int weight; + public int maxWeight; + public int processingPower; + public int processingPowerUsed; + public int partProcessing; + public int partProcessingUsed; + + public int motorPower; + public int motorEUusage; + public int pistonJumpboost; + public int pistonEUusage; + public int electrolyzerProd; + public int electrolyzerEUusage; + public int fieldGenCap; + public int fieldGenEUusage; + + public int jetpackMaxWeight; + public int antiGravMaxWeight; + + public ArmorData(EntityPlayer player, ItemStack stack, int type, int tier) { + this.type = type; + this.armorTier = tier; + ContainerModularArmor tmp = new ContainerBasicArmor((EntityPlayer) player, new InventoryArmor(ModularArmor_Item.class, stack)); + calculateArmor(tmp.mInvArmor.parts); + switch (tier) { + case 0: + maxCharge = 0; + break; + case 1: + maxCharge = 250000; + break; + case 2: + maxCharge = 1000000; + } + readNBT(stack.getTagCompound()); + } + + private void readNBT(NBTTagCompound nbt) { + if (nbt == null) { + return; + } + if (nbt.hasKey("Charge")) { + this.charge = nbt.getInteger("Charge"); + } + } + + public void writeToNBT(NBTTagCompound nbt) { + if (nbt == null) { + return; + } + nbt.setInteger("Charge", this.charge); + } + + public ArmorData calculateArmor(ItemStack[] parts) { + float[] def = ArmorCalculation.calculateArmor(parts); + weight = (int) def[0]; + physicalDef = def[1]; + projectileDef = def[2]; + fireDef = def[3]; + magicDef = def[4]; + explosionDef = def[5]; + radiationDef = def[6]; + electricDef = def[7]; + witherDef = def[8]; + fallDef = def[9]; + thornsSingle = def[10]; + magnetSingle = (int) def[11]; + if (armorTier > 0) { + partsCharge = (int) def[12]; + thaumicGoggles = def[13] > 0.5f; + nightVision = def[14] > 0.5f; + tankCap = (int) def[15]; // tankCap + motorPower = (int) def[16]; // motorPower + motorEUusage = (int) def[17]; // motorEU + pistonJumpboost = (int) def[18]; // pistonPower + fallDef += pistonJumpboost; + pistonEUusage = (int) def[19]; // pistonEU + electrolyzerProd = (int) def[20]; // ElectrolyzerPower + electrolyzerEUusage = (int) def[21]; // ElectrolyzerEU + fieldGenCap = (int) def[22]; // FieldEmmiterPower + fieldGenEUusage = (int) def[23]; // FieldEmmiterEU + jetpackMaxWeight = (int) def[24] + (int) def[26]; // JetpackFuelPower// JetpackEUPower + def[25] = 0; // FuelUsage + def[27] = 0; // JetpackEU + antiGravMaxWeight = (int) def[28]; // AntiGravPower + def[29] = 0; // AntiGravEU + if (armorTier == 2) { + partProcessing = (int) def[30] + 500; // ProcessingPower + } else { + partProcessing = (int) def[30] + 300; // ProcessingPower + } + partProcessingUsed = (int) def[31]; // ProcessingPowerUsed + } + updateTooltip(); + return this; + } + + public void updateTooltip() { + List<String> tagList = new ArrayList<String>(); + String tmp2 = ""; + if (maxWeight > 4000) { + tmp2 = " " + GT_LanguageManager.getTranslation("hav"); + } + if (maxCharge != 0) { + DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.US); + DecimalFormatSymbols symbols = formatter.getDecimalFormatSymbols(); + symbols.setGroupingSeparator(' '); + if (type == 0) { + if (thaumicGoggles) { + tagList.add(GT_LanguageManager.getTranslation("thaum")); + } + if (nightVision) { + tagList.add(GT_LanguageManager.getTranslation("night")); + } + } + tagList.add("EU: " + formatter.format(charge + partsCharge)); + if (type == 2) { + tagList.add(GT_LanguageManager.getTranslation("jum") + ": " + pistonJumpboost / 3 + "m"); + } + if (type == 2 && pistonJumpboost > 0) { + tagList.add(GT_LanguageManager.getTranslation("uph")); + } + if (type == 2 && motorPower > 0) { + tagList.add(GT_LanguageManager.getTranslation("speass") + ": " + motorPower); + tagList.add(GT_LanguageManager.getTranslation("motuse") + ": " + motorEUusage + " EU"); + if (maxWeight > 4000) { + tagList.add(GT_LanguageManager.getTranslation("over")); + } + } + tagList.add(GT_LanguageManager.getTranslation("pro1") + " " + partProcessing + " " + GT_LanguageManager.getTranslation("pro3")); + tagList.add(GT_LanguageManager.getTranslation("pro2") + ": " + partProcessingUsed + " " + GT_LanguageManager.getTranslation("pro3")); + if (type == 0 && electrolyzerProd > 0) { + tagList.add(GT_LanguageManager.getTranslation("elec1") + " " + electrolyzerProd / 2 + GT_LanguageManager.getTranslation("elec2")); + } + if (tankCap > 0) { + if (fluid != null) { + tagList.add(GT_LanguageManager.getTranslation("tank") + ": " + fluid.getLocalizedName() + " " + fluid.amount + "L (" + tankCap + ")"); + } else { + tagList.add(GT_LanguageManager.getTranslation("tankcap") + ": " + tankCap); + } + } + } + tagList.add(GT_LanguageManager.getTranslation("weight") + ": " + weight + tmp2); + tagList.add(GT_LanguageManager.getTranslation("phydef") + ": " + (Math.round(physicalDef * 1000) / 10.0) + "%"); + tagList.add(GT_LanguageManager.getTranslation("prodef") + ": " + (Math.round(projectileDef * 1000) / 10.0) + "%"); + tagList.add(GT_LanguageManager.getTranslation("firedef") + ": " + (Math.round(fireDef * 1000) / 10.0) + "%"); + tagList.add(GT_LanguageManager.getTranslation("magdef") + ": " + (Math.round(magicDef * 1000) / 10.0) + "%"); + tagList.add(GT_LanguageManager.getTranslation("expdef") + ": " + (Math.round(explosionDef * 1000) / 10.0) + "%"); + if (fallDef > 0 && type == 3) { + tagList.add(GT_LanguageManager.getTranslation("abs1") + " " + fallDef + GT_LanguageManager.getTranslation("abs2")); + } + if (thorns > 0) { + tagList.add(GT_LanguageManager.getTranslation("thorns") + ": " + (int) thorns); + } + if (magnet > 0) { + tagList.add(GT_LanguageManager.getTranslation("magnet") + ": " + magnet + "m"); + } + if (fullRadiationDef) { + tagList.add(GT_LanguageManager.getTranslation("radim")); + } else { + if (radiationDef > 0.01d) { + tagList.add(GT_LanguageManager.getTranslation("raddef") + ": " + (Math.round(radiationDef * 1000) / 10.0) + "%"); + } + } + info = tagList; + } + + public void armorPartsEquipped(EntityPlayer aPlayer) { + helmet = null; + chestplate = null; + leggings = null; + boots = null; + for (int i = 1; i < 5; i++) { + ItemStack stack = aPlayer.getEquipmentInSlot(i); + if (stack != null && stack.getItem() instanceof ModularArmor_Item) { + ModularArmor_Item tmp = (ModularArmor_Item) stack.getItem(); + ContainerModularArmor tmp2 = new ContainerBasicArmor(aPlayer, new InventoryArmor(ModularArmor_Item.class, stack)); + if ((this.type + i) == 4) { + fluid = ArmorCalculation.getFluid(tmp2.mInvArmor.parts, tankCap); + } + if (maxCharge > 0 && charge < maxCharge) { + int loaded = ArmorCalculation.deChargeBatterys(tmp2.mInvArmor.parts, maxCharge - charge); + charge = charge + loaded; + tmp.data.partsCharge -= loaded; + + } + switch (tmp.armorType) { + case 0: + helmet = tmp.data; + break; + case 1: + chestplate = tmp.data; + break; + case 2: + leggings = tmp.data; + break; + case 3: + boots = tmp.data; + break; + default: + break; + } + writeToNBT(stack.getTagCompound()); + } + } + if (helmet != null && chestplate != null && leggings != null && boots != null) { + fullArmor = true; + } else { + fullArmor = false; + } + fullRadiationDef = fullArmor && helmet.radiationDef > 0.9f && chestplate.radiationDef > 0.9f && leggings.radiationDef > 0.9f && boots.radiationDef > 0.9f; + fullElectricDef = fullArmor && helmet.electricDef > 0.9f && chestplate.electricDef > 0.9f && leggings.electricDef > 0.9f && boots.electricDef > 0.9f; + magnet = 0; + thorns = 0; + processingPower = 0; + processingPowerUsed = 0; + if (helmet != null) { + magnet += helmet.magnetSingle; + thorns += helmet.thornsSingle; + processingPower += helmet.partProcessing; + processingPowerUsed += helmet.partProcessingUsed; + } + if (chestplate != null) { + magnet += chestplate.magnetSingle; + thorns += chestplate.thornsSingle; + processingPower += chestplate.partProcessing; + processingPowerUsed += chestplate.partProcessingUsed; + } + if (leggings != null) { + magnet += leggings.magnetSingle; + thorns += leggings.thornsSingle; + processingPower += leggings.partProcessing; + processingPowerUsed += leggings.partProcessingUsed; + } + if (boots != null) { + magnet += boots.magnetSingle; + thorns += boots.thornsSingle; + processingPower += boots.partProcessing; + processingPowerUsed += boots.partProcessingUsed; + } + isTopItem = false; + if (type == 0) { + isTopItem = true; + } else if (helmet == null && type == 1) { + isTopItem = true; + } else if (helmet == null && chestplate == null && type == 2) { + isTopItem = true; + } else if (helmet == null && chestplate == null && leggings == null && type == 3) { + isTopItem = true; + } + if (helmet != null) { + maxWeight = helmet.weight; + } + if (chestplate != null) { + maxWeight += chestplate.weight; + } + if (leggings != null) { + maxWeight += leggings.weight; + } + if (boots != null) { + maxWeight += boots.weight; + } + } + + public double getBaseAbsorptionRatio() { + switch (this.type) { + case 0: + return 0.15; + case 1: + return 0.40; + case 2: + return 0.30; + case 3: + return 0.15; + default: + return 0.00; + } + } +} diff --git a/src/main/java/gregtech/common/items/armor/ContainerBasicArmor.java b/src/main/java/gregtech/common/items/armor/ContainerBasicArmor.java new file mode 100644 index 0000000000..108d813707 --- /dev/null +++ b/src/main/java/gregtech/common/items/armor/ContainerBasicArmor.java @@ -0,0 +1,48 @@ +package gregtech.common.items.armor; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class ContainerBasicArmor extends ContainerModularArmor { + + public ContainerBasicArmor(EntityPlayer player, InventoryArmor aInvArmor) { + super(player, aInvArmor); + } + + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new Slot(mInvArmor, 0, 118, 6)); + addSlotToContainer(new Slot(mInvArmor, 1, 136, 6)); + addSlotToContainer(new Slot(mInvArmor, 2, 154, 6)); + addSlotToContainer(new Slot(mInvArmor, 3, 118, 24)); + addSlotToContainer(new Slot(mInvArmor, 4, 136, 24)); + addSlotToContainer(new Slot(mInvArmor, 5, 154, 24)); + addSlotToContainer(new Slot(mInvArmor, 6, 118, 42)); + addSlotToContainer(new Slot(mInvArmor, 7, 136, 42)); + addSlotToContainer(new Slot(mInvArmor, 8, 154, 42)); + + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + addSlotToContainer(new Slot(aInventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + + for (int i = 0; i < 9; i++) { + ItemStack stackInSlot = aInventoryPlayer.getStackInSlot(i); + if(isIdenticalItem(mInvArmor.parent,stackInSlot)){ + addSlotToContainer(new SlotLocked(aInventoryPlayer,i,8+i*18,142)); + }else{ + addSlotToContainer(new Slot(aInventoryPlayer, i, 8 + i * 18, 142));} + } + } + + public int getSlotCount() { + return 9; + } + + public int getShiftClickSlotCount() { + return 9; + } + +} diff --git a/src/main/java/gregtech/common/items/armor/ContainerElectricArmor1.java b/src/main/java/gregtech/common/items/armor/ContainerElectricArmor1.java new file mode 100644 index 0000000000..063807275c --- /dev/null +++ b/src/main/java/gregtech/common/items/armor/ContainerElectricArmor1.java @@ -0,0 +1,53 @@ +package gregtech.common.items.armor; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Slot; +import net.minecraft.item.ItemStack; + +public class ContainerElectricArmor1 extends ContainerBasicArmor { + + public ContainerElectricArmor1(EntityPlayer player, InventoryArmor aInvArmor) { + super(player, aInvArmor); + } + + public void addSlots(InventoryPlayer aInventoryPlayer) { + addSlotToContainer(new Slot(mInvArmor, 0, 118, 6)); + addSlotToContainer(new Slot(mInvArmor, 1, 136, 6)); + addSlotToContainer(new Slot(mInvArmor, 2, 154, 6)); + addSlotToContainer(new Slot(mInvArmor, 3, 118, 24)); + addSlotToContainer(new Slot(mInvArmor, 4, 136, 24)); + addSlotToContainer(new Slot(mInvArmor, 5, 154, 24)); + addSlotToContainer(new Slot(mInvArmor, 6, 118, 42)); + addSlotToContainer(new Slot(mInvArmor, 7, 136, 42)); + addSlotToContainer(new Slot(mInvArmor, 8, 154, 42)); + addSlotToContainer(new Slot(mInvArmor, 9, 118, 60)); + addSlotToContainer(new Slot(mInvArmor, 10, 136, 60)); + addSlotToContainer(new Slot(mInvArmor, 11, 154, 60)); + + addSlotToContainer(new SlotFluid(mInvArmor,12,94,32)); + + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 9; j++) { + addSlotToContainer(new Slot(aInventoryPlayer, j + i * 9 + 9, 8 + j * 18, 84 + i * 18)); + } + } + + for (int i = 0; i < 9; i++) { + ItemStack stackInSlot = aInventoryPlayer.getStackInSlot(i); + if(isIdenticalItem(mInvArmor.parent,stackInSlot)){ + addSlotToContainer(new SlotLocked(aInventoryPlayer,i,8+i*18,142)); + }else{ + addSlotToContainer(new Slot(aInventoryPlayer, i, 8 + i * 18, 142));} + } + } + + public int getSlotCount() { + return 12; + } + + public int getShiftClickSlotCount() { + return 12; + } + +} diff --git a/src/main/java/gregtech/common/items/armor/ContainerModularArmor.java b/src/main/java/gregtech/common/items/armor/ContainerModularArmor.java new file mode 100644 index 0000000000..88f1a71599 --- /dev/null +++ b/src/main/java/gregtech/common/items/armor/ContainerModularArmor.java @@ -0,0 +1,171 @@ +package gregtech.common.items.armor; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.InventoryPlayer; +import net.minecraft.inventory.Container; +import net.minecraft.inventory.IInventory; +import net.minecraft.inventory.Slot; +import net.minecraft.item.Item; +import net.minecraft.item.ItemStack; +import net.minecraftforge.oredict.OreDictionary; + +public abstract class ContainerModularArmor extends Container { + + public InventoryArmor mInvArmor; + + public ContainerModularArmor(EntityPlayer player, InventoryArmor aInvArmor) { + this.mInvArmor = aInvArmor; + addSlots(player.inventory); + } + + public ArmorData getData(EntityPlayer aPlayer){ + + + + return null; + } + + @Override + public boolean canInteractWith(EntityPlayer aPlayer) { + return true; + } + + public abstract void addSlots(InventoryPlayer aInventoryPlayer); + + public abstract int getSlotCount(); + + public abstract int getShi |
