From f5b0670d848512e73223e237e37a7729f2b3076c Mon Sep 17 00:00:00 2001 From: drcrazy Date: Mon, 2 Apr 2018 14:56:17 +0300 Subject: [PATCH] Cleanup for energy storage --- .../tiles/storage/TileAdjustableSU.java | 48 ++++++++-------- .../tiles/storage/TileEnergyStorage.java | 57 ++++++++++--------- .../tiles/storage/TileHighVoltageSU.java | 2 +- 3 files changed, 54 insertions(+), 53 deletions(-) diff --git a/src/main/java/techreborn/tiles/storage/TileAdjustableSU.java b/src/main/java/techreborn/tiles/storage/TileAdjustableSU.java index cbb32c6b1..389f1fde1 100644 --- a/src/main/java/techreborn/tiles/storage/TileAdjustableSU.java +++ b/src/main/java/techreborn/tiles/storage/TileAdjustableSU.java @@ -45,7 +45,7 @@ public class TileAdjustableSU extends TileEnergyStorage implements IContainerPro @ConfigRegistry(config = "machines", category = "aesu", key = "AesuMaxOutput", comment = "AESU Max Output (Value in EU)") public static int maxOutput = 8192; @ConfigRegistry(config = "machines", category = "aesu", key = "AesuMaxEnergy", comment = "AESU Max Energy (Value in EU)") - public static int maxEnergy = 100000000; + public static int maxEnergy = 100_000_000; public Inventory inventory = new Inventory(4, "TileAdjustableSU", 64, this); private int OUTPUT = 64; // The current output @@ -53,16 +53,7 @@ public class TileAdjustableSU extends TileEnergyStorage implements IContainerPro public TileAdjustableSU() { super("ADJUSTABLE_SU", 4, ModBlocks.ADJUSTABLE_SU, EnumPowerTier.INSANE, maxInput, maxOutput, maxEnergy); } - - @Override - public ItemStack getToolDrop(EntityPlayer entityPlayer) { - return getDropWithNBT(); - } - - public boolean isComplete() { - return false; - } - + public void handleGuiInputFromClient(int id) { if (id == 300) { OUTPUT += 256; @@ -92,7 +83,27 @@ public class TileAdjustableSU extends TileEnergyStorage implements IContainerPro dropStack.getTagCompound().setTag("tileEntity", tileEntity); return dropStack; } + + public int getCurrentOutput() { + return OUTPUT; + } + + public void setCurentOutput(int output) { + this.OUTPUT = output; + } + + // TileEnergyStorage + @Override + public ItemStack getToolDrop(EntityPlayer entityPlayer) { + return getDropWithNBT(); + } + + @Override + public double getBaseMaxOutput() { + return OUTPUT; + } + // TilePowerAcceptor @Override public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { super.writeToNBT(tagCompound); @@ -108,20 +119,7 @@ public class TileAdjustableSU extends TileEnergyStorage implements IContainerPro inventory.readFromNBT(nbttagcompound); } - @Override - public double getBaseMaxOutput() { - return OUTPUT; - } - - - public int getCurrentOutput() { - return OUTPUT; - } - - public void setCurentOutput(int output) { - this.OUTPUT = output; - } - + // IContainerProvider @Override public BuiltContainer createContainer(EntityPlayer player) { return new ContainerBuilder("aesu").player(player.inventory).inventory().hotbar().armor() diff --git a/src/main/java/techreborn/tiles/storage/TileEnergyStorage.java b/src/main/java/techreborn/tiles/storage/TileEnergyStorage.java index 827dd1b6b..d99bb08d7 100644 --- a/src/main/java/techreborn/tiles/storage/TileEnergyStorage.java +++ b/src/main/java/techreborn/tiles/storage/TileEnergyStorage.java @@ -28,7 +28,6 @@ import net.minecraft.block.Block; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.item.ItemStack; import net.minecraft.util.EnumFacing; -import net.minecraft.util.ITickable; import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.IEnergyStorage; import reborncore.api.IToolDrop; @@ -46,7 +45,8 @@ import techreborn.utils.IC2ItemCharger; /** * Created by Rushmead */ -public class TileEnergyStorage extends TilePowerAcceptor implements IToolDrop, ITickable, IInventoryProvider { +public class TileEnergyStorage extends TilePowerAcceptor + implements IToolDrop, IInventoryProvider { public Inventory inventory; public String name; @@ -67,6 +67,7 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IToolDrop, I this.maxStorage = maxStorage; } + // TilePowerAcceptor @Override public void update() { super.update(); @@ -106,18 +107,7 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IToolDrop, I } } } - - @Override - public void setFacing(EnumFacing enumFacing) { - world.setBlockState(pos, world.getBlockState(pos).withProperty(BlockEnergyStorage.FACING, enumFacing)); - } - - - @Override - public ItemStack getToolDrop(EntityPlayer entityPlayer) { - return new ItemStack(wrenchDrop); - } - + @Override public double getBaseMaxPower() { return maxStorage; @@ -127,16 +117,7 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IToolDrop, I public boolean canAcceptEnergy(EnumFacing direction) { return getFacing() != direction; } - - @Override - public EnumFacing getFacingEnum() { - Block block = world.getBlockState(pos).getBlock(); - if (block instanceof BlockEnergyStorage) { - return ((BlockEnergyStorage) block).getFacing(world.getBlockState(pos)); - } - return null; - } - + @Override public boolean canProvideEnergy(EnumFacing direction) { return getFacing() == direction; @@ -157,13 +138,35 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IToolDrop, I return tier; } + // TileLegacyMachineBase @Override - public Inventory getInventory() { - return inventory; + public void setFacing(EnumFacing enumFacing) { + world.setBlockState(pos, world.getBlockState(pos).withProperty(BlockEnergyStorage.FACING, enumFacing)); } - + + @Override + public EnumFacing getFacingEnum() { + Block block = world.getBlockState(pos).getBlock(); + if (block instanceof BlockEnergyStorage) { + return ((BlockEnergyStorage) block).getFacing(world.getBlockState(pos)); + } + return null; + } + @Override public boolean canBeUpgraded() { return false; } + + // IToolDrop + @Override + public ItemStack getToolDrop(EntityPlayer entityPlayer) { + return new ItemStack(wrenchDrop); + } + + // IInventoryProvider + @Override + public Inventory getInventory() { + return inventory; + } } diff --git a/src/main/java/techreborn/tiles/storage/TileHighVoltageSU.java b/src/main/java/techreborn/tiles/storage/TileHighVoltageSU.java index f3fc0ef11..45c3aab15 100644 --- a/src/main/java/techreborn/tiles/storage/TileHighVoltageSU.java +++ b/src/main/java/techreborn/tiles/storage/TileHighVoltageSU.java @@ -41,7 +41,7 @@ public class TileHighVoltageSU extends TileEnergyStorage implements IContainerPr * MFSU should store 40M FE with 2048 FE/t I/O */ public TileHighVoltageSU() { - super("HIGH_VOLTAGE_SU", 2, ModBlocks.HIGH_VOLTAGE_SU, EnumPowerTier.HIGH, 512, 512, 10000000); + super("HIGH_VOLTAGE_SU", 2, ModBlocks.HIGH_VOLTAGE_SU, EnumPowerTier.HIGH, 512, 512, 10_000_000); } @Override