Initial untested port to new internal power system.

This resets all the machines internal power buffer
This commit is contained in:
modmuss50 2015-07-23 12:52:51 +01:00
parent 984b502ded
commit e9ece63a99
28 changed files with 580 additions and 486 deletions

View file

@ -5,6 +5,7 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import techreborn.api.power.IEnergyInterfaceTile;
import techreborn.packets.PacketHandler;
import techreborn.tiles.TileMachineBase;
import techreborn.util.Inventory;
@ -30,7 +31,7 @@ public class RecipeCrafter {
/**
* This is the place to use the power from
*/
public BasicSink energy;
public IEnergyInterfaceTile energy;
/**
* This is the amount of inputs that the setRecipe has
@ -62,17 +63,18 @@ public class RecipeCrafter {
*
* @param recipeName
* @param parentTile
* @param energy
* @param inputs
* @param outputs
* @param inventory
* @param inputSlots
* @param outputSlots
*/
public RecipeCrafter(String recipeName, TileMachineBase parentTile, BasicSink energy, int inputs, int outputs, Inventory inventory, int[] inputSlots, int[] outputSlots) {
public RecipeCrafter(String recipeName, TileMachineBase parentTile, int inputs, int outputs, Inventory inventory, int[] inputSlots, int[] outputSlots) {
this.recipeName = recipeName;
this.parentTile = parentTile;
this.energy = energy;
if(parentTile instanceof IEnergyInterfaceTile){
energy = (IEnergyInterfaceTile) parentTile;
}
this.inputs = inputs;
this.outputs = outputs;
this.inventory = inventory;
@ -168,7 +170,8 @@ public class RecipeCrafter {
syncIsActive();
}
} else if (currentRecipe != null && currentTickTime < currentNeededTicks) {
if (energy.useEnergy(getEuPerTick())) {//This uses the power
if (energy.canUseEnergy(getEuPerTick())) {//This uses the power
energy.useEnergy(getEuPerTick());
currentTickTime++;//increase the ticktime
}
}
@ -283,7 +286,7 @@ public class RecipeCrafter {
private boolean isActiveServer() {
return currentRecipe != null && energy.getEnergyStored() >= currentRecipe.euPerTick() && currentTickTime != -1;
return currentRecipe != null && energy.getEnergy() >= currentRecipe.euPerTick() && currentTickTime != -1;
}
public boolean isActive() {

View file

@ -28,8 +28,8 @@ public abstract class ContainerCrafting extends TechRebornContainer {
if(this.currentNeededTicks != crafter.currentNeededTicks){
icrafting.sendProgressBarUpdate(this, 1, crafter.currentNeededTicks);
}
if(this.energy != (int)crafter.energy.getEnergyStored()){
icrafting.sendProgressBarUpdate(this, 2, (int)crafter.energy.getEnergyStored());
if(this.energy != (int)crafter.energy.getEnergy()){
icrafting.sendProgressBarUpdate(this, 2, (int)crafter.energy.getEnergy());
}
}
}
@ -39,7 +39,7 @@ public abstract class ContainerCrafting extends TechRebornContainer {
super.addCraftingToCrafters(crafting);
crafting.sendProgressBarUpdate(this, 0, crafter.currentTickTime);
crafting.sendProgressBarUpdate(this, 1, crafter.currentNeededTicks);
crafting.sendProgressBarUpdate(this, 2, (int)crafter.energy.getEnergyStored());
crafting.sendProgressBarUpdate(this, 2, (int)crafter.energy.getEnergy());
}
@SideOnly(Side.CLIENT)
@ -54,6 +54,6 @@ public abstract class ContainerCrafting extends TechRebornContainer {
}
this.crafter.currentTickTime = currentTickTime;
this.crafter.currentNeededTicks = currentNeededTicks;
this.crafter.energy.setEnergyStored(energy);
this.crafter.energy.setEnergy(energy);
}
}

View file

@ -52,7 +52,7 @@ public class GuiImplosionCompressor extends GuiContainer{
this.drawTexturedModalRect(k + 60, l + 38, 176, 14, j + 1, 16);
j = (int) (this.compresser.crafter.energy.getEnergyStored() * 12 / this.compresser.energy.getCapacity());
j = (int) (this.compresser.crafter.energy.getEnergy() * 12 / this.compresser.getMaxPower());
if(j > 0) {
this.drawTexturedModalRect(k + 16, l + 37 + 12 - j, 176, 12 - j, 14, j + 2);
}

View file

@ -41,7 +41,8 @@ public class FarmTree implements IFarmLogicDevice {
if (tileFarm.getWorldObj().isRemote) {
return;
}
if(tileFarm.energy.useEnergy(ConfigTechReborn.farmEu)){
if(tileFarm.canUseEnergy(ConfigTechReborn.farmEu)){
tileFarm.useEnergy(ConfigTechReborn.farmEu);
if (tileFarm.getWorldObj().getTotalWorldTime() % 20 == 0 || tileFarm.inventory.hasChanged) {
calculateFarmLand(tileFarm);
}

View file

@ -17,6 +17,8 @@ import net.minecraftforge.common.util.ForgeDirection;
import techreborn.api.power.IEnergyInterfaceTile;
import techreborn.asm.Strippable;
import java.util.List;
@Optional.InterfaceList(value = {
@Optional.Interface(iface = "ic2.api.energy.tile.IEnergyTile", modid = "IC2"),
@ -253,4 +255,16 @@ public abstract class TilePowerAcceptor extends RFProviderTile implements
data.setDouble("energy", energy);
tag.setTag("TilePowerAcceptor", data);
}
public int getEnergyScaled(int scale) {
return (int)(getEnergy() * scale / getMaxPower());
}
@Override
public void addWailaInfo(List<String> info) {
super.addWailaInfo(info);
info.add("Energy buffer Size " + getMaxPower() + "eu");
info.add("Max Input " + getMaxInput() + "eu");
info.add("Max Output " + getMaxOutput() + "eu");
}
}

View file

@ -1,6 +1,5 @@
package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
@ -12,34 +11,32 @@ import net.minecraftforge.common.util.ForgeDirection;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.api.upgrade.UpgradeHandler;
import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory;
public class TileAlloySmelter extends TileMachineBase implements IWrenchable, IEnergyTile, IInventory, ISidedInventory {
public class TileAlloySmelter extends TilePowerAcceptor implements IWrenchable, IEnergyTile, IInventory, ISidedInventory {
public int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(8, "TileAlloySmelter", 64);
public RecipeCrafter crafter;
public int capacity = 1000;
UpgradeHandler upgrades;
public TileAlloySmelter(){
//TODO configs
energy = new BasicSink(this, capacity, 1);
super(1);
//Input slots
int[] inputs = new int[2];
inputs[0] = 0;
inputs[1] = 1;
int[] outputs = new int[1];
outputs[0] = 2;
crafter = new RecipeCrafter("alloySmelterRecipe", this, energy, 2, 1, inventory, inputs, outputs);
crafter = new RecipeCrafter("alloySmelterRecipe", this, 2, 1, inventory, inputs, outputs);
upgrades = new UpgradeHandler(crafter, inventory, 4, 5, 6, 7);
}
@Override
public void updateEntity(){
super.updateEntity();
energy.updateEntity();
crafter.updateEntity();
upgrades.tick();
}
@ -84,7 +81,6 @@ public class TileAlloySmelter extends TileMachineBase implements IWrenchable, IE
public void readFromNBT(NBTTagCompound tagCompound){
super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound);
}
@ -92,23 +88,9 @@ public class TileAlloySmelter extends TileMachineBase implements IWrenchable, IE
public void writeToNBT(NBTTagCompound tagCompound){
super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound);
}
@Override
public void invalidate()
{
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
super.onChunkUnload();
}
// @Override
// public void addWailaInfo(List<String> info){
// super.addWailaInfo(info);
@ -206,7 +188,28 @@ public class TileAlloySmelter extends TileMachineBase implements IWrenchable, IE
return 0;
}
public int getEnergyScaled(int scale) {
return (int)energy.getEnergyStored() * scale / energy.getCapacity();
@Override
public double getMaxPower() {
return capacity;
}
@Override
public boolean canAcceptEnergy(ForgeDirection direction) {
return true;
}
@Override
public boolean canProvideEnergy(ForgeDirection direction) {
return false;
}
@Override
public double getMaxOutput() {
return 0;
}
@Override
public double getMaxInput() {
return 32;
}
}

View file

@ -1,6 +1,5 @@
package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
@ -11,33 +10,31 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory;
public class TileAssemblingMachine extends TileMachineBase implements IWrenchable, IEnergyTile, IInventory, ISidedInventory {
public class TileAssemblingMachine extends TilePowerAcceptor implements IWrenchable, IEnergyTile, IInventory, ISidedInventory {
public int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(8, "TileAssemblingMachine", 64);
public RecipeCrafter crafter;
public TileAssemblingMachine()
{
//TODO configs
energy = new BasicSink(this, 1000, 2);
super(2);
//Input slots
int[] inputs = new int[2];
inputs[0] = 0;
inputs[1] = 1;
int[] outputs = new int[1];
outputs[0] = 2;
crafter = new RecipeCrafter("assemblingMachineRecipe", this, energy, 2, 2, inventory, inputs, outputs);
crafter = new RecipeCrafter("assemblingMachineRecipe", this, 2, 2, inventory, inputs, outputs);
}
@Override
public void updateEntity()
{
super.updateEntity();
energy.updateEntity();
crafter.updateEntity();
}
@ -90,7 +87,6 @@ public class TileAssemblingMachine extends TileMachineBase implements IWrenchabl
{
super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound);
}
@ -99,22 +95,9 @@ public class TileAssemblingMachine extends TileMachineBase implements IWrenchabl
{
super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound);
}
@Override
public void invalidate()
{
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
super.onChunkUnload();
}
@Override
public int getSizeInventory() {
@ -214,8 +197,28 @@ public class TileAssemblingMachine extends TileMachineBase implements IWrenchabl
return 0;
}
public int getEnergyScaled(int scale) {
return (int)energy.getEnergyStored() * scale / energy.getCapacity();
@Override
public double getMaxPower() {
return 10000;
}
@Override
public boolean canAcceptEnergy(ForgeDirection direction) {
return true;
}
@Override
public boolean canProvideEnergy(ForgeDirection direction) {
return false;
}
@Override
public double getMaxOutput() {
return 0;
}
@Override
public double getMaxInput() {
return 128;
}
}

View file

@ -18,9 +18,10 @@ import techreborn.blocks.BlockMachineCasing;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.lib.Location;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory;
public class TileBlastFurnace extends TileMachineBase implements IWrenchable, IInventory, IEnergyTile, ISidedInventory {
public class TileBlastFurnace extends TilePowerAcceptor implements IWrenchable, IInventory, IEnergyTile, ISidedInventory {
public int tickTime;
public BasicSink energy;
@ -29,15 +30,15 @@ public class TileBlastFurnace extends TileMachineBase implements IWrenchable, II
public static int euTick = 5;
public TileBlastFurnace() {
super(ConfigTechReborn.CentrifugeTier);
//TODO configs
energy = new BasicSink(this, 10000,ConfigTechReborn.CentrifugeTier);
int[] inputs = new int[2];
inputs[0] = 0;
inputs[1] = 1;
int[] outputs = new int[2];
outputs[0] = 2;
outputs[1] = 3;
crafter = new RecipeCrafter("blastFurnaceRecipe", this, energy, 2, 2, inventory, inputs, outputs);
crafter = new RecipeCrafter("blastFurnaceRecipe", this, 2, 2, inventory, inputs, outputs);
}
@Override
@ -337,5 +338,28 @@ public class TileBlastFurnace extends TileMachineBase implements IWrenchable, II
}
@Override
public double getMaxPower() {
return 10000;
}
@Override
public boolean canAcceptEnergy(ForgeDirection direction) {
return false;
}
@Override
public boolean canProvideEnergy(ForgeDirection direction) {
return false;
}
@Override
public double getMaxOutput() {
return 0;
}
@Override
public double getMaxInput() {
return 128;
}
}

View file

@ -1,6 +1,5 @@
package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
@ -12,14 +11,14 @@ import net.minecraftforge.common.util.ForgeDirection;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory;
import java.util.List;
public class TileCentrifuge extends TileMachineBase implements IWrenchable, IEnergyTile, IInventory, ISidedInventory{
public class TileCentrifuge extends TilePowerAcceptor implements IWrenchable, IEnergyTile, IInventory, ISidedInventory{
public int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(11, "TileCentrifuge", 64);
public RecipeCrafter crafter;
@ -27,8 +26,7 @@ public class TileCentrifuge extends TileMachineBase implements IWrenchable, IEn
public TileCentrifuge()
{
//TODO configs
energy = new BasicSink(this, 1000, 2);
super(2);
//Input slots
int[] inputs = new int[2];
inputs[0] = 0;
@ -39,14 +37,13 @@ public class TileCentrifuge extends TileMachineBase implements IWrenchable, IEn
outputs[2] = 4;
outputs[3] = 5;
crafter = new RecipeCrafter("centrifugeRecipe", this, energy, 2, 4, inventory, inputs, outputs);
crafter = new RecipeCrafter("centrifugeRecipe", this, 2, 4, inventory, inputs, outputs);
}
@Override
public void updateEntity()
{
super.updateEntity();
energy.updateEntity();
crafter.updateEntity();
}
@ -99,7 +96,6 @@ public class TileCentrifuge extends TileMachineBase implements IWrenchable, IEn
{
super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound);
}
@ -108,23 +104,9 @@ public class TileCentrifuge extends TileMachineBase implements IWrenchable, IEn
{
super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound);
}
@Override
public void invalidate()
{
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
super.onChunkUnload();
}
@Override
public void addWailaInfo(List<String> info)
{
@ -224,7 +206,28 @@ public class TileCentrifuge extends TileMachineBase implements IWrenchable, IEn
return 0;
}
public int getEnergyScaled(int scale) {
return (int)energy.getEnergyStored() * scale / energy.getCapacity();
@Override
public double getMaxPower() {
return 10000;
}
@Override
public boolean canAcceptEnergy(ForgeDirection direction) {
return true;
}
@Override
public boolean canProvideEnergy(ForgeDirection direction) {
return false;
}
@Override
public double getMaxOutput() {
return 0;
}
@Override
public double getMaxInput() {
return 32;
}
}

View file

@ -1,6 +1,5 @@
package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.item.ElectricItem;
import ic2.api.item.IElectricItem;
@ -12,22 +11,21 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory;
public class TileChargeBench extends TileMachineBase implements IWrenchable, IEnergyTile, IInventory, ISidedInventory {
public class TileChargeBench extends TilePowerAcceptor implements IWrenchable, IEnergyTile, IInventory, ISidedInventory {
public BasicSink energy;
public Inventory inventory = new Inventory(6, "TileChargeBench", 64);
public int capacity = 100000;
public TileChargeBench(){
energy = new BasicSink(this, capacity, 4);
super(4);
}
@Override
public void updateEntity(){
super.updateEntity();
energy.updateEntity();
for (int i = 0; i < 6; i++)
if(inventory.getStackInSlot(i) != null)
@ -39,10 +37,10 @@ public class TileChargeBench extends TileMachineBase implements IWrenchable, IEn
double amount = ((IElectricItem) stack.getItem()).getTransferLimit(stack);
double CurrentCharge = ElectricItem.manager.getCharge(stack);
int teir = ((IElectricItem) stack.getItem()).getTier(stack);
if(CurrentCharge != MaxCharge && energy.getEnergyStored() >= 0)
if(CurrentCharge != MaxCharge && getEnergy() >= 0)
{
ElectricItem.manager.charge(stack, MaxCharge - CurrentCharge, 3, false, false);
energy.useEnergy(amount);
useEnergy(amount);
}
}
}
@ -89,27 +87,12 @@ public class TileChargeBench extends TileMachineBase implements IWrenchable, IEn
public void readFromNBT(NBTTagCompound tagCompound){
super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
}
@Override
public void writeToNBT(NBTTagCompound tagCompound){
super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
}
@Override
public void invalidate()
{
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
super.onChunkUnload();
}
@Override
@ -172,10 +155,6 @@ public class TileChargeBench extends TileMachineBase implements IWrenchable, IEn
return inventory.isItemValidForSlot(slot, stack);
}
public int getEnergyScaled(int scale) {
return (int)energy.getEnergyStored() * scale / energy.getCapacity();
}
// ISidedInventory
@Override
public int[] getAccessibleSlotsFromSide(int side)
@ -201,4 +180,29 @@ public class TileChargeBench extends TileMachineBase implements IWrenchable, IEn
}
return false;
}
@Override
public double getMaxPower() {
return capacity;
}
@Override
public boolean canAcceptEnergy(ForgeDirection direction) {
return true;
}
@Override
public boolean canProvideEnergy(ForgeDirection direction) {
return false;
}
@Override
public double getMaxOutput() {
return 0;
}
@Override
public double getMaxInput() {
return 512;
}
}

View file

@ -1,6 +1,5 @@
package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
@ -11,33 +10,31 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory;
public class TileChemicalReactor extends TileMachineBase implements IWrenchable, IEnergyTile , IInventory, ISidedInventory{
public class TileChemicalReactor extends TilePowerAcceptor implements IWrenchable, IEnergyTile , IInventory, ISidedInventory{
public int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(8, "TileChemicalReactor", 64);
public RecipeCrafter crafter;
public TileChemicalReactor()
{
//TODO configs
energy = new BasicSink(this, 1000, 2);
super(2);
//Input slots
int[] inputs = new int[2];
inputs[0] = 0;
inputs[1] = 1;
int[] outputs = new int[1];
outputs[0] = 2;
crafter = new RecipeCrafter("chemicalReactorRecipe", this, energy, 2, 2, inventory, inputs, outputs);
crafter = new RecipeCrafter("chemicalReactorRecipe", this, 2, 2, inventory, inputs, outputs);
}
@Override
public void updateEntity()
{
super.updateEntity();
energy.updateEntity();
crafter.updateEntity();
}
@ -90,7 +87,6 @@ public class TileChemicalReactor extends TileMachineBase implements IWrenchable,
{
super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound);
}
@ -99,23 +95,9 @@ public class TileChemicalReactor extends TileMachineBase implements IWrenchable,
{
super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound);
}
@Override
public void invalidate()
{
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
super.onChunkUnload();
}
@Override
public int getSizeInventory() {
return inventory.getSizeInventory();
@ -214,8 +196,28 @@ public class TileChemicalReactor extends TileMachineBase implements IWrenchable,
return 0;
}
public int getEnergyScaled(int scale) {
return (int)energy.getEnergyStored() * scale / energy.getCapacity();
@Override
public double getMaxPower() {
return 10000;
}
@Override
public boolean canAcceptEnergy(ForgeDirection direction) {
return true;
}
@Override
public boolean canProvideEnergy(ForgeDirection direction) {
return false;
}
@Override
public double getMaxOutput() {
return 0;
}
@Override
public double getMaxInput() {
return 128;
}
}

View file

@ -1,17 +1,17 @@
package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory;
public class TileChunkLoader extends TileMachineBase implements IWrenchable, IEnergyTile, IInventory {
public class TileChunkLoader extends TilePowerAcceptor implements IWrenchable, IEnergyTile, IInventory {
public BasicSink energy;
public Inventory inventory = new Inventory(1, "TileChunkLoader", 64);
public boolean isRunning;
@ -21,28 +21,7 @@ public class TileChunkLoader extends TileMachineBase implements IWrenchable, IEn
public TileChunkLoader()
{
energy = new BasicSink(this, 1000,
1);
}
@Override
public void updateEntity()
{
super.updateEntity();
energy.updateEntity();
}
@Override
public void invalidate()
{
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
super.onChunkUnload();
super(1);
}
@Override
@ -149,4 +128,28 @@ public class TileChunkLoader extends TileMachineBase implements IWrenchable, IEn
return inventory.isItemValidForSlot(slot, stack);
}
@Override
public double getMaxPower() {
return 10000;
}
@Override
public boolean canAcceptEnergy(ForgeDirection direction) {
return true;
}
@Override
public boolean canProvideEnergy(ForgeDirection direction) {
return false;
}
@Override
public double getMaxOutput() {
return 0;
}
@Override
public double getMaxInput() {
return 32;
}
}

View file

@ -1,6 +1,5 @@
package techreborn.tiles;
import ic2.api.energy.prefab.BasicSource;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
@ -10,34 +9,26 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.*;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.FluidUtils;
import techreborn.util.Inventory;
import techreborn.util.Tank;
public class TileDieselGenerator extends TileEntity implements IWrenchable,
public class TileDieselGenerator extends TilePowerAcceptor implements IWrenchable,
IFluidHandler, IInventory, IEnergyTile {
public Tank tank = new Tank("TileDieselGenerator",
FluidContainerRegistry.BUCKET_VOLUME * 10, this);
public Inventory inventory = new Inventory(3, "TileDieselGenerator", 64);
public BasicSource energySource;
public static final int euTick = ConfigTechReborn.ThermalGenertaorOutput;
public TileDieselGenerator()
{
this.energySource = new BasicSource(this,
ConfigTechReborn.ThermalGeneratorCharge,
ConfigTechReborn.ThermalGeneratorTier);
super(ConfigTechReborn.ThermalGeneratorTier);
}
@Override
@ -129,7 +120,6 @@ public class TileDieselGenerator extends TileEntity implements IWrenchable,
super.readFromNBT(tagCompound);
tank.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energySource.readFromNBT(tagCompound);
}
@Override
@ -138,7 +128,6 @@ public class TileDieselGenerator extends TileEntity implements IWrenchable,
super.writeToNBT(tagCompound);
tank.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energySource.writeToNBT(tagCompound);
}
public Packet getDescriptionPacket()
@ -164,12 +153,11 @@ public class TileDieselGenerator extends TileEntity implements IWrenchable,
super.updateEntity();
if(!worldObj.isRemote)
FluidUtils.drainContainers(this, inventory, 0, 1);
energySource.updateEntity();
if (tank.getFluidAmount() > 0
&& energySource.getCapacity() - energySource.getEnergyStored() >= euTick)
&& getMaxPower() - getEnergy() >= euTick)
{
tank.drain(1, true);
energySource.addEnergy(euTick);
addEnergy(euTick);
}
if (tank.getFluidType() != null && getStackInSlot(2) == null)
{
@ -254,16 +242,27 @@ public class TileDieselGenerator extends TileEntity implements IWrenchable,
}
@Override
public void onChunkUnload()
{
energySource.onChunkUnload();
public double getMaxPower() {
return ConfigTechReborn.ThermalGeneratorCharge;
}
@Override
public void invalidate()
{
energySource.invalidate();
super.invalidate();
public boolean canAcceptEnergy(ForgeDirection direction) {
return false;
}
@Override
public boolean canProvideEnergy(ForgeDirection direction) {
return true;
}
@Override
public double getMaxOutput() {
return 64;
}
@Override
public double getMaxInput() {
return 0;
}
}

View file

@ -1,45 +1,42 @@
package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import techreborn.api.farm.IFarmLogicContainer;
import techreborn.api.farm.IFarmLogicDevice;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory;
public class TileFarm extends TileMachineBase implements IInventory, IEnergyTile {
public class TileFarm extends TilePowerAcceptor implements IInventory, IEnergyTile {
public Inventory inventory = new Inventory(14, "TileFarm", 64);
IFarmLogicDevice logicDevice;
public int size = 4;
public BasicSink energy;
public TileFarm() {
energy = new BasicSink(this, 100000, 2);
super(2);
}
@Override
public void readFromNBT(NBTTagCompound tagCompound) {
energy.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
super.readFromNBT(tagCompound);
}
@Override
public void writeToNBT(NBTTagCompound tagCompound) {
energy.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
super.writeToNBT(tagCompound);
}
@Override
public void updateEntity() {
energy.updateEntity();
if(inventory.hasChanged){
if(inventory.getStackInSlot(0) != null && inventory.getStackInSlot(0).getItem() instanceof IFarmLogicContainer){
IFarmLogicContainer device = (IFarmLogicContainer) inventory.getStackInSlot(0).getItem();
@ -115,16 +112,29 @@ public class TileFarm extends TileMachineBase implements IInventory, IEnergyTile
return inventory.isItemValidForSlot(slot, stack);
}
@Override
public void invalidate()
{
energy.invalidate();
super.invalidate();
public double getMaxPower() {
return 100000;
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
super.onChunkUnload();
public boolean canAcceptEnergy(ForgeDirection direction) {
return true;
}
@Override
public boolean canProvideEnergy(ForgeDirection direction) {
return false;
}
@Override
public double getMaxOutput() {
return 0;
}
@Override
public double getMaxInput() {
return 128;
}
}

View file

@ -12,12 +12,7 @@ import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.*;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.util.FluidUtils;

View file

@ -1,6 +1,5 @@
package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
@ -10,31 +9,27 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.*;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.blocks.BlockMachineCasing;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.init.ModFluids;
import techreborn.lib.Location;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory;
import techreborn.util.Tank;
public class TileGrinder extends TileMachineBase implements IWrenchable, IEnergyTile, IFluidHandler, IInventory, ISidedInventory {
public class TileGrinder extends TilePowerAcceptor implements IWrenchable, IEnergyTile, IFluidHandler, IInventory, ISidedInventory {
public int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(6, "TileGrinder", 64);
public Tank tank = new Tank("TileGrinder", 16000, this);
public RecipeCrafter crafter;
public TileGrinder() {
super(ConfigTechReborn.CentrifugeTier);
//TODO configs
energy = new BasicSink(this, 1000, ConfigTechReborn.CentrifugeTier);
int[] inputs = new int[2];
inputs[0] = 0;
@ -44,7 +39,7 @@ public class TileGrinder extends TileMachineBase implements IWrenchable, IEnergy
outputs[1] = 3;
outputs[2] = 4;
outputs[3] = 5;
crafter = new RecipeCrafter("grinderRecipe", this, energy, 1, 4, inventory, inputs, outputs);
crafter = new RecipeCrafter("grinderRecipe", this, 1, 4, inventory, inputs, outputs);
}
@Override
@ -107,7 +102,6 @@ public class TileGrinder extends TileMachineBase implements IWrenchable, IEnergy
super.updateEntity();
if(getMutliBlock())
{
energy.updateEntity();
crafter.updateEntity();
}
}
@ -116,7 +110,6 @@ public class TileGrinder extends TileMachineBase implements IWrenchable, IEnergy
public void readFromNBT(NBTTagCompound tagCompound) {
super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
tank.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound);
}
@ -125,7 +118,6 @@ public class TileGrinder extends TileMachineBase implements IWrenchable, IEnergy
public void writeToNBT(NBTTagCompound tagCompound) {
super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
tank.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound);
}
@ -133,13 +125,11 @@ public class TileGrinder extends TileMachineBase implements IWrenchable, IEnergy
@Override
public void invalidate()
{
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
super.onChunkUnload();
}
@ -277,7 +267,28 @@ public class TileGrinder extends TileMachineBase implements IWrenchable, IEnergy
return 0;
}
public int getEnergyScaled(int scale) {
return (int)energy.getEnergyStored() * scale / energy.getCapacity();
@Override
public double getMaxPower() {
return 10000;
}
@Override
public boolean canAcceptEnergy(ForgeDirection direction) {
return true;
}
@Override
public boolean canProvideEnergy(ForgeDirection direction) {
return false;
}
@Override
public double getMaxOutput() {
return 0;
}
@Override
public double getMaxInput() {
return 32;
}
}

View file

@ -1,52 +1,50 @@
package techreborn.tiles;
import ic2.api.energy.prefab.BasicSource;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.init.Blocks;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
public class TileHeatGenerator extends TileMachineBase implements IWrenchable, IEnergyTile {
public class TileHeatGenerator extends TilePowerAcceptor implements IWrenchable, IEnergyTile {
public BasicSource energy;
public static final int euTick = ConfigTechReborn.heatGeneratorOutput;
public TileHeatGenerator()
{
energy = new BasicSource(this, 1000, euTick);
super(1);
}
@Override
public void updateEntity()
{
super.updateEntity();
energy.updateEntity();
if(!worldObj.isRemote)
{
if(worldObj.getBlock(xCoord + 1, yCoord, zCoord) == Blocks.lava)
{
energy.addEnergy(euTick);
addEnergy(euTick);
}
else if(worldObj.getBlock(xCoord, yCoord, zCoord + 1) == Blocks.lava)
{
energy.addEnergy(euTick);
addEnergy(euTick);
}
else if(worldObj.getBlock(xCoord, yCoord, zCoord - 1) == Blocks.lava)
{
energy.addEnergy(euTick);
addEnergy(euTick);
}
else if(worldObj.getBlock(xCoord - 1, yCoord, zCoord) == Blocks.lava)
{
energy.addEnergy(euTick);
addEnergy(euTick);
}
else if(worldObj.getBlock(xCoord, yCoord - 1, zCoord) == Blocks.lava)
{
energy.addEnergy(euTick);
addEnergy(euTick);
}
}
@ -96,31 +94,30 @@ public class TileHeatGenerator extends TileMachineBase implements IWrenchable, I
return false;
}
@Override
public void invalidate()
{
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
super.onChunkUnload();
public double getMaxPower() {
return 10000;
}
@Override
public void readFromNBT(NBTTagCompound tagCompound)
{
super.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
public boolean canAcceptEnergy(ForgeDirection direction) {
return false;
}
@Override
public void writeToNBT(NBTTagCompound tagCompound)
{
super.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
public boolean canProvideEnergy(ForgeDirection direction) {
return true;
}
@Override
public double getMaxOutput() {
return 64;
}
@Override
public double getMaxInput() {
return 0;
}
// @Override

View file

@ -1,6 +1,5 @@
package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
@ -14,17 +13,17 @@ import techreborn.api.recipe.RecipeCrafter;
import techreborn.blocks.BlockMachineCasing;
import techreborn.init.ModBlocks;
import techreborn.lib.Location;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory;
public class TileImplosionCompressor extends TileMachineBase implements IWrenchable, IEnergyTile, IInventory, ISidedInventory {
public class TileImplosionCompressor extends TilePowerAcceptor implements IWrenchable, IEnergyTile, IInventory, ISidedInventory {
public int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(4, "TileImplosionCompressor", 64);
public RecipeCrafter crafter;
public TileImplosionCompressor() {
energy = new BasicSink(this, 100000, 1);
super(1);
//Input slots
int[] inputs = new int[2];
inputs[0] = 0;
@ -32,7 +31,7 @@ public class TileImplosionCompressor extends TileMachineBase implements IWrencha
int[] outputs = new int[2];
outputs[0] = 2;
outputs[1] = 3;
crafter = new RecipeCrafter("implosionCompressorRecipe", this, energy, 2, 2, inventory, inputs, outputs);
crafter = new RecipeCrafter("implosionCompressorRecipe", this, 2, 2, inventory, inputs, outputs);
}
@Override
@ -99,7 +98,6 @@ public class TileImplosionCompressor extends TileMachineBase implements IWrencha
if(getMutliBlock())
{
crafter.updateEntity();
energy.updateEntity();
}
}
@ -109,7 +107,6 @@ public class TileImplosionCompressor extends TileMachineBase implements IWrencha
{
super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound);
}
@ -118,7 +115,6 @@ public class TileImplosionCompressor extends TileMachineBase implements IWrencha
{
super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound);
}
@ -132,20 +128,6 @@ public class TileImplosionCompressor extends TileMachineBase implements IWrencha
// }
// }
@Override
public void invalidate()
{
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
super.onChunkUnload();
}
@Override
public int getSizeInventory() {
return inventory.getSizeInventory();
@ -234,8 +216,28 @@ public class TileImplosionCompressor extends TileMachineBase implements IWrencha
return 0;
}
public int getEnergyScaled(int scale) {
return (int)energy.getEnergyStored() * scale / energy.getCapacity();
@Override
public double getMaxPower() {
return 100000;
}
@Override
public boolean canAcceptEnergy(ForgeDirection direction) {
return true;
}
@Override
public boolean canProvideEnergy(ForgeDirection direction) {
return false;
}
@Override
public double getMaxOutput() {
return 0;
}
@Override
public double getMaxInput() {
return 64;
}
}

View file

@ -1,6 +1,5 @@
package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
@ -9,28 +8,20 @@ import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.init.ModBlocks;
import techreborn.init.ModFluids;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory;
import techreborn.util.Tank;
public class TileIndustrialElectrolyzer extends TileMachineBase implements IWrenchable, IEnergyTile, IInventory, ISidedInventory {
public class TileIndustrialElectrolyzer extends TilePowerAcceptor implements IWrenchable, IEnergyTile, IInventory, ISidedInventory {
public int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(7, "TileIndustrialElectrolyzer", 64);
public RecipeCrafter crafter;
public TileIndustrialElectrolyzer()
{
//TODO configs
energy = new BasicSink(this, 10000, 2);
super(2);
//Input slots
int[] inputs = new int[2];
inputs[0] = 0;
@ -40,14 +31,13 @@ public class TileIndustrialElectrolyzer extends TileMachineBase implements IWren
outputs[1] = 3;
outputs[2] = 4;
outputs[3] = 5;
crafter = new RecipeCrafter("industrialElectrolyzerRecipe", this, energy, 2, 4, inventory, inputs, outputs);
crafter = new RecipeCrafter("industrialElectrolyzerRecipe", this, 2, 4, inventory, inputs, outputs);
}
@Override
public void updateEntity()
{
super.updateEntity();
energy.updateEntity();
crafter.updateEntity();
}
@ -100,7 +90,6 @@ public class TileIndustrialElectrolyzer extends TileMachineBase implements IWren
{
super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound);
}
@ -109,23 +98,9 @@ public class TileIndustrialElectrolyzer extends TileMachineBase implements IWren
{
super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound);
}
@Override
public void invalidate()
{
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
super.onChunkUnload();
}
// @Override
// public void addWailaInfo(List<String> info)
// {
@ -224,7 +199,28 @@ public class TileIndustrialElectrolyzer extends TileMachineBase implements IWren
return 0;
}
public int getEnergyScaled(int scale) {
return (int)energy.getEnergyStored() * scale / energy.getCapacity();
@Override
public double getMaxPower() {
return 10000;
}
@Override
public boolean canAcceptEnergy(ForgeDirection direction) {
return true;
}
@Override
public boolean canProvideEnergy(ForgeDirection direction) {
return false;
}
@Override
public double getMaxOutput() {
return 0;
}
@Override
public double getMaxInput() {
return 128;
}
}

View file

@ -1,6 +1,5 @@
package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
@ -10,33 +9,29 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.*;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.blocks.BlockMachineCasing;
import techreborn.init.ModBlocks;
import techreborn.init.ModFluids;
import techreborn.lib.Location;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory;
import techreborn.util.Tank;
import java.util.List;
public class TileIndustrialSawmill extends TileMachineBase implements IWrenchable, IEnergyTile, IFluidHandler, IInventory, ISidedInventory {
public class TileIndustrialSawmill extends TilePowerAcceptor implements IWrenchable, IEnergyTile, IFluidHandler, IInventory, ISidedInventory {
public int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(5, "TileIndustrialSawmill", 64);
public Tank tank = new Tank("TileGrinder", 16000, this);
public RecipeCrafter crafter;
public TileIndustrialSawmill()
{
super(2);
//TODO configs
energy = new BasicSink(this, 1000, 2);
//Input slots
int[] inputs = new int[2];
inputs[0] = 0;
@ -45,7 +40,7 @@ public class TileIndustrialSawmill extends TileMachineBase implements IWrenchabl
outputs[0] = 2;
outputs[1] = 3;
outputs[2] = 4;
crafter = new RecipeCrafter("industrialSawmillRecipe", this, energy, 2, 3, inventory, inputs, outputs);
crafter = new RecipeCrafter("industrialSawmillRecipe", this, 2, 3, inventory, inputs, outputs);
}
@Override
@ -54,7 +49,6 @@ public class TileIndustrialSawmill extends TileMachineBase implements IWrenchabl
super.updateEntity();
if(getMutliBlock())
{
energy.updateEntity();
crafter.updateEntity();
}
}
@ -128,7 +122,6 @@ public class TileIndustrialSawmill extends TileMachineBase implements IWrenchabl
{
super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
tank.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound);
}
@ -138,29 +131,15 @@ public class TileIndustrialSawmill extends TileMachineBase implements IWrenchabl
{
super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
tank.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound);
}
@Override
public void invalidate()
{
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
super.onChunkUnload();
}
@Override
public void addWailaInfo(List<String> info)
{
super.addWailaInfo(info);
info.add("Power Stored " + energy.getEnergyStored() + " EU");
info.add("Power Stored " + getEnergy() + " EU");
if(crafter.currentRecipe !=null){
info.add("Power Usage " + crafter.currentRecipe.euPerTick() + " EU/t");
}
@ -300,8 +279,28 @@ public class TileIndustrialSawmill extends TileMachineBase implements IWrenchabl
return 0;
}
public int getEnergyScaled(int scale) {
return (int)energy.getEnergyStored() * scale / energy.getCapacity();
@Override
public double getMaxPower() {
return 10000;
}
@Override
public boolean canAcceptEnergy(ForgeDirection direction) {
return true;
}
@Override
public boolean canProvideEnergy(ForgeDirection direction) {
return false;
}
@Override
public double getMaxOutput() {
return 0;
}
@Override
public double getMaxInput() {
return 64;
}
}

View file

@ -1,6 +1,5 @@
package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
@ -11,32 +10,31 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory;
public class TileLathe extends TileMachineBase implements IWrenchable, IEnergyTile, IInventory, ISidedInventory {
public class TileLathe extends TilePowerAcceptor implements IWrenchable, IEnergyTile, IInventory, ISidedInventory {
public int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(7, "TileLathe", 64);
public RecipeCrafter crafter;
public TileLathe()
{
super(2);
//TODO configs
energy = new BasicSink(this, 1000, 2);
//Input slots
int[] inputs = new int[1];
inputs[0] = 0;
int[] outputs = new int[1];
outputs[0] = 1;
crafter = new RecipeCrafter("latheRecipe", this, energy, 1, 1, inventory, inputs, outputs);
crafter = new RecipeCrafter("latheRecipe", this, 1, 1, inventory, inputs, outputs);
}
@Override
public void updateEntity()
{
super.updateEntity();
energy.updateEntity();
crafter.updateEntity();
}
@ -89,7 +87,6 @@ public class TileLathe extends TileMachineBase implements IWrenchable, IEnergyTi
{
super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound);
}
@ -98,23 +95,9 @@ public class TileLathe extends TileMachineBase implements IWrenchable, IEnergyTi
{
super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound);
}
@Override
public void invalidate()
{
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
super.onChunkUnload();
}
@Override
public int getSizeInventory() {
return inventory.getSizeInventory();
@ -213,8 +196,29 @@ public class TileLathe extends TileMachineBase implements IWrenchable, IEnergyTi
return 0;
}
public int getEnergyScaled(int scale) {
return (int)energy.getEnergyStored() * scale / energy.getCapacity();
@Override
public double getMaxPower() {
return 10000;
}
@Override
public boolean canAcceptEnergy(ForgeDirection direction) {
return true;
}
@Override
public boolean canProvideEnergy(ForgeDirection direction) {
return false;
}
@Override
public double getMaxOutput() {
return 0;
}
@Override
public double getMaxInput() {
return 32;
}
}

View file

@ -1,6 +1,5 @@
package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.recipe.RecipeOutput;
import ic2.api.recipe.Recipes;
@ -13,21 +12,21 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import techreborn.init.ModBlocks;
import techreborn.init.ModItems;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory;
import techreborn.util.ItemUtils;
public class TileMatterFabricator extends TileMachineBase implements IWrenchable, IEnergyTile, IInventory, ISidedInventory {
public class TileMatterFabricator extends TilePowerAcceptor implements IWrenchable, IEnergyTile, IInventory, ISidedInventory {
public static int fabricationRate = 2666656;
public int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(7, "TileMatterFabricator", 64);
private int amplifier = 0;
public int progresstime = 0;
public TileMatterFabricator() {
super(6);
//TODO configs
energy = new BasicSink(this, 10000000, 6);
}
@Override
@ -70,26 +69,12 @@ public class TileMatterFabricator extends TileMachineBase implements IWrenchable
public void readFromNBT(NBTTagCompound tagCompound) {
super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
}
@Override
public void writeToNBT(NBTTagCompound tagCompound) {
super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
}
@Override
public void invalidate() {
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload() {
energy.onChunkUnload();
super.onChunkUnload();
}
@Override
@ -177,7 +162,6 @@ public class TileMatterFabricator extends TileMachineBase implements IWrenchable
@Override
public void updateEntity() {
super.updateEntity();
energy.updateEntity();
if (!super.worldObj.isRemote) {
for (int i = 0; i < 6; i++) {
@ -185,7 +169,8 @@ public class TileMatterFabricator extends TileMachineBase implements IWrenchable
if (this.amplifier < 100000 && stack != null) {
int amp = (int) ((long) (getValue(stack) / 32));
if (ItemUtils.isItemEqual(stack, inventory.getStackInSlot(i), true, true)) {
if(energy.useEnergy(1)){
if(canUseEnergy(1)){
useEnergy(1);
this.amplifier += amp;
inventory.decrStackSize(i, 1);
}
@ -194,10 +179,10 @@ public class TileMatterFabricator extends TileMachineBase implements IWrenchable
}
if (this.amplifier > 0) {
if (this.amplifier > this.energy.getEnergyStored()) {
this.progresstime += this.energy.getEnergyStored();
this.amplifier -= this.energy.getEnergyStored();
this.decreaseStoredEnergy(this.energy.getEnergyStored(), true);
if (this.amplifier > this.getEnergy()) {
this.progresstime += this.getEnergy();
this.amplifier -= this.getEnergy();
this.decreaseStoredEnergy(this.getEnergy(), true);
} else {
this.progresstime += this.amplifier;
this.decreaseStoredEnergy(this.amplifier, true);
@ -228,12 +213,12 @@ public class TileMatterFabricator extends TileMachineBase implements IWrenchable
public boolean decreaseStoredEnergy(double aEnergy, boolean aIgnoreTooLessEnergy) {
if (energy.getEnergyStored() - aEnergy < 0 && !aIgnoreTooLessEnergy) {
if (this.getEnergy() - aEnergy < 0 && !aIgnoreTooLessEnergy) {
return false;
} else {
energy.setEnergyStored(energy.getEnergyStored() - aEnergy);
if (energy.getEnergyStored() < 0) {
energy.setEnergyStored(0);
setEnergy(this.getEnergy() - aEnergy);
if (this.getEnergy() < 0) {
setEnergy(0);
return false;
} else {
return true;
@ -253,4 +238,28 @@ public class TileMatterFabricator extends TileMachineBase implements IWrenchable
return 0;
}
@Override
public double getMaxPower() {
return 100000000;
}
@Override
public boolean canAcceptEnergy(ForgeDirection direction) {
return true;
}
@Override
public boolean canProvideEnergy(ForgeDirection direction) {
return false;
}
@Override
public double getMaxOutput() {
return 0;
}
@Override
public double getMaxInput() {
return 4096;
}
}

View file

@ -1,6 +1,5 @@
package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
@ -11,32 +10,31 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import techreborn.api.recipe.RecipeCrafter;
import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory;
public class TilePlateCuttingMachine extends TileMachineBase implements IWrenchable, IEnergyTile, IInventory, ISidedInventory {
public class TilePlateCuttingMachine extends TilePowerAcceptor implements IWrenchable, IEnergyTile, IInventory, ISidedInventory {
public int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(7, "TilePlateCuttingMachine", 64);
public RecipeCrafter crafter;
public TilePlateCuttingMachine()
{
super(2);
//TODO configs
energy = new BasicSink(this, 1000, 2);
//Input slots
int[] inputs = new int[1];
inputs[0] = 0;
int[] outputs = new int[1];
outputs[0] = 1;
crafter = new RecipeCrafter("plateCuttingMachineRecipe", this, energy, 1, 1, inventory, inputs, outputs);
crafter = new RecipeCrafter("plateCuttingMachineRecipe", this, 1, 1, inventory, inputs, outputs);
}
@Override
public void updateEntity()
{
super.updateEntity();
energy.updateEntity();
crafter.updateEntity();
}
@ -89,7 +87,6 @@ public class TilePlateCuttingMachine extends TileMachineBase implements IWrencha
{
super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound);
}
@ -98,7 +95,6 @@ public class TilePlateCuttingMachine extends TileMachineBase implements IWrencha
{
super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound);
}
@ -112,18 +108,6 @@ public class TilePlateCuttingMachine extends TileMachineBase implements IWrencha
// }
// }
@Override
public void invalidate()
{
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
super.onChunkUnload();
}
@Override
public int getSizeInventory() {
@ -213,9 +197,29 @@ public class TilePlateCuttingMachine extends TileMachineBase implements IWrencha
return 0;
}
public int getEnergyScaled(int scale) {
return (int)energy.getEnergyStored() * scale / energy.getCapacity();
@Override
public double getMaxPower() {
return 10000;
}
@Override
public boolean canAcceptEnergy(ForgeDirection direction) {
return true;
}
@Override
public boolean canProvideEnergy(ForgeDirection direction) {
return false;
}
@Override
public double getMaxOutput() {
return 0;
}
@Override
public double getMaxInput() {
return 64;
}
}

View file

@ -1,6 +1,5 @@
package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
@ -9,15 +8,16 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import techreborn.api.RollingMachineRecipe;
import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory;
import techreborn.util.ItemUtils;
//TODO add tick and power bars.
public class TileRollingMachine extends TileMachineBase implements IWrenchable, IEnergyTile, IInventory {
public class TileRollingMachine extends TilePowerAcceptor implements IWrenchable, IEnergyTile, IInventory {
public BasicSink energy;
public Inventory inventory = new Inventory(2, "TileRollingMachine", 64);
public final InventoryCrafting craftMatrix = new InventoryCrafting(
new RollingTileContainer(), 3, 3);
@ -29,6 +29,31 @@ public class TileRollingMachine extends TileMachineBase implements IWrenchable,
public int euTick = 5;
@Override
public double getMaxPower() {
return 100000;
}
@Override
public boolean canAcceptEnergy(ForgeDirection direction) {
return true;
}
@Override
public boolean canProvideEnergy(ForgeDirection direction) {
return false;
}
@Override
public double getMaxOutput() {
return 0;
}
@Override
public double getMaxInput() {
return 64;
}
private static class RollingTileContainer extends Container {
@Override
@ -41,14 +66,13 @@ public class TileRollingMachine extends TileMachineBase implements IWrenchable,
public TileRollingMachine()
{
energy = new BasicSink(this, 100000, 1);
super(1);
}
@Override
public void updateEntity()
{
super.updateEntity();
energy.updateEntity();
if (!worldObj.isRemote)
{
currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(
@ -95,8 +119,9 @@ public class TileRollingMachine extends TileMachineBase implements IWrenchable,
}
if (currentRecipe != null)
{
if (energy.canUseEnergy(euTick) && tickTime < runTime)
if (canUseEnergy(euTick) && tickTime < runTime)
{
useEnergy(euTick);
tickTime++;
}
}
@ -172,7 +197,6 @@ public class TileRollingMachine extends TileMachineBase implements IWrenchable,
{
super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
ItemUtils.readInvFromNBT(craftMatrix, "Crafting", tagCompound);
isRunning = tagCompound.getBoolean("isRunning");
tickTime = tagCompound.getInteger("tickTime");
@ -183,7 +207,6 @@ public class TileRollingMachine extends TileMachineBase implements IWrenchable,
{
super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
ItemUtils.writeInvToNBT(craftMatrix, "Crafting", tagCompound);
writeUpdateToNBT(tagCompound);
}
@ -197,13 +220,11 @@ public class TileRollingMachine extends TileMachineBase implements IWrenchable,
@Override
public void invalidate()
{
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
super.onChunkUnload();
}

View file

@ -12,12 +12,7 @@ import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.*;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.util.FluidUtils;

View file

@ -1,6 +1,5 @@
package techreborn.tiles;
import ic2.api.energy.prefab.BasicSource;
import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer;
@ -10,34 +9,26 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler;
import net.minecraftforge.fluids.*;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.FluidUtils;
import techreborn.util.Inventory;
import techreborn.util.Tank;
public class TileThermalGenerator extends TileEntity implements IWrenchable,
public class TileThermalGenerator extends TilePowerAcceptor implements IWrenchable,
IFluidHandler, IInventory, IEnergyTile {
public Tank tank = new Tank("TileThermalGenerator",
FluidContainerRegistry.BUCKET_VOLUME * 10, this);
public Inventory inventory = new Inventory(3, "TileThermalGenerator", 64);
public BasicSource energySource;
public static final int euTick = ConfigTechReborn.ThermalGenertaorOutput;
public TileThermalGenerator()
{
this.energySource = new BasicSource(this,
ConfigTechReborn.ThermalGeneratorCharge,
ConfigTechReborn.ThermalGeneratorTier);
super(ConfigTechReborn.ThermalGeneratorTier);
}
@Override
@ -135,7 +126,6 @@ public class TileThermalGenerator extends TileEntity implements IWrenchable,
super.readFromNBT(tagCompound);
tank.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energySource.readFromNBT(tagCompound);
}
@Override
@ -144,7 +134,6 @@ public class TileThermalGenerator extends TileEntity implements IWrenchable,
super.writeToNBT(tagCompound);
tank.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energySource.writeToNBT(tagCompound);
}
public Packet getDescriptionPacket()
@ -170,12 +159,11 @@ public class TileThermalGenerator extends TileEntity implements IWrenchable,
super.updateEntity();
if(!worldObj.isRemote)
FluidUtils.drainContainers(this, inventory, 0, 1);
energySource.updateEntity();
if (tank.getFluidAmount() > 0
&& energySource.getCapacity() - energySource.getEnergyStored() >= euTick)
&& getMaxPower() - getEnergy() >= euTick)
{
tank.drain(1, true);
energySource.addEnergy(euTick);
addEnergy(euTick);
}
if (tank.getFluidType() != null && getStackInSlot(2) == null)
{
@ -260,17 +248,27 @@ public class TileThermalGenerator extends TileEntity implements IWrenchable,
}
@Override
public void onChunkUnload()
{
energySource.onChunkUnload();
super.onChunkUnload();
public double getMaxPower() {
return ConfigTechReborn.ThermalGeneratorCharge;
}
@Override
public void invalidate()
{
energySource.invalidate();
super.invalidate();
public boolean canAcceptEnergy(ForgeDirection direction) {
return false;
}
@Override
public boolean canProvideEnergy(ForgeDirection direction) {
return true;
}
@Override
public double getMaxOutput() {
return 128;
}
@Override
public double getMaxInput() {
return 0;
}
}

View file

@ -5,17 +5,12 @@ import com.google.gson.GsonBuilder;
import com.google.gson.reflect.TypeToken;
import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World;
import net.minecraft.world.storage.ISaveHandler;
import net.minecraftforge.event.world.WorldEvent;
import techreborn.packets.PacketSendIDSUManager;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.*;
import java.lang.reflect.Type;
import java.util.HashMap;
import java.util.TreeMap;

View file

@ -19,7 +19,6 @@ import net.minecraftforge.common.util.ForgeDirection;
import techreborn.Core;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.packets.PacketHandler;
public class TileIDSU extends TileEntityBlock implements IEnergySink, IEnergySource, INetworkClientTileEntityEventListener, IEnergyStorage {