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

View file

@ -28,8 +28,8 @@ public abstract class ContainerCrafting extends TechRebornContainer {
if(this.currentNeededTicks != crafter.currentNeededTicks){ if(this.currentNeededTicks != crafter.currentNeededTicks){
icrafting.sendProgressBarUpdate(this, 1, crafter.currentNeededTicks); icrafting.sendProgressBarUpdate(this, 1, crafter.currentNeededTicks);
} }
if(this.energy != (int)crafter.energy.getEnergyStored()){ if(this.energy != (int)crafter.energy.getEnergy()){
icrafting.sendProgressBarUpdate(this, 2, (int)crafter.energy.getEnergyStored()); icrafting.sendProgressBarUpdate(this, 2, (int)crafter.energy.getEnergy());
} }
} }
} }
@ -39,7 +39,7 @@ public abstract class ContainerCrafting extends TechRebornContainer {
super.addCraftingToCrafters(crafting); super.addCraftingToCrafters(crafting);
crafting.sendProgressBarUpdate(this, 0, crafter.currentTickTime); crafting.sendProgressBarUpdate(this, 0, crafter.currentTickTime);
crafting.sendProgressBarUpdate(this, 1, crafter.currentNeededTicks); 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) @SideOnly(Side.CLIENT)
@ -54,6 +54,6 @@ public abstract class ContainerCrafting extends TechRebornContainer {
} }
this.crafter.currentTickTime = currentTickTime; this.crafter.currentTickTime = currentTickTime;
this.crafter.currentNeededTicks = currentNeededTicks; 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); 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) { if(j > 0) {
this.drawTexturedModalRect(k + 16, l + 37 + 12 - j, 176, 12 - j, 14, j + 2); 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) { if (tileFarm.getWorldObj().isRemote) {
return; 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) { if (tileFarm.getWorldObj().getTotalWorldTime() % 20 == 0 || tileFarm.inventory.hasChanged) {
calculateFarmLand(tileFarm); calculateFarmLand(tileFarm);
} }

View file

@ -17,6 +17,8 @@ import net.minecraftforge.common.util.ForgeDirection;
import techreborn.api.power.IEnergyInterfaceTile; import techreborn.api.power.IEnergyInterfaceTile;
import techreborn.asm.Strippable; import techreborn.asm.Strippable;
import java.util.List;
@Optional.InterfaceList(value = { @Optional.InterfaceList(value = {
@Optional.Interface(iface = "ic2.api.energy.tile.IEnergyTile", modid = "IC2"), @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); data.setDouble("energy", energy);
tag.setTag("TilePowerAcceptor", data); 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; package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile; import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable; import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -12,34 +11,32 @@ import net.minecraftforge.common.util.ForgeDirection;
import techreborn.api.recipe.RecipeCrafter; import techreborn.api.recipe.RecipeCrafter;
import techreborn.api.upgrade.UpgradeHandler; import techreborn.api.upgrade.UpgradeHandler;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory; 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 int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(8, "TileAlloySmelter", 64); public Inventory inventory = new Inventory(8, "TileAlloySmelter", 64);
public RecipeCrafter crafter; public RecipeCrafter crafter;
public int capacity = 1000; public int capacity = 1000;
UpgradeHandler upgrades; UpgradeHandler upgrades;
public TileAlloySmelter(){ public TileAlloySmelter(){
//TODO configs super(1);
energy = new BasicSink(this, capacity, 1);
//Input slots //Input slots
int[] inputs = new int[2]; int[] inputs = new int[2];
inputs[0] = 0; inputs[0] = 0;
inputs[1] = 1; inputs[1] = 1;
int[] outputs = new int[1]; int[] outputs = new int[1];
outputs[0] = 2; 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); upgrades = new UpgradeHandler(crafter, inventory, 4, 5, 6, 7);
} }
@Override @Override
public void updateEntity(){ public void updateEntity(){
super.updateEntity(); super.updateEntity();
energy.updateEntity();
crafter.updateEntity(); crafter.updateEntity();
upgrades.tick(); upgrades.tick();
} }
@ -84,7 +81,6 @@ public class TileAlloySmelter extends TileMachineBase implements IWrenchable, IE
public void readFromNBT(NBTTagCompound tagCompound){ public void readFromNBT(NBTTagCompound tagCompound){
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound); inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound); crafter.readFromNBT(tagCompound);
} }
@ -92,22 +88,8 @@ public class TileAlloySmelter extends TileMachineBase implements IWrenchable, IE
public void writeToNBT(NBTTagCompound tagCompound){ public void writeToNBT(NBTTagCompound tagCompound){
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound); inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound); crafter.writeToNBT(tagCompound);
} }
@Override
public void invalidate()
{
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
super.onChunkUnload();
}
// @Override // @Override
// public void addWailaInfo(List<String> info){ // public void addWailaInfo(List<String> info){
@ -206,7 +188,28 @@ public class TileAlloySmelter extends TileMachineBase implements IWrenchable, IE
return 0; return 0;
} }
public int getEnergyScaled(int scale) { @Override
return (int)energy.getEnergyStored() * scale / energy.getCapacity(); 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; package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile; import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable; import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -11,33 +10,31 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import techreborn.api.recipe.RecipeCrafter; import techreborn.api.recipe.RecipeCrafter;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory; 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 int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(8, "TileAssemblingMachine", 64); public Inventory inventory = new Inventory(8, "TileAssemblingMachine", 64);
public RecipeCrafter crafter; public RecipeCrafter crafter;
public TileAssemblingMachine() public TileAssemblingMachine()
{ {
//TODO configs super(2);
energy = new BasicSink(this, 1000, 2);
//Input slots //Input slots
int[] inputs = new int[2]; int[] inputs = new int[2];
inputs[0] = 0; inputs[0] = 0;
inputs[1] = 1; inputs[1] = 1;
int[] outputs = new int[1]; int[] outputs = new int[1];
outputs[0] = 2; 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 @Override
public void updateEntity() public void updateEntity()
{ {
super.updateEntity(); super.updateEntity();
energy.updateEntity();
crafter.updateEntity(); crafter.updateEntity();
} }
@ -90,7 +87,6 @@ public class TileAssemblingMachine extends TileMachineBase implements IWrenchabl
{ {
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound); inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound); crafter.readFromNBT(tagCompound);
} }
@ -99,22 +95,9 @@ public class TileAssemblingMachine extends TileMachineBase implements IWrenchabl
{ {
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound); inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound); crafter.writeToNBT(tagCompound);
} }
@Override
public void invalidate()
{
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
super.onChunkUnload();
}
@Override @Override
public int getSizeInventory() { public int getSizeInventory() {
@ -214,8 +197,28 @@ public class TileAssemblingMachine extends TileMachineBase implements IWrenchabl
return 0; return 0;
} }
public int getEnergyScaled(int scale) { @Override
return (int)energy.getEnergyStored() * scale / energy.getCapacity(); 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.config.ConfigTechReborn;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.lib.Location; import techreborn.lib.Location;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory; 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 int tickTime;
public BasicSink energy; public BasicSink energy;
@ -29,15 +30,15 @@ public class TileBlastFurnace extends TileMachineBase implements IWrenchable, II
public static int euTick = 5; public static int euTick = 5;
public TileBlastFurnace() { public TileBlastFurnace() {
//TODO configs super(ConfigTechReborn.CentrifugeTier);
energy = new BasicSink(this, 10000,ConfigTechReborn.CentrifugeTier); //TODO configs
int[] inputs = new int[2]; int[] inputs = new int[2];
inputs[0] = 0; inputs[0] = 0;
inputs[1] = 1; inputs[1] = 1;
int[] outputs = new int[2]; int[] outputs = new int[2];
outputs[0] = 2; outputs[0] = 2;
outputs[1] = 3; 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 @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; package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile; import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable; import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -12,14 +11,14 @@ import net.minecraftforge.common.util.ForgeDirection;
import techreborn.api.recipe.RecipeCrafter; import techreborn.api.recipe.RecipeCrafter;
import techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory; import techreborn.util.Inventory;
import java.util.List; 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 int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(11, "TileCentrifuge", 64); public Inventory inventory = new Inventory(11, "TileCentrifuge", 64);
public RecipeCrafter crafter; public RecipeCrafter crafter;
@ -27,8 +26,7 @@ public class TileCentrifuge extends TileMachineBase implements IWrenchable, IEn
public TileCentrifuge() public TileCentrifuge()
{ {
//TODO configs super(2);
energy = new BasicSink(this, 1000, 2);
//Input slots //Input slots
int[] inputs = new int[2]; int[] inputs = new int[2];
inputs[0] = 0; inputs[0] = 0;
@ -39,14 +37,13 @@ public class TileCentrifuge extends TileMachineBase implements IWrenchable, IEn
outputs[2] = 4; outputs[2] = 4;
outputs[3] = 5; 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 @Override
public void updateEntity() public void updateEntity()
{ {
super.updateEntity(); super.updateEntity();
energy.updateEntity();
crafter.updateEntity(); crafter.updateEntity();
} }
@ -99,7 +96,6 @@ public class TileCentrifuge extends TileMachineBase implements IWrenchable, IEn
{ {
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound); inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound); crafter.readFromNBT(tagCompound);
} }
@ -108,22 +104,8 @@ public class TileCentrifuge extends TileMachineBase implements IWrenchable, IEn
{ {
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound); inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound); crafter.writeToNBT(tagCompound);
} }
@Override
public void invalidate()
{
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
super.onChunkUnload();
}
@Override @Override
public void addWailaInfo(List<String> info) public void addWailaInfo(List<String> info)
@ -224,7 +206,28 @@ public class TileCentrifuge extends TileMachineBase implements IWrenchable, IEn
return 0; return 0;
} }
public int getEnergyScaled(int scale) { @Override
return (int)energy.getEnergyStored() * scale / energy.getCapacity(); 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; package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile; import ic2.api.energy.tile.IEnergyTile;
import ic2.api.item.ElectricItem; import ic2.api.item.ElectricItem;
import ic2.api.item.IElectricItem; import ic2.api.item.IElectricItem;
@ -12,22 +11,21 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory; 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 Inventory inventory = new Inventory(6, "TileChargeBench", 64);
public int capacity = 100000; public int capacity = 100000;
public TileChargeBench(){ public TileChargeBench(){
energy = new BasicSink(this, capacity, 4); super(4);
} }
@Override @Override
public void updateEntity(){ public void updateEntity(){
super.updateEntity(); super.updateEntity();
energy.updateEntity();
for (int i = 0; i < 6; i++) for (int i = 0; i < 6; i++)
if(inventory.getStackInSlot(i) != null) 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 amount = ((IElectricItem) stack.getItem()).getTransferLimit(stack);
double CurrentCharge = ElectricItem.manager.getCharge(stack); double CurrentCharge = ElectricItem.manager.getCharge(stack);
int teir = ((IElectricItem) stack.getItem()).getTier(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); 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){ public void readFromNBT(NBTTagCompound tagCompound){
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound); inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
} }
@Override @Override
public void writeToNBT(NBTTagCompound tagCompound){ public void writeToNBT(NBTTagCompound tagCompound){
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
inventory.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 @Override
@ -171,10 +154,6 @@ public class TileChargeBench extends TileMachineBase implements IWrenchable, IEn
public boolean isItemValidForSlot(int slot, ItemStack stack) { public boolean isItemValidForSlot(int slot, ItemStack stack) {
return inventory.isItemValidForSlot(slot, stack); return inventory.isItemValidForSlot(slot, stack);
} }
public int getEnergyScaled(int scale) {
return (int)energy.getEnergyStored() * scale / energy.getCapacity();
}
// ISidedInventory // ISidedInventory
@Override @Override
@ -201,4 +180,29 @@ public class TileChargeBench extends TileMachineBase implements IWrenchable, IEn
} }
return false; 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; package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile; import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable; import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -11,33 +10,31 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import techreborn.api.recipe.RecipeCrafter; import techreborn.api.recipe.RecipeCrafter;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory; 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 int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(8, "TileChemicalReactor", 64); public Inventory inventory = new Inventory(8, "TileChemicalReactor", 64);
public RecipeCrafter crafter; public RecipeCrafter crafter;
public TileChemicalReactor() public TileChemicalReactor()
{ {
//TODO configs super(2);
energy = new BasicSink(this, 1000, 2);
//Input slots //Input slots
int[] inputs = new int[2]; int[] inputs = new int[2];
inputs[0] = 0; inputs[0] = 0;
inputs[1] = 1; inputs[1] = 1;
int[] outputs = new int[1]; int[] outputs = new int[1];
outputs[0] = 2; 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 @Override
public void updateEntity() public void updateEntity()
{ {
super.updateEntity(); super.updateEntity();
energy.updateEntity();
crafter.updateEntity(); crafter.updateEntity();
} }
@ -90,7 +87,6 @@ public class TileChemicalReactor extends TileMachineBase implements IWrenchable,
{ {
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound); inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound); crafter.readFromNBT(tagCompound);
} }
@ -99,22 +95,8 @@ public class TileChemicalReactor extends TileMachineBase implements IWrenchable,
{ {
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound); inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound); crafter.writeToNBT(tagCompound);
} }
@Override
public void invalidate()
{
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
super.onChunkUnload();
}
@Override @Override
public int getSizeInventory() { public int getSizeInventory() {
@ -214,8 +196,28 @@ public class TileChemicalReactor extends TileMachineBase implements IWrenchable,
return 0; return 0;
} }
public int getEnergyScaled(int scale) { @Override
return (int)energy.getEnergyStored() * scale / energy.getCapacity(); 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; package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile; import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable; import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraftforge.common.util.ForgeDirection;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory; 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 Inventory inventory = new Inventory(1, "TileChunkLoader", 64);
public boolean isRunning; public boolean isRunning;
@ -21,29 +21,8 @@ public class TileChunkLoader extends TileMachineBase implements IWrenchable, IEn
public TileChunkLoader() public TileChunkLoader()
{ {
energy = new BasicSink(this, 1000, super(1);
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();
}
@Override @Override
public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side) public boolean wrenchCanSetFacing(EntityPlayer entityPlayer, int side)
@ -149,4 +128,28 @@ public class TileChunkLoader extends TileMachineBase implements IWrenchable, IEn
return inventory.isItemValidForSlot(slot, stack); 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; package techreborn.tiles;
import ic2.api.energy.prefab.BasicSource;
import ic2.api.energy.tile.IEnergyTile; import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable; import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -10,34 +9,26 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager; import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet; import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.*;
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 techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.FluidUtils; import techreborn.util.FluidUtils;
import techreborn.util.Inventory; import techreborn.util.Inventory;
import techreborn.util.Tank; import techreborn.util.Tank;
public class TileDieselGenerator extends TileEntity implements IWrenchable, public class TileDieselGenerator extends TilePowerAcceptor implements IWrenchable,
IFluidHandler, IInventory, IEnergyTile { IFluidHandler, IInventory, IEnergyTile {
public Tank tank = new Tank("TileDieselGenerator", public Tank tank = new Tank("TileDieselGenerator",
FluidContainerRegistry.BUCKET_VOLUME * 10, this); FluidContainerRegistry.BUCKET_VOLUME * 10, this);
public Inventory inventory = new Inventory(3, "TileDieselGenerator", 64); public Inventory inventory = new Inventory(3, "TileDieselGenerator", 64);
public BasicSource energySource;
public static final int euTick = ConfigTechReborn.ThermalGenertaorOutput; public static final int euTick = ConfigTechReborn.ThermalGenertaorOutput;
public TileDieselGenerator() public TileDieselGenerator()
{ {
this.energySource = new BasicSource(this, super(ConfigTechReborn.ThermalGeneratorTier);
ConfigTechReborn.ThermalGeneratorCharge,
ConfigTechReborn.ThermalGeneratorTier);
} }
@Override @Override
@ -129,7 +120,6 @@ public class TileDieselGenerator extends TileEntity implements IWrenchable,
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
tank.readFromNBT(tagCompound); tank.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound); inventory.readFromNBT(tagCompound);
energySource.readFromNBT(tagCompound);
} }
@Override @Override
@ -138,7 +128,6 @@ public class TileDieselGenerator extends TileEntity implements IWrenchable,
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
tank.writeToNBT(tagCompound); tank.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound); inventory.writeToNBT(tagCompound);
energySource.writeToNBT(tagCompound);
} }
public Packet getDescriptionPacket() public Packet getDescriptionPacket()
@ -164,12 +153,11 @@ public class TileDieselGenerator extends TileEntity implements IWrenchable,
super.updateEntity(); super.updateEntity();
if(!worldObj.isRemote) if(!worldObj.isRemote)
FluidUtils.drainContainers(this, inventory, 0, 1); FluidUtils.drainContainers(this, inventory, 0, 1);
energySource.updateEntity();
if (tank.getFluidAmount() > 0 if (tank.getFluidAmount() > 0
&& energySource.getCapacity() - energySource.getEnergyStored() >= euTick) && getMaxPower() - getEnergy() >= euTick)
{ {
tank.drain(1, true); tank.drain(1, true);
energySource.addEnergy(euTick); addEnergy(euTick);
} }
if (tank.getFluidType() != null && getStackInSlot(2) == null) if (tank.getFluidType() != null && getStackInSlot(2) == null)
{ {
@ -253,17 +241,28 @@ public class TileDieselGenerator extends TileEntity implements IWrenchable,
return inventory.isItemValidForSlot(p_94041_1_, p_94041_2_); return inventory.isItemValidForSlot(p_94041_1_, p_94041_2_);
} }
@Override @Override
public void onChunkUnload() public double getMaxPower() {
{ return ConfigTechReborn.ThermalGeneratorCharge;
energySource.onChunkUnload(); }
}
@Override @Override
public void invalidate() public boolean canAcceptEnergy(ForgeDirection direction) {
{ return false;
energySource.invalidate(); }
super.invalidate();
}
@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; package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile; import ic2.api.energy.tile.IEnergyTile;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory; import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import techreborn.api.farm.IFarmLogicContainer; import techreborn.api.farm.IFarmLogicContainer;
import techreborn.api.farm.IFarmLogicDevice; import techreborn.api.farm.IFarmLogicDevice;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory; 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); public Inventory inventory = new Inventory(14, "TileFarm", 64);
IFarmLogicDevice logicDevice; IFarmLogicDevice logicDevice;
public int size = 4; public int size = 4;
public BasicSink energy;
public TileFarm() { public TileFarm() {
energy = new BasicSink(this, 100000, 2); super(2);
} }
@Override @Override
public void readFromNBT(NBTTagCompound tagCompound) { public void readFromNBT(NBTTagCompound tagCompound) {
energy.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound); inventory.readFromNBT(tagCompound);
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
} }
@Override @Override
public void writeToNBT(NBTTagCompound tagCompound) { public void writeToNBT(NBTTagCompound tagCompound) {
energy.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound); inventory.writeToNBT(tagCompound);
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
} }
@Override @Override
public void updateEntity() { public void updateEntity() {
energy.updateEntity();
if(inventory.hasChanged){ if(inventory.hasChanged){
if(inventory.getStackInSlot(0) != null && inventory.getStackInSlot(0).getItem() instanceof IFarmLogicContainer){ if(inventory.getStackInSlot(0) != null && inventory.getStackInSlot(0).getItem() instanceof IFarmLogicContainer){
IFarmLogicContainer device = (IFarmLogicContainer) inventory.getStackInSlot(0).getItem(); IFarmLogicContainer device = (IFarmLogicContainer) inventory.getStackInSlot(0).getItem();
@ -115,16 +112,29 @@ public class TileFarm extends TileMachineBase implements IInventory, IEnergyTile
return inventory.isItemValidForSlot(slot, stack); return inventory.isItemValidForSlot(slot, stack);
} }
@Override @Override
public void invalidate() public double getMaxPower() {
{ return 100000;
energy.invalidate();
super.invalidate();
} }
@Override @Override
public void onChunkUnload() public boolean canAcceptEnergy(ForgeDirection direction) {
{ return true;
energy.onChunkUnload(); }
super.onChunkUnload();
@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.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.*;
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 techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.util.FluidUtils; import techreborn.util.FluidUtils;

View file

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

View file

@ -1,6 +1,5 @@
package techreborn.tiles; package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile; import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable; import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -14,17 +13,17 @@ import techreborn.api.recipe.RecipeCrafter;
import techreborn.blocks.BlockMachineCasing; import techreborn.blocks.BlockMachineCasing;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.lib.Location; import techreborn.lib.Location;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory; 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 int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(4, "TileImplosionCompressor", 64); public Inventory inventory = new Inventory(4, "TileImplosionCompressor", 64);
public RecipeCrafter crafter; public RecipeCrafter crafter;
public TileImplosionCompressor() { public TileImplosionCompressor() {
energy = new BasicSink(this, 100000, 1); super(1);
//Input slots //Input slots
int[] inputs = new int[2]; int[] inputs = new int[2];
inputs[0] = 0; inputs[0] = 0;
@ -32,7 +31,7 @@ public class TileImplosionCompressor extends TileMachineBase implements IWrencha
int[] outputs = new int[2]; int[] outputs = new int[2];
outputs[0] = 2; outputs[0] = 2;
outputs[1] = 3; 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 @Override
@ -99,7 +98,6 @@ public class TileImplosionCompressor extends TileMachineBase implements IWrencha
if(getMutliBlock()) if(getMutliBlock())
{ {
crafter.updateEntity(); crafter.updateEntity();
energy.updateEntity();
} }
} }
@ -109,7 +107,6 @@ public class TileImplosionCompressor extends TileMachineBase implements IWrencha
{ {
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound); inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound); crafter.readFromNBT(tagCompound);
} }
@ -118,7 +115,6 @@ public class TileImplosionCompressor extends TileMachineBase implements IWrencha
{ {
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound); inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
crafter.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 @Override
public int getSizeInventory() { public int getSizeInventory() {
return inventory.getSizeInventory(); return inventory.getSizeInventory();
@ -234,8 +216,28 @@ public class TileImplosionCompressor extends TileMachineBase implements IWrencha
return 0; return 0;
} }
public int getEnergyScaled(int scale) { @Override
return (int)energy.getEnergyStored() * scale / energy.getCapacity(); 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; package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile; import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable; import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -9,28 +8,20 @@ import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection; 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.api.recipe.RecipeCrafter;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.init.ModFluids; import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory; 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 int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(7, "TileIndustrialElectrolyzer", 64); public Inventory inventory = new Inventory(7, "TileIndustrialElectrolyzer", 64);
public RecipeCrafter crafter; public RecipeCrafter crafter;
public TileIndustrialElectrolyzer() public TileIndustrialElectrolyzer()
{ {
//TODO configs super(2);
energy = new BasicSink(this, 10000, 2);
//Input slots //Input slots
int[] inputs = new int[2]; int[] inputs = new int[2];
inputs[0] = 0; inputs[0] = 0;
@ -40,14 +31,13 @@ public class TileIndustrialElectrolyzer extends TileMachineBase implements IWren
outputs[1] = 3; outputs[1] = 3;
outputs[2] = 4; outputs[2] = 4;
outputs[3] = 5; 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 @Override
public void updateEntity() public void updateEntity()
{ {
super.updateEntity(); super.updateEntity();
energy.updateEntity();
crafter.updateEntity(); crafter.updateEntity();
} }
@ -100,7 +90,6 @@ public class TileIndustrialElectrolyzer extends TileMachineBase implements IWren
{ {
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound); inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound); crafter.readFromNBT(tagCompound);
} }
@ -109,23 +98,9 @@ public class TileIndustrialElectrolyzer extends TileMachineBase implements IWren
{ {
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound); inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound); crafter.writeToNBT(tagCompound);
} }
@Override
public void invalidate()
{
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
super.onChunkUnload();
}
// @Override // @Override
// public void addWailaInfo(List<String> info) // public void addWailaInfo(List<String> info)
// { // {
@ -224,7 +199,28 @@ public class TileIndustrialElectrolyzer extends TileMachineBase implements IWren
return 0; return 0;
} }
public int getEnergyScaled(int scale) { @Override
return (int)energy.getEnergyStored() * scale / energy.getCapacity(); 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; package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile; import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable; import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -10,33 +9,29 @@ import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.*;
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.api.recipe.RecipeCrafter;
import techreborn.blocks.BlockMachineCasing; import techreborn.blocks.BlockMachineCasing;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.init.ModFluids; import techreborn.init.ModFluids;
import techreborn.lib.Location; import techreborn.lib.Location;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory; import techreborn.util.Inventory;
import techreborn.util.Tank; import techreborn.util.Tank;
import java.util.List; 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 int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(5, "TileIndustrialSawmill", 64); public Inventory inventory = new Inventory(5, "TileIndustrialSawmill", 64);
public Tank tank = new Tank("TileGrinder", 16000, this); public Tank tank = new Tank("TileGrinder", 16000, this);
public RecipeCrafter crafter; public RecipeCrafter crafter;
public TileIndustrialSawmill() public TileIndustrialSawmill()
{ {
//TODO configs super(2);
energy = new BasicSink(this, 1000, 2); //TODO configs
//Input slots //Input slots
int[] inputs = new int[2]; int[] inputs = new int[2];
inputs[0] = 0; inputs[0] = 0;
@ -45,7 +40,7 @@ public class TileIndustrialSawmill extends TileMachineBase implements IWrenchabl
outputs[0] = 2; outputs[0] = 2;
outputs[1] = 3; outputs[1] = 3;
outputs[2] = 4; 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 @Override
@ -54,7 +49,6 @@ public class TileIndustrialSawmill extends TileMachineBase implements IWrenchabl
super.updateEntity(); super.updateEntity();
if(getMutliBlock()) if(getMutliBlock())
{ {
energy.updateEntity();
crafter.updateEntity(); crafter.updateEntity();
} }
} }
@ -128,7 +122,6 @@ public class TileIndustrialSawmill extends TileMachineBase implements IWrenchabl
{ {
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound); inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
tank.readFromNBT(tagCompound); tank.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound); crafter.readFromNBT(tagCompound);
} }
@ -138,29 +131,15 @@ public class TileIndustrialSawmill extends TileMachineBase implements IWrenchabl
{ {
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound); inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
tank.writeToNBT(tagCompound); tank.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound); crafter.writeToNBT(tagCompound);
} }
@Override
public void invalidate()
{
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
super.onChunkUnload();
}
@Override @Override
public void addWailaInfo(List<String> info) public void addWailaInfo(List<String> info)
{ {
super.addWailaInfo(info); super.addWailaInfo(info);
info.add("Power Stored " + energy.getEnergyStored() + " EU"); info.add("Power Stored " + getEnergy() + " EU");
if(crafter.currentRecipe !=null){ if(crafter.currentRecipe !=null){
info.add("Power Usage " + crafter.currentRecipe.euPerTick() + " EU/t"); info.add("Power Usage " + crafter.currentRecipe.euPerTick() + " EU/t");
} }
@ -300,8 +279,28 @@ public class TileIndustrialSawmill extends TileMachineBase implements IWrenchabl
return 0; return 0;
} }
public int getEnergyScaled(int scale) { @Override
return (int)energy.getEnergyStored() * scale / energy.getCapacity(); 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; package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile; import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable; import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -11,32 +10,31 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import techreborn.api.recipe.RecipeCrafter; import techreborn.api.recipe.RecipeCrafter;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory; 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 int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(7, "TileLathe", 64); public Inventory inventory = new Inventory(7, "TileLathe", 64);
public RecipeCrafter crafter; public RecipeCrafter crafter;
public TileLathe() public TileLathe()
{ {
//TODO configs super(2);
energy = new BasicSink(this, 1000, 2); //TODO configs
//Input slots //Input slots
int[] inputs = new int[1]; int[] inputs = new int[1];
inputs[0] = 0; inputs[0] = 0;
int[] outputs = new int[1]; int[] outputs = new int[1];
outputs[0] = 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 @Override
public void updateEntity() public void updateEntity()
{ {
super.updateEntity(); super.updateEntity();
energy.updateEntity();
crafter.updateEntity(); crafter.updateEntity();
} }
@ -89,7 +87,6 @@ public class TileLathe extends TileMachineBase implements IWrenchable, IEnergyTi
{ {
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound); inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound); crafter.readFromNBT(tagCompound);
} }
@ -98,23 +95,9 @@ public class TileLathe extends TileMachineBase implements IWrenchable, IEnergyTi
{ {
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound); inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
crafter.writeToNBT(tagCompound); crafter.writeToNBT(tagCompound);
} }
@Override
public void invalidate()
{
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload()
{
energy.onChunkUnload();
super.onChunkUnload();
}
@Override @Override
public int getSizeInventory() { public int getSizeInventory() {
return inventory.getSizeInventory(); return inventory.getSizeInventory();
@ -213,8 +196,29 @@ public class TileLathe extends TileMachineBase implements IWrenchable, IEnergyTi
return 0; 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; package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile; import ic2.api.energy.tile.IEnergyTile;
import ic2.api.recipe.RecipeOutput; import ic2.api.recipe.RecipeOutput;
import ic2.api.recipe.Recipes; import ic2.api.recipe.Recipes;
@ -13,21 +12,21 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.init.ModItems; import techreborn.init.ModItems;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory; import techreborn.util.Inventory;
import techreborn.util.ItemUtils; 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 static int fabricationRate = 2666656;
public int tickTime; public int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(7, "TileMatterFabricator", 64); public Inventory inventory = new Inventory(7, "TileMatterFabricator", 64);
private int amplifier = 0; private int amplifier = 0;
public int progresstime = 0; public int progresstime = 0;
public TileMatterFabricator() { public TileMatterFabricator() {
//TODO configs super(6);
energy = new BasicSink(this, 10000000, 6); //TODO configs
} }
@Override @Override
@ -70,26 +69,12 @@ public class TileMatterFabricator extends TileMachineBase implements IWrenchable
public void readFromNBT(NBTTagCompound tagCompound) { public void readFromNBT(NBTTagCompound tagCompound) {
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound); inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
} }
@Override @Override
public void writeToNBT(NBTTagCompound tagCompound) { public void writeToNBT(NBTTagCompound tagCompound) {
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
inventory.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 @Override
@ -177,7 +162,6 @@ public class TileMatterFabricator extends TileMachineBase implements IWrenchable
@Override @Override
public void updateEntity() { public void updateEntity() {
super.updateEntity(); super.updateEntity();
energy.updateEntity();
if (!super.worldObj.isRemote) { if (!super.worldObj.isRemote) {
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {
@ -185,19 +169,20 @@ public class TileMatterFabricator extends TileMachineBase implements IWrenchable
if (this.amplifier < 100000 && stack != null) { if (this.amplifier < 100000 && stack != null) {
int amp = (int) ((long) (getValue(stack) / 32)); int amp = (int) ((long) (getValue(stack) / 32));
if (ItemUtils.isItemEqual(stack, inventory.getStackInSlot(i), true, true)) { if (ItemUtils.isItemEqual(stack, inventory.getStackInSlot(i), true, true)) {
if(energy.useEnergy(1)){ if(canUseEnergy(1)){
this.amplifier += amp; useEnergy(1);
inventory.decrStackSize(i, 1); this.amplifier += amp;
} inventory.decrStackSize(i, 1);
}
} }
} }
} }
if (this.amplifier > 0) { if (this.amplifier > 0) {
if (this.amplifier > this.energy.getEnergyStored()) { if (this.amplifier > this.getEnergy()) {
this.progresstime += this.energy.getEnergyStored(); this.progresstime += this.getEnergy();
this.amplifier -= this.energy.getEnergyStored(); this.amplifier -= this.getEnergy();
this.decreaseStoredEnergy(this.energy.getEnergyStored(), true); this.decreaseStoredEnergy(this.getEnergy(), true);
} else { } else {
this.progresstime += this.amplifier; this.progresstime += this.amplifier;
this.decreaseStoredEnergy(this.amplifier, true); this.decreaseStoredEnergy(this.amplifier, true);
@ -228,12 +213,12 @@ public class TileMatterFabricator extends TileMachineBase implements IWrenchable
public boolean decreaseStoredEnergy(double aEnergy, boolean aIgnoreTooLessEnergy) { public boolean decreaseStoredEnergy(double aEnergy, boolean aIgnoreTooLessEnergy) {
if (energy.getEnergyStored() - aEnergy < 0 && !aIgnoreTooLessEnergy) { if (this.getEnergy() - aEnergy < 0 && !aIgnoreTooLessEnergy) {
return false; return false;
} else { } else {
energy.setEnergyStored(energy.getEnergyStored() - aEnergy); setEnergy(this.getEnergy() - aEnergy);
if (energy.getEnergyStored() < 0) { if (this.getEnergy() < 0) {
energy.setEnergyStored(0); setEnergy(0);
return false; return false;
} else { } else {
return true; return true;
@ -253,4 +238,28 @@ public class TileMatterFabricator extends TileMachineBase implements IWrenchable
return 0; 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; package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile; import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable; import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -11,32 +10,31 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import techreborn.api.recipe.RecipeCrafter; import techreborn.api.recipe.RecipeCrafter;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory; 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 int tickTime;
public BasicSink energy;
public Inventory inventory = new Inventory(7, "TilePlateCuttingMachine", 64); public Inventory inventory = new Inventory(7, "TilePlateCuttingMachine", 64);
public RecipeCrafter crafter; public RecipeCrafter crafter;
public TilePlateCuttingMachine() public TilePlateCuttingMachine()
{ {
//TODO configs super(2);
energy = new BasicSink(this, 1000, 2); //TODO configs
//Input slots //Input slots
int[] inputs = new int[1]; int[] inputs = new int[1];
inputs[0] = 0; inputs[0] = 0;
int[] outputs = new int[1]; int[] outputs = new int[1];
outputs[0] = 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 @Override
public void updateEntity() public void updateEntity()
{ {
super.updateEntity(); super.updateEntity();
energy.updateEntity();
crafter.updateEntity(); crafter.updateEntity();
} }
@ -89,7 +87,6 @@ public class TilePlateCuttingMachine extends TileMachineBase implements IWrencha
{ {
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound); inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
crafter.readFromNBT(tagCompound); crafter.readFromNBT(tagCompound);
} }
@ -98,7 +95,6 @@ public class TilePlateCuttingMachine extends TileMachineBase implements IWrencha
{ {
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound); inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
crafter.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 @Override
public int getSizeInventory() { public int getSizeInventory() {
@ -213,9 +197,29 @@ public class TilePlateCuttingMachine extends TileMachineBase implements IWrencha
return 0; 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; package techreborn.tiles;
import ic2.api.energy.prefab.BasicSink;
import ic2.api.energy.tile.IEnergyTile; import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable; import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -9,15 +8,16 @@ import net.minecraft.inventory.IInventory;
import net.minecraft.inventory.InventoryCrafting; import net.minecraft.inventory.InventoryCrafting;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
import net.minecraftforge.common.util.ForgeDirection;
import techreborn.api.RollingMachineRecipe; import techreborn.api.RollingMachineRecipe;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.Inventory; import techreborn.util.Inventory;
import techreborn.util.ItemUtils; import techreborn.util.ItemUtils;
//TODO add tick and power bars. //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 Inventory inventory = new Inventory(2, "TileRollingMachine", 64);
public final InventoryCrafting craftMatrix = new InventoryCrafting( public final InventoryCrafting craftMatrix = new InventoryCrafting(
new RollingTileContainer(), 3, 3); new RollingTileContainer(), 3, 3);
@ -29,7 +29,32 @@ public class TileRollingMachine extends TileMachineBase implements IWrenchable,
public int euTick = 5; public int euTick = 5;
private static class RollingTileContainer extends Container { @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 @Override
public boolean canInteractWith(EntityPlayer entityplayer) public boolean canInteractWith(EntityPlayer entityplayer)
@ -41,14 +66,13 @@ public class TileRollingMachine extends TileMachineBase implements IWrenchable,
public TileRollingMachine() public TileRollingMachine()
{ {
energy = new BasicSink(this, 100000, 1); super(1);
} }
@Override @Override
public void updateEntity() public void updateEntity()
{ {
super.updateEntity(); super.updateEntity();
energy.updateEntity();
if (!worldObj.isRemote) if (!worldObj.isRemote)
{ {
currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe( currentRecipe = RollingMachineRecipe.instance.findMatchingRecipe(
@ -95,8 +119,9 @@ public class TileRollingMachine extends TileMachineBase implements IWrenchable,
} }
if (currentRecipe != null) if (currentRecipe != null)
{ {
if (energy.canUseEnergy(euTick) && tickTime < runTime) if (canUseEnergy(euTick) && tickTime < runTime)
{ {
useEnergy(euTick);
tickTime++; tickTime++;
} }
} }
@ -172,7 +197,6 @@ public class TileRollingMachine extends TileMachineBase implements IWrenchable,
{ {
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound); inventory.readFromNBT(tagCompound);
energy.readFromNBT(tagCompound);
ItemUtils.readInvFromNBT(craftMatrix, "Crafting", tagCompound); ItemUtils.readInvFromNBT(craftMatrix, "Crafting", tagCompound);
isRunning = tagCompound.getBoolean("isRunning"); isRunning = tagCompound.getBoolean("isRunning");
tickTime = tagCompound.getInteger("tickTime"); tickTime = tagCompound.getInteger("tickTime");
@ -183,7 +207,6 @@ public class TileRollingMachine extends TileMachineBase implements IWrenchable,
{ {
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound); inventory.writeToNBT(tagCompound);
energy.writeToNBT(tagCompound);
ItemUtils.writeInvToNBT(craftMatrix, "Crafting", tagCompound); ItemUtils.writeInvToNBT(craftMatrix, "Crafting", tagCompound);
writeUpdateToNBT(tagCompound); writeUpdateToNBT(tagCompound);
} }
@ -197,13 +220,11 @@ public class TileRollingMachine extends TileMachineBase implements IWrenchable,
@Override @Override
public void invalidate() public void invalidate()
{ {
energy.invalidate();
super.invalidate(); super.invalidate();
} }
@Override @Override
public void onChunkUnload() public void onChunkUnload()
{ {
energy.onChunkUnload();
super.onChunkUnload(); super.onChunkUnload();
} }

View file

@ -12,12 +12,7 @@ import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.*;
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 techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.util.FluidUtils; import techreborn.util.FluidUtils;

View file

@ -1,6 +1,5 @@
package techreborn.tiles; package techreborn.tiles;
import ic2.api.energy.prefab.BasicSource;
import ic2.api.energy.tile.IEnergyTile; import ic2.api.energy.tile.IEnergyTile;
import ic2.api.tile.IWrenchable; import ic2.api.tile.IWrenchable;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
@ -10,34 +9,26 @@ import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.network.NetworkManager; import net.minecraft.network.NetworkManager;
import net.minecraft.network.Packet; import net.minecraft.network.Packet;
import net.minecraft.network.play.server.S35PacketUpdateTileEntity; import net.minecraft.network.play.server.S35PacketUpdateTileEntity;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.util.ForgeDirection; import net.minecraftforge.common.util.ForgeDirection;
import net.minecraftforge.fluids.Fluid; import net.minecraftforge.fluids.*;
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 techreborn.config.ConfigTechReborn; import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks; import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.FluidUtils; import techreborn.util.FluidUtils;
import techreborn.util.Inventory; import techreborn.util.Inventory;
import techreborn.util.Tank; import techreborn.util.Tank;
public class TileThermalGenerator extends TileEntity implements IWrenchable, public class TileThermalGenerator extends TilePowerAcceptor implements IWrenchable,
IFluidHandler, IInventory, IEnergyTile { IFluidHandler, IInventory, IEnergyTile {
public Tank tank = new Tank("TileThermalGenerator", public Tank tank = new Tank("TileThermalGenerator",
FluidContainerRegistry.BUCKET_VOLUME * 10, this); FluidContainerRegistry.BUCKET_VOLUME * 10, this);
public Inventory inventory = new Inventory(3, "TileThermalGenerator", 64); public Inventory inventory = new Inventory(3, "TileThermalGenerator", 64);
public BasicSource energySource;
public static final int euTick = ConfigTechReborn.ThermalGenertaorOutput; public static final int euTick = ConfigTechReborn.ThermalGenertaorOutput;
public TileThermalGenerator() public TileThermalGenerator()
{ {
this.energySource = new BasicSource(this, super(ConfigTechReborn.ThermalGeneratorTier);
ConfigTechReborn.ThermalGeneratorCharge,
ConfigTechReborn.ThermalGeneratorTier);
} }
@Override @Override
@ -135,7 +126,6 @@ public class TileThermalGenerator extends TileEntity implements IWrenchable,
super.readFromNBT(tagCompound); super.readFromNBT(tagCompound);
tank.readFromNBT(tagCompound); tank.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound); inventory.readFromNBT(tagCompound);
energySource.readFromNBT(tagCompound);
} }
@Override @Override
@ -144,7 +134,6 @@ public class TileThermalGenerator extends TileEntity implements IWrenchable,
super.writeToNBT(tagCompound); super.writeToNBT(tagCompound);
tank.writeToNBT(tagCompound); tank.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound); inventory.writeToNBT(tagCompound);
energySource.writeToNBT(tagCompound);
} }
public Packet getDescriptionPacket() public Packet getDescriptionPacket()
@ -170,12 +159,11 @@ public class TileThermalGenerator extends TileEntity implements IWrenchable,
super.updateEntity(); super.updateEntity();
if(!worldObj.isRemote) if(!worldObj.isRemote)
FluidUtils.drainContainers(this, inventory, 0, 1); FluidUtils.drainContainers(this, inventory, 0, 1);
energySource.updateEntity();
if (tank.getFluidAmount() > 0 if (tank.getFluidAmount() > 0
&& energySource.getCapacity() - energySource.getEnergyStored() >= euTick) && getMaxPower() - getEnergy() >= euTick)
{ {
tank.drain(1, true); tank.drain(1, true);
energySource.addEnergy(euTick); addEnergy(euTick);
} }
if (tank.getFluidType() != null && getStackInSlot(2) == null) if (tank.getFluidType() != null && getStackInSlot(2) == null)
{ {
@ -259,18 +247,28 @@ public class TileThermalGenerator extends TileEntity implements IWrenchable,
return inventory.isItemValidForSlot(p_94041_1_, p_94041_2_); return inventory.isItemValidForSlot(p_94041_1_, p_94041_2_);
} }
@Override @Override
public void onChunkUnload() public double getMaxPower() {
{ return ConfigTechReborn.ThermalGeneratorCharge;
energySource.onChunkUnload(); }
super.onChunkUnload();
}
@Override @Override
public void invalidate() public boolean canAcceptEnergy(ForgeDirection direction) {
{ return false;
energySource.invalidate(); }
super.invalidate();
}
@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 com.google.gson.reflect.TypeToken;
import cpw.mods.fml.common.eventhandler.EventPriority; import cpw.mods.fml.common.eventhandler.EventPriority;
import cpw.mods.fml.common.eventhandler.SubscribeEvent; import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.world.World; import net.minecraft.world.World;
import net.minecraft.world.storage.ISaveHandler; import net.minecraft.world.storage.ISaveHandler;
import net.minecraftforge.event.world.WorldEvent; import net.minecraftforge.event.world.WorldEvent;
import techreborn.packets.PacketSendIDSUManager; import techreborn.packets.PacketSendIDSUManager;
import java.io.BufferedReader; import java.io.*;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.lang.reflect.Type; import java.lang.reflect.Type;
import java.util.HashMap; import java.util.HashMap;
import java.util.TreeMap; import java.util.TreeMap;

View file

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