.
This commit is contained in:
parent
fab70e6e85
commit
4911151bec
13 changed files with 0 additions and 1437 deletions
|
@ -1,125 +0,0 @@
|
|||
package BasicPipes;
|
||||
import java.io.File;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraftforge.common.Configuration;
|
||||
import universalelectricity.basiccomponents.BasicComponents;
|
||||
import universalelectricity.network.PacketManager;
|
||||
import BasicPipes.pipes.BlockPipe;
|
||||
import BasicPipes.pipes.BlockPump;
|
||||
import BasicPipes.pipes.ItemGuage;
|
||||
import BasicPipes.pipes.ItemParts;
|
||||
import BasicPipes.pipes.ItemPipe;
|
||||
import BasicPipes.pipes.TileEntityPump;
|
||||
import cpw.mods.fml.common.Mod;
|
||||
import cpw.mods.fml.common.Mod.Init;
|
||||
import cpw.mods.fml.common.Mod.Instance;
|
||||
import cpw.mods.fml.common.Mod.PostInit;
|
||||
import cpw.mods.fml.common.Mod.PreInit;
|
||||
import cpw.mods.fml.common.SidedProxy;
|
||||
import cpw.mods.fml.common.event.FMLInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPostInitializationEvent;
|
||||
import cpw.mods.fml.common.event.FMLPreInitializationEvent;
|
||||
import cpw.mods.fml.common.network.NetworkMod;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
@Mod(modid = "basicPipes", name = "Basic Pipes", version = "V4")
|
||||
@NetworkMod(channels = { "Pipes" }, clientSideRequired = true, serverSideRequired = false, packetHandler = PacketManager.class)
|
||||
|
||||
public class BasicPipesMain{
|
||||
@Instance
|
||||
public static BasicPipesMain instance;
|
||||
|
||||
@SidedProxy(clientSide = "BasicPipes.PipeClientProxy", serverSide = "BasicPipes.PipeProxy")
|
||||
public static PipeProxy proxy;
|
||||
static Configuration config = new Configuration((new File(cpw.mods.fml.common.Loader.instance().getConfigDir(), "/EUIndustry/BasicPipes.cfg")));
|
||||
public static int pipeID = configurationProperties();
|
||||
private static int partID;
|
||||
private static int ppipeID;
|
||||
private static int machineID;
|
||||
public static Block pipe = new BlockPipe(pipeID).setBlockName("pipe");
|
||||
public static Block machine = new BlockPump(machineID).setBlockName("pump");
|
||||
public static Item parts = new ItemParts(partID);
|
||||
public static Item itemPipes = new ItemPipe(ppipeID);
|
||||
public static Item gauge = new ItemGuage(ppipeID+1);
|
||||
|
||||
public static String channel = "Pipes";
|
||||
|
||||
public static int configurationProperties()
|
||||
{
|
||||
config.load();
|
||||
pipeID = Integer.parseInt(config.getOrCreateIntProperty("PipeBlock", Configuration.CATEGORY_BLOCK, 155).value);
|
||||
machineID = Integer.parseInt(config.getOrCreateIntProperty("machineBlock", Configuration.CATEGORY_BLOCK, 156).value);
|
||||
partID = Integer.parseInt(config.getOrCreateIntProperty("parts", Configuration.CATEGORY_ITEM, 23022).value);
|
||||
ppipeID = Integer.parseInt(config.getOrCreateIntProperty("pipes", Configuration.CATEGORY_ITEM, 23023).value);
|
||||
config.save();
|
||||
return pipeID;
|
||||
}
|
||||
@PreInit
|
||||
public void preInit(FMLPreInitializationEvent event)
|
||||
{
|
||||
proxy.preInit();
|
||||
GameRegistry.registerBlock(pipe);
|
||||
GameRegistry.registerBlock(machine);
|
||||
}
|
||||
@Init
|
||||
public void load(FMLInitializationEvent evt)
|
||||
{
|
||||
//register
|
||||
proxy.init();
|
||||
GameRegistry.registerTileEntity(TileEntityPump.class, "pump");
|
||||
//Names
|
||||
LanguageRegistry.addName((new ItemStack(gauge, 1, 0)), "guage");
|
||||
LanguageRegistry.addName((new ItemStack(itemPipes, 1, 0)), "SteamPipe");
|
||||
LanguageRegistry.addName((new ItemStack(itemPipes, 1, 1)), "WaterPipe");
|
||||
LanguageRegistry.addName((new ItemStack(itemPipes, 1, 2)), "LavaPipe");
|
||||
LanguageRegistry.addName((new ItemStack(itemPipes, 1, 3)), "OilPipe");
|
||||
LanguageRegistry.addName((new ItemStack(itemPipes, 1, 4)), "FuelPipe");
|
||||
LanguageRegistry.addName((new ItemStack(itemPipes, 1, 5)), "AirPipe");
|
||||
LanguageRegistry.addName((new ItemStack(itemPipes, 1, 6)), "MethainPipe");
|
||||
LanguageRegistry.addName((new ItemStack(itemPipes, 1, 7)), "BioFuelPipe");
|
||||
LanguageRegistry.addName((new ItemStack(itemPipes, 1, 8)), "coolentPipe");
|
||||
LanguageRegistry.addName((new ItemStack(itemPipes, 1, 9)), "NukeWastePipe");
|
||||
LanguageRegistry.addName((new ItemStack(itemPipes, 1, 10)), "Pipe");
|
||||
LanguageRegistry.addName((new ItemStack(parts, 1, 0)), "BronzeTube");
|
||||
LanguageRegistry.addName((new ItemStack(parts, 1, 1)), "IronTube");
|
||||
LanguageRegistry.addName((new ItemStack(parts, 1, 2)), "ObsidianTube");
|
||||
LanguageRegistry.addName((new ItemStack(parts, 1, 3)), "NetherTube");
|
||||
LanguageRegistry.addName((new ItemStack(parts, 1, 4)), "LeatherSeal");
|
||||
LanguageRegistry.addName((new ItemStack(parts, 1, 5)), "SlimeSeal");
|
||||
LanguageRegistry.addName((new ItemStack(parts, 1, 6)), "BronzeTank");
|
||||
LanguageRegistry.addName((new ItemStack(parts, 1, 7)), "Valve");
|
||||
//crafting parts
|
||||
}
|
||||
@PostInit
|
||||
public void postInit(FMLPostInitializationEvent event)
|
||||
{
|
||||
proxy.postInit();
|
||||
GameRegistry.addRecipe(new ItemStack(parts, 2,0), new Object[] { "@@@", '@',BasicComponents.itemBronzeIngot});//bronze tube
|
||||
GameRegistry.addRecipe(new ItemStack(parts, 2,1), new Object[] { "@@@", '@',Item.ingotIron});//iron tube
|
||||
GameRegistry.addRecipe(new ItemStack(parts, 2,2), new Object[] { "@@@", '@',Block.obsidian});//obby Tube
|
||||
GameRegistry.addRecipe(new ItemStack(parts, 2,3), new Object[] { "N@N", 'N',Block.netherrack,'@',new ItemStack(parts, 2,2)});//nether tube
|
||||
GameRegistry.addRecipe(new ItemStack(parts, 2,4), new Object[] { "@@","@@", '@',Item.leather});//seal
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(parts, 1,5), new Object[] { new ItemStack(parts, 1,4),new ItemStack(Item.slimeBall, 1)});//stick seal
|
||||
GameRegistry.addRecipe(new ItemStack(parts, 1,6), new Object[] { " @ ","@ @"," @ ", '@',BasicComponents.itemBronzeIngot});//tank
|
||||
GameRegistry.addRecipe(new ItemStack(parts, 1,7), new Object[] { "T@T", 'T',new ItemStack(parts,1,0),'@',Block.lever});//valve
|
||||
//crafting pipes
|
||||
//{"black", "red", "green", "brown", "blue", "purple", "cyan",
|
||||
//"silver", "gray", "pink", "lime", "yellow", "lightBlue", "magenta", "orange", "white"};
|
||||
//steam
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(itemPipes, 1,0), new Object[] { new ItemStack(parts, 1,0),new ItemStack(parts, 1,4)});
|
||||
//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)});
|
||||
//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)});
|
||||
//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)});
|
||||
//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)});
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,54 +0,0 @@
|
|||
package BasicPipes;
|
||||
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
import BasicPipes.pipes.TileEntityPipe;
|
||||
import cpw.mods.fml.common.network.IGuiHandler;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
|
||||
public class PipeProxy implements IGuiHandler
|
||||
{
|
||||
|
||||
public void preInit()
|
||||
{
|
||||
|
||||
}
|
||||
public void init()
|
||||
{
|
||||
GameRegistry.registerTileEntity(TileEntityPipe.class, "pipe");
|
||||
}
|
||||
public void postInit()
|
||||
{
|
||||
|
||||
}
|
||||
@Override
|
||||
public Object getClientGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
switch(ID)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getServerGuiElement(int ID, EntityPlayer player, World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
|
||||
if (tileEntity != null)
|
||||
{
|
||||
switch(ID)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -1,174 +0,0 @@
|
|||
package BasicPipes;
|
||||
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import BasicPipes.pipes.api.ILiquidConsumer;
|
||||
|
||||
public class TradeHelper {
|
||||
/**
|
||||
*
|
||||
* @param entity - entity at center of search
|
||||
* @return an Array containing found entities and nulls of nonEntities
|
||||
*/
|
||||
public static TileEntity[] getSourounding(TileEntity entity)
|
||||
{
|
||||
TileEntity[] list = new TileEntity[]{null,null,null,null,null,null};
|
||||
for(int i =0; i< 6;i++)
|
||||
{
|
||||
int x = entity.xCoord;
|
||||
int y = entity.yCoord;
|
||||
int z = entity.zCoord;
|
||||
|
||||
switch(i)
|
||||
{
|
||||
case 0: y = y - 1;break;//down
|
||||
case 1: y = y + 1;break;//up
|
||||
case 2: z = z + 1;break;//north
|
||||
case 3: z = z - 1;break;//south
|
||||
case 4: x = x + 1;break;//east
|
||||
case 5: x = x - 1;break;//west
|
||||
}
|
||||
TileEntity aEntity = entity.worldObj.getBlockTileEntity(x, y, z);
|
||||
if(aEntity instanceof TileEntity)
|
||||
{
|
||||
list[i] = aEntity;
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
/**
|
||||
* Only works for steam Power's boiler. Still needs recode to work for all things
|
||||
* @param blockEntity - tile entity trading the liquid
|
||||
* @param type - liquid type see chart for info
|
||||
* @param rise - does the liquid rise up like a gas
|
||||
* @return the remaining untraded liquid
|
||||
*/
|
||||
public static int shareLiquid(TileEntity blockEntity,int type,boolean rise)
|
||||
{
|
||||
TileEntity[] connectedBlocks = getSourounding(blockEntity);
|
||||
ILiquidConsumer blockMachine = (ILiquidConsumer) blockEntity;
|
||||
int wSum = ((ILiquidConsumer)blockEntity).getStoredLiquid(type);
|
||||
int ammountStored = blockMachine.getStoredLiquid(type);
|
||||
int tankCount = 1;
|
||||
boolean bottom = false;
|
||||
TileEntity firstEntity = null;
|
||||
TileEntity secondEntity = null;
|
||||
if(rise)
|
||||
{
|
||||
firstEntity = connectedBlocks[1];
|
||||
secondEntity = connectedBlocks[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
firstEntity = connectedBlocks[0];
|
||||
secondEntity = connectedBlocks[1];
|
||||
}
|
||||
//checks wether or not the block bellow it is a tank to move liquid too
|
||||
if(firstEntity instanceof ILiquidConsumer)
|
||||
{
|
||||
int bWater = ((ILiquidConsumer) firstEntity).getStoredLiquid(type);
|
||||
int bMax = ((ILiquidConsumer) firstEntity).getLiquidCapacity(type);
|
||||
//checks if that tank has room to get liquid.
|
||||
|
||||
if(bWater < bMax)
|
||||
{
|
||||
int tradeVol = 0;
|
||||
int emptyVol = Math.max( bMax - bWater,0);
|
||||
tradeVol = Math.min(emptyVol, ammountStored);
|
||||
int rejected = ((ILiquidConsumer) firstEntity).onReceiveLiquid(type, tradeVol, ForgeDirection.getOrientation(1));
|
||||
ammountStored = ammountStored + rejected - tradeVol;
|
||||
wSum -= tradeVol;
|
||||
}
|
||||
else
|
||||
{
|
||||
bottom = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//there was no tank bellow this tank
|
||||
bottom = true;
|
||||
}
|
||||
//if this is the bottom tank or bottom tank is full. Update average water ammount.
|
||||
if(bottom)
|
||||
{
|
||||
//get average water around center tank
|
||||
for(int i = 2; i<6;i++)
|
||||
{
|
||||
TileEntity entityA = connectedBlocks[i];
|
||||
if(entityA instanceof ILiquidConsumer)
|
||||
{
|
||||
//if is a tank add to the sum
|
||||
wSum += ((ILiquidConsumer) entityA).getStoredLiquid(type);
|
||||
tankCount += 1;
|
||||
}
|
||||
}
|
||||
|
||||
//if this is the bottom tank or bottom tank is full then trade liquid with tanks around it.
|
||||
for(int i = 2; i<6;i++)
|
||||
{
|
||||
int average = Math.round((float)wSum / (float)tankCount);// takes the sum and makes it an average
|
||||
int tradeSum = 0;
|
||||
TileEntity entity = connectedBlocks[i];
|
||||
if(entity instanceof ILiquidConsumer)
|
||||
{
|
||||
int targetW = ((ILiquidConsumer) entity).getStoredLiquid(type);
|
||||
if(targetW < average)
|
||||
{
|
||||
tradeSum = Math.min(average, ammountStored); //gets the ammount to give to the target tank
|
||||
int rejectedAm = ((ILiquidConsumer) entity).onReceiveLiquid(type, tradeSum, ForgeDirection.getOrientation(i)); //send that ammount with safty incase some comes back
|
||||
ammountStored =rejectedAm + ammountStored - tradeSum; //counts up current water sum after trade
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if(secondEntity instanceof ILiquidConsumer)
|
||||
{
|
||||
int bWater = ((ILiquidConsumer) secondEntity).getStoredLiquid(type);
|
||||
int bMax = ((ILiquidConsumer) secondEntity).getLiquidCapacity(type);
|
||||
if(bottom && ammountStored > 0)
|
||||
{
|
||||
if(bWater < bMax)
|
||||
{
|
||||
int emptyVolS = Math.max( bMax - bWater,0);
|
||||
int tradeVolS = Math.min(emptyVolS, ammountStored);
|
||||
int rejectedS = ((ILiquidConsumer) secondEntity).onReceiveLiquid(type, tradeVolS, ForgeDirection.getOrientation(0));;
|
||||
ammountStored =rejectedS + ammountStored - tradeVolS;
|
||||
wSum -= tradeVolS;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ammountStored;
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param entity - entity in question
|
||||
* @return 1-4 if corner 0 if not a corner
|
||||
* you have to figure out which is which depending on what your using this for
|
||||
* 1 should be north east 2 south east
|
||||
*/
|
||||
public static int corner(TileEntity entity)
|
||||
{
|
||||
TileEntity[] en = getSourounding(entity);
|
||||
if(en[4] != null && en[2] != null && en[5] == null && en[3] == null)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if(en[2] != null && en[5] != null && en[3] == null && en[4] == null)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
if(en[5] != null && en[3] != null && en[4] == null && en[2] == null)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
if(en[3] != null && en[4] != null && en[2] == null && en[5] == null)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
}
|
|
@ -1,146 +0,0 @@
|
|||
package BasicPipes.pipes;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.minecraft.src.BlockContainer;
|
||||
import net.minecraft.src.Material;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import BasicPipes.pipes.api.ILiquidConsumer;
|
||||
import BasicPipes.pipes.api.ILiquidProducer;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
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 -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the items to drop on destruction.
|
||||
*/
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
//Per tick
|
||||
public int conductorCapacity()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Called whenever the block is added into the world. Args: world, x, y, z
|
||||
*/
|
||||
@Override
|
||||
public void onBlockAdded(World world, int x, int y, int z)
|
||||
{
|
||||
super.onBlockAdded(world, x, y, z);
|
||||
|
||||
this.updateConductorTileEntity(world, x, y, z);
|
||||
}
|
||||
public static TileEntity getUEUnit(World world, int x, int y, int z, byte side,int type)
|
||||
{
|
||||
switch(side)
|
||||
{
|
||||
case 0: y -= 1; break;
|
||||
case 1: y += 1; break;
|
||||
case 2: z += 1; break;
|
||||
case 3: z -= 1; break;
|
||||
case 4: x += 1; break;
|
||||
case 5: x -= 1; break;
|
||||
}
|
||||
|
||||
//Check if the designated block is a UE Unit - producer, consumer or a conductor
|
||||
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
|
||||
TileEntity returnValue = null;
|
||||
|
||||
if(tileEntity instanceof ILiquidConsumer)
|
||||
{
|
||||
if(((ILiquidConsumer)tileEntity).canRecieveLiquid(type,ForgeDirection.getOrientation(side)))
|
||||
{
|
||||
returnValue = tileEntity;
|
||||
}
|
||||
}
|
||||
|
||||
if (tileEntity instanceof ILiquidProducer)
|
||||
{
|
||||
if(((ILiquidProducer)tileEntity).canProduceLiquid(type,ForgeDirection.getOrientation(side)))
|
||||
{
|
||||
returnValue = tileEntity;
|
||||
}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
/**
|
||||
* 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
|
||||
public void onNeighborBlockChange(World world, int x, int y, int z, int blockID)
|
||||
{
|
||||
super.onNeighborBlockChange(world, x, y, z, blockID);
|
||||
this.updateConductorTileEntity(world, x, y, z);
|
||||
}
|
||||
@Override
|
||||
public boolean canPlaceBlockAt(World par1World, int par2, int par3, int par4)
|
||||
{
|
||||
int var5 = par1World.getBlockId(par2, par3, par4);
|
||||
return var5 == 0 || blocksList[var5].blockMaterial.isGroundCover();
|
||||
}
|
||||
@Override
|
||||
public boolean canPlaceBlockOnSide(World par1World, int par2, int par3, int par4, int par5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
public static void updateConductorTileEntity(World world, int x, int y, int z)
|
||||
{
|
||||
|
||||
for(byte i = 0; i < 6; i++)
|
||||
{
|
||||
//Update the tile entity on neighboring blocks
|
||||
TileEntityPipe conductorTileEntity = (TileEntityPipe)world.getBlockTileEntity(x, y, z);
|
||||
int type = conductorTileEntity.getType();
|
||||
conductorTileEntity.addConnection(getUEUnit(world, x, y, z, i, type), ForgeDirection.getOrientation(i));;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1) {
|
||||
// TODO Auto-generated method stub
|
||||
return new TileEntityPipe();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,155 +0,0 @@
|
|||
package BasicPipes.pipes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.src.*;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockPump extends BlockContainer
|
||||
{
|
||||
|
||||
public BlockPump(int id)
|
||||
{
|
||||
super(id, Material.iron);
|
||||
this.setBlockName("Pump");
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this block (a) opaque and (b) a full 1m cube? This determines whether or not to render the shared face of two
|
||||
* adjacent blocks and also whether the player can attach torches, redstone wire, etc to this block.
|
||||
*/
|
||||
public boolean isOpaqueCube()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public int getBlockTexture(IBlockAccess par1iBlockAccess, int x, int y, int z, int side)
|
||||
{
|
||||
int metadata = par1iBlockAccess.getBlockMetadata(x, y, z);
|
||||
|
||||
if (side == 1)
|
||||
{
|
||||
switch(metadata)
|
||||
{
|
||||
case 0: return 1;
|
||||
case 1: return 3;
|
||||
case 2: return 18;
|
||||
case 3: return 5;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
switch(metadata)
|
||||
{
|
||||
case 1: return 4;
|
||||
case 2: return 16;
|
||||
case 3: return 2;
|
||||
}
|
||||
return 0;
|
||||
|
||||
|
||||
}
|
||||
@Override
|
||||
public int getBlockTextureFromSideAndMetadata(int side, int metadata)
|
||||
{
|
||||
if (side == 1)
|
||||
{
|
||||
switch(metadata)
|
||||
{
|
||||
case 0: return 1;
|
||||
case 1: return 3;
|
||||
case 2: return 18;
|
||||
case 3: return 5;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//If it is the front side
|
||||
if(side == 3)
|
||||
{
|
||||
switch(metadata)
|
||||
{
|
||||
case 0: return 19;
|
||||
case 1: return 6;
|
||||
case 2: return 17;
|
||||
case 3: return 3;
|
||||
}
|
||||
}
|
||||
//If it is the back side
|
||||
else if(side == 2)
|
||||
{
|
||||
switch(metadata)
|
||||
{
|
||||
case 0: return this.blockIndexInTexture + 2;
|
||||
case 1: return this.blockIndexInTexture + 3;
|
||||
case 2: return this.blockIndexInTexture + 2;
|
||||
}
|
||||
}
|
||||
|
||||
switch(metadata)
|
||||
{
|
||||
case 1: return 4;
|
||||
case 2: return 16;
|
||||
case 3: return 2;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* 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 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the ID of the items to drop on destruction.
|
||||
*/
|
||||
public int idDropped(int par1, Random par2Random, int par3)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public String getTextureFile() {
|
||||
// TODO Auto-generated method stub
|
||||
return "/eui/blocks.png";
|
||||
}
|
||||
//Per tick
|
||||
public int conductorCapacity()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
public void addCreativeItems(ArrayList itemList)
|
||||
{
|
||||
|
||||
itemList.add(new ItemStack(this, 1,0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1,int meta) {
|
||||
// TODO Auto-generated method stub
|
||||
switch(meta)
|
||||
{
|
||||
case 0: return new TileEntityPump();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TileEntity createNewTileEntity(World var1) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
package BasicPipes.pipes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import net.minecraft.src.*;
|
||||
|
||||
public class ItemGuage extends Item
|
||||
{
|
||||
private int spawnID;
|
||||
|
||||
public ItemGuage(int id)
|
||||
{
|
||||
super(id);
|
||||
this.setMaxDamage(0);
|
||||
this.setHasSubtypes(true);
|
||||
this.setIconIndex(10);
|
||||
this.setItemName("guage");
|
||||
}
|
||||
@Override
|
||||
public int getIconFromDamage(int par1)
|
||||
{
|
||||
switch(par1)
|
||||
{
|
||||
case 0: return 11;
|
||||
}
|
||||
return this.iconIndex;
|
||||
}
|
||||
@Override
|
||||
public String getItemName()
|
||||
{
|
||||
return "guage";
|
||||
}
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7)
|
||||
{
|
||||
|
||||
TileEntity blockEntity = par3World.getBlockTileEntity(par4, par5, par6);
|
||||
if(blockEntity instanceof TileEntityPipe)
|
||||
{
|
||||
TileEntityPipe pipeEntity = (TileEntityPipe) blockEntity;
|
||||
int steam = pipeEntity.getStoredLiquid(0);
|
||||
int type = pipeEntity.getType();
|
||||
String typeName = getType(type);
|
||||
par2EntityPlayer.addChatMessage(typeName +" " + steam);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
public String getType(int type)
|
||||
{
|
||||
switch(type)
|
||||
{
|
||||
case 0: return "Steam";
|
||||
case 1: return "Water";
|
||||
case 2: return "Lava";
|
||||
case 3: return "Oil";
|
||||
case 4: return "Fuel";
|
||||
case 5: return "Air";
|
||||
default: return "unknow";
|
||||
}
|
||||
}
|
||||
public String getItemNameIS(ItemStack par1ItemStack)
|
||||
{
|
||||
int var3 = par1ItemStack.getItemDamage();
|
||||
switch(var3)
|
||||
{
|
||||
case 1: return "PipeGuage";
|
||||
}
|
||||
return this.getItemName();
|
||||
}
|
||||
@Override
|
||||
public String getTextureFile() {
|
||||
return "/eui/Items.png";
|
||||
}
|
||||
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
package BasicPipes.pipes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.src.CreativeTabs;
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
|
||||
public class ItemParts extends Item{
|
||||
String[] names = new String[]{"BronzeTube","IronTube","ObbyTube","NetherTube","Seal","StickSeal","BronzeTank","Valve",};
|
||||
int[] iconID = new int[] {0 ,1 ,2 ,3 ,16 ,17 ,18 ,19};//TODO check these
|
||||
public ItemParts(int par1)
|
||||
{
|
||||
super(par1);
|
||||
this.setItemName("Parts");
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
this.setMaxStackSize(64);
|
||||
this.setTabToDisplayOn(CreativeTabs.tabMaterials);
|
||||
}
|
||||
@Override
|
||||
public int getIconFromDamage(int par1)
|
||||
{
|
||||
if(par1 < iconID.length)
|
||||
{
|
||||
return iconID[par1];
|
||||
}
|
||||
return par1;
|
||||
}
|
||||
@Override
|
||||
public String getItemNameIS(ItemStack itemstack)
|
||||
{
|
||||
return names[itemstack.getItemDamage()];
|
||||
}
|
||||
@Override
|
||||
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
for(int i = 0; i < names.length; i++)
|
||||
{
|
||||
par3List.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
}
|
||||
public String getTextureFile() {
|
||||
return "/EUIClient/Textures/Items.png";
|
||||
}
|
||||
@Override
|
||||
public String getItemName()
|
||||
{
|
||||
return "parts";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -1,128 +0,0 @@
|
|||
package BasicPipes.pipes;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraft.src.CreativeTabs;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
import BasicPipes.BasicPipesMain;
|
||||
|
||||
public class ItemPipe extends Item
|
||||
{
|
||||
int index = 32;//32 + 4 rows alloted to pipes
|
||||
String[] names = new String[]{"Steam","Water","Lava","Oil","Fuel","Air","Methain","BioFuel","coolent","NukeWaste"};
|
||||
private int spawnID;
|
||||
|
||||
public ItemPipe(int id)
|
||||
{
|
||||
super(id);
|
||||
this.setMaxDamage(0);
|
||||
this.setHasSubtypes(true);
|
||||
this.setIconIndex(10);
|
||||
this.setItemName("pipe");
|
||||
this.setTabToDisplayOn(CreativeTabs.tabRedstone);
|
||||
}
|
||||
@Override
|
||||
public int getIconFromDamage(int par1)
|
||||
{
|
||||
|
||||
return par1+index;
|
||||
}
|
||||
@Override
|
||||
public String getItemNameIS(ItemStack itemstack)
|
||||
{
|
||||
return itemstack.getItemDamage() < names.length ? names[itemstack.getItemDamage()] +" Pipe2" : "EmptyPipe";
|
||||
}
|
||||
@Override
|
||||
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
for(int i = 0; i < names.length; i++)
|
||||
{
|
||||
par3List.add(new ItemStack(this, 1, i));
|
||||
}
|
||||
}
|
||||
public String getTextureFile() {
|
||||
return "/EUIClient/Textures/Items.png";
|
||||
}
|
||||
@Override
|
||||
public String getItemName()
|
||||
{
|
||||
return "Pipes";
|
||||
}
|
||||
@Override
|
||||
public boolean tryPlaceIntoWorld(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
||||
{
|
||||
int blockID = par3World.getBlockId(par4, par5, par6);
|
||||
spawnID = BasicPipesMain.pipeID;
|
||||
if (blockID == Block.snow.blockID)
|
||||
{
|
||||
par7 = 1;
|
||||
}
|
||||
else if (blockID != Block.vine.blockID && blockID != Block.tallGrass.blockID && blockID != Block.deadBush.blockID)
|
||||
{
|
||||
if (par7 == 0)
|
||||
{
|
||||
--par5;
|
||||
}
|
||||
|
||||
if (par7 == 1)
|
||||
{
|
||||
++par5;
|
||||
}
|
||||
|
||||
if (par7 == 2)
|
||||
{
|
||||
--par6;
|
||||
}
|
||||
|
||||
if (par7 == 3)
|
||||
{
|
||||
++par6;
|
||||
}
|
||||
|
||||
if (par7 == 4)
|
||||
{
|
||||
--par4;
|
||||
}
|
||||
|
||||
if (par7 == 5)
|
||||
{
|
||||
++par4;
|
||||
}
|
||||
}
|
||||
|
||||
if (BasicPipesMain.pipe.canPlaceBlockAt(par3World,par4,par5,par6))
|
||||
{
|
||||
Block var9 = Block.blocksList[this.spawnID];
|
||||
par3World.editingBlocks = true;
|
||||
if (par3World.setBlockWithNotify(par4, par5, par6, var9.blockID))
|
||||
{
|
||||
if (par3World.getBlockId(par4, par5, par6) == var9.blockID)
|
||||
{
|
||||
|
||||
Block.blocksList[this.spawnID].onBlockAdded(par3World, par4, par5, par6);
|
||||
Block.blocksList[this.spawnID].onBlockPlacedBy(par3World, par4, par5, par6, par2EntityPlayer);
|
||||
TileEntity blockEntity = par3World.getBlockTileEntity(par4, par5, par6);
|
||||
if(blockEntity instanceof TileEntityPipe)
|
||||
{
|
||||
TileEntityPipe pipeEntity = (TileEntityPipe) blockEntity;
|
||||
int dm = par1ItemStack.getItemDamage();
|
||||
pipeEntity.setType(dm);
|
||||
}
|
||||
}
|
||||
|
||||
--par1ItemStack.stackSize;
|
||||
par3World.editingBlocks = false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
par3World.editingBlocks = false;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
package BasicPipes.pipes;
|
||||
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.extend.IElectricUnit;
|
||||
import BasicPipes.pipes.api.ILiquidProducer;
|
||||
|
||||
public class TileEntityCondenser extends TileEntity implements ILiquidProducer, IElectricUnit {
|
||||
int tickCount = 0;
|
||||
int waterStored = 0;
|
||||
int energyStored = 0;
|
||||
@Override
|
||||
public int onProduceLiquid(int type,int maxVol, ForgeDirection side) {
|
||||
if(type == 1)
|
||||
{
|
||||
int tradeW = Math.min(maxVol, waterStored);
|
||||
waterStored -= tradeW;
|
||||
return tradeW;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
par1NBTTagCompound.setInteger("energyStored", (int)this.energyStored);
|
||||
par1NBTTagCompound.setInteger("waterStored", (int)this.waterStored);
|
||||
}
|
||||
|
||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
this.energyStored = par1NBTTagCompound.getInteger("energyStored");
|
||||
this.waterStored = par1NBTTagCompound.getInteger("waterStored");
|
||||
}
|
||||
public void updateEntity()
|
||||
{
|
||||
if(energyStored > 100 && tickCount > 200 && waterStored < 10)
|
||||
{
|
||||
energyStored -= 100;
|
||||
waterStored += 1;
|
||||
tickCount = 0;
|
||||
}
|
||||
tickCount++;
|
||||
}
|
||||
@Override
|
||||
public boolean canProduceLiquid(int type, ForgeDirection side) {
|
||||
if(type == 1)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void onDisable(int duration) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public boolean isDisabled() {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public void onUpdate(float amps, float voltage, ForgeDirection side) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
}
|
||||
@Override
|
||||
public float electricityRequest() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public boolean canConnect(ForgeDirection side) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean canReceiveFromSide(ForgeDirection side) {
|
||||
// TODO Auto-generated method stub
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public float getVoltage() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getTickInterval() {
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -1,267 +0,0 @@
|
|||
package BasicPipes.pipes;
|
||||
import net.minecraft.src.EntityPlayer;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.NetworkManager;
|
||||
import net.minecraft.src.Packet250CustomPayload;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.Vector3;
|
||||
import universalelectricity.network.IPacketReceiver;
|
||||
import universalelectricity.network.PacketManager;
|
||||
import BasicPipes.BasicPipesMain;
|
||||
import BasicPipes.pipes.api.ILiquidConsumer;
|
||||
import BasicPipes.pipes.api.ILiquidProducer;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
public class TileEntityPipe extends TileEntity implements ILiquidConsumer,IPacketReceiver
|
||||
{
|
||||
//The amount stored in the conductor
|
||||
protected int liquidStored = 0;
|
||||
//the current set type of the pipe 0-5
|
||||
protected int type = 0;
|
||||
//The maximum amount of electricity this conductor can take
|
||||
protected int capacity = 5;
|
||||
private int count = 0;
|
||||
private boolean intiUpdate = true;
|
||||
//Stores information on all connected blocks around this tile entity
|
||||
public TileEntity[] connectedBlocks = {null, null, null, null, null, null};
|
||||
|
||||
//Checks if this is the first the tile entity updates
|
||||
protected boolean firstUpdate = true;
|
||||
/**
|
||||
* This function adds a connection between this pipe and other blocks
|
||||
* @param tileEntity - Must be either a producer, consumer or a conductor
|
||||
* @param side - side in which the connection is coming from
|
||||
*/
|
||||
public void addConnection(TileEntity tileEntity, ForgeDirection side)
|
||||
{
|
||||
int sideN = getNumSide(side);
|
||||
this.connectedBlocks[sideN] = null;
|
||||
if(tileEntity instanceof ILiquidConsumer)
|
||||
{
|
||||
if(((ILiquidConsumer)tileEntity).canRecieveLiquid(this.type, side))
|
||||
{
|
||||
this.connectedBlocks[sideN] = tileEntity;
|
||||
}
|
||||
}
|
||||
if(tileEntity instanceof ILiquidProducer)
|
||||
{
|
||||
if(((ILiquidProducer)tileEntity).canProduceLiquid(this.type, side))
|
||||
{
|
||||
this.connectedBlocks[sideN] = tileEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private int getNumSide(ForgeDirection side) {
|
||||
|
||||
if(side == ForgeDirection.DOWN)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if(side == ForgeDirection.UP)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
if(side == ForgeDirection.NORTH)
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
if(side == ForgeDirection.SOUTH)
|
||||
{
|
||||
return 3;
|
||||
}
|
||||
if(side == ForgeDirection.WEST)
|
||||
{
|
||||
return 4;
|
||||
}
|
||||
if(side == ForgeDirection.EAST)
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* onRecieveLiquid is called whenever a something sends a volume to the pipe (which is this block).
|
||||
* @param vols - The amount of vol source is trying to give to this pipe
|
||||
* @param side - The side of the block in which the liquid came from
|
||||
* @return vol - The amount of rejected liquid that can't enter the pipe
|
||||
*/
|
||||
@Override
|
||||
public int onReceiveLiquid(int type,int vol, ForgeDirection side)
|
||||
{
|
||||
if(type == this.type)
|
||||
{
|
||||
int rejectedVolume = Math.max((this.getStoredLiquid(type) + vol) - this.capacity, 0);
|
||||
this.liquidStored += vol - rejectedVolume;
|
||||
return rejectedVolume;
|
||||
}
|
||||
return vol;
|
||||
}
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
//cause the block to update itself every tick needs to be change to .5 seconds to reduce load
|
||||
BlockPipe.updateConductorTileEntity(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
||||
count++;
|
||||
if(count >= 30 || intiUpdate)
|
||||
{
|
||||
PacketManager.sendTileEntityPacket(this, BasicPipesMain.channel, new Object[]{this.type});
|
||||
count = 0;
|
||||
intiUpdate = false;
|
||||
}
|
||||
if(!this.worldObj.isRemote)
|
||||
{
|
||||
byte connectedUnits = 0;
|
||||
byte connectedConductors = 1;
|
||||
int averageVolume = this.liquidStored;
|
||||
|
||||
Vector3 currentPosition = new Vector3(this.xCoord, this.yCoord, this.zCoord);
|
||||
|
||||
for(byte i = 0; i < 6; i++)
|
||||
{
|
||||
if(connectedBlocks[i] != null)
|
||||
{
|
||||
if(connectedBlocks[i] instanceof ILiquidConsumer || connectedBlocks[i] instanceof ILiquidProducer)
|
||||
{
|
||||
connectedUnits ++;
|
||||
|
||||
if(connectedBlocks[i] instanceof TileEntityPipe)
|
||||
{
|
||||
averageVolume += ((TileEntityPipe)connectedBlocks[i]).liquidStored;
|
||||
|
||||
connectedConductors ++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//average volume used to control volume spread to pipes. Prevent one pipe getting all liquid when another is empty
|
||||
averageVolume = Math.max(averageVolume/connectedConductors,0);
|
||||
if(connectedUnits > 0)
|
||||
{
|
||||
for(byte i = 0; i < 6; i++)
|
||||
{
|
||||
if(connectedBlocks[i] != null)
|
||||
{
|
||||
//Spread the liquid among the different blocks
|
||||
if(connectedBlocks[i] instanceof ILiquidConsumer && this.liquidStored > 0)
|
||||
{
|
||||
if(((ILiquidConsumer)connectedBlocks[i]).canRecieveLiquid(this.type,ForgeDirection.getOrientation(i)))
|
||||
{
|
||||
int transferVolumeAmount = 0; //amount to be moved
|
||||
ILiquidConsumer connectedConsumer = ((ILiquidConsumer)connectedBlocks[i]);
|
||||
|
||||
if(connectedBlocks[i] instanceof TileEntityPipe && this.liquidStored > ((TileEntityPipe)connectedConsumer).liquidStored)
|
||||
{
|
||||
transferVolumeAmount = Math.max(Math.min(averageVolume - ((TileEntityPipe)connectedConsumer).liquidStored, this.liquidStored), 0);
|
||||
}
|
||||
else if(!(connectedConsumer instanceof TileEntityPipe))
|
||||
{
|
||||
transferVolumeAmount = this.liquidStored;
|
||||
}
|
||||
|
||||
int rejectedVolume = connectedConsumer.onReceiveLiquid(this.type,transferVolumeAmount, ForgeDirection.getOrientation(i));
|
||||
this.liquidStored = Math.max(Math.min(this.liquidStored - transferVolumeAmount + rejectedVolume, 5), 0);
|
||||
}
|
||||
}
|
||||
|
||||
if(connectedBlocks[i] instanceof ILiquidProducer && this.liquidStored < this.getLiquidCapacity(type))
|
||||
{
|
||||
if(((ILiquidProducer)connectedBlocks[i]).canProduceLiquid(this.type,ForgeDirection.getOrientation(i)))
|
||||
{
|
||||
int gainedVolume = ((ILiquidProducer)connectedBlocks[i]).onProduceLiquid(this.type,5-this.liquidStored, ForgeDirection.getOrientation(i));
|
||||
this.onReceiveLiquid(this.type, gainedVolume, ForgeDirection.getOrientation(i));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Return the stored volume in this pipe.
|
||||
*/
|
||||
@Override
|
||||
public int getStoredLiquid(int type)
|
||||
{
|
||||
return this.liquidStored;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getLiquidCapacity(int type)
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a tile entity from NBT.
|
||||
*/
|
||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
this.liquidStored = par1NBTTagCompound.getInteger("liquid");
|
||||
this.type = par1NBTTagCompound.getInteger("type");
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a tile entity to NBT.
|
||||
*/
|
||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
par1NBTTagCompound.setInteger("liquid", this.liquidStored);
|
||||
par1NBTTagCompound.setInteger("type", this.type);
|
||||
}
|
||||
//find wether or not this side of X block can recieve X liquid type. Also use to determine connection of a pipe
|
||||
@Override
|
||||
public boolean canRecieveLiquid(int type, ForgeDirection side) {
|
||||
if(type == this.type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
//returns liquid type
|
||||
public int getType() {
|
||||
return this.type;
|
||||
}
|
||||
|
||||
//used by the item to set the liquid type on spawn
|
||||
public void setType(int rType) {
|
||||
this.type = rType;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void handlePacketData(NetworkManager network,
|
||||
Packet250CustomPayload packet, EntityPlayer player,
|
||||
ByteArrayDataInput data) {
|
||||
try
|
||||
{
|
||||
int type = data.readInt();
|
||||
if(worldObj.isRemote)
|
||||
{
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,89 +0,0 @@
|
|||
package BasicPipes.pipes;
|
||||
|
||||
import net.minecraft.src.Block;
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
import universalelectricity.electricity.TileEntityElectricUnit;
|
||||
import universalelectricity.extend.IElectricUnit;
|
||||
import BasicPipes.pipes.api.ILiquidProducer;
|
||||
|
||||
public class TileEntityPump extends TileEntityElectricUnit implements ILiquidProducer,IElectricUnit {
|
||||
int dCount = 0;
|
||||
float eStored = 0;
|
||||
float eMax = 2000;
|
||||
int wStored = 0;
|
||||
int wMax = 10;
|
||||
@Override
|
||||
public void onDisable(int duration) {
|
||||
dCount = duration;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisabled() {
|
||||
if(dCount <= 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(float watts, float voltage, ForgeDirection side) {
|
||||
super.onUpdate(watts, voltage, side);
|
||||
if (electricityRequest() > 0 && canConnect(side))
|
||||
{
|
||||
float rejectedElectricity = (float) Math.max((this.eStored + watts) - this.eMax, 0.0);
|
||||
this.eStored = (float) Math.max(this.eStored + watts - rejectedElectricity, 0.0);
|
||||
}
|
||||
int bBlock = worldObj.getBlockId(xCoord, yCoord -1, zCoord);
|
||||
if(bBlock == Block.waterStill.blockID && this.eStored > 1000 && this.wStored < this.wMax)
|
||||
{
|
||||
eStored -= 1000;
|
||||
wStored += 1;
|
||||
worldObj.setBlockAndMetadataWithNotify(xCoord, yCoord-1, zCoord, 0, 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public float electricityRequest() {
|
||||
return Math.max(eMax - eStored,0);
|
||||
}
|
||||
@Override
|
||||
public boolean canReceiveFromSide(ForgeDirection side) {
|
||||
if(side != ForgeDirection.DOWN)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getVoltage() {
|
||||
return 240;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTickInterval() {
|
||||
return 40;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int onProduceLiquid(int type, int maxVol, ForgeDirection side) {
|
||||
if(type == 1 && wStored > 0)
|
||||
{
|
||||
int tradeW = Math.min(maxVol, wStored);
|
||||
wStored -= tradeW;
|
||||
return tradeW;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canProduceLiquid(int type, ForgeDirection side) {
|
||||
if(type == 1 && side != ForgeDirection.DOWN)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,35 +0,0 @@
|
|||
package BasicPipes.pipes.api;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
|
||||
public interface ILiquidConsumer
|
||||
{
|
||||
/**
|
||||
* onRecieveLiquid
|
||||
* @param vol - The amount this block received.
|
||||
* @param side - The side of the block in which the liquid came from.
|
||||
* @parm type - The type of liquid being received
|
||||
* @return vol - The amount liquid that can't be recieved
|
||||
*/
|
||||
public int onReceiveLiquid(int type, int vol, ForgeDirection side);
|
||||
|
||||
/**
|
||||
* You can use this to check if a pipe can connect to this liquid consumer to properly render the graphics
|
||||
* @param forgeDirection - The side in which the electricity is coming from.
|
||||
* @parm type - The type of liquid
|
||||
* @return Returns true or false if this consumer can receive electricity at this given tick or moment.
|
||||
*/
|
||||
public boolean canRecieveLiquid(int type, ForgeDirection forgeDirection);
|
||||
|
||||
/**
|
||||
* @return Return the stored liquid of type in this consumer.
|
||||
*/
|
||||
public int getStoredLiquid(int type);
|
||||
|
||||
/**
|
||||
* @return Return the maximum amount of stored liquid this consumer can get.
|
||||
*/
|
||||
public int getLiquidCapacity(int type);
|
||||
|
||||
}
|
|
@ -1,30 +0,0 @@
|
|||
package BasicPipes.pipes.api;
|
||||
|
||||
import net.minecraftforge.common.ForgeDirection;
|
||||
|
||||
/**
|
||||
* The UEIProducer interface is an interface that must be applied to all tile entities that can produce electricity.
|
||||
* @author Calclavia
|
||||
*
|
||||
*/
|
||||
public interface ILiquidProducer
|
||||
{
|
||||
/**
|
||||
* onProduceLiquid
|
||||
* block.
|
||||
* @param type - the type of liquid
|
||||
* @param maxvol - The maximum vol or requested volume
|
||||
* @param side - The side
|
||||
* @return vol - Return a vol of liquid type that is produced
|
||||
*/
|
||||
public int onProduceLiquid(int type, int maxVol, ForgeDirection side);
|
||||
/**
|
||||
* canProduceLiquid
|
||||
* block.
|
||||
* @param type - the type of liquid
|
||||
* @param side - The side
|
||||
* @return boolean - True if can, false if can't produce liquid of type or on that side
|
||||
* Also used for connection rules of pipes'
|
||||
*/
|
||||
public boolean canProduceLiquid(int type, ForgeDirection side);
|
||||
}
|
Loading…
Reference in a new issue