mirror of
https://github.com/GTNewHorizons/TinkersConstruct.git
synced 2026-11-25 14:34:22 +00:00
retire modElectric
This commit is contained in:
1 parent
983c91c2c9
commit
b8bd6259ee
38 files changed
+95
-1406
No files matched your search
@@ -1,6 +1,6 @@
|
||||
package tconstruct.library.armor;
|
||||
|
||||
import ic2.api.item.*;
|
||||
import tconstruct.library.util.MathUtils;
|
||||
import net.minecraft.block.BlockDispenser;
|
||||
import net.minecraft.dispenser.IBehaviorDispenseItem;
|
||||
import net.minecraft.entity.*;
|
||||
@@ -10,12 +10,13 @@ import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.DamageSource;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.ISpecialArmor;
|
||||
import cofh.api.energy.IEnergyContainerItem;
|
||||
|
||||
/**
|
||||
* NBTTags
|
||||
* Main tag - InfiArmor
|
||||
*/
|
||||
public abstract class ArmorCore extends ItemArmor implements ICustomElectricItem, IBoxable, ISpecialArmor
|
||||
public abstract class ArmorCore extends ItemArmor implements IEnergyContainerItem, ISpecialArmor
|
||||
{
|
||||
|
||||
public static final String SET_NAME = "InfiArmor";
|
||||
@@ -23,6 +24,11 @@ public abstract class ArmorCore extends ItemArmor implements ICustomElectricItem
|
||||
private static final IBehaviorDispenseItem dispenserBehavior = new BehaviorDispenseArmorCopy();
|
||||
public final int baseProtection;
|
||||
|
||||
//TE power constants -- TODO grab these from the items added
|
||||
protected int capacity = 400000;
|
||||
protected int maxReceive = 75;
|
||||
protected int maxExtract = 75;
|
||||
|
||||
public ArmorCore(int par1, int baseProtection, EnumArmorPart part)
|
||||
{
|
||||
super(par1, EnumArmorMaterial.CHAIN, 0, 0);
|
||||
@@ -94,19 +100,19 @@ public abstract class ArmorCore extends ItemArmor implements ICustomElectricItem
|
||||
|
||||
data = tags.getCompoundTag(SET_NAME);
|
||||
|
||||
if (tags.hasKey("charge"))
|
||||
if (tags.hasKey("Energy"))
|
||||
{
|
||||
int charge = tags.getInteger("charge");
|
||||
if (charge > damage)
|
||||
int energy = tags.getInteger("Energy");
|
||||
if (energy > damage)
|
||||
{
|
||||
charge -= damage;
|
||||
tags.setInteger("charge", charge);
|
||||
energy -= damage;
|
||||
tags.setInteger("Energy", energy);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
damage -= charge;
|
||||
tags.setInteger("charge", 0);
|
||||
damage -= energy;
|
||||
tags.setInteger("Energy", 0);
|
||||
int dmg = data.getInteger("Damage");
|
||||
dmg += damage;
|
||||
data.setInteger("Damage", dmg);
|
||||
@@ -121,143 +127,81 @@ public abstract class ArmorCore extends ItemArmor implements ICustomElectricItem
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* IC2 API support
|
||||
*/
|
||||
|
||||
@Override
|
||||
public boolean canBeStoredInToolbox (ItemStack stack)
|
||||
//TE support section -- from COFH core API reference section
|
||||
public void setMaxTransfer (int maxTransfer)
|
||||
{
|
||||
return true;
|
||||
setMaxReceive(maxTransfer);
|
||||
setMaxExtract(maxTransfer);
|
||||
}
|
||||
|
||||
public void setMaxReceive (int maxReceive)
|
||||
{
|
||||
this.maxReceive = maxReceive;
|
||||
}
|
||||
|
||||
public void setMaxExtract (int maxExtract)
|
||||
{
|
||||
this.maxExtract = maxExtract;
|
||||
}
|
||||
|
||||
/* IEnergyContainerItem */
|
||||
@Override
|
||||
public int receiveEnergy (ItemStack container, int maxReceive, boolean simulate)
|
||||
{
|
||||
NBTTagCompound tags = container.getTagCompound();
|
||||
if (tags == null || !tags.hasKey("Energy"))
|
||||
return 0;
|
||||
int energy = tags.getInteger("Energy");
|
||||
int energyReceived = MathUtils.minInt(capacity - energy, MathUtils.minInt(this.maxReceive, maxReceive));
|
||||
if (!simulate)
|
||||
{
|
||||
energy += energyReceived;
|
||||
tags.setInteger("Energy", energy);
|
||||
container.setItemDamage(1 + (getMaxEnergyStored(container) - energy) * (container.getMaxDamage() - 2) / getMaxEnergyStored(container));
|
||||
|
||||
}
|
||||
return energyReceived;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProvideEnergy (ItemStack stack)
|
||||
public int extractEnergy (ItemStack container, int maxExtract, boolean simulate)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
|
||||
return tags.hasKey("charge");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChargedItemId (ItemStack stack)
|
||||
{
|
||||
return this.itemID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEmptyItemId (ItemStack stack)
|
||||
{
|
||||
return this.itemID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxCharge (ItemStack stack)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
return tags.hasKey("charge") ? 10000 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTier (ItemStack stack)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTransferLimit (ItemStack stack)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
|
||||
return tags.hasKey("charge") ? 32 : 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int charge (ItemStack stack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
if (!tags.hasKey("charge"))
|
||||
NBTTagCompound tags = container.getTagCompound();
|
||||
if (tags == null || !tags.hasKey("Energy"))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (amount > 0)
|
||||
int energy = tags.getInteger("Energy");
|
||||
int energyExtracted = MathUtils.minInt(energy, MathUtils.minInt(this.maxExtract, maxExtract));
|
||||
if (!simulate)
|
||||
{
|
||||
if (amount > getTransferLimit(stack) && !ignoreTransferLimit)
|
||||
{
|
||||
amount = getTransferLimit(stack);
|
||||
}
|
||||
energy -= energyExtracted;
|
||||
tags.setInteger("Energy", energy);
|
||||
container.setItemDamage(1 + (getMaxEnergyStored(container) - energy) * (container.getMaxDamage() - 1) / getMaxEnergyStored(container));
|
||||
|
||||
int charge = tags.getInteger("charge");
|
||||
|
||||
if (amount > getMaxCharge(stack))
|
||||
{
|
||||
amount = getMaxCharge(stack);
|
||||
}
|
||||
|
||||
charge += amount;
|
||||
|
||||
if (!simulate)
|
||||
{
|
||||
tags.setInteger("charge", charge);
|
||||
stack.setItemDamage(1 + (getMaxCharge(stack) - charge) * (stack.getMaxDamage() - 2) / getMaxCharge(stack));
|
||||
}
|
||||
return amount;
|
||||
}
|
||||
|
||||
else
|
||||
return 0;
|
||||
return energyExtracted;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int discharge (ItemStack stack, int amount, int tier, boolean ignoreTransferLimit, boolean simulate)
|
||||
public int getEnergyStored (ItemStack container)
|
||||
{
|
||||
NBTTagCompound tags = stack.getTagCompound();
|
||||
if (!tags.hasKey("charge"))
|
||||
NBTTagCompound tags = container.getTagCompound();
|
||||
if (tags == null || !tags.hasKey("Energy"))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (amount > 0)
|
||||
{
|
||||
if (amount > getTransferLimit(stack))
|
||||
{
|
||||
amount = getTransferLimit(stack);
|
||||
}
|
||||
|
||||
int charge = tags.getInteger("charge");
|
||||
|
||||
if (amount > charge)
|
||||
{
|
||||
amount = charge;
|
||||
}
|
||||
|
||||
charge -= amount;
|
||||
|
||||
if (!simulate)
|
||||
{
|
||||
tags.setInteger("charge", charge);
|
||||
stack.setItemDamage(1 + (getMaxCharge(stack) - charge) * (stack.getMaxDamage() - 1) / getMaxCharge(stack));
|
||||
}
|
||||
|
||||
return charge;
|
||||
}
|
||||
|
||||
else
|
||||
return tags.getInteger("Energy");
|
||||
}
|
||||
@Override
|
||||
public int getMaxEnergyStored (ItemStack container)
|
||||
{
|
||||
NBTTagCompound tags = container.getTagCompound();
|
||||
if (tags == null || !tags.hasKey("Energy"))
|
||||
return 0;
|
||||
return capacity;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canUse (ItemStack stack, int amount)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canShowChargeToolTip (ItemStack stack)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
//end of TE support section
|
||||
|
||||
// Vanilla overrides
|
||||
public boolean isItemTool (ItemStack par1ItemStack)
|
||||
@@ -300,12 +244,12 @@ public abstract class ArmorCore extends ItemArmor implements ICustomElectricItem
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (tags.hasKey("charge"))
|
||||
if (tags.hasKey("Energy"))
|
||||
{
|
||||
int charge = tags.getInteger("charge");
|
||||
if (charge > 0)
|
||||
int energy = tags.getInteger("Energy");
|
||||
if (energy > 0)
|
||||
{
|
||||
return this.getMaxCharge(stack);
|
||||
return this.getMaxEnergyStored(stack);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -320,12 +264,12 @@ public abstract class ArmorCore extends ItemArmor implements ICustomElectricItem
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (tags.hasKey("charge"))
|
||||
if (tags.hasKey("Energy"))
|
||||
{
|
||||
int charge = tags.getInteger("charge");
|
||||
if (charge > 0)
|
||||
int energy = tags.getInteger("Energy");
|
||||
if (energy > 0)
|
||||
{
|
||||
return this.getMaxCharge(stack) - charge;
|
||||
return this.getMaxEnergyStored(stack) - energy;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user