mirror of
https://github.com/HbmMods/Hbm-s-Nuclear-Tech-GIT.git
synced 2026-01-25 10:32:49 +00:00
battery packs
This commit is contained in:
parent
680678b5b2
commit
b8d24b5c2d
@ -10,7 +10,7 @@ public interface IBatteryItem {
|
||||
public void setCharge(ItemStack stack, long i);
|
||||
public void dischargeBattery(ItemStack stack, long i);
|
||||
public long getCharge(ItemStack stack);
|
||||
public long getMaxCharge();
|
||||
public long getMaxCharge(ItemStack stack);
|
||||
public long getChargeRate();
|
||||
public long getDischargeRate();
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ public class HEVBattery extends Block {
|
||||
|
||||
if(st.getItem() instanceof IBatteryItem) {
|
||||
|
||||
long maxcharge = ((IBatteryItem) st.getItem()).getMaxCharge();
|
||||
long maxcharge = ((IBatteryItem) st.getItem()).getMaxCharge(st);
|
||||
long charge = ((IBatteryItem) st.getItem()).getCharge(st);
|
||||
long newcharge = Math.min(charge + 150000, maxcharge);
|
||||
|
||||
|
||||
@ -134,7 +134,7 @@ public class ArmorModHandler {
|
||||
}
|
||||
|
||||
/**
|
||||
* Does what the name implies
|
||||
* Does what the name implies. Returns true if the stack has NBT and that NBT has the MOD_COMPOUND_KEY tag.
|
||||
* @param armor
|
||||
* @return
|
||||
*/
|
||||
@ -171,4 +171,22 @@ public class ArmorModHandler {
|
||||
|
||||
return slots;
|
||||
}
|
||||
|
||||
public static ItemStack pryMod(ItemStack armor, int slot) {
|
||||
|
||||
if(!hasMods(armor))
|
||||
return null;
|
||||
|
||||
NBTTagCompound nbt = armor.getTagCompound();
|
||||
NBTTagCompound mods = nbt.getCompoundTag(MOD_COMPOUND_KEY);
|
||||
NBTTagCompound cmp = mods.getCompoundTag(MOD_SLOT_KEY + slot);
|
||||
ItemStack stack = ItemStack.loadItemStackFromNBT(cmp);
|
||||
|
||||
if(stack != null)
|
||||
return stack;
|
||||
|
||||
removeMod(armor, slot);
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@ -2174,6 +2174,7 @@ public class ModItems {
|
||||
public static Item card_aos;
|
||||
public static Item card_qos;
|
||||
public static Item australium_iii;
|
||||
public static Item armor_battery;
|
||||
|
||||
public static Item hazmat_helmet;
|
||||
public static Item hazmat_plate;
|
||||
@ -3353,6 +3354,7 @@ public class ModItems {
|
||||
card_aos = new ItemModCard().setUnlocalizedName("card_aos").setTextureName(RefStrings.MODID + ":card_aos");
|
||||
card_qos = new ItemModCard().setUnlocalizedName("card_qos").setTextureName(RefStrings.MODID + ":card_qos");
|
||||
australium_iii = new ItemModShield(25F).setUnlocalizedName("australium_iii").setTextureName(RefStrings.MODID + ":australium_iii");
|
||||
armor_battery = new ItemModBattery(1.25D).setUnlocalizedName("armor_battery").setTextureName(RefStrings.MODID + ":armor_battery");
|
||||
|
||||
cap_nuka = new Item().setUnlocalizedName("cap_nuka").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":cap_nuka");
|
||||
cap_quantum = new Item().setUnlocalizedName("cap_quantum").setCreativeTab(MainRegistry.consumableTab).setTextureName(RefStrings.MODID + ":cap_quantum");
|
||||
@ -7388,6 +7390,7 @@ public class ModItems {
|
||||
GameRegistry.registerItem(card_aos, card_aos.getUnlocalizedName());
|
||||
GameRegistry.registerItem(card_qos, card_qos.getUnlocalizedName());
|
||||
GameRegistry.registerItem(australium_iii, australium_iii.getUnlocalizedName());
|
||||
GameRegistry.registerItem(armor_battery, armor_battery.getUnlocalizedName());
|
||||
|
||||
//Chaos
|
||||
GameRegistry.registerItem(chocolate_milk, chocolate_milk.getUnlocalizedName());
|
||||
|
||||
@ -2,6 +2,7 @@ package com.hbm.items.armor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import com.hbm.handler.ArmorModHandler;
|
||||
import com.hbm.util.BobMathUtil;
|
||||
|
||||
import api.hbm.energymk2.IBatteryItem;
|
||||
@ -30,9 +31,7 @@ public class ArmorFSBPowered extends ArmorFSB implements IBatteryItem {
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
|
||||
|
||||
list.add("Charge: " + BobMathUtil.getShortNumber(getCharge(stack)) + " / " + BobMathUtil.getShortNumber(maxPower));
|
||||
|
||||
list.add("Charge: " + BobMathUtil.getShortNumber(getCharge(stack)) + " / " + BobMathUtil.getShortNumber(getMaxCharge(stack)));
|
||||
super.addInformation(stack, player, list, ext);
|
||||
}
|
||||
|
||||
@ -72,7 +71,7 @@ public class ArmorFSBPowered extends ArmorFSB implements IBatteryItem {
|
||||
stack.stackTagCompound.setLong("charge", stack.stackTagCompound.getLong("charge") - i);
|
||||
} else {
|
||||
stack.stackTagCompound = new NBTTagCompound();
|
||||
stack.stackTagCompound.setLong("charge", this.maxPower - i);
|
||||
stack.stackTagCompound.setLong("charge", getMaxCharge(stack) - i);
|
||||
}
|
||||
|
||||
if(stack.stackTagCompound.getLong("charge") < 0)
|
||||
@ -84,10 +83,10 @@ public class ArmorFSBPowered extends ArmorFSB implements IBatteryItem {
|
||||
public long getCharge(ItemStack stack) {
|
||||
if(stack.getItem() instanceof ArmorFSBPowered) {
|
||||
if(stack.hasTagCompound()) {
|
||||
return stack.stackTagCompound.getLong("charge");
|
||||
return Math.min(stack.stackTagCompound.getLong("charge"), getMaxCharge(stack));
|
||||
} else {
|
||||
stack.stackTagCompound = new NBTTagCompound();
|
||||
stack.stackTagCompound.setLong("charge", ((ArmorFSBPowered) stack.getItem()).maxPower);
|
||||
stack.stackTagCompound.setLong("charge", getMaxCharge(stack));
|
||||
return stack.stackTagCompound.getLong("charge");
|
||||
}
|
||||
}
|
||||
@ -97,18 +96,23 @@ public class ArmorFSBPowered extends ArmorFSB implements IBatteryItem {
|
||||
|
||||
@Override
|
||||
public boolean showDurabilityBar(ItemStack stack) {
|
||||
|
||||
return getCharge(stack) < maxPower;
|
||||
return getCharge(stack) < getMaxCharge(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDurabilityForDisplay(ItemStack stack) {
|
||||
|
||||
return 1 - (double) getCharge(stack) / (double) maxPower;
|
||||
return 1 - (double) getCharge(stack) / (double) getMaxCharge(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxCharge() {
|
||||
public long getMaxCharge(ItemStack stack) {
|
||||
if(ArmorModHandler.hasMods(stack)) {
|
||||
ItemStack mod = ArmorModHandler.pryMod(stack, ArmorModHandler.battery);
|
||||
if(mod != null && mod.getItem() instanceof ItemModBattery) {
|
||||
return (long) (maxPower * ((ItemModBattery) mod.getItem()).mod);
|
||||
}
|
||||
}
|
||||
return maxPower;
|
||||
}
|
||||
|
||||
|
||||
@ -108,7 +108,7 @@ public class ArmorHEV extends ArmorFSBPowered {
|
||||
ItemStack armor = player.inventory.armorInventory[i];
|
||||
ArmorFSBPowered item = ((ArmorFSBPowered) player.inventory.armorInventory[i].getItem());
|
||||
|
||||
c += (double) item.getCharge(armor) / (double) item.getMaxCharge();
|
||||
c += (double) item.getCharge(armor) / (double) item.getMaxCharge(armor);
|
||||
}
|
||||
|
||||
int aX = (int) (70 / scale);
|
||||
|
||||
@ -30,7 +30,7 @@ public class ItemPancake extends ItemFood {
|
||||
continue;
|
||||
|
||||
if(st.getItem() instanceof IBatteryItem) {
|
||||
((IBatteryItem)st.getItem()).setCharge(st, ((IBatteryItem)st.getItem()).getMaxCharge());
|
||||
((IBatteryItem)st.getItem()).setCharge(st, ((IBatteryItem)st.getItem()).getMaxCharge(st));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -105,14 +105,17 @@ public class ItemBattery extends Item implements IBatteryItem {
|
||||
return 0;
|
||||
}
|
||||
|
||||
public long getMaxCharge() {
|
||||
@Override
|
||||
public long getMaxCharge(ItemStack stack) {
|
||||
return maxCharge;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getChargeRate() {
|
||||
return chargeRate;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDischargeRate() {
|
||||
return dischargeRate;
|
||||
}
|
||||
@ -134,7 +137,7 @@ public class ItemBattery extends Item implements IBatteryItem {
|
||||
if(item instanceof ItemBattery) {
|
||||
ItemStack stack = new ItemStack(item);
|
||||
stack.stackTagCompound = new NBTTagCompound();
|
||||
stack.stackTagCompound.setLong("charge", ((ItemBattery) item).getMaxCharge());
|
||||
stack.stackTagCompound.setLong("charge", ((ItemBattery) item).getMaxCharge(stack));
|
||||
return stack.copy();
|
||||
}
|
||||
|
||||
@ -146,7 +149,7 @@ public class ItemBattery extends Item implements IBatteryItem {
|
||||
}
|
||||
|
||||
public double getDurabilityForDisplay(ItemStack stack) {
|
||||
return 1D - (double) getCharge(stack) / (double) getMaxCharge();
|
||||
return 1D - (double) getCharge(stack) / (double) getMaxCharge(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@ -38,7 +38,7 @@ public class ItemSelfcharger extends Item implements IBatteryItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxCharge() {
|
||||
public long getMaxCharge(ItemStack stack) {
|
||||
return charge;
|
||||
}
|
||||
|
||||
|
||||
@ -241,7 +241,7 @@ public class ItemGlitch extends Item implements IBatteryItem {
|
||||
@Override public void setCharge(ItemStack stack, long i) { }
|
||||
@Override public void dischargeBattery(ItemStack stack, long i) { }
|
||||
@Override public long getCharge(ItemStack stack) { return 200; }
|
||||
@Override public long getMaxCharge() { return 200; }
|
||||
@Override public long getMaxCharge(ItemStack stack) { return 200; }
|
||||
@Override public long getChargeRate() { return 0; }
|
||||
@Override public long getDischargeRate() { return 200; }
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ public class ItemPotatos extends ItemBattery {
|
||||
|
||||
if(p.getHeldItem() == stack) {
|
||||
|
||||
float pitch = (float)getCharge(stack) / (float)this.getMaxCharge() * 0.5F + 0.5F;
|
||||
float pitch = (float)getCharge(stack) / (float)this.getMaxCharge(stack) * 0.5F + 0.5F;
|
||||
|
||||
world.playSoundAtEntity(p, "hbm:potatos.random", 1.0F, pitch);
|
||||
setTimer(stack, 200 + itemRand.nextInt(100));
|
||||
|
||||
@ -33,7 +33,7 @@ public class ItemFusionCore extends Item {
|
||||
|
||||
if(st.getItem() instanceof IBatteryItem) {
|
||||
|
||||
long maxcharge = ((IBatteryItem) st.getItem()).getMaxCharge();
|
||||
long maxcharge = ((IBatteryItem) st.getItem()).getMaxCharge(st);
|
||||
long charge = ((IBatteryItem) st.getItem()).getCharge(st);
|
||||
long newcharge = Math.min(charge + this.charge, maxcharge);
|
||||
|
||||
|
||||
@ -106,7 +106,7 @@ public class ItemSwordAbilityPower extends ItemSwordAbility implements IBatteryI
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxCharge() {
|
||||
public long getMaxCharge(ItemStack stack) {
|
||||
return maxPower;
|
||||
}
|
||||
|
||||
|
||||
@ -102,7 +102,7 @@ public class ItemToolAbilityPower extends ItemToolAbility implements IBatteryIte
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxCharge() {
|
||||
public long getMaxCharge(ItemStack stack) {
|
||||
return maxPower;
|
||||
}
|
||||
|
||||
|
||||
@ -181,7 +181,7 @@ public class ItemEnergyGunBase extends ItemGunBase implements IBatteryItem {
|
||||
}
|
||||
|
||||
public double getDurabilityForDisplay(ItemStack stack) {
|
||||
return 1D - (double) getCharge(stack) / (double) getMaxCharge();
|
||||
return 1D - (double) getCharge(stack) / (double) getMaxCharge(stack);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -236,7 +236,7 @@ public class ItemEnergyGunBase extends ItemGunBase implements IBatteryItem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getMaxCharge() {
|
||||
public long getMaxCharge(ItemStack stack) {
|
||||
return mainConfig.maxCharge;
|
||||
}
|
||||
|
||||
@ -266,7 +266,7 @@ public class ItemEnergyGunBase extends ItemGunBase implements IBatteryItem {
|
||||
|
||||
ItemStack stack = new ItemStack(item);
|
||||
stack.stackTagCompound = new NBTTagCompound();
|
||||
stack.stackTagCompound.setLong("charge", ((ItemEnergyGunBase) item).getMaxCharge());
|
||||
stack.stackTagCompound.setLong("charge", ((ItemEnergyGunBase) item).getMaxCharge(stack));
|
||||
|
||||
list.add(stack);
|
||||
}
|
||||
|
||||
@ -243,7 +243,7 @@ public class Library {
|
||||
|
||||
IBatteryItem battery = (IBatteryItem) slots[index].getItem();
|
||||
|
||||
long batMax = battery.getMaxCharge();
|
||||
long batMax = battery.getMaxCharge(slots[index]);
|
||||
long batCharge = battery.getCharge(slots[index]);
|
||||
long batRate = battery.getChargeRate();
|
||||
long toCharge = Math.min(Math.min(power, batRate), batMax - batCharge);
|
||||
|
||||
@ -103,12 +103,12 @@ public class TileEntityNukeBalefire extends TileEntityMachineBase implements IGU
|
||||
public int getBattery() {
|
||||
|
||||
if(slots[1] != null && slots[1].getItem() == ModItems.battery_spark &&
|
||||
((IBatteryItem)ModItems.battery_spark).getCharge(slots[1]) == ((IBatteryItem)ModItems.battery_spark).getMaxCharge()) {
|
||||
((IBatteryItem)ModItems.battery_spark).getCharge(slots[1]) == ((IBatteryItem)ModItems.battery_spark).getMaxCharge(slots[1])) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
if(slots[1] != null && slots[1].getItem() == ModItems.battery_trixite &&
|
||||
((IBatteryItem)ModItems.battery_trixite).getCharge(slots[1]) == ((IBatteryItem)ModItems.battery_trixite).getMaxCharge()) {
|
||||
((IBatteryItem)ModItems.battery_trixite).getCharge(slots[1]) == ((IBatteryItem)ModItems.battery_trixite).getMaxCharge(slots[1])) {
|
||||
return 2;
|
||||
}
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ public class TileEntityCharger extends TileEntityLoadedBase implements IEnergyRe
|
||||
|
||||
if(stack != null && stack.getItem() instanceof IBatteryItem) {
|
||||
IBatteryItem battery = (IBatteryItem) stack.getItem();
|
||||
charge += Math.min(battery.getMaxCharge() - battery.getCharge(stack), battery.getChargeRate());
|
||||
charge += Math.min(battery.getMaxCharge(stack) - battery.getCharge(stack), battery.getChargeRate());
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -127,7 +127,7 @@ public class TileEntityCharger extends TileEntityLoadedBase implements IEnergyRe
|
||||
if(stack != null && stack.getItem() instanceof IBatteryItem) {
|
||||
IBatteryItem battery = (IBatteryItem) stack.getItem();
|
||||
|
||||
long toCharge = Math.min(battery.getMaxCharge() - battery.getCharge(stack), battery.getChargeRate());
|
||||
long toCharge = Math.min(battery.getMaxCharge(stack) - battery.getCharge(stack), battery.getChargeRate());
|
||||
toCharge = Math.min(toCharge, power / 5);
|
||||
battery.chargeBattery(stack, toCharge);
|
||||
power -= toCharge;
|
||||
|
||||
@ -111,7 +111,7 @@ public class TileEntityMachineDiesel extends TileEntityMachinePolluting implemen
|
||||
}
|
||||
}
|
||||
if(i == 2) {
|
||||
if(stack.getItem() instanceof IBatteryItem && ((IBatteryItem) stack.getItem()).getCharge(stack) == ((IBatteryItem) stack.getItem()).getMaxCharge()) {
|
||||
if(stack.getItem() instanceof IBatteryItem && ((IBatteryItem) stack.getItem()).getCharge(stack) == ((IBatteryItem) stack.getItem()).getMaxCharge(stack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I
|
||||
if(i == 0 && ((IBatteryItem)itemStack.getItem()).getCharge(itemStack) == 0) {
|
||||
return true;
|
||||
}
|
||||
if(i == 1 && ((IBatteryItem)itemStack.getItem()).getCharge(itemStack) == ((IBatteryItem)itemStack.getItem()).getMaxCharge()) {
|
||||
if(i == 1 && ((IBatteryItem)itemStack.getItem()).getCharge(itemStack) == ((IBatteryItem)itemStack.getItem()).getMaxCharge(itemStack)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -206,4 +206,15 @@ public class BobMathUtil {
|
||||
double delta = (beta - alpha + 180) % 360 - 180;
|
||||
return delta < -180 ? delta + 360 : delta;
|
||||
}
|
||||
|
||||
/** Soft peak sine */
|
||||
public static double sps(double x) {
|
||||
return Math.sin(Math.PI / 2D * Math.cos(x));
|
||||
}
|
||||
|
||||
/** Square wave sine, make sure squarination is [0;1] */
|
||||
public static double sws(double x, double squarination) {
|
||||
double s = Math.sin(x);
|
||||
return Math.pow(Math.abs(s), 2 - squarination) / s;
|
||||
}
|
||||
}
|
||||
|
||||
@ -119,6 +119,7 @@ armorMod.chestplates=Brustplatten
|
||||
armorMod.helmets=Helme
|
||||
armorMod.leggings=Beinschienen
|
||||
armorMod.insertHere=Rüstung zum Modifizieren einlegen...
|
||||
armorMod.type.battery=Batterie
|
||||
armorMod.type.boots=Stiefel
|
||||
armorMod.type.chestplate=Brustplatte
|
||||
armorMod.type.cladding=Beschläge
|
||||
@ -1188,6 +1189,7 @@ item.arc_electrode_burnt.graphite.name=Geschmolzene Graphitelektrode
|
||||
item.arc_electrode_burnt.lanthanium.name=Geschmolzene Lanthanelektrode
|
||||
item.arc_electrode_burnt.saturnite.name=Geschmolzene Saturnitelektrode
|
||||
item.arc_electrode_desh.name=Desh-Elektrode
|
||||
item.armor_battery.name=Powerrüstung-Akkusatz
|
||||
item.armor_polish.name=ShiningArmor™ Rüstungspolitur
|
||||
item.asbestos_boots.name=Hitzeschutzstiefel
|
||||
item.asbestos_cloth.name=Hitzeschutzanzugsstoff
|
||||
|
||||
@ -174,6 +174,7 @@ armorMod.chestplates=Chestplates
|
||||
armorMod.helmets=Helmets
|
||||
armorMod.insertHere=Insert armor to modify...
|
||||
armorMod.leggings=Leggings
|
||||
armorMod.type.battery=Battery
|
||||
armorMod.type.boots=Boots
|
||||
armorMod.type.chestplate=Chestplate
|
||||
armorMod.type.cladding=Cladding
|
||||
@ -1900,6 +1901,7 @@ item.arc_electrode_burnt.graphite.name=Molten Graphite Electrode
|
||||
item.arc_electrode_burnt.lanthanium.name=Molten Lanthanium Electrode
|
||||
item.arc_electrode_burnt.saturnite.name=Molten Saturnite Electrode
|
||||
item.arc_electrode_desh.name=Desh Electrode
|
||||
item.armor_battery.name=Power Armor Battery Pack
|
||||
item.armor_polish.name=ShiningArmor™ Armor Polish
|
||||
item.asbestos_boots.name=Fire Proximity Boots
|
||||
item.asbestos_cloth.name=Fire Proximity Cloth
|
||||
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 367 B After Width: | Height: | Size: 403 B |
Binary file not shown.
|
After Width: | Height: | Size: 367 B |
Loading…
x
Reference in New Issue
Block a user