Initial Modular armor port (from GTExtras)
This commit is contained in:
parent
5132439317
commit
a4bf359b03
16 changed files with 2865 additions and 0 deletions
413
src/main/java/gregtech/common/items/armor/ArmorCalculation.java
Normal file
413
src/main/java/gregtech/common/items/armor/ArmorCalculation.java
Normal file
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
345
src/main/java/gregtech/common/items/armor/ArmorData.java
Normal file
345
src/main/java/gregtech/common/items/armor/ArmorData.java
Normal file
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -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 getShiftClickSlotCount();
|
||||
|
||||
public void saveInventory(EntityPlayer entityplayer) {
|
||||
mInvArmor.onGuiSaved(entityplayer);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onContainerClosed(EntityPlayer player) {
|
||||
super.onContainerClosed(player);
|
||||
if (!player.worldObj.isRemote) {
|
||||
saveInventory(player);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack transferStackInSlot(EntityPlayer player, int slotIndex) {
|
||||
if (player == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack originalStack = null;
|
||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||
int numSlots = inventorySlots.size();
|
||||
if (slot != null && slot.getHasStack()) {
|
||||
ItemStack stackInSlot = slot.getStack();
|
||||
originalStack = stackInSlot.copy();
|
||||
if (slotIndex >= numSlots - 9 * 4 && tryShiftItem(stackInSlot, numSlots)) {
|
||||
} else if (slotIndex >= numSlots - 9 * 4 && slotIndex < numSlots - 9) {
|
||||
if (!shiftItemStack(stackInSlot, numSlots - 9, numSlots)) {
|
||||
return null;
|
||||
}
|
||||
} else if (slotIndex >= numSlots - 9 && slotIndex < numSlots) {
|
||||
if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots - 9)) {
|
||||
return null;
|
||||
}
|
||||
} else if (!shiftItemStack(stackInSlot, numSlots - 9 * 4, numSlots)) {
|
||||
return null;
|
||||
}
|
||||
slot.onSlotChange(stackInSlot, originalStack);
|
||||
if (stackInSlot.stackSize <= 0) {
|
||||
slot.putStack(null);
|
||||
} else {
|
||||
slot.onSlotChanged();
|
||||
}
|
||||
if (stackInSlot.stackSize == originalStack.stackSize) {
|
||||
return null;
|
||||
}
|
||||
slot.onPickupFromSlot(player, stackInSlot);
|
||||
}
|
||||
return originalStack;
|
||||
}
|
||||
|
||||
private boolean tryShiftItem(ItemStack stackToShift, int numSlots) {
|
||||
for (int machineIndex = 0; machineIndex < numSlots - 9 * 4; machineIndex++) {
|
||||
Slot slot = (Slot) inventorySlots.get(machineIndex);
|
||||
if (slot.getHasStack()) {
|
||||
continue;
|
||||
}
|
||||
if(slot instanceof SlotLocked){
|
||||
continue;
|
||||
}
|
||||
if(slot instanceof SlotFluid){
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!slot.isItemValid(stackToShift)) {
|
||||
continue;
|
||||
}
|
||||
if (shiftItemStack(stackToShift, machineIndex, machineIndex + 1)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
protected boolean shiftItemStack(ItemStack stackToShift, int start, int end) {
|
||||
boolean changed = false;
|
||||
if (stackToShift.isStackable()) {
|
||||
for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < end; slotIndex++) {
|
||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||
ItemStack stackInSlot = slot.getStack();
|
||||
if (stackInSlot != null && isIdenticalItem(stackInSlot, stackToShift)) {
|
||||
int resultingStackSize = stackInSlot.stackSize + stackToShift.stackSize;
|
||||
int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
|
||||
if (resultingStackSize <= max) {
|
||||
stackToShift.stackSize = 0;
|
||||
stackInSlot.stackSize = resultingStackSize;
|
||||
slot.onSlotChanged();
|
||||
changed = true;
|
||||
} else if (stackInSlot.stackSize < max) {
|
||||
stackToShift.stackSize -= max - stackInSlot.stackSize;
|
||||
stackInSlot.stackSize = max;
|
||||
slot.onSlotChanged();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (stackToShift.stackSize > 0) {
|
||||
for (int slotIndex = start; stackToShift.stackSize > 0 && slotIndex < end; slotIndex++) {
|
||||
Slot slot = (Slot) inventorySlots.get(slotIndex);
|
||||
ItemStack stackInSlot = slot.getStack();
|
||||
if (stackInSlot == null) {
|
||||
int max = Math.min(stackToShift.getMaxStackSize(), slot.getSlotStackLimit());
|
||||
stackInSlot = stackToShift.copy();
|
||||
stackInSlot.stackSize = Math.min(stackToShift.stackSize, max);
|
||||
stackToShift.stackSize -= stackInSlot.stackSize;
|
||||
slot.putStack(stackInSlot);
|
||||
slot.onSlotChanged();
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return changed;
|
||||
}
|
||||
|
||||
public static boolean isIdenticalItem(ItemStack lhs, ItemStack rhs) {
|
||||
if (lhs == null || rhs == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lhs.getItem() != rhs.getItem()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lhs.getItemDamage() != OreDictionary.WILDCARD_VALUE) {
|
||||
if (lhs.getItemDamage() != rhs.getItemDamage()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return ItemStack.areItemStackTagsEqual(lhs, rhs);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,42 @@
|
|||
package gregtech.common.items.armor;
|
||||
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
|
||||
public class ElectricModularArmor1 extends ModularArmor_Item{
|
||||
|
||||
public boolean mChargeProvider=false;
|
||||
|
||||
public ElectricModularArmor1(int aArmorIndex, int aType, String name,int gui) {
|
||||
super(aArmorIndex, aType, name,gui);
|
||||
}
|
||||
|
||||
public boolean canProvideEnergy(ItemStack aStack) {
|
||||
return mChargeProvider;
|
||||
}
|
||||
|
||||
public Item getChargedItem(ItemStack aStack) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Item getEmptyItem(ItemStack aStack) {
|
||||
return this;
|
||||
}
|
||||
|
||||
public int getMaxCharge(ItemStack aStack) {
|
||||
return data.charge;
|
||||
}
|
||||
|
||||
public int getTier(ItemStack aStack) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
public int getTransferLimit(ItemStack aStack) {
|
||||
return openGuiNr==1?128:512;
|
||||
}
|
||||
}
|
67
src/main/java/gregtech/common/items/armor/FluidSync.java
Normal file
67
src/main/java/gregtech/common/items/armor/FluidSync.java
Normal file
|
@ -0,0 +1,67 @@
|
|||
package gregtech.common.items.armor;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
public class FluidSync /**implements IPacket**/ {
|
||||
String playerName;
|
||||
int amount;
|
||||
String fluid;
|
||||
|
||||
// @Override
|
||||
public byte getPacketID() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public FluidSync(String player, int amount, String fluid) {
|
||||
this.playerName = player;
|
||||
this.amount = amount;
|
||||
this.fluid = fluid.toLowerCase();
|
||||
}
|
||||
|
||||
// @Override
|
||||
public ByteArrayDataOutput encode() {
|
||||
ByteArrayDataOutput rOut = ByteStreams.newDataOutput(4);
|
||||
rOut.writeUTF(playerName + ";" + amount + ";" + fluid);
|
||||
return rOut;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public IPacket decode(ByteArrayDataInput aData) {
|
||||
// String tmp = aData.readUTF();
|
||||
// String[] tmp2 = tmp.split(";");
|
||||
// return new FluidSync(tmp2[0], Integer.parseInt(tmp2[1]), tmp2[2].toLowerCase());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void process(IBlockAccess aWorld, INetworkHandler aNetworkHandler) {
|
||||
// WorldServer[] worlds = DimensionManager.getWorlds();
|
||||
// EntityPlayer tmp;
|
||||
// for (int i = 0; i < worlds.length; i++) {
|
||||
// tmp = worlds[i].getPlayerEntityByName(playerName);
|
||||
// if (tmp != null) {
|
||||
// try {
|
||||
// if (fluid.equals("null")) {
|
||||
// tmp.openContainer.getSlot(12).putStack(null);
|
||||
// } else {
|
||||
// tmp.openContainer.getSlot(12).putStack(UT.Fluids.display(new FluidStack(FluidRegistry.getFluid(fluid), amount), true));
|
||||
// }
|
||||
// tmp.openContainer.detectAndSendChanges();
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
67
src/main/java/gregtech/common/items/armor/FluidSync2.java
Normal file
67
src/main/java/gregtech/common/items/armor/FluidSync2.java
Normal file
|
@ -0,0 +1,67 @@
|
|||
package gregtech.common.items.armor;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.world.IBlockAccess;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import net.minecraftforge.common.DimensionManager;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
|
||||
import com.google.common.base.Charsets;
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import com.google.common.io.ByteStreams;
|
||||
|
||||
public class FluidSync2 /**implements IPacket**/ {
|
||||
String playerName;
|
||||
|
||||
// @Override
|
||||
public byte getPacketID() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
public FluidSync2(String player) {
|
||||
this.playerName = player;
|
||||
}
|
||||
|
||||
// @Override
|
||||
public ByteArrayDataOutput encode() {
|
||||
ByteArrayDataOutput rOut = ByteStreams.newDataOutput(4);
|
||||
rOut.writeUTF(playerName);
|
||||
return rOut;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public IPacket decode(ByteArrayDataInput aData) {
|
||||
// return new FluidSync2(aData.readUTF());
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void process(IBlockAccess aWorld, INetworkHandler aNetworkHandler) {
|
||||
// WorldServer[] worlds = DimensionManager.getWorlds();
|
||||
// EntityPlayer tmp;
|
||||
// for (int i = 0; i < worlds.length; i++) {
|
||||
// tmp = worlds[i].getPlayerEntityByName(playerName);
|
||||
// if (tmp != null) {
|
||||
// try {
|
||||
// ItemStack tmp2 = tmp.inventory.getItemStack();
|
||||
// ItemStack tmp3 = UT.Fluids.getContainerForFilledItem(tmp2, true);
|
||||
// if (tmp2.stackSize <= 1) {
|
||||
// tmp2 = null;
|
||||
// } else {
|
||||
// tmp2.stackSize--;
|
||||
// }
|
||||
// tmp.inventory.setItemStack(tmp2);
|
||||
// if(tmp3!=null){
|
||||
// tmp3.stackSize=1;
|
||||
// tmp.inventory.addItemStackToInventory(tmp3);}
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// }
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
}
|
310
src/main/java/gregtech/common/items/armor/GuiElectricArmor1.java
Normal file
310
src/main/java/gregtech/common/items/armor/GuiElectricArmor1.java
Normal file
|
@ -0,0 +1,310 @@
|
|||
package gregtech.common.items.armor;
|
||||
|
||||
import gregtech.api.util.GT_LanguageManager;
|
||||
import gregtech.api.util.GT_Utility;
|
||||
|
||||
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 org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.Fluid;
|
||||
import net.minecraftforge.fluids.FluidStack;
|
||||
import net.minecraftforge.fluids.IFluidContainerItem;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiElectricArmor1 extends GuiContainer {
|
||||
ContainerModularArmor cont;
|
||||
EntityPlayer player;
|
||||
private int tab;
|
||||
|
||||
public GuiElectricArmor1(ContainerModularArmor containerModularArmor, EntityPlayer aPlayer) {
|
||||
super(containerModularArmor);
|
||||
player = aPlayer;
|
||||
cont = containerModularArmor;
|
||||
tab = 0;
|
||||
}
|
||||
|
||||
public String seperateNumber(long number){
|
||||
DecimalFormat formatter = (DecimalFormat) NumberFormat.getInstance(Locale.US);
|
||||
DecimalFormatSymbols symbols = formatter.getDecimalFormatSymbols();
|
||||
symbols.setGroupingSeparator(' ');
|
||||
return formatter.format(number);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y) {
|
||||
int xStart = (width - xSize) / 2;
|
||||
int yStart = (height - ySize) / 2;
|
||||
int x2 = x - xStart;
|
||||
int y2 = y - yStart;
|
||||
drawTooltip(x2, y2 + 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
this.mc.getTextureManager().bindTexture(new ResourceLocation("gtextras", "textures/gui/armorgui3x4.png"));
|
||||
int xStart = (width - xSize) / 2;
|
||||
int yStart = (height - ySize) / 2;
|
||||
//Draw background
|
||||
drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);
|
||||
//Draw active arrows
|
||||
drawTexturedModalRect(xStart + 10, yStart + 70, 219, 11, 14, 5);
|
||||
//Draw active armor symbol
|
||||
switch (cont.mInvArmor.data.type) {
|
||||
case 0:
|
||||
drawTexturedModalRect(xStart + 73, yStart + 68, 177, 10, 10, 9);
|
||||
break;
|
||||
case 1:
|
||||
drawTexturedModalRect(xStart + 83, yStart + 68, 187, 10, 10, 9);
|
||||
break;
|
||||
case 2:
|
||||
drawTexturedModalRect(xStart + 93, yStart + 68, 197, 10, 10, 9);
|
||||
break;
|
||||
case 3:
|
||||
drawTexturedModalRect(xStart + 103, yStart + 68, 207, 10, 10, 9);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
//Draw active tab
|
||||
switch(tab){
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
drawTexturedModalRect(xStart + 7, yStart + 14, 2, 167, 104, 54);
|
||||
break;
|
||||
case 2:
|
||||
drawTexturedModalRect(xStart + 7, yStart + 14, 107, 167, 104, 54);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if(cont.mInvArmor.data.tankCap>0){
|
||||
drawTexturedModalRect(xStart + 94, yStart + 32, 231, 69, 16, 34);
|
||||
}
|
||||
|
||||
int bar = (int) Math.floor(18 * (cont.mInvArmor.data.weight/(float)1000));
|
||||
drawTexturedModalRect(xStart + 15, yStart + 7, 217, 26, bar, 5);
|
||||
drawTexturedModalRect(xStart + bar + 15, yStart + 7, 197+bar, 26, 18-bar, 5);
|
||||
|
||||
if(tab==0){
|
||||
//processing power bar
|
||||
bar = Math.min((int) Math.floor(52 * ((float)cont.mInvArmor.data.processingPowerUsed/(float)cont.mInvArmor.data.processingPower)),52);
|
||||
drawTexturedModalRect(xStart + 17, yStart + 17, 177, 146, bar, 5);
|
||||
drawTexturedModalRect(xStart + bar + 17, yStart + 17, 177+bar, 139, 52-bar, 5);
|
||||
}else if(tab==1){
|
||||
|
||||
}else{
|
||||
//Def tab values
|
||||
if(cont.mInvArmor.data.physicalDef>0)drawTexturedModalRect(xStart + 30, yStart + 20, 186, 33, 7, 7);
|
||||
drawBars(31, 20, cont.mInvArmor.data.physicalDef);
|
||||
if(cont.mInvArmor.data.projectileDef>0)drawTexturedModalRect(xStart + 30, yStart + 29, 186, 42, 7, 7);
|
||||
drawBars(31, 29, cont.mInvArmor.data.projectileDef);
|
||||
if(cont.mInvArmor.data.fireDef>0)drawTexturedModalRect(xStart + 30, yStart + 38, 186, 51, 7, 7);
|
||||
drawBars(31, 38, cont.mInvArmor.data.fireDef);
|
||||
if(cont.mInvArmor.data.magicDef>0)drawTexturedModalRect(xStart + 30, yStart + 47, 186, 60, 7, 7);
|
||||
drawBars(31, 47, cont.mInvArmor.data.magicDef);
|
||||
if(cont.mInvArmor.data.explosionDef>0)drawTexturedModalRect(xStart + 30, yStart + 56, 186, 69, 7, 7);
|
||||
drawBars(31, 56, cont.mInvArmor.data.explosionDef);
|
||||
if(cont.mInvArmor.data.radiationDef>0)drawTexturedModalRect(xStart + 61, yStart + 20, 186, 87, 7, 7);
|
||||
drawBars(62, 20, cont.mInvArmor.data.radiationDef);
|
||||
if(cont.mInvArmor.data.electricDef>0)drawTexturedModalRect(xStart + 61, yStart + 29, 186, 96, 7, 7);
|
||||
drawBars(62, 29, cont.mInvArmor.data.electricDef);
|
||||
if(cont.mInvArmor.data.witherDef>0)drawTexturedModalRect(xStart + 61, yStart + 38, 186, 105, 7, 7);
|
||||
drawBars(62, 38, cont.mInvArmor.data.witherDef);
|
||||
if(cont.mInvArmor.data.fallDef>0)drawTexturedModalRect(xStart + 61, yStart + 47, 186, 114, 7, 7);
|
||||
if(cont.mInvArmor.data.thorns>0)drawTexturedModalRect(xStart + 61, yStart + 56, 186, 123, 7, 7);
|
||||
if(cont.mInvArmor.data.magnet>0)drawTexturedModalRect(xStart + 70, yStart + 56, 186, 78, 7, 7);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseBtn) {
|
||||
int xStart = mouseX-((width - xSize) / 2);
|
||||
int yStart = mouseY-((height - ySize) / 2);
|
||||
if(yStart>68&&yStart<77){
|
||||
if(xStart>18&&xStart<26){
|
||||
tab++;
|
||||
}else if(xStart>8&&xStart<17){
|
||||
tab--;
|
||||
}
|
||||
if(tab>2){tab=0;}
|
||||
if(tab<0){tab=2;}
|
||||
if(xStart>72&&xStart<112){
|
||||
if(xStart>72&&xStart<81&&cont.mInvArmor.data.helmet!=null){cont.mInvArmor.data.helmet.openGui=true;player.closeScreen();}
|
||||
if(xStart>82&&xStart<91&&cont.mInvArmor.data.chestplate!=null){cont.mInvArmor.data.chestplate.openGui=true;player.closeScreen();}
|
||||
if(xStart>92&&xStart<101&&cont.mInvArmor.data.leggings!=null){cont.mInvArmor.data.leggings.openGui=true;player.closeScreen();}
|
||||
if(xStart>102&&xStart<112&&cont.mInvArmor.data.boots!=null){cont.mInvArmor.data.boots.openGui=true;player.closeScreen();}
|
||||
}
|
||||
}
|
||||
// Slot slot = getSlotAtPosition(mouseX, mouseY);
|
||||
// if (slot != null && slot instanceof SlotFluid && player != null) {
|
||||
// ItemStack tmp = player.inventory.getItemStack();
|
||||
// if (tmp == null) {
|
||||
// GTExtras.NET.sendToServer(new FluidSync(player.getCommandSenderName(), 0, "null"));
|
||||
// }
|
||||
// if (tmp != null && tmp.getItem() instanceof IFluidContainerItem) {
|
||||
// FluidStack tmp2 = ((IFluidContainerItem) tmp.getItem()).getFluid(tmp);
|
||||
// if (!slot.getHasStack() && tmp2 != null) {
|
||||
// slot.putStack(UT.Fluids.display(tmp2, true));
|
||||
// GTExtras.NET.sendToServer(new FluidSync(player.getCommandSenderName(), tmp2.amount, UT.Fluids.name(tmp2, false)));
|
||||
// ItemStack tmp4 = UT.Fluids.getContainerForFilledItem(tmp, true);
|
||||
// tmp4.stackSize = 1;
|
||||
// if (tmp.stackSize > 1) {
|
||||
// player.inventory.addItemStackToInventory(tmp4);
|
||||
// tmp.stackSize--;
|
||||
// player.inventory.setItemStack(tmp);
|
||||
// GTExtras.NET.sendToServer(new FluidSync2(player.getCommandSenderName()));
|
||||
// } else {
|
||||
// player.inventory.setItemStack(null);
|
||||
// player.inventory.addItemStackToInventory(tmp4);
|
||||
// GTExtras.NET.sendToServer(new FluidSync2(player.getCommandSenderName()));
|
||||
// }
|
||||
//
|
||||
// } else if (slot.getHasStack() && tmp2 != null) {
|
||||
// Item fluidSlot = slot.getStack().getItem();
|
||||
// if (fluidSlot.getDamage(slot.getStack()) == tmp2.getFluidID()) {
|
||||
// NBTTagCompound nbt = slot.getStack().getTagCompound();
|
||||
// if (nbt != null) {
|
||||
// tmp2.amount += nbt.getLong("mFluidDisplayAmount");
|
||||
// ItemStack tmp3 = player.inventory.getItemStack();
|
||||
// if (tmp3.stackSize <= 1) {
|
||||
// tmp3 = null;
|
||||
// } else {
|
||||
// tmp3.stackSize--;
|
||||
// }
|
||||
// player.inventory.setItemStack(tmp3);
|
||||
// GTExtras.NET.sendToServer(new FluidSync2(player.getCommandSenderName()));
|
||||
// slot.putStack(UT.Fluids.display(tmp2, true));
|
||||
// GTExtras.NET.sendToServer(new FluidSync(player.getCommandSenderName(), tmp2.amount, UT.Fluids.name(tmp2, false)));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
super.mouseClicked(mouseX, mouseY, mouseBtn);
|
||||
}
|
||||
|
||||
protected void drawTooltip(int x, int y) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
//General tooltips
|
||||
if(x>=7&&y>=11&&x<=33&&y<=17){
|
||||
list.add(GT_LanguageManager.getTranslation("weight") + ": " + cont.mInvArmor.data.weight);
|
||||
list.add("Total Weight: "+cont.mInvArmor.data.maxWeight);
|
||||
if (cont.mInvArmor.data.weight > 1000)
|
||||
list.add("Too Heavy!");
|
||||
}
|
||||
if(x>=56&&y>=11&&x<=112&&y<=17){
|
||||
list.add("Stored Energy: "+seperateNumber(cont.mInvArmor.data.charge)+" EU");
|
||||
}
|
||||
if(y>74&&y<83){
|
||||
if(x>8&&x<17){
|
||||
list.add("Previous Page");
|
||||
}else if(x>18&&x<27){
|
||||
list.add("Next Page");
|
||||
}else if(x>72&&x<80){
|
||||
list.add("Helmet");
|
||||
}else if(x>81&&x<90){
|
||||
list.add("Chestplate");
|
||||
}else if(x>91&&x<100){
|
||||
list.add("Leggings");
|
||||
}else if(x>101&&x<110){
|
||||
list.add("Boots");
|
||||
}
|
||||
}
|
||||
if(tab==0){
|
||||
if(x>=93&&y>=36&&x<=110&&y<=71){list.add("Tank Capacity: "+cont.mInvArmor.data.tankCap+"L");
|
||||
}
|
||||
if(x>=7&&y>=22&&x<=70&&y<=28){list.add("Processing Power Provided: "+cont.mInvArmor.data.processingPower);
|
||||
list.add("Processing Power Used: "+cont.mInvArmor.data.processingPowerUsed);
|
||||
}
|
||||
}else if(tab==1){
|
||||
|
||||
}else{
|
||||
if (x >= 28 && x <= 58) {
|
||||
if (y >= 25 && y <= 32) {
|
||||
list.add(GT_LanguageManager.getTranslation("phydef") + ": " + (Math.round(cont.mInvArmor.data.physicalDef * 1000) / 10.0) + "%");
|
||||
} else if (y >= 33 && y <= 41) {
|
||||
list.add(GT_LanguageManager.getTranslation("prodef") + ": " + (Math.round(cont.mInvArmor.data.projectileDef * 1000) / 10.0) + "%");
|
||||
} else if (y >= 42 && y <= 50) {
|
||||
list.add(GT_LanguageManager.getTranslation("firedef") + ": " + (Math.round(cont.mInvArmor.data.fireDef * 1000) / 10.0) + "%");
|
||||
} else if (y >= 51 && y <= 59) {
|
||||
list.add(GT_LanguageManager.getTranslation("magdef") + ": " + (Math.round(cont.mInvArmor.data.magicDef * 1000) / 10.0) + "%");
|
||||
} else if (y >= 60 && y <= 68) {
|
||||
list.add(GT_LanguageManager.getTranslation("expdef") + ": " + (Math.round(cont.mInvArmor.data.explosionDef * 1000) / 10.0) + "%");
|
||||
}
|
||||
} else if (x >= 59 && x <= 90) {
|
||||
if (y >= 25 && y <= 32) {
|
||||
list.add(GT_LanguageManager.getTranslation("raddef") + ": " + (Math.round(cont.mInvArmor.data.radiationDef * 1000) / 10.0) + "%");
|
||||
if(cont.mInvArmor.data.fullRadiationDef){
|
||||
list.add("Radiation Immunity");}
|
||||
} else if (y >= 33 && y <= 41) {
|
||||
list.add(GT_LanguageManager.getTranslation("eledef") + ": " + (Math.round(cont.mInvArmor.data.electricDef * 1000) / 10.0) + "%");
|
||||
if(cont.mInvArmor.data.fullElectricDef){
|
||||
list.add("Electric Immunity");}
|
||||
} else if (y >= 42 && y <= 50) {
|
||||
list.add(GT_LanguageManager.getTranslation("whidef") + ": " + (Math.round(cont.mInvArmor.data.witherDef * 1000) / 10.0) + "%");
|
||||
} else if (y >= 51 && y <= 59) {
|
||||
if(cont.mInvArmor.data.type!=3){
|
||||
list.add("Fall Damage absorbtion");
|
||||
list.add("Only for Boots");
|
||||
}else{
|
||||
list.add(GT_LanguageManager.getTranslation("abs1") + " " + (int) Math.round(cont.mInvArmor.data.fallDef) + GT_LanguageManager.getTranslation("abs2"));}
|
||||
} else if (y >= 60 && y <= 68) {
|
||||
if(x<69){
|
||||
list.add(GT_LanguageManager.getTranslation("thorns") + ": " + (int) Math.round(cont.mInvArmor.data.thornsSingle) + " Dmg");
|
||||
list.add("Total "+GT_LanguageManager.getTranslation("thorns") + ": " + (int) Math.round(cont.mInvArmor.data.thorns) + " Dmg");
|
||||
}else{
|
||||
list.add(GT_LanguageManager.getTranslation("magnet") + ": " + cont.mInvArmor.data.magnetSingle + " m");
|
||||
list.add("Total "+GT_LanguageManager.getTranslation("magnet") + ": " + cont.mInvArmor.data.magnet + " m");}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!list.isEmpty())
|
||||
drawHoveringText(list, x, y, fontRendererObj);
|
||||
}
|
||||
|
||||
public void drawBars(int x, int y, float value) {
|
||||
|
||||
int bar = (int) Math.floor(18 * value);
|
||||
int xStart = (width - xSize) / 2;
|
||||
int yStart = (height - ySize) / 2;
|
||||
xStart += 8;
|
||||
yStart += 1;
|
||||
drawTexturedModalRect(xStart + x, yStart + y, 217, 26, bar, 5);
|
||||
drawTexturedModalRect(xStart+ bar + x, yStart + y, 197+bar, 26, 18-bar, 5);
|
||||
}
|
||||
|
||||
protected Slot getSlotAtPosition(int p_146975_1_, int p_146975_2_) {
|
||||
for (int k = 0; k < cont.inventorySlots.size(); ++k) {
|
||||
Slot slot = (Slot) cont.inventorySlots.get(k);
|
||||
if (this.isMouseOverSlot(slot, p_146975_1_, p_146975_2_)) {
|
||||
return slot;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private boolean isMouseOverSlot(Slot p_146981_1_, int p_146981_2_, int p_146981_3_) {
|
||||
return this.func_146978_c(p_146981_1_.xDisplayPosition, p_146981_1_.yDisplayPosition, 16, 16, p_146981_2_, p_146981_3_);
|
||||
}
|
||||
}
|
196
src/main/java/gregtech/common/items/armor/GuiModularArmor.java
Normal file
196
src/main/java/gregtech/common/items/armor/GuiModularArmor.java
Normal file
|
@ -0,0 +1,196 @@
|
|||
package gregtech.common.items.armor;
|
||||
|
||||
import gregtech.api.util.GT_LanguageManager;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.gui.inventory.GuiContainer;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public class GuiModularArmor extends GuiContainer {
|
||||
ContainerModularArmor cont;
|
||||
EntityPlayer player;
|
||||
|
||||
public GuiModularArmor(ContainerModularArmor containerModularArmor,EntityPlayer aPlayer) {
|
||||
super(containerModularArmor);
|
||||
cont = containerModularArmor;
|
||||
this.player = aPlayer;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerForegroundLayer(int x, int y) {
|
||||
int xStart = (width - xSize) / 2;
|
||||
int yStart = (height - ySize) / 2;
|
||||
int x2 = x - xStart;
|
||||
int y2 = y - yStart;
|
||||
drawTooltip(x2, y2 + 5);
|
||||
}
|
||||
|
||||
protected void drawTooltip(int x, int y) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
if (x >= 10 && x <= 17) {
|
||||
if (y >= 20 && y <= 27) {
|
||||
list.add(GT_LanguageManager.getTranslation("weight") + ": " + cont.mInvArmor.data.weight);
|
||||
list.add("Total Weight: "+cont.mInvArmor.data.maxWeight);
|
||||
if (cont.mInvArmor.data.weight > 1000)
|
||||
list.add("Too Heavy!");
|
||||
} else if (y >= 29 && y <= 36) {
|
||||
list.add(GT_LanguageManager.getTranslation("phydef") + ": " + (Math.round(cont.mInvArmor.data.physicalDef * 1000) / 10.0) + "%");
|
||||
} else if (y >= 38 && y <= 45) {
|
||||
list.add(GT_LanguageManager.getTranslation("prodef") + ": " + (Math.round(cont.mInvArmor.data.projectileDef * 1000) / 10.0) + "%");
|
||||
} else if (y >= 47 && y <= 54) {
|
||||
list.add(GT_LanguageManager.getTranslation("firedef") + ": " + (Math.round(cont.mInvArmor.data.fireDef * 1000) / 10.0) + "%");
|
||||
} else if (y >= 56 && y <= 63) {
|
||||
list.add(GT_LanguageManager.getTranslation("magdef") + ": " + (Math.round(cont.mInvArmor.data.magicDef * 1000) / 10.0) + "%");
|
||||
} else if (y >= 65 && y <= 72) {
|
||||
list.add(GT_LanguageManager.getTranslation("expdef") + ": " + (Math.round(cont.mInvArmor.data.explosionDef * 1000) / 10.0) + "%");
|
||||
}
|
||||
} else if (x >= 59 && x <= 66) {
|
||||
if (y >= 20 && y <= 27) {
|
||||
list.add(GT_LanguageManager.getTranslation("thorns") + ": " + (int) Math.round(cont.mInvArmor.data.thornsSingle) + " Dmg");
|
||||
list.add("Total "+GT_LanguageManager.getTranslation("thorns") + ": " + (int) Math.round(cont.mInvArmor.data.thorns) + " Dmg");
|
||||
} else if (y >= 29 && y <= 36) {
|
||||
list.add(GT_LanguageManager.getTranslation("magnet") + ": " + cont.mInvArmor.data.magnetSingle + " m");
|
||||
list.add("Total "+GT_LanguageManager.getTranslation("magnet") + ": " + cont.mInvArmor.data.magnet + " m");
|
||||
} else if (y >= 38 && y <= 45) {
|
||||
list.add(GT_LanguageManager.getTranslation("raddef") + ": " + (Math.round(cont.mInvArmor.data.radiationDef * 1000) / 10.0) + "%");
|
||||
if(cont.mInvArmor.data.fullRadiationDef){
|
||||
list.add("Radiation Immunity");}
|
||||
} else if (y >= 47 && y <= 54) {
|
||||
list.add(GT_LanguageManager.getTranslation("eledef") + ": " + (Math.round(cont.mInvArmor.data.electricDef * 1000) / 10.0) + "%");
|
||||
if(cont.mInvArmor.data.fullElectricDef){
|
||||
list.add("Electric Immunity");}
|
||||
} else if (y >= 56 && y <= 63) {
|
||||
list.add(GT_LanguageManager.getTranslation("whidef") + ": " + (Math.round(cont.mInvArmor.data.witherDef * 1000) / 10.0) + "%");
|
||||
} else if (y >= 65 && y <= 72) {
|
||||
if(cont.mInvArmor.data.type!=3){
|
||||
list.add("Fall Damage absorbtion");
|
||||
list.add("Only for Boots");
|
||||
}else{
|
||||
list.add(GT_LanguageManager.getTranslation("abs1") + " " + (int) Math.round(cont.mInvArmor.data.fallDef) + GT_LanguageManager.getTranslation("abs2"));}
|
||||
}
|
||||
}
|
||||
if (!list.isEmpty())
|
||||
drawHoveringText(list, x, y, fontRendererObj);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
|
||||
GL11.glColor4f(1F, 1F, 1F, 1F);
|
||||
this.mc.getTextureManager().bindTexture(new ResourceLocation("gtextras", "textures/gui/armorgui3x3.png"));
|
||||
int xStart = (width - xSize) / 2;
|
||||
int yStart = (height - ySize) / 2;
|
||||
drawTexturedModalRect(xStart, yStart, 0, 0, xSize, ySize);
|
||||
|
||||
switch (cont.mInvArmor.data.type) {
|
||||
case 0:
|
||||
drawTexturedModalRect(xStart + 124, yStart + 67, 177, 10, 10, 9);
|
||||
break;
|
||||
case 1:
|
||||
drawTexturedModalRect(xStart + 134, yStart + 67, 187, 10, 10, 9);
|
||||
break;
|
||||
case 2:
|
||||
drawTexturedModalRect(xStart + 144, yStart + 67, 197, 10, 10, 9);
|
||||
break;
|
||||
case 3:
|
||||
drawTexturedModalRect(xStart + 154, yStart + 67, 207, 10, 10, 9);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Weight: 10, 15 =191, 20
|
||||
if(cont.mInvArmor.data.weight>0){
|
||||
drawTexturedModalRect(xStart + 10, yStart + 15, 191, 20, 7, 7);
|
||||
}
|
||||
// Physical Def: 10, 24 =191, 29
|
||||
if(cont.mInvArmor.data.physicalDef>0){
|
||||
drawTexturedModalRect(xStart + 10, yStart + 24, 191, 29, 7, 7);
|
||||
}
|
||||
// Projectile Def: 10, 33 =191, 38
|
||||
if(cont.mInvArmor.data.projectileDef>0){
|
||||
drawTexturedModalRect(xStart + 10, yStart + 33, 191, 38, 7, 7);
|
||||
}
|
||||
// Fire Def: 10, 42 =191, 47
|
||||
if(cont.mInvArmor.data.fireDef>0){
|
||||
drawTexturedModalRect(xStart + 10, yStart + 42, 191, 47, 7, 7);
|
||||
}
|
||||
// Magic Def: 10, 51 =191, 56
|
||||
if(cont.mInvArmor.data.magicDef>0){
|
||||
drawTexturedModalRect(xStart + 10, yStart + 51, 191, 56, 7, 7);
|
||||
}
|
||||
// Explosive Def: 10, 60 =191, 65
|
||||
if(cont.mInvArmor.data.explosionDef>0){
|
||||
drawTexturedModalRect(xStart + 10, yStart + 60, 191, 65, 7, 7);
|
||||
}
|
||||
// Thorns: 59, 15 =198, 20
|
||||
if(cont.mInvArmor.data.thorns>0){
|
||||
drawTexturedModalRect(xStart + 59, yStart + 15, 198, 20, 7, 7);
|
||||
}
|
||||
// Magnet: 59, 24 =198, 29
|
||||
if(cont.mInvArmor.data.magnetSingle>0){
|
||||
drawTexturedModalRect(xStart + 59, yStart + 24, 198, 29, 7, 7);
|
||||
}
|
||||
// Radiation Def: 59, 33 =198, 38
|
||||
if(cont.mInvArmor.data.radiationDef>0){
|
||||
drawTexturedModalRect(xStart + 59, yStart + 33, 198, 38, 7, 7);
|
||||
}
|
||||
// Electric Def: 59, 42 =198, 47
|
||||
if(cont.mInvArmor.data.electricDef>0){
|
||||
drawTexturedModalRect(xStart + 59, yStart + 42, 198, 47, 7, 7);
|
||||
}
|
||||
// Wither Def: 59, 51 =198, 56
|
||||
if(cont.mInvArmor.data.witherDef>0){
|
||||
drawTexturedModalRect(xStart + 59, yStart + 51, 198, 56, 7, 7);
|
||||
}
|
||||
// Fall Reduction: 59, 60 =198, 65
|
||||
if(cont.mInvArmor.data.fallDef>0){
|
||||
drawTexturedModalRect(xStart + 59, yStart + 60, 198, 65, 7, 7);
|
||||
}
|
||||
|
||||
drawBars(10, 24, cont.mInvArmor.data.physicalDef);
|
||||
drawBars(10, 33, cont.mInvArmor.data.projectileDef);
|
||||
drawBars(10, 42, cont.mInvArmor.data.fireDef);
|
||||
drawBars(10, 51, cont.mInvArmor.data.magicDef);
|
||||
drawBars(10, 60, cont.mInvArmor.data.explosionDef);
|
||||
drawBars(59, 33, cont.mInvArmor.data.radiationDef);
|
||||
drawBars(59, 42, cont.mInvArmor.data.electricDef);
|
||||
drawBars(59, 51, cont.mInvArmor.data.witherDef);
|
||||
}
|
||||
|
||||
public void drawBars(int x, int y, float value) {
|
||||
|
||||
int bar = (int) Math.floor(35 * value);
|
||||
int xStart = (width - xSize) / 2;
|
||||
int yStart = (height - ySize) / 2;
|
||||
xStart += 8;
|
||||
yStart += 1;
|
||||
//drawRect(x + xStart, y + yStart, x + bar + xStart, y + 5 + yStart, 0x8000FF00);
|
||||
//drawRect(x + bar + xStart, y + yStart, x + 36 + xStart, y + 5 + yStart, 0x80FF0000);
|
||||
drawTexturedModalRect(xStart + x, yStart + y, 177, 78, bar, 5);
|
||||
drawTexturedModalRect(xStart+ bar + x, yStart + y, 177, 73, 35-bar, 5);
|
||||
}
|
||||
|
||||
protected void mouseClicked(int mouseX, int mouseY, int mouseBtn) {
|
||||
int xStart = mouseX-((width - xSize) / 2);
|
||||
int yStart = mouseY-((height - ySize) / 2);
|
||||
if(yStart>67&&yStart<77){
|
||||
if(xStart>124&&xStart<163){
|
||||
if(xStart>124&&xStart<133&&cont.mInvArmor.data.helmet!=null){cont.mInvArmor.data.helmet.openGui=true;player.closeScreen();}
|
||||
if(xStart>134&&xStart<143&&cont.mInvArmor.data.chestplate!=null){cont.mInvArmor.data.chestplate.openGui=true;player.closeScreen();}
|
||||
if(xStart>144&&xStart<153&&cont.mInvArmor.data.leggings!=null){cont.mInvArmor.data.leggings.openGui=true;player.closeScreen();}
|
||||
if(xStart>154&&xStart<163&&cont.mInvArmor.data.boots!=null){cont.mInvArmor.data.boots.openGui=true;player.closeScreen();}
|
||||
}
|
||||
}
|
||||
super.mouseClicked(mouseX, mouseY, mouseBtn);
|
||||
}
|
||||
|
||||
}
|
235
src/main/java/gregtech/common/items/armor/InventoryArmor.java
Normal file
235
src/main/java/gregtech/common/items/armor/InventoryArmor.java
Normal file
|
@ -0,0 +1,235 @@
|
|||
package gregtech.common.items.armor;
|
||||
|
||||
import gregtech.api.util.GT_Utility;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.Container;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.nbt.NBTTagList;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
import net.minecraftforge.oredict.OreDictionary;
|
||||
|
||||
public class InventoryArmor implements IInventory {
|
||||
|
||||
public ItemStack[] parts;
|
||||
public ItemStack parent;
|
||||
// float[] def = new float[32];
|
||||
public int maxCharge;
|
||||
public int charge;
|
||||
public ArmorData data;
|
||||
|
||||
public InventoryArmor(Class<ModularArmor_Item> class1, ItemStack currentEquippedItem) {
|
||||
this.parts = new ItemStack[16];
|
||||
this.parent = currentEquippedItem;
|
||||
setUID(false);
|
||||
readFromNBT(currentEquippedItem.getTagCompound());
|
||||
// for (int i = 0; i < def.length; i++) {
|
||||
// def[i] = 0.0f;
|
||||
// }
|
||||
if(currentEquippedItem.getItem() instanceof ModularArmor_Item){
|
||||
data = ((ModularArmor_Item)currentEquippedItem.getItem()).data;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSizeInventory() {
|
||||
return this.parts.length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlot(int i) {
|
||||
return parts[i];
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i, int j) {
|
||||
if (parts[i] == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
ItemStack product;
|
||||
if (parts[i].stackSize <= j) {
|
||||
product = parts[i];
|
||||
parts[i] = null;
|
||||
// def = ArmorCalculation.calculateArmor(parts);
|
||||
data.calculateArmor(parts);
|
||||
return product;
|
||||
} else {
|
||||
product = parts[i].splitStack(j);
|
||||
if (parts[i].stackSize == 0) {
|
||||
parts[i] = null;
|
||||
}
|
||||
// def = ArmorCalculation.calculateArmor(parts);
|
||||
data.calculateArmor(parts);
|
||||
return product;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getStackInSlotOnClosing(int slot) {
|
||||
if (parts[slot] == null) {
|
||||
return null;
|
||||
}
|
||||
ItemStack toReturn = parts[slot];
|
||||
parts[slot] = null;
|
||||
return toReturn;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setInventorySlotContents(int i, ItemStack itemstack) {
|
||||
parts[i] = itemstack;
|
||||
// def = ArmorCalculation.calculateArmor(parts);
|
||||
data.calculateArmor(parts);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getInventoryName() {
|
||||
return "container.armor";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCustomInventoryName() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getInventoryStackLimit() {
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void markDirty() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUseableByPlayer(EntityPlayer p_70300_1_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValidForSlot(int p_94041_1_, ItemStack p_94041_2_) {
|
||||
return true;
|
||||
}
|
||||
|
||||
public void onGuiSaved(EntityPlayer entityplayer) {
|
||||
parent = findParentInInventory(entityplayer);
|
||||
if (parent != null) {
|
||||
save();
|
||||
}
|
||||
}
|
||||
|
||||
public void save() {
|
||||
NBTTagCompound nbt = parent.getTagCompound();
|
||||
if (nbt == null) {
|
||||
nbt = new NBTTagCompound();
|
||||
}
|
||||
writeToNBT(nbt);
|
||||
ModularArmor_Item tmp = (ModularArmor_Item) parent.getItem();
|
||||
tmp.data.calculateArmor(parts);
|
||||
parent.setTagCompound(nbt);
|
||||
}
|
||||
|
||||
public void writeToNBT(NBTTagCompound nbt) {
|
||||
NBTTagList nbttaglist = new NBTTagList();
|
||||
for (int i = 0; i < parts.length; i++) {
|
||||
if (parts[i] != null) {
|
||||
NBTTagCompound nbttagcompound1 = new NBTTagCompound();
|
||||
nbttagcompound1.setByte("Slot", (byte) i);
|
||||
parts[i].writeToNBT(nbttagcompound1);
|
||||
nbttaglist.appendTag(nbttagcompound1);
|
||||
}
|
||||
}
|
||||
nbt.setTag("Items", nbttaglist);
|
||||
}
|
||||
|
||||
public ItemStack findParentInInventory(EntityPlayer player) {
|
||||
for (int i = 0; i < player.inventory.getSizeInventory(); i++) {
|
||||
ItemStack stack = player.inventory.getStackInSlot(i);
|
||||
if (isIdenticalItem(stack, parent)) {
|
||||
return stack;
|
||||
}
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
|
||||
public static boolean isIdenticalItem(ItemStack lhs, ItemStack rhs) {
|
||||
if (lhs == null || rhs == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lhs.getItem() != rhs.getItem()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (lhs.getItemDamage() != OreDictionary.WILDCARD_VALUE) {
|
||||
if (lhs.getItemDamage() != rhs.getItemDamage()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return ItemStack.areItemStackTagsEqual(lhs, rhs);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound nbt) {
|
||||
if (nbt == null) {
|
||||
return;
|
||||
}
|
||||
if (nbt.hasKey("Items")) {
|
||||
NBTTagList nbttaglist = nbt.getTagList("Items", 10);
|
||||
parts = new ItemStack[getSizeInventory()];
|
||||
for (int i = 0; i < nbttaglist.tagCount(); i++) {
|
||||
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
|
||||
byte byte0 = nbttagcompound1.getByte("Slot");
|
||||
if (byte0 >= 0 && byte0 < parts.length) {
|
||||
parts[byte0] = ItemStack.loadItemStackFromNBT(nbttagcompound1);
|
||||
//parts[12]= UT.Fluids.display(UT.Fluids.water(1234), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void setUID(boolean override) {
|
||||
if (parent.getTagCompound() == null) {
|
||||
parent.setTagCompound(new NBTTagCompound());
|
||||
}
|
||||
NBTTagCompound nbt = parent.getTagCompound();
|
||||
if (override || !nbt.hasKey("UID")) {
|
||||
nbt.setInteger("UID", new Random().nextInt());
|
||||
}
|
||||
}
|
||||
|
||||
public static int getOccupiedSlotCount(ItemStack itemStack) {
|
||||
NBTTagCompound nbt = itemStack.getTagCompound();
|
||||
if (nbt == null) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int count = 0;
|
||||
if (nbt.hasKey("Items")) {
|
||||
NBTTagList nbttaglist = nbt.getTagList("Items", 10);
|
||||
for (int i = 0; i < nbttaglist.tagCount(); i++) {
|
||||
NBTTagCompound nbttagcompound1 = nbttaglist.getCompoundTagAt(i);
|
||||
ItemStack itemStack1 = ItemStack.loadItemStackFromNBT(nbttagcompound1);
|
||||
if (itemStack1 != null && itemStack1.stackSize > 0) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
}
|
449
src/main/java/gregtech/common/items/armor/ModularArmor_Item.java
Normal file
449
src/main/java/gregtech/common/items/armor/ModularArmor_Item.java
Normal file
|
@ -0,0 +1,449 @@
|
|||
package gregtech.common.items.armor;
|
||||
|
||||
import gregtech.api.damagesources.GT_DamageSources;
|
||||
import ic2.core.IC2;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import cpw.mods.fml.common.FMLCommonHandler;
|
||||
import cpw.mods.fml.common.Optional;
|
||||
import thaumcraft.api.IGoggles;
|
||||
import thaumcraft.api.nodes.IRevealer;
|
||||
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.texture.IIconRegister;
|
||||
import net.minecraft.client.settings.GameSettings;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.entity.EntityLivingBase;
|
||||
import net.minecraft.entity.item.EntityItem;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.init.Items;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemArmor;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.item.ItemArmor.ArmorMaterial;
|
||||
import net.minecraft.potion.Potion;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ISpecialArmor;
|
||||
import net.minecraftforge.common.MinecraftForge;
|
||||
import net.minecraftforge.common.util.ForgeDirection;
|
||||
import net.minecraftforge.event.entity.living.LivingFallEvent;
|
||||
|
||||
@Optional.InterfaceList(value = { @Optional.Interface(iface = "thaumcraft.api.IGoggles", modid = "Thaumcraft", striprefs = true),
|
||||
@Optional.Interface(iface = "thaumcraft.api.nodes.IRevealer", modid = "Thaumcraft", striprefs = true) })
|
||||
public class ModularArmor_Item extends ItemArmor implements ISpecialArmor, IGoggles, IRevealer {
|
||||
|
||||
public String mName;
|
||||
public int timer = 160;
|
||||
public Item repairMaterial;
|
||||
public int openGuiNr;
|
||||
public ArmorData data;
|
||||
public int jumpticks;
|
||||
|
||||
// public int maxEU;
|
||||
|
||||
public ModularArmor_Item(int aArmorIndex, int aType, String name, int gui) {
|
||||
super(ArmorMaterial.DIAMOND, aArmorIndex, aType);
|
||||
MinecraftForge.EVENT_BUS.register(this);
|
||||
setUnlocalizedName("gtextras:" + name);
|
||||
GameRegistry.registerItem(this, name);
|
||||
mName = name;
|
||||
int mMaxDamage = (gui + 1) * 1024;
|
||||
mMaxDamage *= getBaseAbsorptionRatio() * 2.5;
|
||||
setMaxDamage(mMaxDamage);
|
||||
repairMaterial = Items.leather;
|
||||
openGuiNr = gui;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack onItemRightClick(ItemStack aStack, World aWorld, EntityPlayer aPlayer) {
|
||||
if (data == null) {
|
||||
data = fillArmorData(aPlayer, aStack);
|
||||
}
|
||||
if (!aWorld.isRemote) {
|
||||
//TODO
|
||||
// aPlayer.openGui(GTExtras.INSTANCE, openGuiNr, aWorld, (int) aPlayer.posX, (int) aPlayer.posY, (int) aPlayer.posZ);
|
||||
}
|
||||
return aStack;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISpecialArmor.ArmorProperties getProperties(EntityLivingBase player, ItemStack armor, DamageSource source, double damage, int slot) {
|
||||
if (data == null) {
|
||||
data = fillArmorData((EntityPlayer) player, armor);
|
||||
}
|
||||
if (player != null && armor != null && source != null) {
|
||||
double tmp = 0.0d;
|
||||
if (source.isMagicDamage()) {
|
||||
tmp = data.magicDef;
|
||||
} else if (source == GT_DamageSources.getRadioactiveDamage()) {
|
||||
tmp = data.radiationDef;
|
||||
} else if (source == GT_DamageSources.getElectricDamage()) {
|
||||
tmp = data.electricDef;
|
||||
} else if (source == DamageSource.wither) {
|
||||
tmp = data.witherDef;
|
||||
} else if (source.isFireDamage() || source == GT_DamageSources.getHeatDamage()) {
|
||||
tmp = data.fireDef;
|
||||
} else if (source.isExplosion()) {
|
||||
tmp = data.explosionDef;
|
||||
} else if (source.isProjectile()) {
|
||||
tmp = data.projectileDef;
|
||||
} else {
|
||||
tmp = data.physicalDef;
|
||||
}
|
||||
if (data.thorns > 0.1d && source != DamageSource.fall && source.getSourceOfDamage() != null) {
|
||||
source.getSourceOfDamage().attackEntityFrom(new DamageSource("Thorns"), data.thorns);
|
||||
}
|
||||
|
||||
// fallDamage
|
||||
if (source == DamageSource.fall) {
|
||||
int fallDef = 0;
|
||||
ItemStack stack = player.getEquipmentInSlot(1);
|
||||
if (stack != null && stack.getItem() instanceof ModularArmor_Item) {
|
||||
fallDef = (int) data.boots.fallDef;
|
||||
}
|
||||
tmp = 1.0d - (fallDef > damage ? 0.0d : (1.0d - tmp) * 0.5d);
|
||||
}
|
||||
if (tmp == 0.0d) {
|
||||
tmp = data.physicalDef;
|
||||
}
|
||||
if (openGuiNr == 2) {
|
||||
tmp = 1.0f - ((1.0f - tmp) / 2.0f);
|
||||
}
|
||||
return new ISpecialArmor.ArmorProperties(0, data.getBaseAbsorptionRatio() * tmp, 1000);
|
||||
|
||||
} else {
|
||||
return new ISpecialArmor.ArmorProperties(0, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getArmorDisplay(EntityPlayer player, ItemStack armor, int slot) {
|
||||
if (data == null) {
|
||||
data = fillArmorData(player, armor);
|
||||
}
|
||||
int tmp = (int) -Math.floor(-(data.getBaseAbsorptionRatio() * 20 * data.physicalDef));
|
||||
|
||||
return tmp;
|
||||
}
|
||||
|
||||
public void addInformation(ItemStack itemStack, EntityPlayer player, List info, boolean b) {
|
||||
if (data == null) {
|
||||
data = fillArmorData(player, itemStack);
|
||||
}
|
||||
if (data.info != null)
|
||||
info.addAll(data.info);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void damageArmor(EntityLivingBase entity, ItemStack stack, DamageSource source, int damage, int slot) {
|
||||
if (data == null) {
|
||||
data = fillArmorData((EntityPlayer) entity, stack);
|
||||
}
|
||||
stack.damageItem(damage, entity);
|
||||
ContainerModularArmor tmp = new ContainerBasicArmor((EntityPlayer) entity, new InventoryArmor(ModularArmor_Item.class, stack));
|
||||
if (stack.getItemDamage() > stack.getMaxDamage() / 2 && new Random().nextInt(100) < 5) {
|
||||
tmp.getSlot(new Random().nextInt(tmp.getSlotCount())).decrStackSize(1);
|
||||
tmp.mInvArmor.onGuiSaved((EntityPlayer) entity);
|
||||
|
||||
/*public void eject(ItemStack drop)
|
||||
{
|
||||
if ((!IC2.platform.isSimulating()) || (drop == null)) {
|
||||
return;
|
||||
}
|
||||
float f = 0.7F;
|
||||
double d = this.worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D;
|
||||
double d1 = this.worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D;
|
||||
double d2 = this.worldObj.rand.nextFloat() * f + (1.0F - f) * 0.5D;
|
||||
EntityItem entityitem = new EntityItem(this.worldObj, this.xCoord + d, this.yCoord + d1, this.zCoord + d2, drop);
|
||||
entityitem.delayBeforeCanPickup = 10;
|
||||
this.worldObj.spawnEntityInWorld(entityitem);
|
||||
}*/
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@SubscribeEvent
|
||||
public void onEntityLivingFallEvent(LivingFallEvent event) {
|
||||
if (FMLCommonHandler.instance().getEffectiveSide().isServer() && event.entity instanceof EntityPlayer) {
|
||||
EntityPlayer player = (EntityPlayer) event.entity;
|
||||
ItemStack armor = player.inventory.armorInventory[0];
|
||||
if (data != null && event != null && data.type == 3 && data.charge >= data.pistonEUusage && event.distance - 3 <= data.fallDef) {
|
||||
event.setCanceled(true);
|
||||
} else if (data != null && event != null && data.type == 3 && data.charge >= data.pistonEUusage) {
|
||||
event.distance -= data.fallDef;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onArmorTick(World aWorld, EntityPlayer aPlayer, ItemStack aStack) {
|
||||
if (data == null) {
|
||||
data = fillArmorData(aPlayer, aStack);
|
||||
}
|
||||
if (data.tooltipUpdate > 40) {
|
||||
data.armorPartsEquipped(aPlayer);
|
||||
data.tooltipUpdate = 0;
|
||||
data.updateTooltip();
|
||||
} else {
|
||||
data.tooltipUpdate++;
|
||||
}
|
||||
if (aPlayer.onGround) {
|
||||
jumpticks = 4;
|
||||
} else {
|
||||
jumpticks--;
|
||||
}
|
||||
|
||||
// Breathing
|
||||
if (data.type == 0 && aPlayer.getAir() < 100) {
|
||||
int air = 0;
|
||||
if (data.fluid.getUnlocalizedName().equals("fluid.oxygen") && data.fluid.amount >= 150) {
|
||||
aPlayer.setAir(aPlayer.getAir() + 150);
|
||||
air = 150;
|
||||
} else if (data.fluid.getUnlocalizedName().equals("fluid.air") && data.fluid.amount >= 500) {
|
||||
aPlayer.setAir(aPlayer.getAir() + 100);
|
||||
air = 500;
|
||||
}
|
||||
if (air > 0) {
|
||||
data.fluid.amount -= air;
|
||||
ItemStack stack = aPlayer.getEquipmentInSlot(4);
|
||||
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));
|
||||
ArmorCalculation.useFluid(tmp2.mInvArmor.parts, air);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fill Air Tank
|
||||
if (data.tooltipUpdate == 40 && data.processingPower > data.processingPowerUsed && data.type == 0 && data.fluid != null
|
||||
&& data.fluid.getUnlocalizedName().equals("oxygen") && data.fluid.amount < data.tankCap && data.charge > data.electrolyzerEUusage) {
|
||||
data.charge -= data.electrolyzerEUusage;
|
||||
ItemStack stack = aPlayer.getEquipmentInSlot(4);
|
||||
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));
|
||||
ArmorCalculation.useFluid(tmp2.mInvArmor.parts, -data.electrolyzerProd);
|
||||
}
|
||||
}
|
||||
|
||||
if (data.isTopItem) {
|
||||
if(IC2.keyboard.isModeSwitchKeyDown(aPlayer)&&!aWorld.isRemote){
|
||||
int typeMod=0;
|
||||
switch(data.type){
|
||||
case 0:
|
||||
typeMod=400;
|
||||
break;
|
||||
case 1:
|
||||
typeMod=300;
|
||||
break;
|
||||
case 2:
|
||||
typeMod=200;
|
||||
break;
|
||||
case 3:
|
||||
typeMod=100;
|
||||
break;
|
||||
}
|
||||
//TODO
|
||||
// aPlayer.openGui(GTExtras.INSTANCE, openGuiNr+(typeMod), aWorld, (int) aPlayer.posX, (int) aPlayer.posY, (int) aPlayer.posZ);
|
||||
}
|
||||
//TODO
|
||||
// if(data.helmet!=null&&data.helmet.openGui){data.helmet.openGui=false;aPlayer.openGui(GTExtras.INSTANCE, openGuiNr+400, aWorld, (int) aPlayer.posX, (int) aPlayer.posY, (int) aPlayer.posZ);}
|
||||
// if(data.chestplate!=null&&data.chestplate.openGui){data.chestplate.openGui=false;aPlayer.openGui(GTExtras.INSTANCE, openGuiNr+300, aWorld, (int) aPlayer.posX, (int) aPlayer.posY, (int) aPlayer.posZ);}
|
||||
// if(data.leggings!=null&&data.leggings.openGui){data.leggings.openGui=false;aPlayer.openGui(GTExtras.INSTANCE, openGuiNr+200, aWorld, (int) aPlayer.posX, (int) aPlayer.posY, (int) aPlayer.posZ);}
|
||||
// if(data.boots!=null&&data.boots.openGui){data.boots.openGui=false;aPlayer.openGui(GTExtras.INSTANCE, openGuiNr+100, aWorld, (int) aPlayer.posX, (int) aPlayer.posY, (int) aPlayer.posZ);}
|
||||
// Night Vision
|
||||
if (timer >= 200) {
|
||||
timer = 0;
|
||||
if (data.processingPower > data.processingPowerUsed && data.helmet != null && data.helmet.nightVision && data.charge > 3) {
|
||||
aPlayer.addPotionEffect(new PotionEffect(Potion.nightVision.getId(), 500, -3));
|
||||
data.charge -= 4;
|
||||
} else {
|
||||
PotionEffect nv = aPlayer.getActivePotionEffect(Potion.nightVision);
|
||||
if (nv != null && nv.getAmplifier() == -3) {
|
||||
if (aPlayer.worldObj.isRemote) {
|
||||
aPlayer.removePotionEffectClient(Potion.nightVision.id);
|
||||
} else {
|
||||
aPlayer.removePotionEffect(Potion.nightVision.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
timer++;
|
||||
}
|
||||
|
||||
// Item Magnet
|
||||
if (data.magnet > 1) {
|
||||
double x = aPlayer.posX;
|
||||
double y = aPlayer.posY - (aPlayer.worldObj.isRemote ? 1.62 : 0) + 0.75;
|
||||
double z = aPlayer.posZ;
|
||||
List<EntityItem> items = aPlayer.worldObj.getEntitiesWithinAABB(EntityItem.class,
|
||||
AxisAlignedBB.getBoundingBox(x - data.magnet, y - data.magnet, z - data.magnet, x + data.magnet, y + data.magnet, z + data.magnet));
|
||||
for (EntityItem item : items) {
|
||||
ItemStack stack = item.getEntityItem();
|
||||
if (!item.isDead && stack != null) {
|
||||
setEntityMotionFromVector(item, new Vector3(x, y, z), 0.45F);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Weight limit calcuation
|
||||
double motorSpeed = 0;
|
||||
if (data.leggings != null) {
|
||||
motorSpeed = data.leggings.motorPower;
|
||||
}
|
||||
if (data.maxWeight > 4000) {
|
||||
if (data.leggings != null && data.leggings.charge > data.leggings.motorEUusage) {
|
||||
motorSpeed -= data.maxWeight - 4000;
|
||||
data.leggings.charge -= (data.leggings.motorEUusage / 100);
|
||||
} else {
|
||||
aPlayer.motionX *= (4000.0d / data.maxWeight);
|
||||
aPlayer.motionZ *= (4000.0d / data.maxWeight);
|
||||
}
|
||||
}
|
||||
if (data.leggings != null && data.leggings.charge > data.leggings.motorEUusage && data.processingPower > data.processingPowerUsed && motorSpeed > 0
|
||||
&& aPlayer.isSprinting() && jumpticks > 0
|
||||
&& (aPlayer.onGround && Math.abs(aPlayer.motionX) + Math.abs(aPlayer.motionZ) > 0.10000000149011612D)) {
|
||||
data.leggings.charge -= data.leggings.motorEUusage;
|
||||
motorSpeed = Math.sqrt(motorSpeed) / 3;
|
||||
|
||||
float var7 = (float) (0.02f * motorSpeed);
|
||||
if (aPlayer.isInWater()) {
|
||||
var7 = 0.1F;
|
||||
if (aPlayer.motionY > 0) {
|
||||
aPlayer.motionY += 0.10000000149011612D;
|
||||
}
|
||||
}
|
||||
|
||||
if (var7 > 0.0F) {
|
||||
aPlayer.moveFlying(0.0F, 1.0F, var7);
|
||||
}
|
||||
}
|
||||
|
||||
// jump+step up assist
|
||||
if (data.processingPower > data.processingPowerUsed && data.leggings != null) {
|
||||
double stepup = data.leggings.pistonJumpboost;
|
||||
if (stepup > 1) {
|
||||
aPlayer.stepHeight = 1.0f;
|
||||
}
|
||||
if (GameSettings.isKeyDown(Minecraft.getMinecraft().gameSettings.keyBindJump)) {
|
||||
if (stepup > 0 && jumpticks > 0) {
|
||||
if (data.maxWeight > 2000) {
|
||||
stepup *= 2000.0D / data.maxWeight;
|
||||
}
|
||||
aPlayer.motionY += 0.04 * stepup;
|
||||
}
|
||||
aPlayer.jumpMovementFactor = aPlayer.getAIMoveSpeed() * .2f;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// immune effect removal
|
||||
List<PotionEffect> effects = new LinkedList(aPlayer.getActivePotionEffects());
|
||||
for (PotionEffect effect : effects) {
|
||||
int id = effect.getPotionID();
|
||||
if (id == 24 && data.fullRadiationDef) {
|
||||
aPlayer.removePotionEffect(id);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setEntityMotionFromVector(Entity entity, Vector3 originalPosVector, float modifier) {
|
||||
Vector3 entityVector = Vector3.fromEntityCenter(entity);
|
||||
Vector3 finalVector = originalPosVector.copy().subtract(entityVector);
|
||||
if (finalVector.mag() > 1)
|
||||
finalVector.normalize();
|
||||
entity.motionX = finalVector.x * modifier;
|
||||
entity.motionY = finalVector.y * modifier;
|
||||
entity.motionZ = finalVector.z * modifier;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemEnchantability() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBookEnchantable(ItemStack itemstack1, ItemStack itemstack2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsRepairable(ItemStack par1ItemStack, ItemStack par2ItemStack) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void registerIcons(IIconRegister aIconRegister) {
|
||||
this.itemIcon = aIconRegister.registerIcon("gtextras:" + mName);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public String getArmorTexture(ItemStack stack, Entity entity, int slot, String type) {
|
||||
String armor="gtextras:textures/item/armorhelmet.png";
|
||||
String tier="";
|
||||
try{
|
||||
if (data == null) {
|
||||
data = fillArmorData((EntityPlayer) entity, stack);
|
||||
}
|
||||
if(this.data.armorTier==0){
|
||||
tier="basic";
|
||||
}else if(this.data.armorTier==1){
|
||||
tier="e1";
|
||||
}else if(this.data.armorTier==2){
|
||||
tier="e2";
|
||||
}
|
||||
if(this.data.type==0||this.data.type==1){
|
||||
armor = "gtextras:textures/models/armor/"+tier+"_helmet_chest.png";
|
||||
}else{
|
||||
armor = "gtextras:textures/models/armor/"+tier+"_leggings_boots.png";
|
||||
}}catch(Exception e){System.err.println(e);}
|
||||
return armor;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showNodes(ItemStack aStack, EntityLivingBase aPlayer) {
|
||||
if (data == null) {
|
||||
data = fillArmorData((EntityPlayer) aPlayer, aStack);
|
||||
}
|
||||
return data.thaumicGoggles && data.armorTier > 0 && data.charge > 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean showIngamePopups(ItemStack aStack, EntityLivingBase aPlayer) {
|
||||
if (data == null) {
|
||||
data = fillArmorData((EntityPlayer) aPlayer, aStack);
|
||||
}
|
||||
return data.thaumicGoggles && data.armorTier > 0 && data.charge > 0;
|
||||
}
|
||||
|
||||
public ArmorData fillArmorData(EntityPlayer player, ItemStack stack) {
|
||||
return new ArmorData(player, stack, this.armorType, openGuiNr);
|
||||
}
|
||||
|
||||
public double getBaseAbsorptionRatio() {
|
||||
switch (this.armorType) {
|
||||
case 0:
|
||||
return 0.15;
|
||||
case 1:
|
||||
return 0.40;
|
||||
case 2:
|
||||
return 0.30;
|
||||
case 3:
|
||||
return 0.15;
|
||||
default:
|
||||
return 0.00;
|
||||
}
|
||||
}
|
||||
}
|
33
src/main/java/gregtech/common/items/armor/SlotFluid.java
Normal file
33
src/main/java/gregtech/common/items/armor/SlotFluid.java
Normal file
|
@ -0,0 +1,33 @@
|
|||
package gregtech.common.items.armor;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import scala.reflect.internal.Trees.This;
|
||||
import net.minecraft.client.renderer.texture.TextureMap;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.util.IIcon;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraftforge.fluids.FluidRegistry;
|
||||
|
||||
public class SlotFluid extends Slot{
|
||||
|
||||
public SlotFluid(IInventory inventory, int slot_index, int x, int y) {
|
||||
super(inventory, slot_index, x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer p_82869_1_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack p_75214_1_)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
33
src/main/java/gregtech/common/items/armor/SlotLocked.java
Normal file
33
src/main/java/gregtech/common/items/armor/SlotLocked.java
Normal file
|
@ -0,0 +1,33 @@
|
|||
package gregtech.common.items.armor;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.inventory.IInventory;
|
||||
import net.minecraft.inventory.Slot;
|
||||
import net.minecraft.item.ItemStack;
|
||||
|
||||
|
||||
public class SlotLocked extends Slot{
|
||||
|
||||
public SlotLocked(IInventory par1iInventory, int par2, int par3, int par4) {
|
||||
super(par1iInventory, par2, par3, par4);
|
||||
}
|
||||
@Override
|
||||
public void onPickupFromSlot(EntityPlayer player, ItemStack itemStack) {
|
||||
}
|
||||
@Override
|
||||
public boolean isItemValid(ItemStack par1ItemStack) {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean getHasStack() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public ItemStack decrStackSize(int i) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canTakeStack(EntityPlayer stack) {
|
||||
return false;}
|
||||
|
||||
}
|
125
src/main/java/gregtech/common/items/armor/Values.java
Normal file
125
src/main/java/gregtech/common/items/armor/Values.java
Normal file
|
@ -0,0 +1,125 @@
|
|||
package gregtech.common.items.armor;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import gregtech.api.enums.Materials;
|
||||
|
||||
public class Values {
|
||||
public static Values INSTANCE;
|
||||
public static final Map<Materials, Values> MATERIAL_MAP = new HashMap<Materials, Values>();
|
||||
|
||||
public int weight;
|
||||
public float physicalDef;
|
||||
public float projectileDef;
|
||||
public float fireDef;
|
||||
public float magicDef;
|
||||
public float explosionDef;
|
||||
|
||||
public Values(Materials material, int weight, float physicalDef, float projectileDef, float fireDef, float magicDef, float explosionDef) {
|
||||
this.weight = weight;
|
||||
this.physicalDef = physicalDef;
|
||||
this.projectileDef = projectileDef;
|
||||
this.fireDef = fireDef;
|
||||
this.magicDef = magicDef;
|
||||
this.explosionDef = explosionDef;
|
||||
}
|
||||
|
||||
public Values() {
|
||||
INSTANCE = this;
|
||||
MATERIAL_MAP.put(Materials._NULL, new Values(Materials._NULL, 0, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f));
|
||||
MATERIAL_MAP.put(Materials.Rubber, new Values(Materials.Rubber, 60, 0.06f, 0.06f, 0.02f, 0.1f, 0.1f));
|
||||
MATERIAL_MAP.put(Materials.Wood, new Values(Materials.Wood, 80, 0.08f, 0.09f, 0.02f, 0.08f, 0.08f));
|
||||
MATERIAL_MAP.put(Materials.Brass, new Values(Materials.Brass, 140, 0.12f, 0.12f, 0.10f, 0.10f, 0.12f));
|
||||
MATERIAL_MAP.put(Materials.Copper, new Values(Materials.Copper, 140, 0.11f, 0.11f, 0.10f, 0.10f, 0.11f));
|
||||
MATERIAL_MAP.put(Materials.Lead, new Values(Materials.Lead, 280, 0.05f, 0.05f, 0.05f, 0.05f, 0.05f));
|
||||
MATERIAL_MAP.put(Materials.Plastic, new Values(Materials.Plastic, 60, 0.10f, 0.10f, 0.02f, 0.02f, 0.10f));
|
||||
MATERIAL_MAP.put(Materials.Aluminium, new Values(Materials.Aluminium, 120, 0.14f, 0.14f, 0.12f, 0.12f, 0.14f));
|
||||
MATERIAL_MAP.put(Materials.AstralSilver, new Values(Materials.AstralSilver, 180, 0.10f, 0.10f, 0.10f, 0.18f, 0.10f));
|
||||
MATERIAL_MAP.put(Materials.BismuthBronze, new Values(Materials.BismuthBronze, 160, 0.12f, 0.12f, 0.10f, 0.10f, 0.12f));
|
||||
MATERIAL_MAP.put(Materials.BlackBronze, new Values(Materials.BlackBronze, 160, 0.13f, 0.13f, 0.10f, 0.10f, 0.13f));
|
||||
MATERIAL_MAP.put(Materials.BlackSteel, new Values(Materials.BlackSteel, 200, 0.19f, 0.19f, 0.17f, 0.17f, 0.19f));
|
||||
MATERIAL_MAP.put(Materials.BlueSteel, new Values(Materials.BlueSteel, 200, 0.21f, 0.21f, 0.19f, 0.19f, 0.21f));
|
||||
MATERIAL_MAP.put(Materials.Bronze, new Values(Materials.Bronze, 160, 0.13f, 0.13f, 0.12f, 0.12f, 0.13f));
|
||||
MATERIAL_MAP.put(Materials.CobaltBrass, new Values(Materials.CobaltBrass, 180, 0.15f, 0.15f, 0.14f, 0.14f, 0.15f));
|
||||
MATERIAL_MAP.put(Materials.DamascusSteel, new Values(Materials.DamascusSteel, 200, 0.22f, 0.22f, 0.20f, 0.20f, 0.22f));
|
||||
MATERIAL_MAP.put(Materials.Electrum, new Values(Materials.Electrum, 250, 0.11f, 0.11f, 0.10f, 0.10f, 0.11f));
|
||||
MATERIAL_MAP.put(Materials.Emerald, new Values(Materials.Emerald, 160, 0.10f, 0.10f, 0.14f, 0.14f, 0.10f));
|
||||
MATERIAL_MAP.put(Materials.Gold, new Values(Materials.Gold, 300, 0.09f, 0.09f, 0.05f, 0.25f, 0.09f));
|
||||
MATERIAL_MAP.put(Materials.GreenSapphire, new Values(Materials.GreenSapphire, 160, 0.10f, 0.10f, 0.14f, 0.14f, 0.10f));
|
||||
MATERIAL_MAP.put(Materials.Invar, new Values(Materials.Invar, 190, 0.10f, 0.10f, 0.22f, 0.22f, 0.10f));
|
||||
MATERIAL_MAP.put(Materials.Iron, new Values(Materials.Iron, 200, 0.12f, 0.12f, 0.10f, 0.10f, 0.12f));
|
||||
MATERIAL_MAP.put(Materials.IronWood, new Values(Materials.IronWood, 150, 0.17f, 0.17f, 0.02f, 0.02f, 0.17f));
|
||||
MATERIAL_MAP.put(Materials.Magnalium, new Values(Materials.Magnalium, 120, 0.15f, 0.15f, 0.17f, 0.17f, 0.15f));
|
||||
MATERIAL_MAP.put(Materials.NeodymiumMagnetic, new Values(Materials.NeodymiumMagnetic, 220, 0.14f, 0.14f, 0.14f, 0.14f, 0.14f));
|
||||
MATERIAL_MAP.put(Materials.Manganese, new Values(Materials.Manganese, 180, 0.15f, 0.15f, 0.14f, 0.14f, 0.15f));
|
||||
MATERIAL_MAP.put(Materials.MeteoricIron, new Values(Materials.MeteoricIron, 200, 0.18f, 0.18f, 0.16f, 0.16f, 0.18f));
|
||||
MATERIAL_MAP.put(Materials.MeteoricSteel, new Values(Materials.MeteoricSteel, 200, 0.21f, 0.21f, 0.19f, 0.19f, 0.21f));
|
||||
MATERIAL_MAP.put(Materials.Molybdenum, new Values(Materials.Molybdenum, 140, 0.14f, 0.14f, 0.14f, 0.14f, 0.14f));
|
||||
MATERIAL_MAP.put(Materials.Nickel, new Values(Materials.Nickel, 180, 0.12f, 0.12f, 0.15f, 0.15f, 0.12f));
|
||||
MATERIAL_MAP.put(Materials.Olivine, new Values(Materials.Olivine, 180, 0.10f, 0.10f, 0.14f, 0.14f, 0.10f));
|
||||
MATERIAL_MAP.put(Materials.Opal, new Values(Materials.Opal, 180, 0.10f, 0.10f, 0.14f, 0.14f, 0.10f));
|
||||
MATERIAL_MAP.put(Materials.Palladium, new Values(Materials.Palladium, 280, 0.14f, 0.14f, 0.12f, 0.12f, 0.14f));
|
||||
MATERIAL_MAP.put(Materials.Platinum, new Values(Materials.Platinum, 290, 0.15f, 0.15f, 0.13f, 0.13f, 0.15f));
|
||||
MATERIAL_MAP.put(Materials.GarnetRed, new Values(Materials.GarnetRed, 180, 0.10f, 0.10f, 0.14f, 0.14f, 0.10f));
|
||||
MATERIAL_MAP.put(Materials.RedSteel, new Values(Materials.RedSteel, 200, 0.20f, 0.20f, 0.18f, 0.18f, 0.20f));
|
||||
MATERIAL_MAP.put(Materials.RoseGold, new Values(Materials.RoseGold, 240, 0.10f, 0.10f, 0.08f, 0.18f, 0.10f));
|
||||
MATERIAL_MAP.put(Materials.Ruby, new Values(Materials.Ruby, 180, 0.10f, 0.10f, 0.20f, 0.20f, 0.10f));
|
||||
MATERIAL_MAP.put(Materials.Sapphire, new Values(Materials.Sapphire, 180, 0.10f, 0.10f, 0.14f, 0.14f, 0.10f));
|
||||
MATERIAL_MAP.put(Materials.Silver, new Values(Materials.Silver, 220, 0.11f, 0.11f, 0.07f, 0.24f, 0.11f));
|
||||
MATERIAL_MAP.put(Materials.StainlessSteel, new Values(Materials.StainlessSteel, 200, 0.16f, 0.16f, 0.21f, 0.21f, 0.16f));
|
||||
MATERIAL_MAP.put(Materials.Steel, new Values(Materials.Steel, 200, 0.18f, 0.18f, 0.16f, 0.16f, 0.18f));
|
||||
MATERIAL_MAP.put(Materials.SterlingSilver, new Values(Materials.SterlingSilver, 210, 0.15f, 0.15f, 0.13f, 0.13f, 0.15f));
|
||||
MATERIAL_MAP.put(Materials.Tanzanite, new Values(Materials.Tanzanite, 180, 0.10f, 0.10f, 0.14f, 0.14f, 0.10f));
|
||||
MATERIAL_MAP.put(Materials.Thorium, new Values(Materials.Thorium, 280, 0.13f, 0.13f, 0.16f, 0.16f, 0.13f));
|
||||
MATERIAL_MAP.put(Materials.WroughtIron, new Values(Materials.WroughtIron, 200, 0.14f, 0.14f, 0.12f, 0.12f, 0.14f));
|
||||
MATERIAL_MAP.put(Materials.GarnetYellow, new Values(Materials.GarnetYellow, 180, 0.10f, 0.10f, 0.14f, 0.14f, 0.10f));
|
||||
MATERIAL_MAP.put(Materials.Carbon, new Values(Materials.Carbon, 60, 0.06f, 0.23f, 0.05f, 0.05f, 0.06f));
|
||||
MATERIAL_MAP.put(Materials.InfusedAir,new Values(Materials.InfusedAir, 10, 0.10f, 0.10f, 0.10f,0.10f, 0.10f));
|
||||
MATERIAL_MAP.put(Materials.Amethyst, new Values(Materials.Amethyst, 180, 0.10f, 0.10f, 0.14f, 0.14f, 0.10f));
|
||||
MATERIAL_MAP.put(Materials.InfusedWater,new Values(Materials.InfusedWater, 150, 0.10f, 0.10f,0.20f, 0.20f, 0.10f));
|
||||
MATERIAL_MAP.put(Materials.BlueTopaz, new Values(Materials.BlueTopaz, 180, 0.10f, 0.10f, 0.14f, 0.14f, 0.10f));
|
||||
MATERIAL_MAP.put(Materials.Chrome, new Values(Materials.Chrome, 200, 0.12f, 0.12f, 0.21f, 0.21f, 0.12f));
|
||||
MATERIAL_MAP.put(Materials.Cobalt, new Values(Materials.Cobalt, 220, 0.16f, 0.16f, 0.14f, 0.14f, 0.16f));
|
||||
MATERIAL_MAP.put(Materials.DarkIron, new Values(Materials.DarkIron, 200, 0.21f, 0.21f, 0.19f, 0.19f, 0.21f));
|
||||
MATERIAL_MAP.put(Materials.Diamond, new Values(Materials.Diamond, 200, 0.20f, 0.20f, 0.22f, 0.22f, 0.20f));
|
||||
MATERIAL_MAP.put(Materials.Enderium, new Values(Materials.Enderium, 250, 0.22f, 0.22f, 0.21f, 0.21f, 0.22f));
|
||||
MATERIAL_MAP.put(Materials.ElectrumFlux,new Values(Materials.ElectrumFlux, 180, 0.19f, 0.19f, 0.16f, 0.16f, 0.19f));
|
||||
MATERIAL_MAP.put(Materials.Force, new Values(Materials.Force, 180, 0.10f, 0.10f, 0.20f, 0.20f, 0.10f));
|
||||
MATERIAL_MAP.put(Materials.HSLA, new Values(Materials.HSLA, 200, 0.21f, 0.21f, 0.17f, 0.17f, 0.21f));
|
||||
MATERIAL_MAP.put(Materials.InfusedFire,new Values(Materials.InfusedFire, 150, 0.12f, 0.10f, 0.30f, 0.30f, 0.12f));
|
||||
MATERIAL_MAP.put(Materials.InfusedGold, new Values(Materials.InfusedGold, 300, 0.15f, 0.15f, 0.05f, 0.05f, 0.15f));
|
||||
MATERIAL_MAP.put(Materials.Mithril, new Values(Materials.Mithril, 200, 0.25f, 0.25f, 0.10f, 0.30f, 0.25f));
|
||||
MATERIAL_MAP.put(Materials.InfusedOrder,new Values(Materials.InfusedOrder, 150, 0.18f, 0.22f,0.22f, 0.25f, 0.22f));
|
||||
MATERIAL_MAP.put(Materials.Steeleaf, new Values(Materials.Steeleaf, 120, 0.16f, 0.16f, 0.06f, 0.06f, 0.16f));
|
||||
MATERIAL_MAP.put(Materials.InfusedEarth,new Values(Materials.InfusedEarth, 350, 0.30f, 0.30f,0.30f, 0.30f, 0.30f));
|
||||
MATERIAL_MAP.put(Materials.Thaumium, new Values(Materials.Thaumium, 200, 0.18f, 0.19f, 0.20f, 0.30f, 0.18f));
|
||||
MATERIAL_MAP.put(Materials.Titanium, new Values(Materials.Titanium, 140, 0.20f, 0.20f, 0.18f, 0.18f, 0.20f));
|
||||
MATERIAL_MAP.put(Materials.Tungsten, new Values(Materials.Tungsten, 270, 0.27f, 0.26f, 0.23f, 0.26f, 0.26f));
|
||||
MATERIAL_MAP.put(Materials.Topaz, new Values(Materials.Topaz, 180, 0.10f, 0.10f, 0.14f, 0.14f, 0.10f));
|
||||
MATERIAL_MAP.put(Materials.Ultimet, new Values(Materials.Ultimet, 180, 0.21f, 0.21f, 0.19f, 0.19f, 0.21f));
|
||||
MATERIAL_MAP.put(Materials.Uranium, new Values(Materials.Uranium, 290, 0.27f, 0.23f, 0.20f, 0.15f, 0.21f));
|
||||
MATERIAL_MAP.put(Materials.Vinteum, new Values(Materials.Vinteum, 180, 0.10f, 0.12f, 0.14f, 0.28f, 0.12f));
|
||||
MATERIAL_MAP.put(Materials.Duranium, new Values(Materials.Duranium, 140, 0.24f, 0.24f, 0.24f, 0.24f, 0.24f));
|
||||
MATERIAL_MAP.put(Materials.Iridium, new Values(Materials.Iridium, 220, 0.24f, 0.24f, 0.22f, 0.22f, 0.24f));
|
||||
MATERIAL_MAP.put(Materials.Osmiridium, new Values(Materials.Osmiridium, 240, 0.18f, 0.18f, 0.16f, 0.16f, 0.18f));
|
||||
MATERIAL_MAP.put(Materials.Osmium, new Values(Materials.Osmium, 250, 0.12f, 0.12f, 0.10f, 0.10f, 0.12f));
|
||||
MATERIAL_MAP.put(Materials.Naquadah, new Values(Materials.Naquadah, 250, 0.27f, 0.27f, 0.25f, 0.25f, 0.27f));
|
||||
MATERIAL_MAP.put(Materials.NetherStar, new Values(Materials.NetherStar, 140, 0.22f, 0.22f, 0.24f, 0.24f, 0.22f));
|
||||
MATERIAL_MAP.put(Materials.InfusedEntropy,new Values(Materials.InfusedEntropy, 150, 0.10f, 0.10f,0.10f, 0.10f, 0.10f));
|
||||
MATERIAL_MAP.put(Materials.Tritanium, new Values(Materials.Tritanium, 140, 0.26f, 0.26f, 0.26f, 0.26f, 0.26f));
|
||||
MATERIAL_MAP.put(Materials.TungstenSteel, new Values(Materials.TungstenSteel, 270, 0.30f, 0.28f, 0.25f, 0.28f, 0.30f));
|
||||
MATERIAL_MAP.put(Materials.Adamantium, new Values(Materials.Adamantium, 200, 0.28f, 0.28f, 0.26f, 0.30f, 0.30f));
|
||||
MATERIAL_MAP.put(Materials.NaquadahAlloy, new Values(Materials.NaquadahAlloy, 300, 0.33f, 0.33f, 0.33f, 0.33f, 0.33f));
|
||||
MATERIAL_MAP.put(Materials.Neutronium, new Values(Materials.Neutronium, 600, 0.50f, 0.50f, 0.50f, 0.50f, 0.50f));
|
||||
}
|
||||
|
||||
public Values getValues(Materials mat) {
|
||||
Values tmp = MATERIAL_MAP.get(mat);
|
||||
|
||||
if (tmp == null) {
|
||||
return MATERIAL_MAP.get(Materials._NULL);
|
||||
}
|
||||
return tmp;
|
||||
}
|
||||
}
|
278
src/main/java/gregtech/common/items/armor/Vector3.java
Normal file
278
src/main/java/gregtech/common/items/armor/Vector3.java
Normal file
|
@ -0,0 +1,278 @@
|
|||
package gregtech.common.items.armor;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
import java.math.RoundingMode;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.AxisAlignedBB;
|
||||
import net.minecraft.util.Vec3;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import org.lwjgl.util.vector.Vector3f;
|
||||
import org.lwjgl.util.vector.Vector4f;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
public class Vector3 {
|
||||
public static Vector3 zero = new Vector3();
|
||||
public static Vector3 one = new Vector3(1, 1, 1);
|
||||
public static Vector3 center = new Vector3(0.5, 0.5, 0.5);
|
||||
public double x;
|
||||
public double y;
|
||||
public double z;
|
||||
|
||||
public Vector3() {
|
||||
}
|
||||
|
||||
public Vector3(double d, double d1, double d2) {
|
||||
x = d;
|
||||
y = d1;
|
||||
z = d2;
|
||||
}
|
||||
|
||||
public Vector3(Vector3 vec) {
|
||||
x = vec.x;
|
||||
y = vec.y;
|
||||
z = vec.z;
|
||||
}
|
||||
|
||||
public Vector3(Vec3 vec) {
|
||||
x = vec.xCoord;
|
||||
y = vec.yCoord;
|
||||
z = vec.zCoord;
|
||||
}
|
||||
|
||||
public Vector3 copy() {
|
||||
return new Vector3(this);
|
||||
}
|
||||
|
||||
public static Vector3 fromEntity(Entity e) {
|
||||
return new Vector3(e.posX, e.posY, e.posZ);
|
||||
}
|
||||
|
||||
public static Vector3 fromEntityCenter(Entity e) {
|
||||
return new Vector3(e.posX, e.posY - e.yOffset + e.height / 2, e.posZ);
|
||||
}
|
||||
|
||||
public static Vector3 fromTileEntity(TileEntity e) {
|
||||
return new Vector3(e.xCoord, e.yCoord, e.zCoord);
|
||||
}
|
||||
|
||||
public static Vector3 fromTileEntityCenter(TileEntity e) {
|
||||
return new Vector3(e.xCoord + 0.5, e.yCoord + 0.5, e.zCoord + 0.5);
|
||||
}
|
||||
|
||||
public Vector3 set(double d, double d1, double d2) {
|
||||
x = d;
|
||||
y = d1;
|
||||
z = d2;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vector3 set(Vector3 vec) {
|
||||
x = vec.x;
|
||||
y = vec.y;
|
||||
z = vec.z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double dotProduct(Vector3 vec) {
|
||||
double d = vec.x * x + vec.y * y + vec.z * z;
|
||||
if (d > 1 && d < 1.00001)
|
||||
d = 1;
|
||||
else if (d < -1 && d > -1.00001)
|
||||
d = -1;
|
||||
return d;
|
||||
}
|
||||
|
||||
public double dotProduct(double d, double d1, double d2) {
|
||||
return d * x + d1 * y + d2 * z;
|
||||
}
|
||||
|
||||
public Vector3 crossProduct(Vector3 vec) {
|
||||
double d = y * vec.z - z * vec.y;
|
||||
double d1 = z * vec.x - x * vec.z;
|
||||
double d2 = x * vec.y - y * vec.x;
|
||||
x = d;
|
||||
y = d1;
|
||||
z = d2;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vector3 add(double d, double d1, double d2) {
|
||||
x += d;
|
||||
y += d1;
|
||||
z += d2;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vector3 add(Vector3 vec) {
|
||||
x += vec.x;
|
||||
y += vec.y;
|
||||
z += vec.z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vector3 add(double d) {
|
||||
return add(d, d, d);
|
||||
}
|
||||
|
||||
public Vector3 sub(Vector3 vec) {
|
||||
return subtract(vec);
|
||||
}
|
||||
|
||||
public Vector3 subtract(Vector3 vec) {
|
||||
x -= vec.x;
|
||||
y -= vec.y;
|
||||
z -= vec.z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vector3 negate(Vector3 vec) {
|
||||
x = -x;
|
||||
y = -y;
|
||||
z = -z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vector3 multiply(double d) {
|
||||
x *= d;
|
||||
y *= d;
|
||||
z *= d;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vector3 multiply(Vector3 f) {
|
||||
x *= f.x;
|
||||
y *= f.y;
|
||||
z *= f.z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vector3 multiply(double fx, double fy, double fz) {
|
||||
x *= fx;
|
||||
y *= fy;
|
||||
z *= fz;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double mag() {
|
||||
return Math.sqrt(x * x + y * y + z * z);
|
||||
}
|
||||
|
||||
public double magSquared() {
|
||||
return x * x + y * y + z * z;
|
||||
}
|
||||
|
||||
public Vector3 normalize() {
|
||||
double d = mag();
|
||||
if (d != 0)
|
||||
multiply(1 / d);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
MathContext cont = new MathContext(4, RoundingMode.HALF_UP);
|
||||
return "Vector3(" + new BigDecimal(x, cont) + ", " + new BigDecimal(y, cont) + ", " + new BigDecimal(z, cont) + ")";
|
||||
}
|
||||
|
||||
public Vector3 perpendicular() {
|
||||
if (z == 0)
|
||||
return zCrossProduct();
|
||||
return xCrossProduct();
|
||||
}
|
||||
|
||||
public Vector3 xCrossProduct() {
|
||||
double d = z;
|
||||
double d1 = -y;
|
||||
x = 0;
|
||||
y = d;
|
||||
z = d1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vector3 zCrossProduct() {
|
||||
double d = y;
|
||||
double d1 = -x;
|
||||
x = d;
|
||||
y = d1;
|
||||
z = 0;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vector3 yCrossProduct() {
|
||||
double d = -z;
|
||||
double d1 = x;
|
||||
x = d;
|
||||
y = 0;
|
||||
z = d1;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Vec3 toVec3D() {
|
||||
return Vec3.createVectorHelper(x, y, z);
|
||||
}
|
||||
|
||||
public double angle(Vector3 vec) {
|
||||
return Math.acos(copy().normalize().dotProduct(vec.copy().normalize()));
|
||||
}
|
||||
|
||||
public boolean isInside(AxisAlignedBB aabb) {
|
||||
return x >= aabb.minX && y >= aabb.maxY && z >= aabb.minZ && x < aabb.maxX && y < aabb.maxY && z < aabb.maxZ;
|
||||
}
|
||||
|
||||
public boolean isZero() {
|
||||
return x == 0 && y == 0 && z == 0;
|
||||
}
|
||||
|
||||
public boolean isAxial() {
|
||||
return x == 0 ? y == 0 || z == 0 : y == 0 && z == 0;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Vector3f vector3f() {
|
||||
return new Vector3f((float) x, (float) y, (float) z);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public Vector4f vector4f() {
|
||||
return new Vector4f((float) x, (float) y, (float) z, 1);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void glVertex() {
|
||||
GL11.glVertex3d(x, y, z);
|
||||
}
|
||||
|
||||
public Vector3 negate() {
|
||||
x = -x;
|
||||
y = -y;
|
||||
z = -z;
|
||||
return this;
|
||||
}
|
||||
|
||||
public double scalarProject(Vector3 b) {
|
||||
double l = b.mag();
|
||||
return l == 0 ? 0 : dotProduct(b) / l;
|
||||
}
|
||||
|
||||
public Vector3 project(Vector3 b) {
|
||||
double l = b.magSquared();
|
||||
if (l == 0) {
|
||||
set(0, 0, 0);
|
||||
return this;
|
||||
}
|
||||
double m = dotProduct(b) / l;
|
||||
set(b).multiply(m);
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (!(o instanceof Vector3))
|
||||
return false;
|
||||
Vector3 v = (Vector3) o;
|
||||
return x == v.x && y == v.y && z == v.z;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue