seperated pipes to another repo
cleaning up how i do stuff and moved pipes to its own repo
This commit is contained in:
parent
07f231fb72
commit
2043d4b09e
9 changed files with 0 additions and 838 deletions
|
@ -1,136 +0,0 @@
|
|||
package net.minecraft.src.eui.pipes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.src.eui.api.*;
|
||||
import net.minecraft.src.eui.pipes.api.ILiquidConsumer;
|
||||
import net.minecraft.src.eui.pipes.api.ILiquidProducer;
|
||||
import net.minecraft.src.eui.*;
|
||||
import net.minecraft.src.universalelectricity.UniversalElectricity;
|
||||
import net.minecraft.src.*;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
public TileEntity getBlockEntity()
|
||||
{
|
||||
return new TileEntityPipe();
|
||||
}
|
||||
|
||||
//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,UniversalElectricity.getOrientationFromSide(side, (byte)2)))
|
||||
{
|
||||
returnValue = tileEntity;
|
||||
}
|
||||
}
|
||||
|
||||
if (tileEntity instanceof ILiquidProducer)
|
||||
{
|
||||
if(((ILiquidProducer)tileEntity).canProduceLiquid(type,UniversalElectricity.getOrientationFromSide(side, (byte)2)))
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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), i);;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1,85 +0,0 @@
|
|||
package net.minecraft.src.eui.pipes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.src.forge.*;
|
||||
import net.minecraft.src.*;
|
||||
|
||||
public class ItemGuage extends Item implements ITextureProvider
|
||||
{
|
||||
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";
|
||||
}
|
||||
@Override
|
||||
public void addCreativeItems(ArrayList itemList) {
|
||||
|
||||
itemList.add(new ItemStack(this, 1,0));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,68 +0,0 @@
|
|||
package net.minecraft.src.eui.pipes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.src.Item;
|
||||
import net.minecraft.src.ItemStack;
|
||||
import net.minecraft.src.forge.ITextureProvider;
|
||||
|
||||
public class ItemParts extends Item implements ITextureProvider{
|
||||
|
||||
public ItemParts(int par1)
|
||||
{
|
||||
super(par1);
|
||||
this.setItemName("Parts");
|
||||
this.setHasSubtypes(true);
|
||||
this.setMaxDamage(0);
|
||||
this.setMaxStackSize(64);
|
||||
}
|
||||
@Override
|
||||
public int getIconFromDamage(int par1)
|
||||
{
|
||||
switch(par1)
|
||||
{
|
||||
case 0: return 7;
|
||||
case 1: return 7;
|
||||
case 2: return 8;
|
||||
}
|
||||
return this.iconIndex;
|
||||
}
|
||||
@Override
|
||||
public String getTextureFile() {
|
||||
// TODO Auto-generated method stub
|
||||
return "/eui/Items.png";
|
||||
}
|
||||
@Override
|
||||
public String getItemName()
|
||||
{
|
||||
return "parts";
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String getItemNameIS(ItemStack par1ItemStack)
|
||||
{
|
||||
int var3 = par1ItemStack.getItemDamage();
|
||||
switch(var3)
|
||||
{
|
||||
case 0: return "BronzeTube";
|
||||
case 1: return "ObbyTube";
|
||||
case 2: return "Seal";
|
||||
case 3: return "IronTube";
|
||||
case 4: return "StickSeal";
|
||||
}
|
||||
return this.getItemName();
|
||||
}
|
||||
@Override
|
||||
public void addCreativeItems(ArrayList itemList)
|
||||
{
|
||||
itemList.add(new ItemStack(this, 1,0));
|
||||
itemList.add(new ItemStack(this, 1,1));
|
||||
itemList.add(new ItemStack(this, 1,2));
|
||||
itemList.add(new ItemStack(this, 1,3));
|
||||
itemList.add(new ItemStack(this, 1,4));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,137 +0,0 @@
|
|||
package net.minecraft.src.eui.pipes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.src.forge.*;
|
||||
import net.minecraft.src.*;
|
||||
|
||||
public class ItemPipe extends Item implements ITextureProvider
|
||||
{
|
||||
private int spawnID;
|
||||
|
||||
public ItemPipe(int id)
|
||||
{
|
||||
super(id);
|
||||
this.setMaxDamage(0);
|
||||
this.setHasSubtypes(true);
|
||||
this.setIconIndex(10);
|
||||
this.setItemName("pipe");
|
||||
}
|
||||
@Override
|
||||
public int getIconFromDamage(int par1)
|
||||
{
|
||||
switch(par1)
|
||||
{
|
||||
case 0: return 11;
|
||||
case 1: return 10;
|
||||
case 2: return 14;
|
||||
case 3: return 12;
|
||||
case 4: return 13;
|
||||
case 5: return 15;
|
||||
}
|
||||
return this.iconIndex;
|
||||
}
|
||||
@Override
|
||||
public String getItemName()
|
||||
{
|
||||
return "Pipes";
|
||||
}
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7)
|
||||
{
|
||||
int blockID = par3World.getBlockId(par4, par5, par6);
|
||||
spawnID = mod_BasicPipes.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 (par3World.canBlockBePlacedAt(this.spawnID, par4, par5, par6, false, par7))
|
||||
{
|
||||
Block var9 = Block.blocksList[this.spawnID];
|
||||
|
||||
if (par3World.setBlockWithNotify(par4, par5, par6, this.spawnID))
|
||||
{
|
||||
if (par3World.getBlockId(par4, par5, par6) == this.spawnID)
|
||||
{
|
||||
Block.blocksList[this.spawnID].onBlockPlaced(par3World, par4, par5, par6, par7);
|
||||
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();
|
||||
String rType = "air";
|
||||
pipeEntity.setType(dm);
|
||||
}
|
||||
}
|
||||
|
||||
--par1ItemStack.stackSize;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
public String getItemNameIS(ItemStack par1ItemStack)
|
||||
{
|
||||
int var3 = par1ItemStack.getItemDamage();
|
||||
switch(var3)
|
||||
{
|
||||
case 0: return "steamPipe";
|
||||
case 1: return "waterPipe";
|
||||
case 2: return "lavaPipe";
|
||||
case 3: return "oilPipe";
|
||||
case 4: return "fuelPipe";
|
||||
case 5: return "airPipe";
|
||||
default: return "Pipe";
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public String getTextureFile() {
|
||||
return "/eui/Items.png";
|
||||
}
|
||||
@Override
|
||||
public void addCreativeItems(ArrayList itemList) {
|
||||
|
||||
itemList.add(new ItemStack(this, 1,0));
|
||||
itemList.add(new ItemStack(this, 1,1));
|
||||
itemList.add(new ItemStack(this, 1,2));
|
||||
itemList.add(new ItemStack(this, 1,3));
|
||||
itemList.add(new ItemStack(this, 1,4));
|
||||
itemList.add(new ItemStack(this, 1,5));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
package net.minecraft.src.eui.pipes;
|
||||
|
||||
import net.minecraft.src.*;
|
||||
|
||||
public class ModelPipe extends ModelBase
|
||||
{
|
||||
//fields
|
||||
ModelRenderer Middle;
|
||||
ModelRenderer Right;
|
||||
ModelRenderer Left;
|
||||
ModelRenderer Back;
|
||||
ModelRenderer Front;
|
||||
ModelRenderer Top;
|
||||
ModelRenderer Bottom;
|
||||
|
||||
public ModelPipe()
|
||||
{
|
||||
textureWidth = 64;
|
||||
textureHeight = 32;
|
||||
|
||||
Middle = new ModelRenderer(this, 0, 0);
|
||||
Middle.addBox(-1F, -1F, -1F, 4, 4, 4);
|
||||
Middle.setRotationPoint(-1F, 15F, -1F);
|
||||
Middle.setTextureSize(64, 32);
|
||||
Middle.mirror = true;
|
||||
setRotation(Middle, 0F, 0F, 0F);
|
||||
Right = new ModelRenderer(this, 21, 0);
|
||||
Right.addBox(0F, 0F, 0F, 6, 4, 4);
|
||||
Right.setRotationPoint(2F, 14F, -2F);
|
||||
Right.setTextureSize(64, 32);
|
||||
Right.mirror = true;
|
||||
setRotation(Right, 0F, 0F, 0F);
|
||||
Left = new ModelRenderer(this, 21, 0);
|
||||
Left.addBox(0F, 0F, 0F, 6, 4, 4);
|
||||
Left.setRotationPoint(-8F, 14F, -2F);
|
||||
Left.setTextureSize(64, 32);
|
||||
Left.mirror = true;
|
||||
setRotation(Left, 0F, 0F, 0F);
|
||||
Back = new ModelRenderer(this, 0, 11);
|
||||
Back.addBox(0F, 0F, 0F, 4, 4, 6);
|
||||
Back.setRotationPoint(-2F, 14F, 2F);
|
||||
Back.setTextureSize(64, 32);
|
||||
Back.mirror = true;
|
||||
setRotation(Back, 0F, 0F, 0F);
|
||||
Front = new ModelRenderer(this, 0, 11);
|
||||
Front.addBox(0F, 0F, 0F, 4, 4, 6);
|
||||
Front.setRotationPoint(-2F, 14F, -8F);
|
||||
Front.setTextureSize(64, 32);
|
||||
Front.mirror = true;
|
||||
setRotation(Front, 0F, 0F, 0F);
|
||||
Top = new ModelRenderer(this, 21, 11);
|
||||
Top.addBox(0F, 0F, 0F, 4, 6, 4);
|
||||
Top.setRotationPoint(-2F, 8F, -2F);
|
||||
Top.setTextureSize(64, 32);
|
||||
Top.mirror = true;
|
||||
setRotation(Top, 0F, 0F, 0F);
|
||||
Bottom = new ModelRenderer(this, 21, 11);
|
||||
Bottom.addBox(0F, 0F, 0F, 4, 6, 4);
|
||||
Bottom.setRotationPoint(-2F, 18F, -2F);
|
||||
Bottom.setTextureSize(64, 32);
|
||||
Bottom.mirror = true;
|
||||
setRotation(Bottom, 0F, 0F, 0F);
|
||||
}
|
||||
|
||||
public void render(Entity entity, float f, float f1, float f2, float f3, float f4, float f5)
|
||||
{
|
||||
super.render(entity, f, f1, f2, f3, f4, f5);
|
||||
setRotationAngles(f, f1, f2, f3, f4, f5);
|
||||
this.renderMiddle();
|
||||
this.renderBottom();
|
||||
this.renderTop();
|
||||
this.renderLeft();
|
||||
this.renderRight();
|
||||
this.renderBack();
|
||||
this.renderFront();
|
||||
}
|
||||
|
||||
public void renderMiddle() { Middle.render(0.0625F); }
|
||||
public void renderBottom() { Bottom.render(0.0625F); }
|
||||
public void renderTop() { Top.render(0.0625F); }
|
||||
public void renderLeft() { Left.render(0.0625F); }
|
||||
public void renderRight() { Right.render(0.0625F); }
|
||||
public void renderBack() { Back.render(0.0625F); }
|
||||
public void renderFront() { Front.render(0.0625F);}
|
||||
|
||||
private void setRotation(ModelRenderer model, float x, float y, float z)
|
||||
{
|
||||
model.rotateAngleX = x;
|
||||
model.rotateAngleY = y;
|
||||
model.rotateAngleZ = z;
|
||||
}
|
||||
|
||||
public void setRotationAngles(float f, float f1, float f2, float f3, float f4, float f5)
|
||||
{
|
||||
super.setRotationAngles(f, f1, f2, f3, f4, f5);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
package net.minecraft.src.eui.pipes;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import net.minecraft.src.*;
|
||||
|
||||
public class RenderPipe extends TileEntitySpecialRenderer
|
||||
{
|
||||
int type = 0;
|
||||
private ModelPipe model;
|
||||
|
||||
public RenderPipe()
|
||||
{
|
||||
model = new ModelPipe();
|
||||
}
|
||||
|
||||
public void renderAModelAt(TileEntityPipe tileEntity, double d, double d1, double d2, float f)
|
||||
{
|
||||
//Texture file
|
||||
|
||||
type = tileEntity.getType();
|
||||
switch(type)
|
||||
{
|
||||
case 0: bindTextureByName("/eui/SteamPipe.png");break;
|
||||
case 1: bindTextureByName("/eui/WaterPipe.png");break;
|
||||
//case 2: bindTextureByName("/eui/lavaPipe.png");break;
|
||||
//case 3: bindTextureByName("/eui/oilPipe.png");break;
|
||||
//case 4: bindTextureByName("/eui/fuelPipe.png");break;
|
||||
//case 5: bindTextureByName("/eui/airPipe.png");break;
|
||||
default:bindTextureByName("/eui/DefaultPipe.png"); break;
|
||||
}
|
||||
|
||||
GL11.glPushMatrix();
|
||||
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
|
||||
GL11.glScalef(1.0F, -1F, -1F);
|
||||
|
||||
if(tileEntity.connectedBlocks[0] != null) model.renderBottom();
|
||||
if(tileEntity.connectedBlocks[1] != null) model.renderTop();
|
||||
if(tileEntity.connectedBlocks[2] != null) model.renderFront();
|
||||
if(tileEntity.connectedBlocks[3] != null) model.renderBack();
|
||||
if(tileEntity.connectedBlocks[4] != null) model.renderRight();
|
||||
if(tileEntity.connectedBlocks[5] != null) model.renderLeft();
|
||||
|
||||
model.renderMiddle();
|
||||
GL11.glPopMatrix();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8) {
|
||||
this.renderAModelAt((TileEntityPipe)tileEntity, var2, var4, var6, var8);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,200 +0,0 @@
|
|||
package net.minecraft.src.eui.pipes;
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.World;
|
||||
import net.minecraft.src.eui.pipes.api.ILiquidConsumer;
|
||||
import net.minecraft.src.eui.pipes.api.ILiquidProducer;
|
||||
import net.minecraft.src.universalelectricity.UniversalElectricity;
|
||||
import net.minecraft.src.universalelectricity.Vector3;
|
||||
|
||||
public class TileEntityPipe extends TileEntity implements ILiquidConsumer
|
||||
{
|
||||
//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;
|
||||
|
||||
//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, byte side)
|
||||
{
|
||||
this.connectedBlocks[side] = null;
|
||||
if(tileEntity instanceof ILiquidConsumer)
|
||||
{
|
||||
if(((ILiquidConsumer)tileEntity).canRecieveLiquid(this.type, side))
|
||||
{
|
||||
this.connectedBlocks[side] = tileEntity;
|
||||
}
|
||||
}
|
||||
if(tileEntity instanceof ILiquidProducer)
|
||||
{
|
||||
if(((ILiquidProducer)tileEntity).canProduceLiquid(this.type, side))
|
||||
{
|
||||
this.connectedBlocks[side] = tileEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 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, byte 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)this.getBlockType()).updateConductorTileEntity(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
||||
|
||||
|
||||
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,UniversalElectricity.getOrientationFromSide(i, (byte)2)))
|
||||
{
|
||||
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, UniversalElectricity.getOrientationFromSide(i, (byte)2));
|
||||
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,UniversalElectricity.getOrientationFromSide(i, (byte)2)))
|
||||
{
|
||||
int gainedVolume = ((ILiquidProducer)connectedBlocks[i]).onProduceLiquid(this.type,5-this.liquidStored, UniversalElectricity.getOrientationFromSide(i, (byte)2));
|
||||
this.onReceiveLiquid(this.type, gainedVolume, 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, byte 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;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,33 +0,0 @@
|
|||
package net.minecraft.src.eui.pipes.api;
|
||||
|
||||
|
||||
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, byte side);
|
||||
|
||||
/**
|
||||
* You can use this to check if a pipe can connect to this liquid consumer to properly render the graphics
|
||||
* @param side - 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, byte side);
|
||||
|
||||
/**
|
||||
* @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,28 +0,0 @@
|
|||
package net.minecraft.src.eui.pipes.api;
|
||||
|
||||
/**
|
||||
* 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, int 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, byte side);
|
||||
}
|
Loading…
Reference in a new issue