Added pump
This commit is contained in:
parent
58371903d3
commit
45e31c1aef
4 changed files with 213 additions and 45 deletions
25
src/main/java/techreborn/blocks/BlockPump.java
Normal file
25
src/main/java/techreborn/blocks/BlockPump.java
Normal file
|
@ -0,0 +1,25 @@
|
||||||
|
package techreborn.blocks;
|
||||||
|
|
||||||
|
import net.minecraft.block.material.Material;
|
||||||
|
import net.minecraft.tileentity.TileEntity;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import reborncore.common.BaseTileBlock;
|
||||||
|
import techreborn.client.TechRebornCreativeTab;
|
||||||
|
import techreborn.tiles.TilePump;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by modmuss50 on 08/05/2016.
|
||||||
|
*/
|
||||||
|
public class BlockPump extends BaseTileBlock {
|
||||||
|
public BlockPump() {
|
||||||
|
super(Material.IRON);
|
||||||
|
setHardness(2f);
|
||||||
|
setUnlocalizedName("techreborn.pump");
|
||||||
|
setCreativeTab(TechRebornCreativeTab.instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public TileEntity createNewTileEntity(World worldIn, int meta) {
|
||||||
|
return new TilePump();
|
||||||
|
}
|
||||||
|
}
|
|
@ -33,6 +33,7 @@ public class ConfigTechReborn
|
||||||
public static int FarmEu;
|
public static int FarmEu;
|
||||||
public static int AesuMaxOutput;
|
public static int AesuMaxOutput;
|
||||||
public static int AesuMaxStorage;
|
public static int AesuMaxStorage;
|
||||||
|
public static int pumpExtractEU;
|
||||||
|
|
||||||
public static int LVTransformerMaxInput;
|
public static int LVTransformerMaxInput;
|
||||||
public static int LVTransformerMaxOutput;
|
public static int LVTransformerMaxOutput;
|
||||||
|
@ -213,6 +214,9 @@ public class ConfigTechReborn
|
||||||
AesuMaxStorage = config.get(CATEGORY_POWER, "AESU Max Storage", 30, "Set the max Storage for the AESU")
|
AesuMaxStorage = config.get(CATEGORY_POWER, "AESU Max Storage", 30, "Set the max Storage for the AESU")
|
||||||
.getInt();
|
.getInt();
|
||||||
|
|
||||||
|
pumpExtractEU = config.get(CATEGORY_POWER, "Pump extract eu", 20, "How mutch eu should the pump use to extract the fluid")
|
||||||
|
.getInt();
|
||||||
|
|
||||||
//Transformers
|
//Transformers
|
||||||
LVTransformerMaxInput = config.get(CATEGORY_POWER, "LV Transformer Max Input", 128, "Set the max input for the LV Trasnformer")
|
LVTransformerMaxInput = config.get(CATEGORY_POWER, "LV Transformer Max Input", 128, "Set the max input for the LV Trasnformer")
|
||||||
.getInt();
|
.getInt();
|
||||||
|
|
|
@ -10,28 +10,7 @@ import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||||
import net.minecraftforge.oredict.OreDictionary;
|
import net.minecraftforge.oredict.OreDictionary;
|
||||||
import reborncore.common.tile.TileMachineBase;
|
import reborncore.common.tile.TileMachineBase;
|
||||||
import techreborn.Core;
|
import techreborn.Core;
|
||||||
import techreborn.blocks.BlockComputerCube;
|
import techreborn.blocks.*;
|
||||||
import techreborn.blocks.BlockDigitalChest;
|
|
||||||
import techreborn.blocks.BlockElectricCraftingTable;
|
|
||||||
import techreborn.blocks.BlockFusionCoil;
|
|
||||||
import techreborn.blocks.BlockFusionControlComputer;
|
|
||||||
import techreborn.blocks.BlockIronFence;
|
|
||||||
import techreborn.blocks.BlockMachineCasing;
|
|
||||||
import techreborn.blocks.BlockMachineFrame;
|
|
||||||
import techreborn.blocks.BlockNuke;
|
|
||||||
import techreborn.blocks.BlockOre;
|
|
||||||
import techreborn.blocks.BlockOre2;
|
|
||||||
import techreborn.blocks.BlockPlayerDetector;
|
|
||||||
import techreborn.blocks.BlockQuantumChest;
|
|
||||||
import techreborn.blocks.BlockQuantumTank;
|
|
||||||
import techreborn.blocks.BlockReinforcedGlass;
|
|
||||||
import techreborn.blocks.BlockRubberLeaves;
|
|
||||||
import techreborn.blocks.BlockRubberLog;
|
|
||||||
import techreborn.blocks.BlockRubberPlank;
|
|
||||||
import techreborn.blocks.BlockRubberSapling;
|
|
||||||
import techreborn.blocks.BlockStorage;
|
|
||||||
import techreborn.blocks.BlockStorage2;
|
|
||||||
import techreborn.blocks.BlockSupercondensator;
|
|
||||||
import techreborn.blocks.advanced_machine.BlockBlastFurnace;
|
import techreborn.blocks.advanced_machine.BlockBlastFurnace;
|
||||||
import techreborn.blocks.advanced_machine.BlockCentrifuge;
|
import techreborn.blocks.advanced_machine.BlockCentrifuge;
|
||||||
import techreborn.blocks.advanced_machine.BlockDistillationTower;
|
import techreborn.blocks.advanced_machine.BlockDistillationTower;
|
||||||
|
@ -91,29 +70,7 @@ import techreborn.itemblocks.ItemBlockQuantumTank;
|
||||||
import techreborn.itemblocks.ItemBlockRubberSapling;
|
import techreborn.itemblocks.ItemBlockRubberSapling;
|
||||||
import techreborn.itemblocks.ItemBlockStorage;
|
import techreborn.itemblocks.ItemBlockStorage;
|
||||||
import techreborn.itemblocks.ItemBlockStorage2;
|
import techreborn.itemblocks.ItemBlockStorage2;
|
||||||
import techreborn.tiles.TileAesu;
|
import techreborn.tiles.*;
|
||||||
import techreborn.tiles.TileAlloyFurnace;
|
|
||||||
import techreborn.tiles.TileAlloySmelter;
|
|
||||||
import techreborn.tiles.TileAssemblingMachine;
|
|
||||||
import techreborn.tiles.TileBlastFurnace;
|
|
||||||
import techreborn.tiles.TileCentrifuge;
|
|
||||||
import techreborn.tiles.TileChargeBench;
|
|
||||||
import techreborn.tiles.TileChemicalReactor;
|
|
||||||
import techreborn.tiles.TileChunkLoader;
|
|
||||||
import techreborn.tiles.TileDigitalChest;
|
|
||||||
import techreborn.tiles.TileImplosionCompressor;
|
|
||||||
import techreborn.tiles.TileIndustrialElectrolyzer;
|
|
||||||
import techreborn.tiles.TileIndustrialGrinder;
|
|
||||||
import techreborn.tiles.TileIndustrialSawmill;
|
|
||||||
import techreborn.tiles.TileIronFurnace;
|
|
||||||
import techreborn.tiles.TileMachineCasing;
|
|
||||||
import techreborn.tiles.TileMatterFabricator;
|
|
||||||
import techreborn.tiles.TilePlayerDectector;
|
|
||||||
import techreborn.tiles.TileQuantumChest;
|
|
||||||
import techreborn.tiles.TileQuantumTank;
|
|
||||||
import techreborn.tiles.TileRollingMachine;
|
|
||||||
import techreborn.tiles.TileScrapboxinator;
|
|
||||||
import techreborn.tiles.TileVacuumFreezer;
|
|
||||||
import techreborn.tiles.fusionReactor.TileEntityFusionController;
|
import techreborn.tiles.fusionReactor.TileEntityFusionController;
|
||||||
import techreborn.tiles.generator.TileDieselGenerator;
|
import techreborn.tiles.generator.TileDieselGenerator;
|
||||||
import techreborn.tiles.generator.TileDragonEggSiphoner;
|
import techreborn.tiles.generator.TileDragonEggSiphoner;
|
||||||
|
@ -201,6 +158,7 @@ public class ModBlocks
|
||||||
public static Block lvt;
|
public static Block lvt;
|
||||||
public static Block mvt;
|
public static Block mvt;
|
||||||
public static Block hvt;
|
public static Block hvt;
|
||||||
|
public static Block pump;
|
||||||
|
|
||||||
public static BlockOre ore;
|
public static BlockOre ore;
|
||||||
public static BlockOre2 ore2;
|
public static BlockOre2 ore2;
|
||||||
|
@ -466,6 +424,10 @@ public class ModBlocks
|
||||||
registerBlock(hvt, "hvt");
|
registerBlock(hvt, "hvt");
|
||||||
GameRegistry.registerTileEntity(TileHVTransformer.class, "TileHVTransformer");
|
GameRegistry.registerTileEntity(TileHVTransformer.class, "TileHVTransformer");
|
||||||
|
|
||||||
|
pump = new BlockPump();
|
||||||
|
registerBlock(pump, "pump");
|
||||||
|
GameRegistry.registerTileEntity(TilePump.class, "TilePump");
|
||||||
|
|
||||||
ironFurnace = new BlockIronFurnace();
|
ironFurnace = new BlockIronFurnace();
|
||||||
registerBlock(ironFurnace, "ironfurnace");
|
registerBlock(ironFurnace, "ironfurnace");
|
||||||
GameRegistry.registerTileEntity(TileIronFurnace.class, "TileIronFurnaceTR");
|
GameRegistry.registerTileEntity(TileIronFurnace.class, "TileIronFurnaceTR");
|
||||||
|
|
177
src/main/java/techreborn/tiles/TilePump.java
Normal file
177
src/main/java/techreborn/tiles/TilePump.java
Normal file
|
@ -0,0 +1,177 @@
|
||||||
|
package techreborn.tiles;
|
||||||
|
|
||||||
|
import com.mojang.realmsclient.gui.ChatFormatting;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.block.BlockLiquid;
|
||||||
|
import net.minecraft.block.state.IBlockState;
|
||||||
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
|
import net.minecraft.util.EnumFacing;
|
||||||
|
import net.minecraft.util.math.BlockPos;
|
||||||
|
import net.minecraft.world.World;
|
||||||
|
import net.minecraftforge.fluids.*;
|
||||||
|
import reborncore.api.power.EnumPowerTier;
|
||||||
|
import reborncore.common.powerSystem.PowerSystem;
|
||||||
|
import reborncore.common.powerSystem.TilePowerAcceptor;
|
||||||
|
import reborncore.common.util.Tank;
|
||||||
|
import techreborn.config.ConfigTechReborn;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by modmuss50 on 08/05/2016.
|
||||||
|
*/
|
||||||
|
public class TilePump extends TilePowerAcceptor implements IFluidHandler {
|
||||||
|
|
||||||
|
public Tank tank = new Tank("TilePump", 10000, this);
|
||||||
|
|
||||||
|
public TilePump() {
|
||||||
|
super(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateEntity() {
|
||||||
|
super.updateEntity();
|
||||||
|
if(!worldObj.isRemote && worldObj.getTotalWorldTime() % (20 * 5) == 0 && !tank.isFull() && tank.getCapacity() - tank.getFluidAmount() >= 1000 && canUseEnergy(ConfigTechReborn.pumpExtractEU)){
|
||||||
|
FluidStack fluidStack = drainBlock(worldObj, pos.down(), false);
|
||||||
|
if(fluidStack != null){
|
||||||
|
tank.fill(drainBlock(worldObj, pos.down(), true), true);
|
||||||
|
useEnergy(ConfigTechReborn.pumpExtractEU);
|
||||||
|
}
|
||||||
|
tank.compareAndUpdate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addInfo(List<String> info, boolean isRealTile) {
|
||||||
|
super.addInfo(info, isRealTile);
|
||||||
|
info.add(ChatFormatting.LIGHT_PURPLE + "Eu per extract " + ChatFormatting.GREEN
|
||||||
|
+ PowerSystem.getLocaliszedPower(ConfigTechReborn.pumpExtractEU));
|
||||||
|
info.add(ChatFormatting.LIGHT_PURPLE + "Speed: " + ChatFormatting.GREEN
|
||||||
|
+ "1000mb/5 sec");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FluidStack drainBlock(World world, BlockPos pos, boolean doDrain) {
|
||||||
|
IBlockState state = world.getBlockState(pos);
|
||||||
|
Block block = state.getBlock();
|
||||||
|
Fluid fluid = FluidRegistry.lookupFluidForBlock(block);
|
||||||
|
|
||||||
|
if (fluid != null && FluidRegistry.isFluidRegistered(fluid)) {
|
||||||
|
if (block instanceof IFluidBlock) {
|
||||||
|
IFluidBlock fluidBlock = (IFluidBlock) block;
|
||||||
|
if (!fluidBlock.canDrain(world, pos)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return fluidBlock.drain(world, pos, doDrain);
|
||||||
|
} else {
|
||||||
|
//Checks if source
|
||||||
|
int level = state.getValue(BlockLiquid.LEVEL);
|
||||||
|
if (level != 0) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if (doDrain) {
|
||||||
|
world.setBlockToAir(pos);
|
||||||
|
}
|
||||||
|
return new FluidStack(fluid, 1000);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getMaxPower() {
|
||||||
|
return 10000;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canAcceptEnergy(EnumFacing direction) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canProvideEnergy(EnumFacing direction) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getMaxOutput() {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public double getMaxInput() {
|
||||||
|
return 32;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public EnumPowerTier getTier() {
|
||||||
|
return EnumPowerTier.LOW;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void readFromNBT(NBTTagCompound tagCompound)
|
||||||
|
{
|
||||||
|
super.readFromNBT(tagCompound);
|
||||||
|
readFromNBTWithoutCoords(tagCompound);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void readFromNBTWithoutCoords(NBTTagCompound tagCompound)
|
||||||
|
{
|
||||||
|
tank.readFromNBT(tagCompound);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void writeToNBT(NBTTagCompound tagCompound)
|
||||||
|
{
|
||||||
|
super.writeToNBT(tagCompound);
|
||||||
|
writeToNBTWithoutCoords(tagCompound);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void writeToNBTWithoutCoords(NBTTagCompound tagCompound)
|
||||||
|
{
|
||||||
|
tank.writeToNBT(tagCompound);
|
||||||
|
}
|
||||||
|
|
||||||
|
// IFluidHandler
|
||||||
|
@Override
|
||||||
|
public int fill(EnumFacing from, FluidStack resource, boolean doFill)
|
||||||
|
{
|
||||||
|
int fill = tank.fill(resource, doFill);
|
||||||
|
tank.compareAndUpdate();
|
||||||
|
return fill;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain)
|
||||||
|
{
|
||||||
|
FluidStack drain = tank.drain(resource.amount, doDrain);
|
||||||
|
tank.compareAndUpdate();
|
||||||
|
return drain;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain)
|
||||||
|
{
|
||||||
|
FluidStack drain = tank.drain(maxDrain, doDrain);
|
||||||
|
tank.compareAndUpdate();
|
||||||
|
return drain;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canFill(EnumFacing from, Fluid fluid)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean canDrain(EnumFacing from, Fluid fluid)
|
||||||
|
{
|
||||||
|
return tank.getFluid() == null || tank.getFluid().getFluid() == fluid;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public FluidTankInfo[] getTankInfo(EnumFacing from)
|
||||||
|
{
|
||||||
|
return new FluidTankInfo[] { tank.getInfo() };
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue