Fixes #171
This commit is contained in:
parent
e257c424e2
commit
3a9c469965
3 changed files with 79 additions and 58 deletions
|
@ -1,35 +1,33 @@
|
||||||
package techreborn.tiles;
|
package techreborn.tiles;
|
||||||
|
|
||||||
import ic2.api.energy.prefab.BasicSource;
|
|
||||||
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.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.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;
|
||||||
|
|
||||||
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 Inventory inventory = new Inventory(3, "TileAlloySmelter", 64);
|
||||||
public static final int euTick = ConfigTechReborn.DragoneggsiphonerOutput;
|
public static final int euTick = ConfigTechReborn.DragoneggsiphonerOutput;
|
||||||
|
|
||||||
public TileDragonEggSiphoner() {
|
public TileDragonEggSiphoner() {
|
||||||
energy = new BasicSource(this, 1000, 2);
|
super(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateEntity() {
|
public void updateEntity() {
|
||||||
super.updateEntity();
|
super.updateEntity();
|
||||||
energy.updateEntity();
|
|
||||||
|
|
||||||
if (!worldObj.isRemote) {
|
if (!worldObj.isRemote) {
|
||||||
if (worldObj.getBlock(xCoord, yCoord + 1, zCoord) == Blocks.dragon_egg) {
|
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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void invalidate() {
|
|
||||||
energy.invalidate();
|
|
||||||
super.invalidate();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onChunkUnload() {
|
|
||||||
energy.onChunkUnload();
|
|
||||||
super.onChunkUnload();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
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
|
@Override
|
||||||
|
@ -156,4 +140,28 @@ public class TileDragonEggSiphoner extends TileMachineBase implements IWrenchabl
|
||||||
return inventory.isItemValidForSlot(slot, stack);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package techreborn.tiles;
|
package techreborn.tiles;
|
||||||
|
|
||||||
import ic2.api.energy.prefab.BasicSource;
|
|
||||||
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;
|
||||||
|
@ -10,11 +8,11 @@ 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.*;
|
import net.minecraftforge.fluids.*;
|
||||||
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;
|
||||||
|
@ -22,13 +20,12 @@ import techreborn.util.Tank;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class TileGasTurbine extends TileEntity implements IWrenchable,
|
public class TileGasTurbine extends TilePowerAcceptor implements IWrenchable,
|
||||||
IFluidHandler, IInventory, IEnergyTile {
|
IFluidHandler, IInventory {
|
||||||
|
|
||||||
public Tank tank = new Tank("TileGasTurbine",
|
public Tank tank = new Tank("TileGasTurbine",
|
||||||
FluidContainerRegistry.BUCKET_VOLUME * 10, this);
|
FluidContainerRegistry.BUCKET_VOLUME * 10, this);
|
||||||
public Inventory inventory = new Inventory(3, "TileGasTurbine", 64);
|
public Inventory inventory = new Inventory(3, "TileGasTurbine", 64);
|
||||||
public BasicSource energySource;
|
|
||||||
|
|
||||||
//TODO: run this off config
|
//TODO: run this off config
|
||||||
public static final int euTick = 16;
|
public static final int euTick = 16;
|
||||||
|
@ -39,10 +36,8 @@ public class TileGasTurbine extends TileEntity implements IWrenchable,
|
||||||
double pendingWithdraw = 0.0;
|
double pendingWithdraw = 0.0;
|
||||||
|
|
||||||
public TileGasTurbine() {
|
public TileGasTurbine() {
|
||||||
|
super(ConfigTechReborn.ThermalGeneratorTier);
|
||||||
//TODO: fix this to have Gas Turbine generator values
|
//TODO: fix this to have Gas Turbine generator values
|
||||||
this.energySource = new BasicSource(this,
|
|
||||||
ConfigTechReborn.ThermalGeneratorCharge,
|
|
||||||
ConfigTechReborn.ThermalGeneratorTier);
|
|
||||||
|
|
||||||
fluids.put("fluidhydrogen", 15000);
|
fluids.put("fluidhydrogen", 15000);
|
||||||
fluids.put("fluidmethane", 45000);
|
fluids.put("fluidmethane", 45000);
|
||||||
|
@ -125,7 +120,6 @@ public class TileGasTurbine 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
|
||||||
|
@ -133,7 +127,6 @@ public class TileGasTurbine 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() {
|
||||||
|
@ -159,9 +152,8 @@ public class TileGasTurbine extends TileEntity implements IWrenchable,
|
||||||
tank.compareAndUpdate();
|
tank.compareAndUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
energySource.updateEntity();
|
|
||||||
if (tank.getFluidAmount() > 0
|
if (tank.getFluidAmount() > 0
|
||||||
&& energySource.getCapacity() - energySource.getEnergyStored() >= euTick) {
|
&& getMaxPower() - getEnergy() >= euTick) {
|
||||||
Integer euPerBucket = fluids.get(tank.getFluidType().getName());
|
Integer euPerBucket = fluids.get(tank.getFluidType().getName());
|
||||||
//float totalTicks = (float)euPerBucket / 8f; //x eu per bucket / 8 eu per tick
|
//float totalTicks = (float)euPerBucket / 8f; //x eu per bucket / 8 eu per tick
|
||||||
//float millibucketsPerTick = 1000f / totalTicks;
|
//float millibucketsPerTick = 1000f / totalTicks;
|
||||||
|
@ -172,7 +164,7 @@ public class TileGasTurbine extends TileEntity implements IWrenchable,
|
||||||
pendingWithdraw -= currentWithdraw;
|
pendingWithdraw -= currentWithdraw;
|
||||||
|
|
||||||
tank.drain(currentWithdraw, true);
|
tank.drain(currentWithdraw, true);
|
||||||
energySource.addEnergy(euTick);
|
addEnergy(euTick);
|
||||||
}
|
}
|
||||||
if (tank.getFluidType() != null && getStackInSlot(2) == null) {
|
if (tank.getFluidType() != null && getStackInSlot(2) == null) {
|
||||||
inventory.setInventorySlotContents(2, new ItemStack(tank
|
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_);
|
return inventory.isItemValidForSlot(p_94041_1_, p_94041_2_);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChunkUnload() {
|
public double getMaxPower() {
|
||||||
energySource.onChunkUnload();
|
return ConfigTechReborn.ThermalGeneratorCharge;
|
||||||
super.onChunkUnload();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invalidate() {
|
public boolean canAcceptEnergy(ForgeDirection direction) {
|
||||||
energySource.invalidate();
|
return false;
|
||||||
super.invalidate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canProvideEnergy(ForgeDirection direction) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getMaxOutput() {
|
||||||
|
return euTick;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getMaxInput() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
package techreborn.tiles;
|
package techreborn.tiles;
|
||||||
|
|
||||||
import ic2.api.energy.prefab.BasicSource;
|
|
||||||
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;
|
||||||
|
@ -10,11 +8,11 @@ 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.*;
|
import net.minecraftforge.fluids.*;
|
||||||
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;
|
||||||
|
@ -22,13 +20,12 @@ import techreborn.util.Tank;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
public class TileSemifluidGenerator extends TileEntity implements IWrenchable,
|
public class TileSemifluidGenerator extends TilePowerAcceptor implements IWrenchable,
|
||||||
IFluidHandler, IInventory, IEnergyTile {
|
IFluidHandler, IInventory{
|
||||||
|
|
||||||
public Tank tank = new Tank("TileSemifluidGenerator",
|
public Tank tank = new Tank("TileSemifluidGenerator",
|
||||||
FluidContainerRegistry.BUCKET_VOLUME * 10, this);
|
FluidContainerRegistry.BUCKET_VOLUME * 10, this);
|
||||||
public Inventory inventory = new Inventory(3, "TileSemifluidGenerator", 64);
|
public Inventory inventory = new Inventory(3, "TileSemifluidGenerator", 64);
|
||||||
public BasicSource energySource;
|
|
||||||
|
|
||||||
//TODO: run this off config
|
//TODO: run this off config
|
||||||
public static final int euTick = 8;
|
public static final int euTick = 8;
|
||||||
|
@ -39,6 +36,7 @@ public class TileSemifluidGenerator extends TileEntity implements IWrenchable,
|
||||||
double pendingWithdraw = 0.0;
|
double pendingWithdraw = 0.0;
|
||||||
|
|
||||||
public TileSemifluidGenerator() {
|
public TileSemifluidGenerator() {
|
||||||
|
super(ConfigTechReborn.ThermalGeneratorTier);
|
||||||
//TODO: fix this to have SemiFluid generator values
|
//TODO: fix this to have SemiFluid generator values
|
||||||
this.energySource = new BasicSource(this,
|
this.energySource = new BasicSource(this,
|
||||||
ConfigTechReborn.ThermalGeneratorCharge,
|
ConfigTechReborn.ThermalGeneratorCharge,
|
||||||
|
@ -131,7 +129,6 @@ public class TileSemifluidGenerator 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
|
||||||
|
@ -139,7 +136,6 @@ public class TileSemifluidGenerator 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() {
|
||||||
|
@ -162,9 +158,9 @@ public class TileSemifluidGenerator 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) {
|
||||||
Integer euPerBucket = fluids.get(tank.getFluidType().getName());
|
Integer euPerBucket = fluids.get(tank.getFluidType().getName());
|
||||||
//float totalTicks = (float)euPerBucket / 8f; //x eu per bucket / 8 eu per tick
|
//float totalTicks = (float)euPerBucket / 8f; //x eu per bucket / 8 eu per tick
|
||||||
//float millibucketsPerTick = 1000f / totalTicks;
|
//float millibucketsPerTick = 1000f / totalTicks;
|
||||||
|
@ -175,7 +171,7 @@ public class TileSemifluidGenerator extends TileEntity implements IWrenchable,
|
||||||
pendingWithdraw -= currentWithdraw;
|
pendingWithdraw -= currentWithdraw;
|
||||||
|
|
||||||
tank.drain(currentWithdraw, true);
|
tank.drain(currentWithdraw, true);
|
||||||
energySource.addEnergy(euTick);
|
addEnergy(euTick);
|
||||||
}
|
}
|
||||||
if (tank.getFluidType() != null && getStackInSlot(2) == null) {
|
if (tank.getFluidType() != null && getStackInSlot(2) == null) {
|
||||||
inventory.setInventorySlotContents(2, new ItemStack(tank
|
inventory.setInventorySlotContents(2, new ItemStack(tank
|
||||||
|
@ -246,15 +242,27 @@ public class TileSemifluidGenerator extends TileEntity implements IWrenchable,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onChunkUnload() {
|
public double getMaxPower() {
|
||||||
energySource.onChunkUnload();
|
return ConfigTechReborn.ThermalGeneratorCharge;
|
||||||
super.onChunkUnload();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void invalidate() {
|
public boolean canAcceptEnergy(ForgeDirection direction) {
|
||||||
energySource.invalidate();
|
return false;
|
||||||
super.invalidate();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canProvideEnergy(ForgeDirection direction) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getMaxOutput() {
|
||||||
|
return euTick;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getMaxInput() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue