i like eating lead-sulfur batteries

This commit is contained in:
Bob 2025-12-23 20:51:55 +01:00
parent ef2b20d357
commit de2a11389c
44 changed files with 1927 additions and 141 deletions

View File

@ -11,8 +11,8 @@ public interface IBatteryItem {
public void dischargeBattery(ItemStack stack, long i);
public long getCharge(ItemStack stack);
public long getMaxCharge(ItemStack stack);
public long getChargeRate();
public long getDischargeRate();
public long getChargeRate(ItemStack stack);
public long getDischargeRate(ItemStack stack);
/** Returns a string for the NBT tag name of the long storing power */
public default String getChargeTagName() {

View File

@ -43,7 +43,7 @@ public interface IEnergyProviderMK2 extends IEnergyHandlerMK2 {
if(te instanceof IEnergyReceiverMK2 && te != this) {
IEnergyReceiverMK2 rec = (IEnergyReceiverMK2) te;
if(rec.canConnect(dir.getOpposite())) {
if(rec.canConnect(dir.getOpposite()) && rec.allowDirectProvision()) {
long provides = Math.min(this.getPower(), this.getProviderSpeed());
long receives = Math.min(rec.getMaxPower() - rec.getPower(), rec.getReceiverSpeed());
long toTransfer = Math.min(provides, receives);

View File

@ -31,6 +31,9 @@ public interface IEnergyReceiverMK2 extends IEnergyHandlerMK2 {
public default long getReceiverSpeed() {
return this.getMaxPower();
}
/** Whether a provider can provide power by touching the block (i.e. via proxies), bypassing the need for a network entirely */
public default boolean allowDirectProvision() { return true; }
public default void trySubscribe(World world, DirPos pos) { trySubscribe(world, pos.getX(), pos.getY(), pos.getZ(), pos.getDir()); }

View File

@ -78,7 +78,7 @@ public class PowerNetMK2 extends NodeNet<IEnergyReceiverMK2, IEnergyProviderMK2,
for(Pair<IEnergyReceiverMK2, Long> entry : list) {
double weight = (double) entry.getValue() / (double) (priorityDemand);
long toSend = (long) Math.max(toTransfer * weight, 0D);
long toSend = (long) Math.min(Math.max(toTransfer * weight, 0D), entry.getValue());
energyUsed += (toSend - entry.getKey().transferPower(toSend)); //leftovers are subtracted from the intended amount to use up
}

View File

@ -740,16 +740,16 @@ public class ModBlocks {
public static Block machine_electric_furnace_off;
public static Block machine_electric_furnace_on;
public static Block machine_microwave;
public static Block machine_battery_potato;
public static Block machine_battery;
public static Block machine_lithium_battery;
public static Block machine_schrabidium_battery;
public static Block machine_dineutronium_battery;
public static Block machine_battery_socket;
@Deprecated public static Block machine_battery_potato;
@Deprecated public static Block machine_battery;
@Deprecated public static Block machine_lithium_battery;
@Deprecated public static Block machine_schrabidium_battery;
@Deprecated public static Block machine_dineutronium_battery;
public static Block machine_fensu;
public static final int guiID_machine_fensu = 99;
public static Block capacitor_bus;
public static Block capacitor_copper;
@ -1862,6 +1862,7 @@ public class ModBlocks {
machine_arc_furnace = new MachineArcFurnaceLarge().setBlockName("machine_arc_furnace").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
machine_microwave = new MachineMicrowave(Material.iron).setBlockName("machine_microwave").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":machine_microwave");
machine_battery_socket = new MachineBatterySocket().setBlockName("machine_battery_socket").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab).setBlockTextureName(RefStrings.MODID + ":block_steel");
machine_battery_potato = new MachineBattery(Material.iron, 10_000).setBlockName("machine_battery_potato").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
machine_battery = new MachineBattery(Material.iron, 1_000_000).setBlockName("machine_battery").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
machine_lithium_battery = new MachineBattery(Material.iron, 50_000_000).setBlockName("machine_lithium_battery").setHardness(5.0F).setResistance(10.0F).setCreativeTab(MainRegistry.machineTab);
@ -3259,6 +3260,7 @@ public class ModBlocks {
register(barrel_steel);
register(barrel_tcalloy);
register(barrel_antimatter);
register(machine_battery_socket);
register(machine_battery_potato);
register(machine_battery);
register(machine_lithium_battery);

View File

@ -0,0 +1,51 @@
package com.hbm.blocks.network;
import java.util.List;
import com.hbm.blocks.BlockDummyable;
import com.hbm.blocks.ITooltipProvider;
import com.hbm.tileentity.TileEntityProxyCombo;
import com.hbm.tileentity.machine.storage.TileEntityBatterySocket;
import net.minecraft.block.material.Material;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class MachineBatterySocket extends BlockDummyable implements ITooltipProvider {
public MachineBatterySocket() {
super(Material.iron);
}
@Override
public TileEntity createNewTileEntity(World world, int meta) {
if(meta >= 12) return new TileEntityBatterySocket();
if(meta >= 6) return new TileEntityProxyCombo().inventory().power().conductor();
return null;
}
@Override
public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ) {
return standardOpenBehavior(world, x, y, z, player, side);
}
@Override public int[] getDimensions() { return new int[] {1, 0, 1, 0, 1, 0}; }
@Override public int getOffset() { return 0; }
protected void fillSpace(World world, int x, int y, int z, ForgeDirection dir, int o) {
super.fillSpace(world, x, y, z, dir, o);
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
this.makeExtra(world, x - dir.offsetX, y, z - dir.offsetZ);
this.makeExtra(world, x + rot.offsetX, y, z + rot.offsetZ);
this.makeExtra(world, x - dir.offsetX + rot.offsetX, y, z - dir.offsetZ + rot.offsetZ);
}
@Override
public void addInformation(ItemStack stack, EntityPlayer player, List list, boolean ext) {
addStandardInfo(stack, player, list, ext);
}
}

View File

@ -52,7 +52,7 @@ public abstract class EntityRailCarElectric extends EntityRailCarRidable {
if(stack != null && stack.getItem() instanceof IBatteryItem) {
IBatteryItem battery = (IBatteryItem) stack.getItem();
int powerNeeded = this.getMaxPower() - this.getPower();
long powerProvided = Math.min(battery.getDischargeRate(), battery.getCharge(stack));
long powerProvided = Math.min(battery.getDischargeRate(stack), battery.getCharge(stack));
int powerTransfered = (int) Math.min(powerNeeded, powerProvided);
if(powerTransfered > 0) {

View File

@ -421,7 +421,6 @@ public class ExplosionNukeGeneric {
public static void emp(World world, int x, int y, int z) {
if (!world.isRemote) {
Block b = world.getBlock(x,y,z);
TileEntity te = world.getTileEntity(x, y, z);
if (te != null && te instanceof IEnergyHandlerMK2) {

View File

@ -0,0 +1,61 @@
package com.hbm.inventory.container;
import com.hbm.inventory.SlotNonRetarded;
import com.hbm.tileentity.machine.storage.TileEntityBatterySocket;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.item.ItemStack;
public class ContainerBatterySocket extends Container {
protected TileEntityBatterySocket socket;
public ContainerBatterySocket(InventoryPlayer invPlayer, TileEntityBatterySocket tedf) {
this.socket = tedf;
this.addSlotToContainer(new SlotNonRetarded(socket, 0, 35, 35));
for(int i = 0; i < 3; i++) {
for(int j = 0; j < 9; j++) {
this.addSlotToContainer(new Slot(invPlayer, j + i * 9 + 9, 8 + j * 18, 99 + i * 18));
}
}
for(int i = 0; i < 9; i++) {
this.addSlotToContainer(new Slot(invPlayer, i, 8 + i * 18, 157));
}
}
@Override
public boolean canInteractWith(EntityPlayer player) {
return socket.isUseableByPlayer(player);
}
@Override
public ItemStack transferStackInSlot(EntityPlayer player, int index) {
ItemStack copy = null;
Slot slot = (Slot) this.inventorySlots.get(index);
if(slot != null && slot.getHasStack()) {
ItemStack stack = slot.getStack();
copy = stack.copy();
if(index == 0) {
if(!this.mergeItemStack(stack, 1, this.inventorySlots.size(), true)) return null;
} else {
if(!this.mergeItemStack(stack, 0, 1, false)) return null;
}
if(stack.stackSize == 0) {
slot.putStack((ItemStack) null);
} else {
slot.onSlotChanged();
}
}
return copy;
}
}

View File

@ -0,0 +1,110 @@
package com.hbm.inventory.gui;
import java.util.ArrayList;
import java.util.List;
import org.lwjgl.opengl.GL11;
import com.hbm.inventory.container.ContainerBatterySocket;
import com.hbm.lib.RefStrings;
import com.hbm.packet.PacketDispatcher;
import com.hbm.packet.toserver.NBTControlPacket;
import com.hbm.tileentity.machine.storage.TileEntityBatterySocket;
import com.hbm.util.BobMathUtil;
import com.hbm.util.i18n.I18nUtil;
import api.hbm.energymk2.IBatteryItem;
import net.minecraft.client.Minecraft;
import net.minecraft.client.resources.I18n;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
public class GUIBatterySocket extends GuiInfoContainer {
private static ResourceLocation texture = new ResourceLocation(RefStrings.MODID + ":textures/gui/storage/gui_battery_socket.png");
private TileEntityBatterySocket battery;
public GUIBatterySocket(InventoryPlayer invPlayer, TileEntityBatterySocket tedf) {
super(new ContainerBatterySocket(invPlayer, tedf));
battery = tedf;
this.xSize = 176;
this.ySize = 181;
}
@Override
public void drawScreen(int mouseX, int mouseY, float f) {
super.drawScreen(mouseX, mouseY, f);
if(battery.slots[0] != null && battery.slots[0].getItem() instanceof IBatteryItem) {
//this.drawElectricityInfo(this, mouseX, mouseY, guiLeft + 62, guiTop + 69 - 52, 52, 52, battery.power, battery.getMaxPower());
IBatteryItem item = (IBatteryItem) battery.slots[0].getItem();
String deltaText = BobMathUtil.getShortNumber(Math.abs(battery.delta)) + "HE/s";
if(battery.delta > 0) deltaText = EnumChatFormatting.GREEN + "+" + deltaText;
else if(battery.delta < 0) deltaText = EnumChatFormatting.RED + "-" + deltaText;
else deltaText = EnumChatFormatting.YELLOW + "+" + deltaText;
String[] info = { BobMathUtil.getShortNumber(item.getCharge(battery.slots[0])) + "/" + BobMathUtil.getShortNumber(item.getMaxCharge(battery.slots[0])) + "HE", deltaText };
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 62, guiTop + 69 - 52, 34, 52, mouseX, mouseY, info);
}
String lang = null;
switch(battery.priority) {
case LOW: lang = "low"; break;
case HIGH: lang = "high"; break;
default: lang = "normal"; break;
}
List<String> priority = new ArrayList();
priority.add(I18nUtil.resolveKey("battery.priority." + lang));
priority.add(I18nUtil.resolveKey("battery.priority.recommended"));
String[] desc = I18nUtil.resolveKeyArray("battery.priority." + lang + ".desc");
for(String s : desc) priority.add(s);
this.drawCustomInfoStat(mouseX, mouseY, guiLeft + 152, guiTop + 35, 16, 16, mouseX, mouseY, priority);
}
protected void mouseClicked(int x, int y, int i) {
super.mouseClicked(x, y, i);
NBTTagCompound data = new NBTTagCompound();
if(this.checkClick(x, y, 106, 16, 18, 18)) { this.click(); data.setBoolean("low", true); }
if(this.checkClick(x, y, 106, 52, 18, 18)) { this.click(); data.setBoolean("high", true); }
if(this.checkClick(x, y, 125, 35, 16, 16)) { this.click(); data.setBoolean("priority", true); }
if(!data.hasNoTags()) PacketDispatcher.wrapper.sendToServer(new NBTControlPacket(data, battery.xCoord, battery.yCoord, battery.zCoord));
}
@Override
protected void drawGuiContainerForegroundLayer(int i, int j) {
String name = this.battery.hasCustomInventoryName() ? this.battery.getInventoryName() : I18n.format(this.battery.getInventoryName());
this.fontRendererObj.drawString(name, this.xSize / 2 - this.fontRendererObj.getStringWidth(name) / 2, 6, 4210752);
this.fontRendererObj.drawString(I18n.format("container.inventory"), 8, this.ySize - 96 + 2, 4210752);
}
@Override
protected void drawGuiContainerBackgroundLayer(float p_146976_1_, int p_146976_2_, int p_146976_3_) {
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
Minecraft.getMinecraft().getTextureManager().bindTexture(texture);
drawTexturedModalRect(guiLeft, guiTop, 0, 0, xSize, ySize);
if(battery.slots[0] != null && battery.slots[0].getItem() instanceof IBatteryItem) {
IBatteryItem item = (IBatteryItem) battery.slots[0].getItem();
long power = item.getCharge(battery.slots[0]);
long maxPower = item.getMaxCharge(battery.slots[0]);
int p = (int) (power * 52 / maxPower); // won't work then flying too close to the sun (the limits of the LONG data type)
drawTexturedModalRect(guiLeft + 62, guiTop + 69 - p, 176, 52 - p, 34, p);
}
drawTexturedModalRect(guiLeft + 106, guiTop + 16, 176, 52 + battery.redLow * 18, 18, 18);
drawTexturedModalRect(guiLeft + 106, guiTop + 52, 176, 52 + battery.redHigh * 18, 18, 18);
drawTexturedModalRect(guiLeft + 125, guiTop + 35, 194, 52 + battery.priority.ordinal() * 16 - 16, 16, 16);
}
}

View File

@ -1627,33 +1627,34 @@ public class ModItems {
public static Item custom_schrab;
public static Item custom_fall;
public static Item battery_generic;
public static Item battery_advanced;
public static Item battery_lithium;
public static Item battery_schrabidium;
public static Item battery_spark;
public static Item battery_trixite;
@Deprecated public static Item battery_generic;
@Deprecated public static Item battery_advanced;
@Deprecated public static Item battery_lithium;
@Deprecated public static Item battery_schrabidium;
@Deprecated public static Item battery_spark;
@Deprecated public static Item battery_trixite;
@Deprecated public static Item battery_red_cell;
@Deprecated public static Item battery_red_cell_6;
@Deprecated public static Item battery_red_cell_24;
@Deprecated public static Item battery_advanced_cell;
@Deprecated public static Item battery_advanced_cell_4;
@Deprecated public static Item battery_advanced_cell_12;
@Deprecated public static Item battery_lithium_cell;
@Deprecated public static Item battery_lithium_cell_3;
@Deprecated public static Item battery_lithium_cell_6;
@Deprecated public static Item battery_schrabidium_cell;
@Deprecated public static Item battery_schrabidium_cell_2;
@Deprecated public static Item battery_schrabidium_cell_4;
@Deprecated public static Item battery_spark_cell_6;
@Deprecated public static Item battery_spark_cell_25;
@Deprecated public static Item battery_spark_cell_100;
@Deprecated public static Item battery_spark_cell_1000;
@Deprecated public static Item battery_spark_cell_2500;
@Deprecated public static Item battery_spark_cell_10000;
@Deprecated public static Item battery_spark_cell_power;
public static Item battery_pack;
public static Item battery_creative;
public static Item battery_red_cell;
public static Item battery_red_cell_6;
public static Item battery_red_cell_24;
public static Item battery_advanced_cell;
public static Item battery_advanced_cell_4;
public static Item battery_advanced_cell_12;
public static Item battery_lithium_cell;
public static Item battery_lithium_cell_3;
public static Item battery_lithium_cell_6;
public static Item battery_schrabidium_cell;
public static Item battery_schrabidium_cell_2;
public static Item battery_schrabidium_cell_4;
public static Item battery_spark_cell_6;
public static Item battery_spark_cell_25;
public static Item battery_spark_cell_100;
public static Item battery_spark_cell_1000;
public static Item battery_spark_cell_2500;
public static Item battery_spark_cell_10000;
public static Item battery_spark_cell_power;
public static Item cube_power;
public static Item battery_sc_uranium;
@ -3868,33 +3869,34 @@ public class ModItems {
custom_schrab = new ItemCustomLore().setUnlocalizedName("custom_schrab").setMaxStackSize(1).setCreativeTab(MainRegistry.nukeTab).setTextureName(RefStrings.MODID + ":custom_schrab");
custom_fall = new ItemCustomLore().setUnlocalizedName("custom_fall").setMaxStackSize(1).setCreativeTab(MainRegistry.nukeTab).setTextureName(RefStrings.MODID + ":custom_fall");
battery_generic = new ItemBattery(5000, 100, 100).setUnlocalizedName("battery_generic").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_generic_new");
battery_advanced = new ItemBattery(20000, 500, 500).setUnlocalizedName("battery_advanced").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_advanced_new");
battery_lithium = new ItemBattery(250000, 1000, 1000).setUnlocalizedName("battery_lithium").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_lithium");
battery_schrabidium = new ItemBattery(1000000, 5000, 5000).setUnlocalizedName("battery_schrabidium").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_schrabidium_new");
battery_spark = new ItemBattery(100000000, 2000000, 2000000).setUnlocalizedName("battery_spark").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_spark");
battery_trixite = new ItemBattery(5000000, 40000, 200000).setUnlocalizedName("battery_trixite").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_trixite");
battery_generic = new ItemBattery(5000, 100, 100).setUnlocalizedName("battery_generic").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_generic_new");
battery_advanced = new ItemBattery(20000, 500, 500).setUnlocalizedName("battery_advanced").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_advanced_new");
battery_lithium = new ItemBattery(250000, 1000, 1000).setUnlocalizedName("battery_lithium").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_lithium");
battery_schrabidium = new ItemBattery(1000000, 5000, 5000).setUnlocalizedName("battery_schrabidium").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_schrabidium_new");
battery_spark = new ItemBattery(100000000, 2000000, 2000000).setUnlocalizedName("battery_spark").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_spark");
battery_trixite = new ItemBattery(5000000, 40000, 200000).setUnlocalizedName("battery_trixite").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_trixite");
battery_red_cell = new ItemBattery(15000, 100, 100).setUnlocalizedName("battery_red_cell").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_red_cell");
battery_red_cell_6 = new ItemBattery(15000 * 6, 100, 100).setUnlocalizedName("battery_red_cell_6").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_red_cell_6");
battery_red_cell_24 = new ItemBattery(15000 * 24, 100, 100).setUnlocalizedName("battery_red_cell_24").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_red_cell_24");
battery_advanced_cell = new ItemBattery(60000, 500, 500).setUnlocalizedName("battery_advanced_cell").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_advanced_cell");
battery_advanced_cell_4 = new ItemBattery(60000 * 4, 500, 500).setUnlocalizedName("battery_advanced_cell_4").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_advanced_cell_4");
battery_advanced_cell_12 = new ItemBattery(60000 * 12, 500, 500).setUnlocalizedName("battery_advanced_cell_12").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_advanced_cell_12");
battery_lithium_cell = new ItemBattery(750000, 1000, 1000).setUnlocalizedName("battery_lithium_cell").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_lithium_cell");
battery_lithium_cell_3 = new ItemBattery(750000 * 3, 1000, 1000).setUnlocalizedName("battery_lithium_cell_3").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_lithium_cell_3");
battery_lithium_cell_6 = new ItemBattery(750000 * 6, 1000, 1000).setUnlocalizedName("battery_lithium_cell_6").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_lithium_cell_6");
battery_schrabidium_cell = new ItemBattery(3000000, 5000, 5000).setUnlocalizedName("battery_schrabidium_cell").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_schrabidium_cell");
battery_schrabidium_cell_2 = new ItemBattery(3000000 * 2, 5000, 5000).setUnlocalizedName("battery_schrabidium_cell_2").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_schrabidium_cell_2");
battery_schrabidium_cell_4 = new ItemBattery(3000000 * 4, 5000, 5000).setUnlocalizedName("battery_schrabidium_cell_4").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_schrabidium_cell_4");
battery_spark_cell_6 = new ItemBattery(100000000L * 6L, 2000000, 2000000).setUnlocalizedName("battery_spark_cell_6").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_spark_cell_6");
battery_spark_cell_25 = new ItemBattery(100000000L * 25L, 2000000, 2000000).setUnlocalizedName("battery_spark_cell_25").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_spark_cell_25");
battery_spark_cell_100 = new ItemBattery(100000000L * 100L, 2000000, 2000000).setUnlocalizedName("battery_spark_cell_100").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_spark_cell_100");
battery_spark_cell_1000 = new ItemBattery(100000000L * 1000L, 20000000, 20000000).setUnlocalizedName("battery_spark_cell_1000").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_spark_cell_1000");
battery_spark_cell_2500 = new ItemBattery(100000000L * 2500L, 20000000, 20000000).setUnlocalizedName("battery_spark_cell_2500").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_spark_cell_2500");
battery_spark_cell_10000 = new ItemBattery(100000000L * 10000L, 200000000, 200000000).setUnlocalizedName("battery_spark_cell_10000").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_spark_cell_10000");
battery_spark_cell_power = new ItemBattery(100000000L * 1000000L, 200000000, 200000000).setUnlocalizedName("battery_spark_cell_power").setMaxStackSize(1).setCreativeTab(null).setTextureName(RefStrings.MODID + ":battery_spark_cell_power");
battery_pack = new ItemBatteryPack().setUnlocalizedName("battery_pack").setTextureName(RefStrings.MODID + ":battery_generic_new");
battery_creative = new Item().setUnlocalizedName("battery_creative").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_creative_new");
battery_red_cell = new ItemBattery(15000, 100, 100).setUnlocalizedName("battery_red_cell").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_red_cell");
battery_red_cell_6 = new ItemBattery(15000 * 6, 100, 100).setUnlocalizedName("battery_red_cell_6").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_red_cell_6");
battery_red_cell_24 = new ItemBattery(15000 * 24, 100, 100).setUnlocalizedName("battery_red_cell_24").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_red_cell_24");
battery_advanced_cell = new ItemBattery(60000, 500, 500).setUnlocalizedName("battery_advanced_cell").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_advanced_cell");
battery_advanced_cell_4 = new ItemBattery(60000 * 4, 500, 500).setUnlocalizedName("battery_advanced_cell_4").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_advanced_cell_4");
battery_advanced_cell_12 = new ItemBattery(60000 * 12, 500, 500).setUnlocalizedName("battery_advanced_cell_12").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_advanced_cell_12");
battery_lithium_cell = new ItemBattery(750000, 1000, 1000).setUnlocalizedName("battery_lithium_cell").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_lithium_cell");
battery_lithium_cell_3 = new ItemBattery(750000 * 3, 1000, 1000).setUnlocalizedName("battery_lithium_cell_3").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_lithium_cell_3");
battery_lithium_cell_6 = new ItemBattery(750000 * 6, 1000, 1000).setUnlocalizedName("battery_lithium_cell_6").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_lithium_cell_6");
battery_schrabidium_cell = new ItemBattery(3000000, 5000, 5000).setUnlocalizedName("battery_schrabidium_cell").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_schrabidium_cell");
battery_schrabidium_cell_2 = new ItemBattery(3000000 * 2, 5000, 5000).setUnlocalizedName("battery_schrabidium_cell_2").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_schrabidium_cell_2");
battery_schrabidium_cell_4 = new ItemBattery(3000000 * 4, 5000, 5000).setUnlocalizedName("battery_schrabidium_cell_4").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_schrabidium_cell_4");
battery_spark_cell_6 = new ItemBattery(100000000L * 6L, 2000000, 2000000).setUnlocalizedName("battery_spark_cell_6").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_spark_cell_6");
battery_spark_cell_25 = new ItemBattery(100000000L * 25L, 2000000, 2000000).setUnlocalizedName("battery_spark_cell_25").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_spark_cell_25");
battery_spark_cell_100 = new ItemBattery(100000000L * 100L, 2000000, 2000000).setUnlocalizedName("battery_spark_cell_100").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_spark_cell_100");
battery_spark_cell_1000 = new ItemBattery(100000000L * 1000L, 20000000, 20000000).setUnlocalizedName("battery_spark_cell_1000").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_spark_cell_1000");
battery_spark_cell_2500 = new ItemBattery(100000000L * 2500L, 20000000, 20000000).setUnlocalizedName("battery_spark_cell_2500").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_spark_cell_2500");
battery_spark_cell_10000 = new ItemBattery(100000000L * 10000L, 200000000, 200000000).setUnlocalizedName("battery_spark_cell_10000").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_spark_cell_10000");
battery_spark_cell_power = new ItemBattery(100000000L * 1000000L, 200000000, 200000000).setUnlocalizedName("battery_spark_cell_power").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_spark_cell_power");
cube_power = new ItemBattery(1000000000000000000L, 1000000000000000L, 1000000000000000L).setUnlocalizedName("cube_power").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":cube_power");
battery_sc_uranium = new ItemSelfcharger(5).setUnlocalizedName("battery_sc_uranium").setMaxStackSize(1).setCreativeTab(MainRegistry.controlTab).setTextureName(RefStrings.MODID + ":battery_sc_uranium");
@ -5700,8 +5702,11 @@ public class ModItems {
GameRegistry.registerItem(battery_spark_cell_2500, battery_spark_cell_2500.getUnlocalizedName());
GameRegistry.registerItem(battery_spark_cell_10000, battery_spark_cell_10000.getUnlocalizedName());
GameRegistry.registerItem(battery_spark_cell_power, battery_spark_cell_power.getUnlocalizedName());
GameRegistry.registerItem(cube_power, cube_power.getUnlocalizedName());
GameRegistry.registerItem(battery_pack, battery_pack.getUnlocalizedName());
GameRegistry.registerItem(battery_creative, battery_creative.getUnlocalizedName());
GameRegistry.registerItem(cube_power, cube_power.getUnlocalizedName());
GameRegistry.registerItem(battery_potato, battery_potato.getUnlocalizedName());
GameRegistry.registerItem(battery_potatos, battery_potatos.getUnlocalizedName());
GameRegistry.registerItem(battery_sc_uranium, battery_sc_uranium.getUnlocalizedName());

View File

@ -117,12 +117,12 @@ public class ArmorFSBPowered extends ArmorFSB implements IBatteryItem {
}
@Override
public long getChargeRate() {
public long getChargeRate(ItemStack stack) {
return chargeRate;
}
@Override
public long getDischargeRate() {
public long getDischargeRate(ItemStack stack) {
return 0;
}

View File

@ -111,12 +111,12 @@ public class ItemBattery extends Item implements IBatteryItem {
}
@Override
public long getChargeRate() {
public long getChargeRate(ItemStack stack) {
return chargeRate;
}
@Override
public long getDischargeRate() {
public long getDischargeRate(ItemStack stack) {
return dischargeRate;
}

View File

@ -0,0 +1,158 @@
package com.hbm.items.machine;
import java.util.List;
import com.hbm.interfaces.IOrderedEnum;
import com.hbm.items.ItemEnumMulti;
import com.hbm.lib.RefStrings;
import com.hbm.main.MainRegistry;
import com.hbm.util.BobMathUtil;
import com.hbm.util.EnumUtil;
import api.hbm.energymk2.IBatteryItem;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumChatFormatting;
import net.minecraft.util.ResourceLocation;
public class ItemBatteryPack extends ItemEnumMulti implements IBatteryItem {
public ItemBatteryPack() {
super(EnumBatteryPack.class, true, false);
this.setMaxStackSize(1);
this.setCreativeTab(MainRegistry.controlTab);
}
public static enum EnumBatteryPack {
REDSTONE ("battery_redstone", 100L),
LEAD ("battery_lead", 1_000L),
LITHIUM ("battery_lithium", 10_000L),
SODIUM ("battery_sodium", 50_000L),
SCHRABIDIUM ("battery_schrabidium", 250_000L),
QUANTUM ("battery_quantum", 1_000_000L);
public ResourceLocation texture;
public long capacity;
public long chargeRate;
public long dischargeRate;
private EnumBatteryPack(String tex, long dischargeRate) {
this(tex, dischargeRate * 20 * 60 * 15, dischargeRate * 10, dischargeRate);
}
private EnumBatteryPack(String tex, long capacity, long chargeRate, long dischargeRate) {
this.texture = new ResourceLocation(RefStrings.MODID, "textures/models/machines/" + tex + ".png");
this.capacity = capacity;
this.chargeRate = chargeRate;
this.dischargeRate = dischargeRate;
}
}
@Override
public void chargeBattery(ItemStack stack, long i) {
if(stack.hasTagCompound()) {
stack.stackTagCompound.setLong("charge", stack.stackTagCompound.getLong("charge") + i);
} else {
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setLong("charge", i);
}
}
@Override
public void setCharge(ItemStack stack, long i) {
if(stack.hasTagCompound()) {
stack.stackTagCompound.setLong("charge", i);
} else {
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setLong("charge", i);
}
}
@Override
public void dischargeBattery(ItemStack stack, long i) {
if(stack.hasTagCompound()) {
stack.stackTagCompound.setLong("charge", stack.stackTagCompound.getLong("charge") - i);
} else {
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setLong("charge", this.getMaxCharge(stack) - i);
}
}
@Override
public long getCharge(ItemStack stack) {
if(stack.hasTagCompound()) {
return stack.stackTagCompound.getLong("charge");
} else {
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setLong("charge", getMaxCharge(stack));
return stack.stackTagCompound.getLong("charge");
}
}
@Override
public long getMaxCharge(ItemStack stack) {
EnumBatteryPack pack = EnumUtil.grabEnumSafely(EnumBatteryPack.class, stack.getItemDamage());
return pack.capacity;
}
@Override
public long getChargeRate(ItemStack stack) {
EnumBatteryPack pack = EnumUtil.grabEnumSafely(EnumBatteryPack.class, stack.getItemDamage());
return pack.chargeRate;
}
@Override
public long getDischargeRate(ItemStack stack) {
EnumBatteryPack pack = EnumUtil.grabEnumSafely(EnumBatteryPack.class, stack.getItemDamage());
return pack.dischargeRate;
}
@Override public boolean showDurabilityBar(ItemStack stack) { return true; }
@Override public double getDurabilityForDisplay(ItemStack stack) { return 1D - (double) getCharge(stack) / (double) getMaxCharge(stack); }
@Override
public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean bool) {
long maxCharge = this.getMaxCharge(itemstack);
long chargeRate = this.getChargeRate(itemstack);
long dischargeRate = this.getDischargeRate(itemstack);
long charge = maxCharge;
if(itemstack.hasTagCompound()) charge = getCharge(itemstack);
list.add(EnumChatFormatting.GREEN + "Energy stored: " + BobMathUtil.getShortNumber(charge) + "/" + BobMathUtil.getShortNumber(maxCharge) + "HE");
list.add(EnumChatFormatting.YELLOW + "Charge rate: " + BobMathUtil.getShortNumber(chargeRate) + "HE/t");
list.add(EnumChatFormatting.YELLOW + "Discharge rate: " + BobMathUtil.getShortNumber(dischargeRate) + "HE/t");
list.add(EnumChatFormatting.GOLD + "Time for full charge: " + (maxCharge / chargeRate / 20 / 60D) + "min");
list.add(EnumChatFormatting.GOLD + "Charge lasts for: " + (maxCharge / dischargeRate / 20 / 60D) + "min");
}
public static ItemStack makeEmptyBattery(ItemStack stack) {
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setLong("charge", 0);
return stack;
}
public static ItemStack makeFullBattery(ItemStack stack) {
stack.stackTagCompound = new NBTTagCompound();
stack.stackTagCompound.setLong("charge", ((ItemBatteryPack) stack.getItem()).getMaxCharge(stack));
return stack;
}
@Override
@SideOnly(Side.CLIENT)
public void getSubItems(Item item, CreativeTabs tab, List list) {
Enum[] order = theEnum.getEnumConstants();
if(order[0] instanceof IOrderedEnum) order = ((IOrderedEnum) order[0]).getOrder();
for(int i = 0; i < order.length; i++) {
list.add(makeEmptyBattery(new ItemStack(item, 1, order[i].ordinal())));
list.add(makeFullBattery(new ItemStack(item, 1, order[i].ordinal())));
}
}
}

View File

@ -43,12 +43,12 @@ public class ItemSelfcharger extends Item implements IBatteryItem {
}
@Override
public long getChargeRate() {
public long getChargeRate(ItemStack stack) {
return 0;
}
@Override
public long getDischargeRate() {
public long getDischargeRate(ItemStack stack) {
return charge;
}

View File

@ -243,6 +243,6 @@ public class ItemGlitch extends Item implements IBatteryItem {
@Override public void dischargeBattery(ItemStack stack, long i) { }
@Override public long getCharge(ItemStack stack) { return 200; }
@Override public long getMaxCharge(ItemStack stack) { return 200; }
@Override public long getChargeRate() { return 0; }
@Override public long getDischargeRate() { return 200; }
@Override public long getChargeRate(ItemStack stack) { return 0; }
@Override public long getDischargeRate(ItemStack stack) { return 200; }
}

View File

@ -111,12 +111,12 @@ public class ItemSwordAbilityPower extends ItemSwordAbility implements IBatteryI
}
@Override
public long getChargeRate() {
public long getChargeRate(ItemStack stack) {
return chargeRate;
}
@Override
public long getDischargeRate() {
public long getDischargeRate(ItemStack stack) {
return 0;
}

View File

@ -107,12 +107,12 @@ public class ItemToolAbilityPower extends ItemToolAbility implements IBatteryIte
}
@Override
public long getChargeRate() {
public long getChargeRate(ItemStack stack) {
return chargeRate;
}
@Override
public long getDischargeRate() {
public long getDischargeRate(ItemStack stack) {
return 0;
}

View File

@ -133,6 +133,6 @@ public class ItemGunDrill extends ItemGunBaseNT implements IFillableItem, IBatte
return 0;
}
@Override public long getChargeRate() { return 50_000; }
@Override public long getDischargeRate() { return 0; }
@Override public long getChargeRate(ItemStack stack) { return 50_000; }
@Override public long getDischargeRate(ItemStack stack) { return 0; }
}

View File

@ -244,7 +244,7 @@ public class Library {
long batMax = battery.getMaxCharge(slots[index]);
long batCharge = battery.getCharge(slots[index]);
long batRate = battery.getChargeRate();
long batRate = battery.getChargeRate(slots[index]);
long toCharge = Math.min(Math.min(power, batRate), batMax - batCharge);
power -= toCharge;
@ -264,7 +264,7 @@ public class Library {
IBatteryItem battery = (IBatteryItem) slots[index].getItem();
long batCharge = battery.getCharge(slots[index]);
long batRate = battery.getDischargeRate();
long batRate = battery.getDischargeRate(slots[index]);
long toDischarge = Math.min(Math.min((maxPower - power), batRate), batCharge);
battery.dischargeBattery(slots[index], toDischarge);

View File

@ -306,6 +306,7 @@ public class ClientProxy extends ServerProxy {
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityFF.class, new RenderForceField());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityForceField.class, new RenderMachineForceField());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineFENSU.class, new RenderFENSU());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityBatterySocket.class, new RenderBatterySocket());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineLargeTurbine.class, new RenderBigTurbine());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntityMachineReactorBreeding.class, new RenderBreeder());
ClientRegistry.bindTileEntitySpecialRenderer(TileEntitySolarBoiler.class, new RenderSolarBoiler());
@ -541,6 +542,7 @@ public class ClientProxy extends ServerProxy {
MinecraftForgeClient.registerItemRenderer(ModItems.missile_doomsday_rusted, new ItemRenderMissileGeneric(RenderMissileType.TYPE_NUCLEAR));
MinecraftForgeClient.registerItemRenderer(ModItems.missile_shuttle, new ItemRenderMissileGeneric(RenderMissileType.TYPE_ROBIN));
MinecraftForgeClient.registerItemRenderer(ModItems.battery_pack, new ItemRenderBatteryPack());
//templates
MinecraftForgeClient.registerItemRenderer(ModItems.assembly_template, new ItemRenderTemplate());
MinecraftForgeClient.registerItemRenderer(ModItems.chemistry_template, new ItemRenderTemplate());

View File

@ -270,6 +270,7 @@ public class ResourceManager {
public static final IModelCustom watz_pump = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/machines/watz_pump.obj")).asVBO();
//FENSU
public static final IModelCustom battery_socket = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/machines/battery.obj")).asVBO();
public static final IModelCustom fensu = new HFRWavefrontObject(new ResourceLocation(RefStrings.MODID, "models/machines/fensu.obj")).asVBO();
//Radar
@ -737,6 +738,7 @@ public class ResourceManager {
public static final ResourceLocation watz_pump_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/watz_pump.png");
//FENSU
public static final ResourceLocation battery_socket_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/battery_socket.png");
public static final ResourceLocation fensu_tex = new ResourceLocation(RefStrings.MODID, "textures/models/machines/fensu.png");
//Radar

View File

@ -2,6 +2,7 @@ package com.hbm.packet.toserver;
import com.hbm.config.MobConfig;
import com.hbm.entity.mob.EntityDuck;
import com.hbm.interfaces.NotableComments;
import com.hbm.items.weapon.ItemCustomMissilePart.PartSize;
import com.hbm.tileentity.TileEntityMachineBase;
import com.hbm.tileentity.TileEntityTickingBase;
@ -25,6 +26,7 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Vec3;
@NotableComments
@Deprecated //use the NBT control packet instead
public class AuxButtonPacket implements IMessage {
@ -34,13 +36,9 @@ public class AuxButtonPacket implements IMessage {
int value;
int id;
public AuxButtonPacket()
{
}
public AuxButtonPacket() { }
public AuxButtonPacket(int x, int y, int z, int value, int id)
{
public AuxButtonPacket(int x, int y, int z, int value, int id) {
this.x = x;
this.y = y;
this.z = z;
@ -77,58 +75,45 @@ public class AuxButtonPacket implements IMessage {
//try {
TileEntity te = p.worldObj.getTileEntity(m.x, m.y, m.z);
if (te instanceof TileEntityForceField) {
if(te instanceof TileEntityForceField) {
TileEntityForceField field = (TileEntityForceField)te;
field.isOn = !field.isOn;
}
if (te instanceof TileEntityMachineMissileAssembly) {
if(te instanceof TileEntityMachineMissileAssembly) {
TileEntityMachineMissileAssembly assembly = (TileEntityMachineMissileAssembly)te;
assembly.construct();
}
if (te instanceof TileEntityLaunchTable) {
if(te instanceof TileEntityLaunchTable) {
TileEntityLaunchTable launcher = (TileEntityLaunchTable)te;
launcher.padSize = PartSize.values()[m.value];
}
if (te instanceof TileEntityCoreEmitter) {
if(te instanceof TileEntityCoreEmitter) {
TileEntityCoreEmitter core = (TileEntityCoreEmitter)te;
if(m.id == 0) {
core.watts = m.value;
}
if(m.id == 1) {
core.isOn = !core.isOn;
}
if(m.id == 0) core.watts = m.value;
if(m.id == 1) core.isOn = !core.isOn;
}
if (te instanceof TileEntityCoreStabilizer) {
if(te instanceof TileEntityCoreStabilizer) {
TileEntityCoreStabilizer core = (TileEntityCoreStabilizer)te;
if(m.id == 0) {
core.watts = m.value;
}
if(m.id == 0) core.watts = m.value;
}
if (te instanceof TileEntityBarrel) {
if(te instanceof TileEntityBarrel) {
TileEntityBarrel barrel = (TileEntityBarrel)te;
barrel.mode = (short) ((barrel.mode + 1) % barrel.modes);
barrel.markDirty();
}
if (te instanceof TileEntityMachineBattery) {
if(te instanceof TileEntityMachineBattery) {
TileEntityMachineBattery bat = (TileEntityMachineBattery)te;
if(m.id == 0) {
bat.redLow = (short) ((bat.redLow + 1) % 4);
bat.markDirty();
}
if(m.id == 1) {
bat.redHigh = (short) ((bat.redHigh + 1) % 4);
bat.markDirty();
@ -136,26 +121,22 @@ public class AuxButtonPacket implements IMessage {
if(m.id == 2) {
switch(bat.priority) {
case LOW: bat.priority = ConnectionPriority.NORMAL; break;
case NORMAL: bat.priority = ConnectionPriority.HIGH; break;
case HIGH: bat.priority = ConnectionPriority.LOW; break;
case LOW: bat.priority = ConnectionPriority.NORMAL; break;
case NORMAL: bat.priority = ConnectionPriority.HIGH; break;
case HIGH: bat.priority = ConnectionPriority.LOW; break;
}
bat.markDirty();
}
}
if (te instanceof TileEntitySoyuzLauncher) {
if(te instanceof TileEntitySoyuzLauncher) {
TileEntitySoyuzLauncher launcher = (TileEntitySoyuzLauncher)te;
if(m.id == 0)
launcher.mode = (byte) m.value;
if(m.id == 1)
launcher.startCountdown();
if(m.id == 0) launcher.mode = (byte) m.value;
if(m.id == 1) launcher.startCountdown();
}
if (te instanceof TileEntityMachineMiningLaser) {
if(te instanceof TileEntityMachineMiningLaser) {
TileEntityMachineMiningLaser laser = (TileEntityMachineMiningLaser)te;
laser.isOn = !laser.isOn;
}

View File

@ -0,0 +1,28 @@
package com.hbm.render.item;
import org.lwjgl.opengl.GL11;
import com.hbm.items.machine.ItemBatteryPack.EnumBatteryPack;
import com.hbm.main.ResourceManager;
import com.hbm.util.EnumUtil;
import net.minecraft.client.Minecraft;
import net.minecraft.item.ItemStack;
public class ItemRenderBatteryPack extends ItemRenderBase {
@Override
public void renderInventory() {
GL11.glTranslated(0, -3, 0);
GL11.glScaled(5, 5, 5);
}
@Override
public void renderCommonWithStack(ItemStack item) {
EnumBatteryPack pack = EnumUtil.grabEnumSafely(EnumBatteryPack.class, item.getItemDamage());
GL11.glShadeModel(GL11.GL_SMOOTH);
Minecraft.getMinecraft().getTextureManager().bindTexture(pack.texture);
ResourceManager.battery_socket.renderPart("Battery");
GL11.glShadeModel(GL11.GL_FLAT);
}
}

View File

@ -0,0 +1,71 @@
package com.hbm.render.tileentity;
import org.lwjgl.opengl.GL11;
import com.hbm.blocks.ModBlocks;
import com.hbm.items.machine.ItemBatteryPack.EnumBatteryPack;
import com.hbm.main.ResourceManager;
import com.hbm.render.item.ItemRenderBase;
import com.hbm.tileentity.machine.storage.TileEntityBatterySocket;
import com.hbm.util.EnumUtil;
import net.minecraft.client.renderer.tileentity.TileEntitySpecialRenderer;
import net.minecraft.item.Item;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.client.IItemRenderer;
public class RenderBatterySocket extends TileEntitySpecialRenderer implements IItemRendererProvider {
@Override
public void renderTileEntityAt(TileEntity tile, double x, double y, double z, float interp) {
GL11.glPushMatrix();
GL11.glTranslated(x + 0.5, y, z + 0.5);
GL11.glEnable(GL11.GL_LIGHTING);
GL11.glEnable(GL11.GL_CULL_FACE);
switch(tile.getBlockMetadata() - 10) {
case 2: GL11.glRotatef(90, 0F, 1F, 0F); break;
case 4: GL11.glRotatef(180, 0F, 1F, 0F); break;
case 3: GL11.glRotatef(270, 0F, 1F, 0F); break;
case 5: GL11.glRotatef(0, 0F, 1F, 0F); break;
}
GL11.glTranslated(-0.5, 0, 0.5);
TileEntityBatterySocket socket = (TileEntityBatterySocket) tile;
GL11.glShadeModel(GL11.GL_SMOOTH);
bindTexture(ResourceManager.battery_socket_tex);
ResourceManager.battery_socket.renderPart("Socket");
if(socket.renderPack >= 0) {
EnumBatteryPack pack = EnumUtil.grabEnumSafely(EnumBatteryPack.class, socket.renderPack);
bindTexture(pack.texture);
ResourceManager.battery_socket.renderPart("Battery");
}
GL11.glShadeModel(GL11.GL_FLAT);
GL11.glPopMatrix();
}
@Override
public Item getItemForRenderer() {
return Item.getItemFromBlock(ModBlocks.machine_battery_socket);
}
@Override
public IItemRenderer getRenderer() {
return new ItemRenderBase() {
public void renderInventory() {
GL11.glTranslated(0, -2, 0);
GL11.glScaled(5, 5, 5);
}
public void renderCommon() {
GL11.glShadeModel(GL11.GL_SMOOTH);
bindTexture(ResourceManager.battery_socket_tex);
ResourceManager.battery_socket.renderPart("Socket");
GL11.glShadeModel(GL11.GL_FLAT);
}};
}
}

View File

@ -148,7 +148,6 @@ public class AnnihilatorSavedData extends WorldSavedData {
serializeKey(compound, entry.getKey());
compound.setByteArray("amount", entry.getValue().toByteArray());
nbt.appendTag(compound);
System.out.println("Serializing " + entry.getValue().toString() + " of " + entry.getKey());
}
}
@ -158,7 +157,6 @@ public class AnnihilatorSavedData extends WorldSavedData {
NBTTagCompound compound = (NBTTagCompound) nbt.tagList.get(i);
Object key = deserializeKey(compound);
if(key != null) this.items.put(key, new BigInteger(compound.getByteArray("amount")));
System.out.println("Deserializing " + new BigInteger(compound.getByteArray("amount")).toString() + " of " + key);
}
} catch(Throwable ex) { } // because world data can be dented to all fucking hell and back
}

View File

@ -6,6 +6,7 @@ import com.hbm.handler.CompatHandler.OCComponent;
import com.hbm.inventory.fluid.FluidType;
import com.hbm.inventory.fluid.tank.FluidTank;
import api.hbm.energymk2.IEnergyConductorMK2;
import api.hbm.energymk2.IEnergyReceiverMK2;
import api.hbm.fluidmk2.IFluidConnectorMK2;
import api.hbm.fluidmk2.IFluidReceiverMK2;
@ -31,11 +32,12 @@ import net.minecraftforge.common.util.ForgeDirection;
@Optional.Interface(iface = "com.hbm.handler.CompatHandler.OCComponent", modid = "opencomputers"),
@Optional.Interface(iface = "li.cil.oc.api.network.SimpleComponent", modid = "opencomputers")
})
public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergyReceiverMK2, ISidedInventory, IFluidReceiverMK2, IHeatSource, ICrucibleAcceptor, SimpleComponent, OCComponent, IRORValueProvider, IRORInteractive {
public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergyReceiverMK2, IEnergyConductorMK2, ISidedInventory, IFluidReceiverMK2, IHeatSource, ICrucibleAcceptor, SimpleComponent, OCComponent, IRORValueProvider, IRORInteractive {
TileEntity tile;
boolean inventory;
boolean power;
boolean conductor;
boolean fluid;
boolean heat;
public boolean moltenMetal;
@ -56,11 +58,15 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy
this.inventory = true;
return this;
}
public TileEntityProxyCombo power() {
this.power = true;
return this;
}
public TileEntityProxyCombo conductor() {
this.conductor = true;
return this;
}
public TileEntityProxyCombo moltenMetal() {
this.moltenMetal = true;
return this;
@ -141,13 +147,21 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy
@Override
public boolean canConnect(ForgeDirection dir) {
if(!power)
return false;
if(getCoreObject() instanceof IEnergyReceiverMK2) {
if(power && getCoreObject() instanceof IEnergyReceiverMK2) {
return ((IEnergyReceiverMK2)getCoreObject()).canConnect(dir);
}
if(conductor && getCoreObject() instanceof IEnergyConductorMK2) {
return ((IEnergyConductorMK2)getCoreObject()).canConnect(dir);
}
return true;
}
@Override
public boolean allowDirectProvision() {
if(!power) return false;
if(getCoreObject() instanceof IEnergyReceiverMK2) return ((IEnergyReceiverMK2)getCoreObject()).allowDirectProvision();
return true;
}
@ -402,6 +416,7 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy
this.inventory = nbt.getBoolean("inv");
this.power = nbt.getBoolean("power");
this.conductor = nbt.getBoolean("conductor");
this.fluid = nbt.getBoolean("fluid");
this.moltenMetal = nbt.getBoolean("metal");
this.heat = nbt.getBoolean("heat");
@ -416,6 +431,7 @@ public class TileEntityProxyCombo extends TileEntityProxyBase implements IEnergy
nbt.setBoolean("inv", inventory);
nbt.setBoolean("power", power);
nbt.setBoolean("conductor", conductor);
nbt.setBoolean("fluid", fluid);
nbt.setBoolean("metal", moltenMetal);
nbt.setBoolean("heat", heat);

View File

@ -81,6 +81,7 @@ public class TileMappings {
put(TileEntityDecoPoleTop.class, "tileentity_poletop");
put(TileEntityDecoPoleSatelliteReceiver.class, "tileentity_satellitereceicer");
put(TileEntityMachineBattery.class, "tileentity_battery");
put(TileEntityBatterySocket.class, "tileentity_battery_socket");
put(TileEntityCapacitor.class, "tileentity_capacitor");
put(TileEntityMachineWoodBurner.class, "tileentity_wood_burner");
put(TileEntityRedBarrel.class, "tileentity_barrel");

View File

@ -46,7 +46,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(stack) - battery.getCharge(stack), battery.getChargeRate());
charge += Math.min(battery.getMaxCharge(stack) - battery.getCharge(stack), battery.getChargeRate(stack));
}
}
}
@ -129,7 +129,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(stack) - battery.getCharge(stack), battery.getChargeRate());
long toCharge = Math.min(battery.getMaxCharge(stack) - battery.getCharge(stack), battery.getChargeRate(null));
toCharge = Math.min(toCharge, Math.max(power / 5, 1));
battery.chargeBattery(stack, toCharge);
power -= toCharge;

View File

@ -0,0 +1,279 @@
package com.hbm.tileentity.machine.storage;
import com.hbm.interfaces.IControlReceiver;
import com.hbm.inventory.container.ContainerBatterySocket;
import com.hbm.inventory.gui.GUIBatterySocket;
import com.hbm.items.ModItems;
import com.hbm.tileentity.IGUIProvider;
import com.hbm.tileentity.TileEntityMachineBase;
import com.hbm.uninos.UniNodespace;
import com.hbm.util.EnumUtil;
import com.hbm.util.fauxpointtwelve.BlockPos;
import com.hbm.util.fauxpointtwelve.DirPos;
import api.hbm.energymk2.IBatteryItem;
import api.hbm.energymk2.IEnergyConductorMK2;
import api.hbm.energymk2.IEnergyProviderMK2;
import api.hbm.energymk2.IEnergyReceiverMK2;
import api.hbm.energymk2.Nodespace;
import api.hbm.energymk2.Nodespace.PowerNode;
import io.netty.buffer.ByteBuf;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import net.minecraftforge.common.util.ForgeDirection;
public class TileEntityBatterySocket extends TileEntityMachineBase implements IEnergyConductorMK2, IEnergyProviderMK2, IEnergyReceiverMK2, IControlReceiver, IGUIProvider {
public long[] log = new long[20];
public long delta = 0;
public byte lastRedstone = 0;
public long prevPowerState = 0;
public static final int mode_input = 0;
public static final int mode_buffer = 1;
public static final int mode_output = 2;
public static final int mode_none = 3;
public short redLow = 0;
public short redHigh = 2;
public ConnectionPriority priority = ConnectionPriority.LOW;
public int renderPack = -1;
protected PowerNode node;
public TileEntityBatterySocket() {
super(1);
}
@Override public String getName() { return "container.batterySocket"; }
@Override
public void updateEntity() {
if(!worldObj.isRemote) {
if(priority == null || priority.ordinal() == 0 || priority.ordinal() == 4) {
priority = ConnectionPriority.LOW;
}
long prevPower = this.getPower();
if(this.node == null || this.node.expired) {
this.node = (PowerNode) UniNodespace.getNode(worldObj, xCoord, yCoord, zCoord, Nodespace.THE_POWER_PROVIDER);
if(this.node == null || this.node.expired) {
this.node = this.createNode();
UniNodespace.createNode(worldObj, this.node);
}
}
if(this.node != null && this.node.hasValidNet()) switch(this.getRelevantMode(false)) {
case mode_input: this.node.net.removeProvider(this); this.node.net.addReceiver(this); break;
case mode_output: this.node.net.addProvider(this); this.node.net.removeReceiver(this); break;
case mode_buffer: this.node.net.addProvider(this); this.node.net.addReceiver(this); break;
case mode_none: this.node.net.removeProvider(this); this.node.net.removeReceiver(this); break;
}
byte comp = this.getComparatorPower();
if(comp != this.lastRedstone) this.markDirty();
this.lastRedstone = comp;
long avg = (this.getPower() + prevPower) / 2;
this.delta = avg - this.log[0];
for(int i = 1; i < this.log.length; i++) {
this.log[i - 1] = this.log[i];
}
this.log[19] = avg;
prevPowerState = this.getPower();
this.networkPackNT(100);
}
}
@Override
public PowerNode createNode() {
return new PowerNode(this.getPortPos()).setConnections(this.getConPos());
}
public byte getComparatorPower() {
double frac = (double) this.getPower() / (double) this.getMaxPower() * 15D;
return (byte) (MathHelper.clamp_int((int) frac + 1, 0, 15)); //to combat eventual rounding errors with the FEnSU's stupid maxPower
}
@Override
public void invalidate() {
super.invalidate();
if(!worldObj.isRemote) {
if(this.node != null) {
UniNodespace.destroyNode(worldObj, xCoord, yCoord, zCoord, Nodespace.THE_POWER_PROVIDER);
}
}
}
@Override
public void serialize(ByteBuf buf) {
super.serialize(buf);
int renderPack = -1;
if(slots[0] != null && slots[0].getItem() == ModItems.battery_pack) {
renderPack = slots[0].getItemDamage();
}
buf.writeInt(renderPack);
buf.writeLong(delta);
buf.writeShort(redLow);
buf.writeShort(redHigh);
buf.writeByte(priority.ordinal());
}
@Override
public void deserialize(ByteBuf buf) {
super.deserialize(buf);
renderPack = buf.readInt();
delta = buf.readLong();
redLow = buf.readShort();
redHigh = buf.readShort();
priority = EnumUtil.grabEnumSafely(ConnectionPriority.class, buf.readByte());
}
@Override
public void readFromNBT(NBTTagCompound nbt) {
super.readFromNBT(nbt);
this.redLow = nbt.getShort("redLow");
this.redHigh = nbt.getShort("redHigh");
this.lastRedstone = nbt.getByte("lastRedstone");
this.priority = EnumUtil.grabEnumSafely(ConnectionPriority.class, nbt.getByte("priority"));
}
@Override
public void writeToNBT(NBTTagCompound nbt) {
super.writeToNBT(nbt);
nbt.setShort("redLow", redLow);
nbt.setShort("redHigh", redHigh);
nbt.setByte("lastRedstone", lastRedstone);
nbt.setByte("priority", (byte) this.priority.ordinal());
}
@Override
public boolean canExtractItem(int i, ItemStack stack, int j) {
if(stack.getItem() instanceof IBatteryItem) {
if(i == mode_input && ((IBatteryItem)stack.getItem()).getCharge(stack) == 0) return true;
if(i == mode_output && ((IBatteryItem)stack.getItem()).getCharge(stack) == ((IBatteryItem)stack.getItem()).getMaxCharge(stack)) return true;
}
return false;
}
@Override
public boolean isItemValidForSlot(int i, ItemStack stack) {
return stack.getItem() instanceof IBatteryItem;
}
@Override public int[] getAccessibleSlotsFromSide(int side) { return new int[] {0}; }
@Override
public long getPower() {
if(slots[0] == null || !(slots[0].getItem() instanceof IBatteryItem)) return 0;
return ((IBatteryItem) slots[0].getItem()).getCharge(slots[0]);
}
@Override
public void setPower(long power) {
if(slots[0] == null || !(slots[0].getItem() instanceof IBatteryItem)) return;
((IBatteryItem) slots[0].getItem()).setCharge(slots[0], power);
}
@Override
public long getMaxPower() {
if(slots[0] == null || !(slots[0].getItem() instanceof IBatteryItem)) return 0;
return ((IBatteryItem) slots[0].getItem()).getMaxCharge(slots[0]);
}
@Override public boolean allowDirectProvision() { return false; }
@Override public ConnectionPriority getPriority() { return this.priority; }
@Override public long getProviderSpeed() {
if(slots[0] == null || !(slots[0].getItem() instanceof IBatteryItem)) return 0;
int mode = this.getRelevantMode(true);
return mode == mode_output || mode == mode_buffer ? ((IBatteryItem) slots[0].getItem()).getDischargeRate(slots[0]) : 0;
}
@Override public long getReceiverSpeed() {
if(slots[0] == null || !(slots[0].getItem() instanceof IBatteryItem)) return 0;
int mode = this.getRelevantMode(true);
return mode == mode_input || mode == mode_buffer ? ((IBatteryItem) slots[0].getItem()).getChargeRate(slots[0]) : 0;
}
public BlockPos[] getPortPos() {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10);
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
return new BlockPos[] {
new BlockPos(xCoord, yCoord, zCoord),
new BlockPos(xCoord - dir.offsetX, yCoord, zCoord - dir.offsetZ),
new BlockPos(xCoord + rot.offsetX, yCoord, zCoord + rot.offsetZ),
new BlockPos(xCoord - dir.offsetX + rot.offsetX, yCoord, zCoord - dir.offsetZ + rot.offsetZ)
};
}
public DirPos[] getConPos() {
ForgeDirection dir = ForgeDirection.getOrientation(this.getBlockMetadata() - 10);
ForgeDirection rot = dir.getRotation(ForgeDirection.UP);
return new DirPos[] {
new DirPos(xCoord + dir.offsetX, yCoord, zCoord + dir.offsetZ, dir),
new DirPos(xCoord + dir.offsetX + rot.offsetX, yCoord, zCoord + dir.offsetZ + rot.offsetZ, dir),
new DirPos(xCoord - dir.offsetX * 2, yCoord, zCoord - dir.offsetZ * 2, dir.getOpposite()),
new DirPos(xCoord - dir.offsetX * 2 + rot.offsetX, yCoord, zCoord - dir.offsetZ * 2 + rot.offsetZ, dir.getOpposite()),
new DirPos(xCoord + rot.offsetX * 2, yCoord, zCoord + rot.offsetZ * 2, rot),
new DirPos(xCoord + rot.offsetX * 2 - dir.offsetX, yCoord, zCoord + rot.offsetZ * 2 - dir.offsetZ, rot),
new DirPos(xCoord - rot.offsetX, yCoord, zCoord - rot.offsetZ, rot.getOpposite()),
new DirPos(xCoord - rot.offsetX - dir.offsetX, yCoord, zCoord - rot.offsetZ - dir.offsetZ, rot.getOpposite())
};
}
private short modeCache = 0;
public short getRelevantMode(boolean useCache) {
if(useCache) return this.modeCache;
boolean powered = false;
for(BlockPos pos : getPortPos()) if(worldObj.isBlockIndirectlyGettingPowered(pos.getX(), pos.getY(), pos.getZ())) { powered = true; break; }
this.modeCache = powered ? this.redHigh : this.redLow;
return this.modeCache;
}
@Override public Container provideContainer(int ID, EntityPlayer player, World world, int x, int y, int z) { return new ContainerBatterySocket(player.inventory, this); }
@Override public Object provideGUI(int ID, EntityPlayer player, World world, int x, int y, int z) { return new GUIBatterySocket(player.inventory, this); }
@Override public boolean hasPermission(EntityPlayer player) { return this.isUseableByPlayer(player); }
@Override
public void receiveControl(NBTTagCompound data) {
if(data.hasKey("low")) {
this.redLow++;
if(this.redLow > 3) this.redLow = 0;
}
if(data.hasKey("high")) {
this.redHigh++;
if(this.redHigh > 3) this.redHigh = 0;
}
if(data.hasKey("priority")) {
int ordinal = this.priority.ordinal();
ordinal++;
if(ordinal > ConnectionPriority.HIGH.ordinal()) ordinal = ConnectionPriority.LOW.ordinal();
this.priority = EnumUtil.grabEnumSafely(ConnectionPriority.class, ordinal);
}
}
}

View File

@ -245,10 +245,6 @@ public class TileEntityMachineBattery extends TileEntityMachineBase implements I
}
}
public void onNodeDestroyedCallback() {
this.node = null;
}
@Override
public void invalidate() {
super.invalidate();

View File

@ -47,6 +47,7 @@ public class TileEntityPneumoTube extends TileEntityMachineBase implements IGUIP
public byte sendOrder = 0;
public byte receiveOrder = 0;
public int soundDelay = 0;
public int sendCounter = 0;
public FluidTank compair;
@ -113,7 +114,7 @@ public class TileEntityPneumoTube extends TileEntityMachineBase implements IGUIP
if(sendFrom instanceof IInventory) {
PneumaticNetwork net = node.net;
if(net.send((IInventory) sendFrom, this, this.insertionDir.getOpposite(), sendOrder, receiveOrder, getRangeFromPressure(compair.getPressure()))) {
if(net.send((IInventory) sendFrom, this, this.insertionDir.getOpposite(), sendOrder, receiveOrder, getRangeFromPressure(compair.getPressure()), sendCounter)) {
this.compair.setFill(this.compair.getFill() - 50);
if(this.soundDelay <= 0 && !this.muffled) {
@ -121,6 +122,8 @@ public class TileEntityPneumoTube extends TileEntityMachineBase implements IGUIP
this.soundDelay = 20;
}
}
this.sendCounter++;
}
}
}
@ -229,6 +232,7 @@ public class TileEntityPneumoTube extends TileEntityMachineBase implements IGUIP
this.sendOrder = nbt.getByte("sendOrder");
this.receiveOrder = nbt.getByte("receiveOrder");
this.sendCounter = nbt.getInteger("sendCounter");
this.whitelist = nbt.getBoolean("whitelist");
this.redstone = nbt.getBoolean("redstone");
@ -244,6 +248,7 @@ public class TileEntityPneumoTube extends TileEntityMachineBase implements IGUIP
nbt.setByte("sendOrder", sendOrder);
nbt.setByte("receiveOrder", receiveOrder);
nbt.setInteger("sendCounter", sendCounter);
nbt.setBoolean("whitelist", whitelist);
nbt.setBoolean("redstone", redstone);

View File

@ -31,7 +31,6 @@ public class PneumaticNetwork extends NodeNet {
public static final byte RECEIVE_RANDOM = 1;
public Random rand = new Random();
public int nextReceiver = 0;
protected static final int timeout = 1_000;
public static final int ITEMS_PER_TRANSFER = 64;
@ -53,7 +52,7 @@ public class PneumaticNetwork extends NodeNet {
receivers.entrySet().removeIf(x -> { return (timestamp - x.getValue().getY() > timeout) || NodeNet.isBadLink(x.getKey()); });
}
public boolean send(IInventory source, TileEntityPneumoTube tube, ForgeDirection accessDir, int sendOrder, int receiveOrder, int maxRange) {
public boolean send(IInventory source, TileEntityPneumoTube tube, ForgeDirection accessDir, int sendOrder, int receiveOrder, int maxRange, int nextReceiver) {
// turns out there may be a short time window where the cleanup hasn't happened yet, but chunkloading has already caused tiles to go invalid
// so we just run it again here, just to be sure.
@ -76,7 +75,6 @@ public class PneumaticNetwork extends NodeNet {
int index = nextReceiver % receivers.size();
Entry<IInventory, Triplet<ForgeDirection, Long, TileEntityPneumoTube>> chosenReceiverEntry = null;
nextReceiver++;
if(receiveOrder == RECEIVE_ROBIN) chosenReceiverEntry = receiverList.get(index);
if(receiveOrder == RECEIVE_RANDOM) chosenReceiverEntry = receiverList.get(rand.nextInt(receiverList.size()));

View File

@ -36,7 +36,7 @@ public class CompatEnergyControl {
/** Standardized discharge for IBatteryItem, returns the amount that was removed */
public static double dischargeItem(ItemStack stack, double needed) {
IBatteryItem battery = (IBatteryItem) stack.getItem();
long toDischarge = Math.min(battery.getDischargeRate(), Math.min(battery.getCharge(stack), (long) needed));
long toDischarge = Math.min(battery.getDischargeRate(stack), Math.min(battery.getCharge(stack), (long) needed));
battery.dischargeBattery(stack, toDischarge);
return toDischarge;
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 626 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1022 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1003 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB