Fixed charging \ discharging items items. Closes #1547
This commit is contained in:
parent
ca9a2c9b38
commit
30302e241b
16 changed files with 37 additions and 61 deletions
|
@ -33,6 +33,7 @@ import reborncore.client.multiblock.Multiblock;
|
|||
import reborncore.client.multiblock.MultiblockRenderEvent;
|
||||
import reborncore.client.multiblock.MultiblockSet;
|
||||
import reborncore.common.network.NetworkManager;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import reborncore.common.util.Torus;
|
||||
import techreborn.client.gui.widget.GuiButtonHologram;
|
||||
import techreborn.client.gui.widget.GuiButtonUpDown;
|
||||
|
@ -85,7 +86,7 @@ public class GuiFusionReactor extends GuiBase {
|
|||
builder.drawHologramButton(this, 6, 4, mouseX, mouseY, layer);
|
||||
drawCentredString(tile.getStateString(), 20, Color.BLUE.darker().getRGB(), layer);
|
||||
if(tile.state == 2){
|
||||
drawCentredString( tile.getLocaliszedPowerFormatted((int) tile.getPowerChange()) + "/t", 30, Color.GREEN.darker().getRGB(), layer);
|
||||
drawCentredString( PowerSystem.getLocaliszedPowerFormatted((int) tile.getPowerChange()) + "/t", 30, Color.GREEN.darker().getRGB(), layer);
|
||||
}
|
||||
} else {
|
||||
builder.drawMultiblockMissingBar(this, layer);
|
||||
|
|
|
@ -56,12 +56,11 @@ public class ItemAdvancedChainsaw extends ItemChainsaw {
|
|||
return;
|
||||
}
|
||||
ItemStack stack = new ItemStack(ModItems.ADVANCED_CHAINSAW);
|
||||
ItemStack uncharged = stack.copy();
|
||||
ItemStack charged = stack.copy();
|
||||
ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
||||
|
||||
itemList.add(uncharged);
|
||||
itemList.add(stack);
|
||||
itemList.add(charged);
|
||||
}
|
||||
|
||||
|
|
|
@ -151,12 +151,11 @@ public class ItemAdvancedDrill extends ItemDrill {
|
|||
return;
|
||||
}
|
||||
ItemStack stack = new ItemStack(ModItems.ADVANCED_DRILL);
|
||||
ItemStack uncharged = stack.copy();
|
||||
ItemStack charged = stack.copy();
|
||||
ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
||||
|
||||
itemList.add(uncharged);
|
||||
itemList.add(stack);
|
||||
itemList.add(charged);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -50,12 +50,11 @@ public class ItemAdvancedJackhammer extends ItemJackhammer {
|
|||
return;
|
||||
}
|
||||
ItemStack stack = new ItemStack(ModItems.ADVANCED_JACKHAMMER);
|
||||
ItemStack uncharged = stack.copy();
|
||||
ItemStack charged = stack.copy();
|
||||
ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
||||
|
||||
itemList.add(uncharged);
|
||||
itemList.add(stack);
|
||||
itemList.add(charged);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ import javax.annotation.Nullable;
|
|||
@RebornRegistry(modID = ModInfo.MOD_ID)
|
||||
public class ItemCloakingDevice extends ItemTRArmour implements IEnergyItemInfo {
|
||||
|
||||
@ConfigRegistry(config = "items", category = "cloacking_device", key = "ClockingDeviceEnergyUsage", comment = "Cloacking device energy usesage (Value in EU)")
|
||||
@ConfigRegistry(config = "items", category = "cloacking_device", key = "ClockingDeviceEnergyUsage", comment = "Cloacking device energy usesage (Value in FE)")
|
||||
public static int usage = 10;
|
||||
|
||||
public static int MaxCharge = ConfigTechReborn.CloakingDeviceCharge;
|
||||
|
|
|
@ -39,8 +39,7 @@ import techreborn.init.ModItems;
|
|||
public class ItemDiamondChainsaw extends ItemChainsaw {
|
||||
|
||||
public ItemDiamondChainsaw() {
|
||||
super(ToolMaterial.DIAMOND, "techreborn.diamondChainsaw", ConfigTechReborn.DiamondChainsawCharge,
|
||||
1.0F);
|
||||
super(ToolMaterial.DIAMOND, "techreborn.diamondChainsaw", ConfigTechReborn.DiamondChainsawCharge, 1.0F);
|
||||
this.cost = 250;
|
||||
}
|
||||
|
||||
|
@ -51,12 +50,11 @@ public class ItemDiamondChainsaw extends ItemChainsaw {
|
|||
return;
|
||||
}
|
||||
ItemStack stack = new ItemStack(ModItems.DIAMOND_CHAINSAW);
|
||||
ItemStack uncharged = stack.copy();
|
||||
ItemStack charged = stack.copy();
|
||||
ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
||||
|
||||
itemList.add(uncharged);
|
||||
itemList.add(stack);
|
||||
itemList.add(charged);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,8 +39,7 @@ import techreborn.init.ModItems;
|
|||
public class ItemDiamondDrill extends ItemDrill {
|
||||
|
||||
public ItemDiamondDrill() {
|
||||
super(ToolMaterial.DIAMOND, "techreborn.diamondDrill", ConfigTechReborn.DiamondDrillCharge,
|
||||
0.5F, 15F);
|
||||
super(ToolMaterial.DIAMOND, "techreborn.diamondDrill", ConfigTechReborn.DiamondDrillCharge, 0.5F, 15F);
|
||||
this.cost = 250;
|
||||
}
|
||||
|
||||
|
@ -51,12 +50,11 @@ public class ItemDiamondDrill extends ItemDrill {
|
|||
return;
|
||||
}
|
||||
ItemStack stack = new ItemStack(ModItems.DIAMOND_DRILL);
|
||||
ItemStack uncharged = stack.copy();
|
||||
ItemStack charged = stack.copy();
|
||||
ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
||||
|
||||
itemList.add(uncharged);
|
||||
itemList.add(stack);
|
||||
itemList.add(charged);
|
||||
}
|
||||
|
||||
|
|
|
@ -49,12 +49,11 @@ public class ItemDiamondJackhammer extends ItemJackhammer {
|
|||
return;
|
||||
}
|
||||
ItemStack stack = new ItemStack(ModItems.DIAMOND_JACKHAMMER);
|
||||
ItemStack uncharged = stack.copy();
|
||||
ItemStack charged = stack.copy();
|
||||
ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
||||
|
||||
itemList.add(uncharged);
|
||||
itemList.add(stack);
|
||||
itemList.add(charged);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -59,7 +59,7 @@ import javax.annotation.Nullable;
|
|||
*/
|
||||
public class ItemElectricTreetap extends ItemTR implements IEnergyItemInfo {
|
||||
|
||||
public static final int maxCharge = 10000;
|
||||
public static final int maxCharge = 10_000;
|
||||
public static final int tier = 1;
|
||||
public int cost = 20;
|
||||
|
||||
|
|
|
@ -95,12 +95,7 @@ public class ItemRockCutter extends ItemPickaxe implements IEnergyItemInfo {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getHarvestLevel(ItemStack stack,
|
||||
String toolClass,
|
||||
@Nullable
|
||||
EntityPlayer player,
|
||||
@Nullable
|
||||
IBlockState blockState) {
|
||||
public int getHarvestLevel(ItemStack stack, String toolClass, @Nullable EntityPlayer player, @Nullable IBlockState blockState) {
|
||||
if (!stack.isItemEnchanted()) {
|
||||
stack.addEnchantment(Enchantments.SILK_TOUCH, 1);
|
||||
}
|
||||
|
@ -135,9 +130,7 @@ public class ItemRockCutter extends ItemPickaxe implements IEnergyItemInfo {
|
|||
|
||||
@Override
|
||||
@Nullable
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack,
|
||||
@Nullable
|
||||
NBTTagCompound nbt) {
|
||||
public ICapabilityProvider initCapabilities(ItemStack stack, @Nullable NBTTagCompound nbt) {
|
||||
return new PoweredItemContainerProvider(stack);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,8 +39,7 @@ import techreborn.init.ModItems;
|
|||
public class ItemSteelChainsaw extends ItemChainsaw {
|
||||
|
||||
public ItemSteelChainsaw() {
|
||||
super(ToolMaterial.IRON, "techreborn.ironChainsaw", ConfigTechReborn.IronChainsawCharge,
|
||||
0.5F);
|
||||
super(ToolMaterial.IRON, "techreborn.ironChainsaw", ConfigTechReborn.IronChainsawCharge, 0.5F);
|
||||
this.cost = 50;
|
||||
}
|
||||
|
||||
|
@ -52,12 +51,11 @@ public class ItemSteelChainsaw extends ItemChainsaw {
|
|||
return;
|
||||
}
|
||||
ItemStack stack = new ItemStack(ModItems.STEEL_CHAINSAW);
|
||||
ItemStack uncharged = stack.copy();
|
||||
ItemStack charged = stack.copy();
|
||||
ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
||||
|
||||
itemList.add(uncharged);
|
||||
itemList.add(stack);
|
||||
itemList.add(charged);
|
||||
}
|
||||
|
||||
|
|
|
@ -39,8 +39,7 @@ import techreborn.init.ModItems;
|
|||
public class ItemSteelDrill extends ItemDrill {
|
||||
|
||||
public ItemSteelDrill() {
|
||||
super(ToolMaterial.IRON, "techreborn.ironDrill", ConfigTechReborn.IronDrillCharge,
|
||||
0.5F, 10F);
|
||||
super(ToolMaterial.IRON, "techreborn.ironDrill", ConfigTechReborn.IronDrillCharge, 0.5F, 10F);
|
||||
this.cost = 50;
|
||||
}
|
||||
|
||||
|
@ -52,12 +51,11 @@ public class ItemSteelDrill extends ItemDrill {
|
|||
return;
|
||||
}
|
||||
ItemStack stack = new ItemStack(ModItems.STEEL_DRILL);
|
||||
ItemStack uncharged = stack.copy();
|
||||
ItemStack charged = stack.copy();
|
||||
ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
||||
|
||||
itemList.add(uncharged);
|
||||
itemList.add(stack);
|
||||
itemList.add(charged);
|
||||
}
|
||||
|
||||
|
|
|
@ -44,18 +44,16 @@ public class ItemSteelJackhammer extends ItemJackhammer {
|
|||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@Override
|
||||
public void getSubItems(
|
||||
CreativeTabs par2CreativeTabs, NonNullList<ItemStack> itemList) {
|
||||
public void getSubItems( CreativeTabs par2CreativeTabs, NonNullList<ItemStack> itemList) {
|
||||
if (!isInCreativeTab(par2CreativeTabs)) {
|
||||
return;
|
||||
}
|
||||
ItemStack stack = new ItemStack(ModItems.STEEL_JACKHAMMER);
|
||||
ItemStack uncharged = stack.copy();
|
||||
ItemStack charged = stack.copy();
|
||||
ForgePowerItemManager capEnergy = (ForgePowerItemManager) charged.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
capEnergy.setEnergyStored(capEnergy.getMaxEnergyStored());
|
||||
|
||||
itemList.add(uncharged);
|
||||
itemList.add(stack);
|
||||
itemList.add(charged);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import net.minecraft.util.Rotation;
|
|||
import net.minecraft.util.text.TextFormatting;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.util.StringUtils;
|
||||
import techreborn.Core;
|
||||
|
@ -157,13 +158,13 @@ public class TileSolarPanel extends TilePowerAcceptor implements IToolDrop {
|
|||
@Override
|
||||
public void addInfo(List<String> info, boolean isRealTile) {
|
||||
info.add(TextFormatting.GRAY + "Internal Energy Storage: " + TextFormatting.GOLD
|
||||
+ getLocaliszedPowerFormatted((int) getMaxPower()));
|
||||
+ PowerSystem.getLocaliszedPowerFormatted((int) getMaxPower()));
|
||||
|
||||
info.add(TextFormatting.GRAY + "Generation Rate Day: " + TextFormatting.GOLD
|
||||
+ getLocaliszedPowerFormatted(panel.generationRateD));
|
||||
+ PowerSystem.getLocaliszedPowerFormatted(panel.generationRateD));
|
||||
|
||||
info.add(TextFormatting.GRAY + "Generation Rate Night: " + TextFormatting.GOLD
|
||||
+ getLocaliszedPowerFormatted(panel.generationRateN));
|
||||
+ PowerSystem.getLocaliszedPowerFormatted(panel.generationRateN));
|
||||
|
||||
info.add(TextFormatting.GRAY + "Tier: " + TextFormatting.GOLD + StringUtils.toFirstCapitalAllLowercase(getTier().toString()));
|
||||
}
|
||||
|
|
|
@ -32,6 +32,7 @@ import net.minecraftforge.energy.CapabilityEnergy;
|
|||
import net.minecraftforge.energy.IEnergyStorage;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.api.power.IEnergyItemInfo;
|
||||
import reborncore.api.tile.IInventoryProvider;
|
||||
import reborncore.common.RebornCoreConfig;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
|
@ -71,27 +72,20 @@ public class TileEnergyStorage extends TilePowerAcceptor
|
|||
super.update();
|
||||
if (!inventory.getStackInSlot(0).isEmpty()) {
|
||||
ItemStack stack = inventory.getStackInSlot(0);
|
||||
if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
IEnergyStorage energyStorage = stack.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
if(getEnergy() > 0 && energyStorage.getEnergyStored() < energyStorage.getMaxEnergyStored()){
|
||||
energyStorage.receiveEnergy((int) useEnergy(getMaxOutput()) * RebornCoreConfig.euPerFU, false);
|
||||
if (stack.hasCapability(CapabilityEnergy.ENERGY, null)) {
|
||||
IEnergyStorage powerItem = stack.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
int maxReceive = Math.min((powerItem.getMaxEnergyStored() - powerItem.getEnergyStored()),
|
||||
(int) ((IEnergyItemInfo) stack.getItem()).getMaxTransfer(stack));
|
||||
double maxUse = Math.min((double) (maxReceive / RebornCoreConfig.euPerFU), getMaxOutput());
|
||||
if (getEnergy() >= 0.0 && maxReceive > 0) {
|
||||
powerItem.receiveEnergy((int) useEnergy(maxUse) * RebornCoreConfig.euPerFU, false);
|
||||
}
|
||||
}
|
||||
if(CompatManager.isIC2Loaded){
|
||||
} else if (CompatManager.isIC2Loaded) {
|
||||
IC2ItemCharger.chargeIc2Item(this, stack);
|
||||
}
|
||||
}
|
||||
if (!inventory.getStackInSlot(1).isEmpty()) {
|
||||
ItemStack stack = inventory.getStackInSlot(1);
|
||||
if(stack.hasCapability(CapabilityEnergy.ENERGY, null)){
|
||||
IEnergyStorage energyStorage = stack.getCapability(CapabilityEnergy.ENERGY, null);
|
||||
if(getEnergy() != getMaxPower() && energyStorage.getEnergyStored() > 0){
|
||||
addEnergy(energyStorage.extractEnergy((int) (getMaxInput() * RebornCoreConfig.euPerFU), false) / RebornCoreConfig.euPerFU);
|
||||
}
|
||||
}
|
||||
if(CompatManager.isIC2Loaded){
|
||||
IC2ItemCharger.dischargeIc2Item(this, stack);
|
||||
}
|
||||
charge(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@ import net.minecraft.util.text.TextFormatting;
|
|||
import reborncore.api.IListInfoProvider;
|
||||
import reborncore.api.IToolDrop;
|
||||
import reborncore.api.power.EnumPowerTier;
|
||||
import reborncore.common.powerSystem.PowerSystem;
|
||||
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||
import reborncore.common.registration.RebornRegistry;
|
||||
import reborncore.common.registration.impl.ConfigRegistry;
|
||||
|
@ -140,9 +141,9 @@ public class TileTransformer extends TilePowerAcceptor
|
|||
// IListInfoProvider
|
||||
@Override
|
||||
public void addInfo(List<String> info, boolean isRealTile) {
|
||||
info.add(TextFormatting.GRAY + "Input Rate: " + TextFormatting.GOLD + getLocaliszedPowerFormatted((int) getMaxInput()));
|
||||
info.add(TextFormatting.GRAY + "Input Rate: " + TextFormatting.GOLD + PowerSystem.getLocaliszedPowerFormatted((int) getMaxInput()));
|
||||
info.add(TextFormatting.GRAY + "Input Tier: " + TextFormatting.GOLD + StringUtils.toFirstCapitalAllLowercase(inputTier.toString()));
|
||||
info.add(TextFormatting.GRAY + "Output Rate: " + TextFormatting.GOLD + getLocaliszedPowerFormatted((int) getMaxOutput()));
|
||||
info.add(TextFormatting.GRAY + "Output Rate: " + TextFormatting.GOLD + PowerSystem.getLocaliszedPowerFormatted((int) getMaxOutput()));
|
||||
info.add(TextFormatting.GRAY + "Output Tier: " + TextFormatting.GOLD + StringUtils.toFirstCapitalAllLowercase(ouputTier.toString()));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue