fixed issues, and finished preversion of eValve

fixed some issues with pipes but the main change is the addition of the
extractor valve(better name to come). This valve cause a machine to
start to output liqiud to basic Utilities pipes at a pressure so they
work. The Valve can also be turned off by redstone input to act as a
output control of storage tanks.
This commit is contained in:
Rseifert 2012-12-22 08:46:23 -05:00
parent 494d98bb05
commit 2ca16920ec
8 changed files with 655 additions and 281 deletions

View file

@ -42,8 +42,11 @@ import dark.BasicUtilities.mechanical.BlockGenerator;
import dark.BasicUtilities.mechanical.BlockRod;
import dark.BasicUtilities.mechanical.TileEntityGen;
import dark.BasicUtilities.mechanical.TileEntityRod;
import dark.BasicUtilities.pipes.BlockEValve;
import dark.BasicUtilities.pipes.BlockPipe;
import dark.BasicUtilities.pipes.ItemEValve;
import dark.BasicUtilities.pipes.ItemPipe;
import dark.BasicUtilities.pipes.TileEntityEValve;
import dark.BasicUtilities.pipes.TileEntityPipe;
/**
@ -54,7 +57,7 @@ import dark.BasicUtilities.pipes.TileEntityPipe;
*/
@Mod(modid = BasicUtilitiesMain.NAME, name = BasicUtilitiesMain.NAME, version = BasicUtilitiesMain.VERSION, dependencies = "after:BasicComponents")
@NetworkMod(channels =
{ BasicUtilitiesMain.CHANNEL }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketManager.class)
{ BasicUtilitiesMain.CHANNEL }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketManager.class)
public class BasicUtilitiesMain extends DummyModContainer
{
// TODO need changed on release
@ -77,6 +80,7 @@ public class BasicUtilitiesMain extends DummyModContainer
public static Block valve = new BlockValve(UniversalElectricity.CONFIGURATION.getBlock("Valve", BLOCK_ID_PREFIX + 2).getInt());
public static Block rod = new BlockRod(UniversalElectricity.CONFIGURATION.getBlock("MechanicalRod", BLOCK_ID_PREFIX + 3).getInt());
public static Block generator = new BlockGenerator((UniversalElectricity.CONFIGURATION.getBlock("UEGenerator", BLOCK_ID_PREFIX + 4).getInt()));
public static Block eValve = new BlockEValve((UniversalElectricity.CONFIGURATION.getBlock("EValve", BLOCK_ID_PREFIX + 5).getInt()));
public static Block SteamBlock = new BlockSteam(UniversalElectricity.CONFIGURATION.getBlock("SteamBlock", LIQUID_ID_PREFIX).getInt());
@ -87,7 +91,10 @@ public class BasicUtilitiesMain extends DummyModContainer
public static Item parts = new ItemParts(UniversalElectricity.CONFIGURATION.getItem("Parts", ITEM_ID_PREFIX).getInt());
public static Item itemPipes = new ItemPipe(UniversalElectricity.CONFIGURATION.getItem("PipeItem", ITEM_ID_PREFIX + 1).getInt());
// public static Item itemTank = new ItemTank(UniversalElectricity.CONFIGURATION.getItem("TankItem", ITEM_ID_PREFIX + 2).getInt());
public static Item itemEValve = new ItemEValve(UniversalElectricity.CONFIGURATION.getItem("EValveItem", ITEM_ID_PREFIX + 2).getInt());
// public static Item itemTank = new
// ItemTank(UniversalElectricity.CONFIGURATION.getItem("TankItem",
// ITEM_ID_PREFIX + 2).getInt());
public static Item gauge = new ItemGuage(UniversalElectricity.CONFIGURATION.getItem("PipeGuage", ITEM_ID_PREFIX + 3).getInt());
public static Item itemOilBucket = new ItemOilBucket(UniversalElectricity.CONFIGURATION.getItem("Oil Bucket", ITEM_ID_PREFIX + 4).getInt(), 4);
// mod stuff
@ -102,10 +109,13 @@ public class BasicUtilitiesMain extends DummyModContainer
instance = this;
proxy.preInit();
GameRegistry.registerBlock(pipe, "multi pipe");
GameRegistry.registerBlock(eValve, "eValve");
GameRegistry.registerBlock(rod, "mech rod");
GameRegistry.registerBlock(generator, "EU Generator");
GameRegistry.registerBlock(machine, ItemMachine.class, "Machines");
GameRegistry.registerBlock(SteamBlock, "steam");
GameRegistry.registerBlock(oilStill, "oil s");
GameRegistry.registerBlock(oilMoving, "oil m");
LiquidContainerRegistry.registerLiquid(new LiquidContainerData(new LiquidStack(oilStill, LiquidContainerRegistry.BUCKET_VOLUME), new ItemStack(itemOilBucket), new ItemStack(Item.bucketEmpty)));
}
@ -118,29 +128,28 @@ public class BasicUtilitiesMain extends DummyModContainer
GameRegistry.registerTileEntity(TileEntityPipe.class, "Pipe");
GameRegistry.registerTileEntity(TileEntityPump.class, "pump");
GameRegistry.registerTileEntity(TileEntityRod.class, "rod");
// GameRegistry.registerTileEntity(TileEntityLTank.class, "ltank");
GameRegistry.registerTileEntity(TileEntityEValve.class, "EValve");
// GameRegistry.registerTileEntity(TileEntityLTank.class, "ltank");
GameRegistry.registerTileEntity(TileEntityGen.class, "WattGenerator");
// Pipe Names
for (int i = 0; i < Liquid.values().length; i++)
{
LanguageRegistry.addName((new ItemStack(itemPipes, 1, i)),
Liquid.getLiquid(i).displayerName + " Pipe");
}
/** liquid tank names
for (int i = 0; i < Liquid.values().length; i++)
{
LanguageRegistry.addName((new ItemStack(itemTank, 1, i)),
Liquid.getLiquid(i).displayerName + " Tank");
}*/
for (int i = 0; i < ItemParts.basicParts.values().length; i++)
{
Liquid.getLiquid(i).displayerName + " Pipe");
LanguageRegistry.addName((new ItemStack(parts, 1, i)),
ItemParts.basicParts.values()[i].name);
LanguageRegistry.addName((new ItemStack(eValve, 1, i)),
Liquid.getLiquid(i).displayerName + "release Valve");
}
/**
* liquid tank names for (int i = 0; i < Liquid.values().length; i++) {
* LanguageRegistry.addName((new ItemStack(itemTank, 1, i)),
* Liquid.getLiquid(i).displayerName + " Tank"); }
*/
// machines
LanguageRegistry.addName((new ItemStack(machine, 1, 0)), "WaterPump");
LanguageRegistry.addName((new ItemStack(machine, 1, 4)),
"WaterCondensor");
LanguageRegistry.addName((new ItemStack(machine, 1, 4)), "WaterCondensor");
// mechanical rod
LanguageRegistry.addName((new ItemStack(rod, 1)), "MechRod");
// Tools
@ -156,114 +165,101 @@ public class BasicUtilitiesMain extends DummyModContainer
.getRecipeList()
.add(new ShapedOreRecipe(new ItemStack(this.generator, 1),
new Object[]
{ "@T@", "OVO", "@T@", 'T',
new ItemStack(BasicUtilitiesMain.rod, 1), '@',
"plateSteel", 'O', "basicCircuit", 'V',
"motor" }));
{ "@T@", "OVO", "@T@", 'T',
new ItemStack(BasicUtilitiesMain.rod, 1), '@',
"plateSteel", 'O', "basicCircuit", 'V',
"motor" }));
GameRegistry.addRecipe(new ItemStack(this.gauge, 1, 0), new Object[]
{
"TVT", " T ", 'V', new ItemStack(parts, 1, 7), 'T',
new ItemStack(parts, 1, 1) });
{
"TVT", " T ", 'V', new ItemStack(parts, 1, 7), 'T',
new ItemStack(parts, 1, 1) });
// iron tube
GameRegistry.addRecipe(new ItemStack(parts, 2, 1), new Object[]
{
"@@@", '@', Item.ingotIron });
{
"@@@", '@', Item.ingotIron });
// obby tube
GameRegistry.addRecipe(new ItemStack(parts, 2, 2), new Object[]
{
"@@@", '@', Block.obsidian });
{
"@@@", '@', Block.obsidian });
// nether tube
GameRegistry
.addRecipe(new ItemStack(parts, 2, 3),
new Object[]
{ "N@N", 'N', Block.netherrack, '@',
new ItemStack(parts, 2, 2) });
{ "N@N", 'N', Block.netherrack, '@',
new ItemStack(parts, 2, 2) });
// seal
GameRegistry.addRecipe(new ItemStack(parts, 2, 4), new Object[]
{ "@@",
"@@", '@', Item.leather });
{ "@@",
"@@", '@', Item.leather });
// slime steal
GameRegistry.addShapelessRecipe(new ItemStack(parts, 1, 5),
new Object[]
{ new ItemStack(parts, 1, 4),
new ItemStack(Item.slimeBall, 1) });// stick seal
{ new ItemStack(parts, 1, 4),
new ItemStack(Item.slimeBall, 1) });// stick seal
// crafting pipes
// {"black", "red", "green", "brown", "blue", "purple", "cyan",
// "silver", "gray", "pink", "lime", "yellow", "lightBlue", "magenta",
// "orange", "white"};
GameRegistry.addRecipe(new ItemStack(rod, 1), new Object[]
{ "I@I",
'I', Item.ingotIron, '@', new ItemStack(parts, 1, 1) });
{ "I@I",
'I', Item.ingotIron, '@', new ItemStack(parts, 1, 1) });
// water
GameRegistry.addShapelessRecipe(new ItemStack(itemPipes, 1, 1),
new Object[]
{ new ItemStack(parts, 1, 1),
new ItemStack(parts, 1, 4),
new ItemStack(Item.dyePowder, 1, 4) });
{ new ItemStack(parts, 1, 1),
new ItemStack(parts, 1, 4),
new ItemStack(Item.dyePowder, 1, 4) });
// lava TODO change to use obby pipe and nether items
GameRegistry.addShapelessRecipe(new ItemStack(itemPipes, 1, 2),
new Object[]
{ new ItemStack(parts, 1, 2),
new ItemStack(Item.dyePowder, 1, 1) });
{ new ItemStack(parts, 1, 2),
new ItemStack(Item.dyePowder, 1, 1) });
// oil
GameRegistry.addShapelessRecipe(new ItemStack(itemPipes, 1, 3),
new Object[]
{ new ItemStack(parts, 1, 1),
new ItemStack(parts, 1, 4),
new ItemStack(Item.dyePowder, 1, 0) });
{ new ItemStack(parts, 1, 1),
new ItemStack(parts, 1, 4),
new ItemStack(Item.dyePowder, 1, 0) });
// fuel
GameRegistry.addShapelessRecipe(new ItemStack(itemPipes, 1, 4),
new Object[]
{ new ItemStack(parts, 1, 1),
new ItemStack(parts, 1, 4),
new ItemStack(Item.dyePowder, 1, 11) });
{ new ItemStack(parts, 1, 1),
new ItemStack(parts, 1, 4),
new ItemStack(Item.dyePowder, 1, 11) });
GameRegistry.addRecipe(new ItemStack(parts, 1, 7), new Object[]
{
"T@T", 'T', new ItemStack(parts, 1, 1), '@', Block.lever });// valve
{
"T@T", 'T', new ItemStack(parts, 1, 1), '@', Block.lever });// valve
GameRegistry.addRecipe(new ItemStack(parts, 1, 6), new Object[]
{
" @ ", "@ @", " @ ", '@', Item.ingotIron });// tank
{
" @ ", "@ @", " @ ", '@', Item.ingotIron });// tank
/**
GameRegistry.addShapelessRecipe(new ItemStack(itemTank, 1, 0),
new Object[]
{ new ItemStack(parts, 1, 6),
new ItemStack(parts, 1, 4),
new ItemStack(Item.dyePowder, 1, 15) });
GameRegistry.addShapelessRecipe(new ItemStack(itemTank, 1, 1),
new Object[]
{ new ItemStack(parts, 1, 6),
new ItemStack(parts, 1, 4),
new ItemStack(Item.dyePowder, 1, 4) });
// lava TODO change to use obby pipe and nether items
GameRegistry.addShapelessRecipe(new ItemStack(itemTank, 1, 2),
new Object[]
{ new ItemStack(parts, 1, 6), Block.obsidian,
Block.obsidian, Block.obsidian, Block.obsidian });
// oil
GameRegistry.addShapelessRecipe(new ItemStack(itemTank, 1, 3),
new Object[]
{ new ItemStack(parts, 1, 6),
new ItemStack(parts, 1, 4),
new ItemStack(Item.dyePowder, 1, 0) });
// fuel
GameRegistry.addShapelessRecipe(
new ItemStack(itemTank, 1, Liquid.Fuel.ordinal()),
new Object[]
{
new ItemStack(parts, 1, basicParts.Tank.ordinal()),
new ItemStack(parts, 1, 4),
new ItemStack(Item.dyePowder, 1, 11) });
*/
* GameRegistry.addShapelessRecipe(new ItemStack(itemTank, 1, 0), new
* Object[] { new ItemStack(parts, 1, 6), new ItemStack(parts, 1, 4),
* new ItemStack(Item.dyePowder, 1, 15) });
* GameRegistry.addShapelessRecipe(new ItemStack(itemTank, 1, 1), new
* Object[] { new ItemStack(parts, 1, 6), new ItemStack(parts, 1, 4),
* new ItemStack(Item.dyePowder, 1, 4) }); // lava TODO change to use
* obby pipe and nether items GameRegistry.addShapelessRecipe(new
* ItemStack(itemTank, 1, 2), new Object[] { new ItemStack(parts, 1, 6),
* Block.obsidian, Block.obsidian, Block.obsidian, Block.obsidian }); //
* oil GameRegistry.addShapelessRecipe(new ItemStack(itemTank, 1, 3),
* new Object[] { new ItemStack(parts, 1, 6), new ItemStack(parts, 1,
* 4), new ItemStack(Item.dyePowder, 1, 0) }); // fuel
* GameRegistry.addShapelessRecipe( new ItemStack(itemTank, 1,
* Liquid.Fuel.ordinal()), new Object[] { new ItemStack(parts, 1,
* basicParts.Tank.ordinal()), new ItemStack(parts, 1, 4), new
* ItemStack(Item.dyePowder, 1, 11) });
*/
GameRegistry.addShapelessRecipe(new ItemStack(itemPipes, 1, 0),
new Object[]
{ new ItemStack(parts, 1, 1),
new ItemStack(parts, 1, 4) });
{ new ItemStack(parts, 1, 1),
new ItemStack(parts, 1, 4) });
GameRegistry.addRecipe(new ItemStack(machine, 1, 0), new Object[]
{
"@T@", "BPB", "@P@", '@', new ItemStack(Item.ingotIron, 2),
'B', new ItemStack(parts, 1, 7), 'P',
new ItemStack(Block.pistonBase), 'T',
new ItemStack(parts, 1, 6) });
{
"@T@", "BPB", "@P@", '@', new ItemStack(Item.ingotIron, 2),
'B', new ItemStack(parts, 1, 7), 'P',
new ItemStack(Block.pistonBase), 'T',
new ItemStack(parts, 1, 6) });
}
}

View file

@ -10,72 +10,92 @@ import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import dark.BasicUtilities.ItemRenderHelper;
public class BlockRod extends universalelectricity.prefab.BlockMachine {
public class BlockRod extends universalelectricity.prefab.BlockMachine
{
public BlockRod(int par1) {
super("MechanicRod", par1, Material.iron);
this.setCreativeTab(CreativeTabs.tabRedstone);
}
@Override
public int damageDropped(int metadata)
{
return 0;
}
@Override
public void onBlockPlacedBy(World world,int i,int j,int k, EntityLiving player)
{
int angle= MathHelper.floor_double((player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int meta = 0;
ForgeDirection idr;
int dZ = 0;
int dX = 0;
switch(angle)
{
case 0: meta = 2;dZ--;break;
case 1: meta = 5;dX--;break;
case 2: meta = 3;dZ++;break;
case 3: meta = 4;dX++;break;
}
world.setBlockAndMetadataWithUpdate(i, j, k,blockID, meta, true);
}
@Override
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
int meta = world.getBlockMetadata(x, y, z);
if(meta >= 5)
{
world.setBlockMetadataWithNotify(x, y, z, 0);
}
else
{
world.setBlockMetadataWithNotify(x,y,z,meta+1);
}
return true;
}
@Override
public TileEntity createNewTileEntity(World var1)
{
return new TileEntityRod();
}
public boolean isOpaqueCube()
{
return false;
}
public BlockRod(int par1)
{
super("MechanicRod", par1, Material.iron);
this.setCreativeTab(CreativeTabs.tabRedstone);
}
/**
* If this block doesn't render as an ordinary block it will return False (examples: signs, buttons, stairs, etc)
*/
public boolean renderAsNormalBlock()
{
return false;
}
/**
* The type of render function that is called for this block
*/
public int getRenderType()
{
return ItemRenderHelper.renderID;
}
@Override
public int damageDropped(int metadata)
{
return 0;
}
@Override
public void onBlockPlacedBy(World world, int i, int j, int k, EntityLiving player)
{
int angle = MathHelper.floor_double((player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
int meta = 0;
ForgeDirection idr;
int dZ = 0;
int dX = 0;
switch (angle)
{
case 0:
meta = 2;
dZ--;
break;
case 1:
meta = 5;
dX--;
break;
case 2:
meta = 3;
dZ++;
break;
case 3:
meta = 4;
dX++;
break;
}
world.setBlockAndMetadataWithUpdate(i, j, k, blockID, meta, true);
}
@Override
public boolean onUseWrench(World world, int x, int y, int z, EntityPlayer player, int side, float hitX, float hitY, float hitZ)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta >= 5)
{
world.setBlockMetadataWithNotify(x, y, z, 0);
}
else
{
world.setBlockMetadataWithNotify(x, y, z, meta + 1);
}
return true;
}
@Override
public TileEntity createNewTileEntity(World var1)
{
return new TileEntityRod();
}
public boolean isOpaqueCube()
{
return false;
}
/**
* If this block doesn't render as an ordinary block it will return False
* (examples: signs, buttons, stairs, etc)
*/
public boolean renderAsNormalBlock()
{
return false;
}
/**
* The type of render function that is called for this block
*/
public int getRenderType()
{
return ItemRenderHelper.renderID;
}
}

View file

@ -0,0 +1,85 @@
package dark.BasicUtilities.pipes;
import java.util.Random;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.item.EntityItem;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import universalelectricity.prefab.implement.IRedstoneReceptor;
import dark.BasicUtilities.BasicUtilitiesMain;
public class BlockEValve extends BlockContainer
{
public BlockEValve(int par1)
{
super(par1, Material.iron);
}
@Override
public TileEntity createNewTileEntity(World var1)
{
return new TileEntityEValve();
}
public boolean isOpaqueCube()
{
return false;
}
public boolean renderAsNormalBlock()
{
return true;
}
public int getRenderType()
{
return 0;
}
public int idDropped(int par1, Random par2Random, int par3)
{
return 0;
}
@Override
public void onNeighborBlockChange(World par1World, int x, int y, int z, int side)
{
super.onNeighborBlockChange(par1World, x, y, z, side);
TileEntity tileEntity = par1World.getBlockTileEntity(x, y, z);
if (tileEntity instanceof IRedstoneReceptor)
{
if (par1World.isBlockIndirectlyGettingPowered(x, y, z))
{
((IRedstoneReceptor) par1World.getBlockTileEntity(x, y, z)).onPowerOn();
}
}
}
public void breakBlock(World world, int x, int y, int z, int par5, int par6)
{
super.breakBlock(world, x, y, z, par5, par6);
TileEntity ent = world.getBlockTileEntity(x, y, z);
Random furnaceRand = new Random();
if (ent instanceof TileEntityPipe)
{
TileEntityEValve pipe = (TileEntityEValve) ent;
int meta = pipe.type.ordinal();
float var8 = furnaceRand.nextFloat() * 0.8F + 0.1F;
float var9 = furnaceRand.nextFloat() * 0.8F + 0.1F;
float var10 = furnaceRand.nextFloat() * 0.8F + 0.1F;
EntityItem var12 = new EntityItem(world, (double) ((float) x + var8), (double) ((float) y + var9),
(double) ((float) z + var10), new ItemStack(BasicUtilitiesMain.itemEValve, 1, meta));
float var13 = 0.05F;
var12.motionX = (double) ((float) furnaceRand.nextGaussian() * var13);
var12.motionY = (double) ((float) furnaceRand.nextGaussian() * var13 + 0.2F);
var12.motionZ = (double) ((float) furnaceRand.nextGaussian() * var13);
world.spawnEntityInWorld(var12);
}
}
}

View file

@ -10,75 +10,96 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import dark.BasicUtilities.BasicUtilitiesMain;
public class BlockPipe extends BlockContainer
{
public BlockPipe(int id)
{
super(id, Material.iron);
this.setBlockName("Pipe");
this.setBlockBounds(0.30F, 0.30F, 0.30F, 0.70F, 0.70F, 0.70F);
this.setHardness(1f);
this.setResistance(3f);
}
public boolean isOpaqueCube(){return false;}
public boolean renderAsNormalBlock(){return false;}
public int getRenderType(){return -1;}
public int idDropped(int par1, Random par2Random, int par3){return 0;}
@Override
public class BlockPipe extends BlockContainer
{
public BlockPipe(int id)
{
super(id, Material.iron);
this.setBlockName("Pipe");
this.setBlockBounds(0.30F, 0.30F, 0.30F, 0.70F, 0.70F, 0.70F);
this.setHardness(1f);
this.setResistance(3f);
}
public boolean isOpaqueCube()
{
return false;
}
public boolean renderAsNormalBlock()
{
return false;
}
public int getRenderType()
{
return -1;
}
public int idDropped(int par1, Random par2Random, int par3)
{
return 0;
}
@Override
public void onBlockAdded(World world, int x, int y, int z)
{
super.onBlockAdded(world, x, y, z);
}
/**
* Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed (coordinates passed are
* their own) Args: x, y, z, neighbor blockID
* Lets the block know when one of its neighbor changes. Doesn't know which
* neighbor changed (coordinates passed are their own) Args: x, y, z,
* neighbor blockID
*/
@Override
@Override
public void onNeighborBlockChange(World world, int x, int y, int z, int blockID)
{
super.onNeighborBlockChange(world, x, y, z, blockID);
super.onNeighborBlockChange(world, x, y, z, blockID);
}
@Override
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
@Override
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
{
int var5 = par1World.getBlockId(par2, par3, par4);
int var5 = par1World.getBlockId(par2, par3, par4);
return var5 == 0 || blocksList[var5].blockMaterial.isReplaceable();
}
@Override
public boolean canPlaceBlockOnSide(World par1World, int par2, int par3, int par4, int par5)
@Override
public boolean canPlaceBlockOnSide(World par1World, int par2, int par3, int par4, int par5)
{
return true;
}
return true;
}
@Override
public TileEntity createNewTileEntity(World var1) {
// TODO Auto-generated method stub
return new TileEntityPipe();
}
@Override
public void breakBlock(World world, int x, int y, int z,int par5, int par6)
{
super.breakBlock(world, x, y, z, par5, par6);
TileEntity ent = world.getBlockTileEntity(x, y, z);
Random furnaceRand = new Random();
if(ent instanceof TileEntityPipe)
{
TileEntityPipe pipe = (TileEntityPipe) ent;
int meta = pipe.type.ordinal();
float var8 = furnaceRand.nextFloat() * 0.8F + 0.1F;
float var9 = furnaceRand.nextFloat() * 0.8F + 0.1F;
float var10 = furnaceRand.nextFloat() * 0.8F + 0.1F;
EntityItem var12 = new EntityItem(world, (double)((float)x + var8), (double)((float)y + var9),
(double)((float)z + var10), new ItemStack(BasicUtilitiesMain.itemPipes, 1, meta));
float var13 = 0.05F;
var12.motionX = (double)((float)furnaceRand.nextGaussian() * var13);
var12.motionY = (double)((float)furnaceRand.nextGaussian() * var13 + 0.2F);
var12.motionZ = (double)((float)furnaceRand.nextGaussian() * var13);
world.spawnEntityInWorld(var12);
}
}
}
@Override
public TileEntity createNewTileEntity(World var1)
{
// TODO Auto-generated method stub
return new TileEntityPipe();
}
@Override
public void breakBlock(World world, int x, int y, int z, int par5, int par6)
{
super.breakBlock(world, x, y, z, par5, par6);
TileEntity ent = world.getBlockTileEntity(x, y, z);
Random furnaceRand = new Random();
if (ent instanceof TileEntityPipe)
{
TileEntityPipe pipe = (TileEntityPipe) ent;
int meta = pipe.type.ordinal();
float var8 = furnaceRand.nextFloat() * 0.8F + 0.1F;
float var9 = furnaceRand.nextFloat() * 0.8F + 0.1F;
float var10 = furnaceRand.nextFloat() * 0.8F + 0.1F;
EntityItem var12 = new EntityItem(world, (double) ((float) x + var8), (double) ((float) y + var9),
(double) ((float) z + var10), new ItemStack(BasicUtilitiesMain.itemPipes, 1, meta));
float var13 = 0.05F;
var12.motionX = (double) ((float) furnaceRand.nextGaussian() * var13);
var12.motionY = (double) ((float) furnaceRand.nextGaussian() * var13 + 0.2F);
var12.motionZ = (double) ((float) furnaceRand.nextGaussian() * var13);
world.spawnEntityInWorld(var12);
}
}
}

View file

@ -0,0 +1,137 @@
package dark.BasicUtilities.pipes;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.Item;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import dark.BasicUtilities.BasicUtilitiesMain;
import dark.BasicUtilities.api.Liquid;
public class ItemEValve extends Item
{
int index = 32;// 32 + 4 rows alloted to pipes
private int spawnID;
public ItemEValve(int id)
{
super(id);
this.setMaxDamage(0);
this.setHasSubtypes(true);
this.setIconIndex(10);
this.setItemName("eValve");
this.setCreativeTab(CreativeTabs.tabRedstone);
}
@Override
public int getIconFromDamage(int par1)
{
return par1 + index;
}
@Override
public String getItemNameIS(ItemStack itemstack)
{
return itemstack.getItemDamage() < Liquid.values().length ? Liquid.getLiquid(itemstack.getItemDamage()).displayerName + " Pipe" : "Empty Pipe";
}
@Override
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for (int i = 0; i < Liquid.values().length; i++)
{
par3List.add(new ItemStack(this, 1, i));
}
}
public String getTextureFile()
{
return BasicUtilitiesMain.ITEM_PNG;
}
@Override
public String getItemName()
{
return "Pipes";
}
@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10)
{
int blockID = world.getBlockId(x, y, z);
spawnID = BasicUtilitiesMain.eValve.blockID;
int angle= MathHelper.floor_double((player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
if (blockID == Block.snow.blockID)
{
side = 1;
}
else if (blockID != Block.vine.blockID && blockID != Block.tallGrass.blockID && blockID != Block.deadBush.blockID)
{
if (side == 0)
{
--y;
}
if (side == 1)
{
++y;
}
if (side == 2)
{
--z;
}
if (side == 3)
{
++z;
}
if (side == 4)
{
--x;
}
if (side == 5)
{
++x;
}
}
if (BasicUtilitiesMain.pipe.canPlaceBlockAt(world, x, y, z))
{
Block var9 = Block.blocksList[this.spawnID];
world.editingBlocks = true;
if (world.setBlockWithNotify(x, y, z, var9.blockID))
{
if (world.getBlockId(x, y, z) == var9.blockID)
{
Block.blocksList[this.spawnID].onBlockAdded(world, x, y, z);
Block.blocksList[this.spawnID].onBlockPlacedBy(world, x, y, z, player);
TileEntity blockEntity = world.getBlockTileEntity(x, y, z);
if (blockEntity instanceof TileEntityEValve)
{
TileEntityEValve pipeEntity = (TileEntityEValve) blockEntity;
Liquid dm = Liquid.getLiquid(itemstack.getItemDamage());
pipeEntity.setType(dm);
pipeEntity.tank.setLiquid(Liquid.getStack(dm, 1));
}
}
--itemstack.stackSize;
world.editingBlocks = false;
return true;
}
}
world.editingBlocks = false;
return false;
}
}

View file

@ -0,0 +1,189 @@
package dark.BasicUtilities.pipes;
import universalelectricity.prefab.implement.IRedstoneReceptor;
import cpw.mods.fml.common.FMLLog;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.ITankContainer;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidStack;
import net.minecraftforge.liquids.LiquidTank;
import dark.BasicUtilities.api.IReadOut;
import dark.BasicUtilities.api.ITankOutputer;
import dark.BasicUtilities.api.Liquid;
import dark.BasicUtilities.api.MHelper;
public class TileEntityEValve extends TileEntity implements ITankOutputer, IReadOut, IRedstoneReceptor
{
public Liquid type = Liquid.DEFUALT;
public LiquidTank tank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME);
public TileEntity[] connected = new TileEntity[6];
private int count = 0;
private boolean isPowered = false;
public void updateEntity()
{
super.updateEntity();
this.connected = MHelper.getSourounding(worldObj, xCoord, yCoord, zCoord);
if (!this.worldObj.isRemote && count++ == 10 && !isPowered)
{
if (tank.getLiquid() == null)
{
tank.setLiquid(Liquid.getStack(this.type, 1));
}
if (tank.getLiquid() != null && tank.getLiquid().amount < tank.getCapacity())
{
for (int i = 0; i < 6; i++)
{
ForgeDirection dir = ForgeDirection.getOrientation(i);
if (connected[i] instanceof ITankContainer && !(connected[i] instanceof TileEntityPipe))
{
// FMLLog.warning("container");
ILiquidTank[] tanks = ((ITankContainer) connected[i]).getTanks(dir);
for (int t = 0; t < tanks.length; t++)
{
LiquidStack ll = tanks[t].getLiquid();
if (ll != null && Liquid.isStackEqual(ll, this.type))
{
// FMLLog.warning("draining");
int drainVol = this.tank.getCapacity();
if (this.tank.getLiquid() != null) drainVol = tank.getCapacity() - tank.getLiquid().amount;
LiquidStack drained = ((ITankContainer) connected[i]).drain(t, this.tank.getCapacity(), true);
int f = this.tank.fill(drained, true);
//FMLLog.warning("leftOver " + f);
}
}
}
}
}
count = 0;
LiquidStack stack = tank.getLiquid();
if (stack != null && this.canOutput())
for (int i = 0; i < 6; i++)
{
if (connected[i] instanceof TileEntityPipe)
{
//FMLLog.warning("moving to pipe");
int ee = ((TileEntityPipe) connected[i]).fill(ForgeDirection.getOrientation(i), stack, true);
tank.drain(ee, true);
}
}
}
}
private boolean canOutput()
{
// TODO add redstone input here to cause it to stop outputting
return true;
}
@Override
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill)
{
return 0;
}
@Override
public int fill(int tankIndex, LiquidStack resource, boolean doFill)
{
if (tankIndex != 0 || resource == null) return 0;
return tank.fill(resource, doFill);
}
@Override
public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
{
return null;
}
@Override
public LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain)
{
return null;
}
@Override
public ILiquidTank[] getTanks(ForgeDirection direction)
{
return new ILiquidTank[] { this.tank };
}
@Override
public ILiquidTank getTank(ForgeDirection direction, LiquidStack type)
{
return null;
}
public int presureOutput(Liquid type, ForgeDirection dir)
{
if (type == this.type) { return type.defaultPresure; }
return 0;
}
@Override
public boolean canPressureToo(Liquid type, ForgeDirection dir)
{
if (type == this.type) return true;
return false;
}
@Override
public String getMeterReading(EntityPlayer user, ForgeDirection side)
{
String output = "";
LiquidStack stack = tank.getLiquid();
if (stack != null) output += (stack.amount / LiquidContainerRegistry.BUCKET_VOLUME) + " " + this.type.displayerName+" on = "+!this.isPowered;
if (stack != null) return output;
return "0/0 " + this.type.displayerName+" on = "+!this.isPowered;
}
@Override
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
{
super.readFromNBT(par1NBTTagCompound);
this.type = Liquid.getLiquid(par1NBTTagCompound.getInteger("type"));
int vol = par1NBTTagCompound.getInteger("liquid");
this.tank.setLiquid(Liquid.getStack(type, vol));
}
/**
* Writes a tile entity to NBT.
*/
@Override
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
{
super.writeToNBT(par1NBTTagCompound);
int s = 0;
LiquidStack stack = this.tank.getLiquid();
if (stack != null) s = stack.amount;
par1NBTTagCompound.setInteger("liquid", s);
par1NBTTagCompound.setInteger("type", this.type.ordinal());
}
public void setType(Liquid dm)
{
this.type = dm;
}
@Override
public void onPowerOn()
{
this.isPowered = true;
}
@Override
public void onPowerOff()
{
this.isPowered = false;
}
}

View file

@ -99,7 +99,6 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IPacke
// FMLLog.warning("Moved "+moved+ " "+ i);
if (stack.amount <= 0)
{
FMLLog.warning("Empty");
break;
}
}

View file

@ -1,73 +0,0 @@
package dark.BasicUtilities.pipes;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.LiquidStack;
import dark.BasicUtilities.api.ITankOutputer;
import dark.BasicUtilities.api.Liquid;
public class TileEntityPumpPipe extends TileEntity implements ITankOutputer
{
private ForgeDirection input;
private Liquid outputType = Liquid.DEFUALT;
@Override
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill)
{
// TODO Auto-generated method stub
return 0;
}
@Override
public int fill(int tankIndex, LiquidStack resource, boolean doFill)
{
// TODO Auto-generated method stub
return 0;
}
@Override
public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
{
// TODO Auto-generated method stub
return null;
}
@Override
public LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain)
{
// TODO Auto-generated method stub
return null;
}
@Override
public ILiquidTank[] getTanks(ForgeDirection direction)
{
// TODO Auto-generated method stub
return null;
}
@Override
public ILiquidTank getTank(ForgeDirection direction, LiquidStack type)
{
// TODO Auto-generated method stub
return null;
}
public int presureOutput(Liquid type, ForgeDirection dir)
{
if(dir != this.input.getOpposite() && type == this.outputType)
{
return type.defaultPresure;
}
return 0;
}
@Override
public boolean canPressureToo(Liquid type, ForgeDirection dir)
{
if(type == this.outputType && dir != this.input.getOpposite()) return true;
return false;
}
}