Cleanup for energy storage

This commit is contained in:
drcrazy 2018-04-02 14:56:17 +03:00
parent 8038a7cf17
commit f5b0670d84
3 changed files with 54 additions and 53 deletions

View file

@ -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)") @ConfigRegistry(config = "machines", category = "aesu", key = "AesuMaxOutput", comment = "AESU Max Output (Value in EU)")
public static int maxOutput = 8192; public static int maxOutput = 8192;
@ConfigRegistry(config = "machines", category = "aesu", key = "AesuMaxEnergy", comment = "AESU Max Energy (Value in EU)") @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); public Inventory inventory = new Inventory(4, "TileAdjustableSU", 64, this);
private int OUTPUT = 64; // The current output private int OUTPUT = 64; // The current output
@ -54,15 +54,6 @@ public class TileAdjustableSU extends TileEnergyStorage implements IContainerPro
super("ADJUSTABLE_SU", 4, ModBlocks.ADJUSTABLE_SU, EnumPowerTier.INSANE, maxInput, maxOutput, maxEnergy); 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) { public void handleGuiInputFromClient(int id) {
if (id == 300) { if (id == 300) {
OUTPUT += 256; OUTPUT += 256;
@ -93,6 +84,26 @@ public class TileAdjustableSU extends TileEnergyStorage implements IContainerPro
return dropStack; 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 @Override
public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) { public NBTTagCompound writeToNBT(NBTTagCompound tagCompound) {
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
@ -108,20 +119,7 @@ public class TileAdjustableSU extends TileEnergyStorage implements IContainerPro
inventory.readFromNBT(nbttagcompound); inventory.readFromNBT(nbttagcompound);
} }
@Override // IContainerProvider
public double getBaseMaxOutput() {
return OUTPUT;
}
public int getCurrentOutput() {
return OUTPUT;
}
public void setCurentOutput(int output) {
this.OUTPUT = output;
}
@Override @Override
public BuiltContainer createContainer(EntityPlayer player) { public BuiltContainer createContainer(EntityPlayer player) {
return new ContainerBuilder("aesu").player(player.inventory).inventory().hotbar().armor() return new ContainerBuilder("aesu").player(player.inventory).inventory().hotbar().armor()

View file

@ -28,7 +28,6 @@ import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.EnumFacing; import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import net.minecraftforge.energy.CapabilityEnergy; import net.minecraftforge.energy.CapabilityEnergy;
import net.minecraftforge.energy.IEnergyStorage; import net.minecraftforge.energy.IEnergyStorage;
import reborncore.api.IToolDrop; import reborncore.api.IToolDrop;
@ -46,7 +45,8 @@ import techreborn.utils.IC2ItemCharger;
/** /**
* Created by Rushmead * Created by Rushmead
*/ */
public class TileEnergyStorage extends TilePowerAcceptor implements IToolDrop, ITickable, IInventoryProvider { public class TileEnergyStorage extends TilePowerAcceptor
implements IToolDrop, IInventoryProvider {
public Inventory inventory; public Inventory inventory;
public String name; public String name;
@ -67,6 +67,7 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IToolDrop, I
this.maxStorage = maxStorage; this.maxStorage = maxStorage;
} }
// TilePowerAcceptor
@Override @Override
public void update() { public void update() {
super.update(); super.update();
@ -107,17 +108,6 @@ 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 @Override
public double getBaseMaxPower() { public double getBaseMaxPower() {
return maxStorage; return maxStorage;
@ -128,15 +118,6 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IToolDrop, I
return getFacing() != 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 @Override
public boolean canProvideEnergy(EnumFacing direction) { public boolean canProvideEnergy(EnumFacing direction) {
return getFacing() == direction; return getFacing() == direction;
@ -157,13 +138,35 @@ public class TileEnergyStorage extends TilePowerAcceptor implements IToolDrop, I
return tier; return tier;
} }
// TileLegacyMachineBase
@Override @Override
public Inventory getInventory() { public void setFacing(EnumFacing enumFacing) {
return inventory; 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 @Override
public boolean canBeUpgraded() { public boolean canBeUpgraded() {
return false; return false;
} }
// IToolDrop
@Override
public ItemStack getToolDrop(EntityPlayer entityPlayer) {
return new ItemStack(wrenchDrop);
}
// IInventoryProvider
@Override
public Inventory getInventory() {
return inventory;
}
} }

View file

@ -41,7 +41,7 @@ public class TileHighVoltageSU extends TileEnergyStorage implements IContainerPr
* MFSU should store 40M FE with 2048 FE/t I/O * MFSU should store 40M FE with 2048 FE/t I/O
*/ */
public TileHighVoltageSU() { 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 @Override