This commit is contained in:
Modmuss50 2015-10-07 08:19:39 +01:00
parent e257c424e2
commit 3a9c469965
3 changed files with 79 additions and 58 deletions

View file

@ -1,35 +1,33 @@
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.inventory.IInventory;
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;
import techreborn.util.Inventory;
public class TileDragonEggSiphoner extends TileMachineBase implements IWrenchable, IEnergyTile, IInventory {
public class TileDragonEggSiphoner extends TilePowerAcceptor implements IWrenchable, IInventory {
public BasicSource energy;
public Inventory inventory = new Inventory(3, "TileAlloySmelter", 64);
public static final int euTick = ConfigTechReborn.DragoneggsiphonerOutput;
public TileDragonEggSiphoner() {
energy = new BasicSource(this, 1000, 2);
super(2);
}
@Override
public void updateEntity() {
super.updateEntity();
energy.updateEntity();
if (!worldObj.isRemote) {
if (worldObj.getBlock(xCoord, yCoord + 1, zCoord) == Blocks.dragon_egg) {
energy.addEnergy(euTick);
addEnergy(euTick);
}
}
}
@ -70,30 +68,16 @@ public class TileDragonEggSiphoner extends TileMachineBase implements IWrenchabl
return false;
}
@Override
public void invalidate() {
energy.invalidate();
super.invalidate();
}
@Override
public void onChunkUnload() {
energy.onChunkUnload();
super.onChunkUnload();
}
@Override
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
@ -156,4 +140,28 @@ public class TileDragonEggSiphoner extends TileMachineBase implements IWrenchabl
return inventory.isItemValidForSlot(slot, stack);
}
@Override
public double getMaxPower() {
return 1000;
}
@Override
public boolean canAcceptEnergy(ForgeDirection direction) {
return false;
}
@Override
public boolean canProvideEnergy(ForgeDirection direction) {
return true;
}
@Override
public double getMaxOutput() {
return euTick;
}
@Override
public double getMaxInput() {
return 0;
}
}

View file

@ -1,7 +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;
import net.minecraft.inventory.IInventory;
@ -10,11 +8,11 @@ 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.*;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.FluidUtils;
import techreborn.util.Inventory;
import techreborn.util.Tank;
@ -22,13 +20,12 @@ import techreborn.util.Tank;
import java.util.HashMap;
import java.util.Map;
public class TileGasTurbine extends TileEntity implements IWrenchable,
IFluidHandler, IInventory, IEnergyTile {
public class TileGasTurbine extends TilePowerAcceptor implements IWrenchable,
IFluidHandler, IInventory {
public Tank tank = new Tank("TileGasTurbine",
FluidContainerRegistry.BUCKET_VOLUME * 10, this);
public Inventory inventory = new Inventory(3, "TileGasTurbine", 64);
public BasicSource energySource;
//TODO: run this off config
public static final int euTick = 16;
@ -39,10 +36,8 @@ public class TileGasTurbine extends TileEntity implements IWrenchable,
double pendingWithdraw = 0.0;
public TileGasTurbine() {
super(ConfigTechReborn.ThermalGeneratorTier);
//TODO: fix this to have Gas Turbine generator values
this.energySource = new BasicSource(this,
ConfigTechReborn.ThermalGeneratorCharge,
ConfigTechReborn.ThermalGeneratorTier);
fluids.put("fluidhydrogen", 15000);
fluids.put("fluidmethane", 45000);
@ -125,7 +120,6 @@ public class TileGasTurbine extends TileEntity implements IWrenchable,
super.readFromNBT(tagCompound);
tank.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energySource.readFromNBT(tagCompound);
}
@Override
@ -133,7 +127,6 @@ public class TileGasTurbine extends TileEntity implements IWrenchable,
super.writeToNBT(tagCompound);
tank.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energySource.writeToNBT(tagCompound);
}
public Packet getDescriptionPacket() {
@ -159,9 +152,8 @@ public class TileGasTurbine extends TileEntity implements IWrenchable,
tank.compareAndUpdate();
}
energySource.updateEntity();
if (tank.getFluidAmount() > 0
&& energySource.getCapacity() - energySource.getEnergyStored() >= euTick) {
&& getMaxPower() - getEnergy() >= euTick) {
Integer euPerBucket = fluids.get(tank.getFluidType().getName());
//float totalTicks = (float)euPerBucket / 8f; //x eu per bucket / 8 eu per tick
//float millibucketsPerTick = 1000f / totalTicks;
@ -172,7 +164,7 @@ public class TileGasTurbine extends TileEntity implements IWrenchable,
pendingWithdraw -= currentWithdraw;
tank.drain(currentWithdraw, true);
energySource.addEnergy(euTick);
addEnergy(euTick);
}
if (tank.getFluidType() != null && getStackInSlot(2) == null) {
inventory.setInventorySlotContents(2, new ItemStack(tank
@ -242,16 +234,29 @@ public class TileGasTurbine extends TileEntity implements IWrenchable,
return inventory.isItemValidForSlot(p_94041_1_, p_94041_2_);
}
@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 euTick;
}
@Override
public double getMaxInput() {
return 0;
}
}

View file

@ -1,7 +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;
import net.minecraft.inventory.IInventory;
@ -10,11 +8,11 @@ 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.*;
import techreborn.config.ConfigTechReborn;
import techreborn.init.ModBlocks;
import techreborn.powerSystem.TilePowerAcceptor;
import techreborn.util.FluidUtils;
import techreborn.util.Inventory;
import techreborn.util.Tank;
@ -22,13 +20,12 @@ import techreborn.util.Tank;
import java.util.HashMap;
import java.util.Map;
public class TileSemifluidGenerator extends TileEntity implements IWrenchable,
IFluidHandler, IInventory, IEnergyTile {
public class TileSemifluidGenerator extends TilePowerAcceptor implements IWrenchable,
IFluidHandler, IInventory{
public Tank tank = new Tank("TileSemifluidGenerator",
FluidContainerRegistry.BUCKET_VOLUME * 10, this);
public Inventory inventory = new Inventory(3, "TileSemifluidGenerator", 64);
public BasicSource energySource;
//TODO: run this off config
public static final int euTick = 8;
@ -39,6 +36,7 @@ public class TileSemifluidGenerator extends TileEntity implements IWrenchable,
double pendingWithdraw = 0.0;
public TileSemifluidGenerator() {
super(ConfigTechReborn.ThermalGeneratorTier);
//TODO: fix this to have SemiFluid generator values
this.energySource = new BasicSource(this,
ConfigTechReborn.ThermalGeneratorCharge,
@ -131,7 +129,6 @@ public class TileSemifluidGenerator extends TileEntity implements IWrenchable,
super.readFromNBT(tagCompound);
tank.readFromNBT(tagCompound);
inventory.readFromNBT(tagCompound);
energySource.readFromNBT(tagCompound);
}
@Override
@ -139,7 +136,6 @@ public class TileSemifluidGenerator extends TileEntity implements IWrenchable,
super.writeToNBT(tagCompound);
tank.writeToNBT(tagCompound);
inventory.writeToNBT(tagCompound);
energySource.writeToNBT(tagCompound);
}
public Packet getDescriptionPacket() {
@ -162,9 +158,9 @@ public class TileSemifluidGenerator 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) {
Integer euPerBucket = fluids.get(tank.getFluidType().getName());
//float totalTicks = (float)euPerBucket / 8f; //x eu per bucket / 8 eu per tick
//float millibucketsPerTick = 1000f / totalTicks;
@ -175,7 +171,7 @@ public class TileSemifluidGenerator extends TileEntity implements IWrenchable,
pendingWithdraw -= currentWithdraw;
tank.drain(currentWithdraw, true);
energySource.addEnergy(euTick);
addEnergy(euTick);
}
if (tank.getFluidType() != null && getStackInSlot(2) == null) {
inventory.setInventorySlotContents(2, new ItemStack(tank
@ -246,15 +242,27 @@ public class TileSemifluidGenerator 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 euTick;
}
@Override
public double getMaxInput() {
return 0;
}
}