Remove old code
*already remove from main code but forgot to delete from git repo
This commit is contained in:
parent
e3f5753b0e
commit
23b1e4ee29
8 changed files with 0 additions and 999 deletions
|
@ -1,139 +0,0 @@
|
|||
package net.minecraft.src.eui.steam;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.src.eui.api.*;
|
||||
import net.minecraft.src.eui.*;
|
||||
import net.minecraft.src.eui.boiler.TileEntityBoiler;
|
||||
import net.minecraft.src.eui.turbine.TileEntityGenerator;
|
||||
import net.minecraft.src.eui.steam.TileEntityPipe;
|
||||
import net.minecraft.src.universalelectricity.UniversalElectricity;
|
||||
import net.minecraft.src.*;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockPipe extends BlockContainer
|
||||
{
|
||||
static String type = "";
|
||||
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 mod_EUIndustry.pipeID;
|
||||
}
|
||||
|
||||
public TileEntity getBlockEntity()
|
||||
{
|
||||
return new TileEntityPipe();
|
||||
}
|
||||
|
||||
//Per tick
|
||||
public int conductorCapacity()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
public static TileEntity getUEUnit(World world, int x, int y, int z, byte side)
|
||||
{
|
||||
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 ISteamConsumer)
|
||||
{
|
||||
if(((ISteamConsumer)tileEntity).canRecieveSteam(UniversalElectricity.getOrientationFromSide(side, (byte)2)))
|
||||
{
|
||||
returnValue = tileEntity;
|
||||
}
|
||||
}
|
||||
|
||||
if (tileEntity instanceof ISteamProducer)
|
||||
{
|
||||
if(((ISteamProducer)tileEntity).canProduceSteam(UniversalElectricity.getOrientationFromSide(side, (byte)2)))
|
||||
{
|
||||
returnValue = tileEntity;
|
||||
}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 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);
|
||||
conductorTileEntity.addConnection(getUEUnit(world, x, y, z, i), i);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,139 +0,0 @@
|
|||
package net.minecraft.src.eui.steam;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import net.minecraft.src.eui.api.IWaterConsumer;
|
||||
import net.minecraft.src.eui.api.IWaterProducer;
|
||||
import net.minecraft.src.eui.*;
|
||||
import net.minecraft.src.eui.boiler.TileEntityBoiler;
|
||||
import net.minecraft.src.eui.turbine.TileEntityGenerator;
|
||||
import net.minecraft.src.eui.steam.TileEntityPipeWater;
|
||||
import net.minecraft.src.universalelectricity.UniversalElectricity;
|
||||
import net.minecraft.src.*;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
public class BlockPipeWater extends BlockContainer
|
||||
{
|
||||
static String type = "";
|
||||
public BlockPipeWater(int id)
|
||||
{
|
||||
super(id, Material.iron);
|
||||
this.setBlockName("PipeW");
|
||||
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 mod_EUIndustry.pipeID;
|
||||
}
|
||||
|
||||
public TileEntity getBlockEntity()
|
||||
{
|
||||
return new TileEntityPipeWater();
|
||||
}
|
||||
|
||||
//Per tick
|
||||
public int conductorCapacity()
|
||||
{
|
||||
return 5;
|
||||
}
|
||||
public static TileEntity getUEUnit(World world, int x, int y, int z, byte side)
|
||||
{
|
||||
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 IWaterConsumer)
|
||||
{
|
||||
if(((IWaterConsumer)tileEntity).canRecieveWater(UniversalElectricity.getOrientationFromSide(side, (byte)2)))
|
||||
{
|
||||
returnValue = tileEntity;
|
||||
}
|
||||
}
|
||||
|
||||
if (tileEntity instanceof IWaterProducer)
|
||||
{
|
||||
if(((IWaterProducer)tileEntity).canProduceWater(UniversalElectricity.getOrientationFromSide(side, (byte)2)))
|
||||
{
|
||||
returnValue = tileEntity;
|
||||
}
|
||||
}
|
||||
|
||||
return returnValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 void updateConductorTileEntity(World world, int x, int y, int z)
|
||||
{
|
||||
for(byte i = 0; i < 6; i++)
|
||||
{
|
||||
//Update the tile entity on neighboring blocks
|
||||
TileEntityPipeWater conductorTileEntity = (TileEntityPipeWater)world.getBlockTileEntity(x, y, z);
|
||||
conductorTileEntity.addConnection(getUEUnit(world, x, y, z, i), i);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -1,123 +0,0 @@
|
|||
package net.minecraft.src.eui.steam;
|
||||
|
||||
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;
|
||||
}
|
||||
return this.iconIndex;
|
||||
}
|
||||
public String getItemNameIS(ItemStack par1ItemStack)
|
||||
{
|
||||
int var3 = par1ItemStack.getItemDamage();
|
||||
switch(var3)
|
||||
{
|
||||
case 1: return "waterPipe";
|
||||
case 0: return "steamPipe";
|
||||
}
|
||||
return this.getItemName();
|
||||
}
|
||||
/**
|
||||
* Callback for item usage. If the item does something special on right clicking, he will have one of those. Return
|
||||
* True if something happen and false if it don't. This is for ITEMS, not BLOCKS !
|
||||
*/
|
||||
public boolean onItemUse(ItemStack par1ItemStack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7)
|
||||
{
|
||||
int blockID = par3World.getBlockId(par4, par5, par6);
|
||||
if(par1ItemStack.getItemDamage() == 0)
|
||||
{
|
||||
spawnID = mod_EUIndustry.pipeBlockID;
|
||||
}
|
||||
if(par1ItemStack.getItemDamage() == 1)
|
||||
{
|
||||
spawnID = mod_EUIndustry.pipeBlockID2;
|
||||
}
|
||||
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);
|
||||
}
|
||||
|
||||
--par1ItemStack.stackSize;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTextureFile() {
|
||||
return "/eui/Items.png";
|
||||
}
|
||||
public void addCreativeItems(ArrayList itemList) {
|
||||
|
||||
itemList.add(new ItemStack(this, 1,0));
|
||||
itemList.add(new ItemStack(this, 1,1));
|
||||
}
|
||||
|
||||
}
|
|
@ -1,98 +0,0 @@
|
|||
package net.minecraft.src.eui.steam;
|
||||
|
||||
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,40 +0,0 @@
|
|||
package net.minecraft.src.eui.steam;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import net.minecraft.src.*;
|
||||
|
||||
public class RenderPipe extends TileEntitySpecialRenderer
|
||||
{
|
||||
private ModelPipe model;
|
||||
|
||||
public RenderPipe()
|
||||
{
|
||||
model = new ModelPipe();
|
||||
}
|
||||
|
||||
public void renderAModelAt(TileEntityPipe tileEntity, double d, double d1, double d2, float f)
|
||||
{
|
||||
//Texture file
|
||||
bindTextureByName("/eui/CopperWire.png");
|
||||
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,40 +0,0 @@
|
|||
package net.minecraft.src.eui.steam;
|
||||
|
||||
import org.lwjgl.opengl.GL11;
|
||||
import net.minecraft.src.*;
|
||||
|
||||
public class RenderPipeWater extends TileEntitySpecialRenderer
|
||||
{
|
||||
private ModelPipe model;
|
||||
|
||||
public RenderPipeWater()
|
||||
{
|
||||
model = new ModelPipe();
|
||||
}
|
||||
|
||||
public void renderAModelAt(TileEntityPipeWater tileEntity, double d, double d1, double d2, float f)
|
||||
{
|
||||
//Texture file
|
||||
bindTextureByName("/eui/WaterPipe.png");
|
||||
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((TileEntityPipeWater)tileEntity, var2, var4, var6, var8);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,213 +0,0 @@
|
|||
package net.minecraft.src.eui.steam;
|
||||
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.eui.api.ISteamConsumer;
|
||||
import net.minecraft.src.eui.api.ISteamProducer;
|
||||
import net.minecraft.src.universalelectricity.UniversalElectricity;
|
||||
import net.minecraft.src.universalelectricity.Vector3;
|
||||
|
||||
public class TileEntityPipe extends TileEntity implements ISteamConsumer
|
||||
{
|
||||
//The amount of electricity stored in the conductor
|
||||
protected int steamStored = 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;
|
||||
|
||||
/**
|
||||
* The tile entity of the closest electric consumer. Null if none. Use this to detect if electricity
|
||||
* should transfer
|
||||
*/
|
||||
public TileEntity closestConsumer = null;
|
||||
|
||||
/**
|
||||
* This function adds a connection between this conductor and the UE unit
|
||||
* @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)
|
||||
{
|
||||
if(tileEntity instanceof ISteamConsumer || tileEntity instanceof ISteamProducer)
|
||||
{
|
||||
this.connectedBlocks[side] = tileEntity;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.connectedBlocks[side] = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* onRecieveElectricity is called whenever a Universal Electric conductor sends a packet of electricity to the consumer (which is this block).
|
||||
* @param watts - The amount of watt this block recieved
|
||||
* @param side - The side of the block in which the electricity came from
|
||||
* @return watt - The amount of rejected power to be sent back into the conductor
|
||||
*/
|
||||
@Override
|
||||
public int onReceiveSteam(int watt, byte side)
|
||||
{
|
||||
int rejectedElectricity = Math.max((this.steamStored + watt) - this.capacity, 0);
|
||||
this.steamStored += watt - rejectedElectricity;
|
||||
return rejectedElectricity;
|
||||
}
|
||||
|
||||
/**
|
||||
* You can use this to check if a wire can connect to this UE consumer to properly render the graphics
|
||||
* @return Returns true or false if this consumer can receive electricity at this given tick or moment.
|
||||
*/
|
||||
public boolean canRecieveSteam(byte side)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count
|
||||
* ticks and creates a new spawn inside its implementation.
|
||||
*/
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if(this.firstUpdate)
|
||||
{
|
||||
//Update some variables
|
||||
BlockPipe conductorBlock = (BlockPipe)this.getBlockType();
|
||||
this.capacity = (conductorBlock).conductorCapacity();
|
||||
((BlockPipe)this.getBlockType()).updateConductorTileEntity(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
||||
this.firstUpdate = false;
|
||||
}
|
||||
|
||||
//Spread the electricity to neighboring blocks
|
||||
byte connectedUnits = 0;
|
||||
byte connectedConductors = 1;
|
||||
int averageElectricity = this.steamStored;
|
||||
this.closestConsumer = null;
|
||||
|
||||
Vector3 currentPosition = new Vector3(this.xCoord, this.yCoord, this.zCoord);
|
||||
if(this.steamStored * 3.3 > 250)
|
||||
{
|
||||
// TODO add logic to damage pipe if steam rises to 250PSI
|
||||
}
|
||||
//Find the connected unit with the least amount of electricity and give more to them
|
||||
for(byte i = 0; i < 6; i++)
|
||||
{
|
||||
if(connectedBlocks[i] != null)
|
||||
{
|
||||
if(connectedBlocks[i] instanceof ISteamConsumer)
|
||||
{
|
||||
connectedUnits ++;
|
||||
|
||||
if(connectedBlocks[i].getClass() == this.getClass())
|
||||
{
|
||||
averageElectricity += ((TileEntityPipe)connectedBlocks[i]).steamStored;
|
||||
|
||||
TileEntity tileEntity = ((TileEntityPipe)connectedBlocks[i]).closestConsumer;
|
||||
|
||||
if(tileEntity != null)
|
||||
{
|
||||
this.closestConsumer = tileEntity;
|
||||
}
|
||||
|
||||
connectedConductors ++;
|
||||
}
|
||||
else if(connectedBlocks[i] instanceof ISteamConsumer)
|
||||
{
|
||||
if(((ISteamConsumer)connectedBlocks[i]).canRecieveSteam(UniversalElectricity.getOrientationFromSide(i, (byte)2)))
|
||||
{
|
||||
this.closestConsumer = connectedBlocks[i];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
averageElectricity = averageElectricity/connectedConductors;
|
||||
|
||||
|
||||
float averageWatt = 0;
|
||||
|
||||
if(connectedUnits > 0)
|
||||
{
|
||||
for(byte i = 0; i < 6; i++)
|
||||
{
|
||||
if(connectedBlocks[i] != null)
|
||||
{
|
||||
//Spread the electricity among the different blocks
|
||||
if(connectedBlocks[i] instanceof ISteamConsumer && this.steamStored > 0)
|
||||
{
|
||||
if(((ISteamConsumer)connectedBlocks[i]).canRecieveSteam(UniversalElectricity.getOrientationFromSide(i, (byte) 2)))
|
||||
{
|
||||
int transferElectricityAmount = 0;
|
||||
ISteamConsumer connectedConsumer = ((ISteamConsumer)connectedBlocks[i]);
|
||||
|
||||
if(connectedBlocks[i].getClass() == this.getClass() && this.steamStored > ((TileEntityPipe)connectedConsumer).steamStored)
|
||||
{
|
||||
transferElectricityAmount = Math.max(Math.min(averageElectricity - ((TileEntityPipe)connectedConsumer).steamStored, this.steamStored), 0);
|
||||
}
|
||||
else if(!(connectedConsumer instanceof TileEntityPipe))
|
||||
{
|
||||
transferElectricityAmount = this.steamStored;
|
||||
}
|
||||
|
||||
int rejectedElectricity = connectedConsumer.onReceiveSteam(transferElectricityAmount, UniversalElectricity.getOrientationFromSide(i, (byte)2));
|
||||
this.steamStored = Math.max(Math.min(this.steamStored - transferElectricityAmount + rejectedElectricity, this.capacity), 0);
|
||||
}
|
||||
}
|
||||
|
||||
if(connectedBlocks[i] instanceof ISteamProducer && this.steamStored < this.getSteamCapacity())
|
||||
{
|
||||
if(((ISteamProducer)connectedBlocks[i]).canProduceSteam(UniversalElectricity.getOrientationFromSide(i, (byte)2)))
|
||||
{
|
||||
int gainedElectricity = ((ISteamProducer)connectedBlocks[i]).onProduceSteam(this.capacity-this.steamStored, UniversalElectricity.getOrientationFromSide(i, (byte)2));
|
||||
this.steamStored = Math.max(Math.min(this.steamStored + gainedElectricity, this.capacity), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Return the stored electricity in this consumer. Called by conductors to spread electricity to this unit.
|
||||
*/
|
||||
@Override
|
||||
public int getStoredSteam()
|
||||
{
|
||||
return this.steamStored;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSteamCapacity()
|
||||
{
|
||||
return this.capacity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a tile entity from NBT.
|
||||
*/
|
||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
this.steamStored = par1NBTTagCompound.getInteger("steamStored");
|
||||
this.capacity = par1NBTTagCompound.getInteger("capacity");
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a tile entity to NBT.
|
||||
*/
|
||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
par1NBTTagCompound.setInteger("steamStored", this.steamStored);
|
||||
par1NBTTagCompound.setInteger("capacity", this.capacity);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,207 +0,0 @@
|
|||
package net.minecraft.src.eui.steam;
|
||||
|
||||
import net.minecraft.src.NBTTagCompound;
|
||||
import net.minecraft.src.TileEntity;
|
||||
import net.minecraft.src.eui.api.IWaterConsumer;
|
||||
import net.minecraft.src.eui.api.IWaterProducer;
|
||||
import net.minecraft.src.universalelectricity.UniversalElectricity;
|
||||
import net.minecraft.src.universalelectricity.Vector3;
|
||||
|
||||
public class TileEntityPipeWater extends TileEntity implements IWaterConsumer
|
||||
{
|
||||
//The amount of electricity stored in the conductor
|
||||
protected int waterStored = 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;
|
||||
|
||||
/**
|
||||
* The tile entity of the closest electric consumer. Null if none. Use this to detect if electricity
|
||||
* should transfer
|
||||
*/
|
||||
public TileEntity closestConsumer = null;
|
||||
|
||||
/**
|
||||
* This function adds a connection between this conductor and the UE unit
|
||||
* @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)
|
||||
{
|
||||
if(tileEntity instanceof IWaterConsumer || tileEntity instanceof IWaterProducer)
|
||||
{
|
||||
this.connectedBlocks[side] = tileEntity;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.connectedBlocks[side] = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* onRecieveElectricity is called whenever a Universal Electric conductor sends a packet of electricity to the consumer (which is this block).
|
||||
* @param watts - The amount of watt this block recieved
|
||||
* @param side - The side of the block in which the electricity came from
|
||||
* @return watt - The amount of rejected power to be sent back into the conductor
|
||||
*/
|
||||
@Override
|
||||
public int onReceiveWater(int watt, byte side)
|
||||
{
|
||||
int rejectedElectricity = Math.max((this.waterStored + watt) - this.capacity, 0);
|
||||
this.waterStored += watt - rejectedElectricity;
|
||||
return rejectedElectricity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Allows the entity to update its state. Overridden in most subclasses, e.g. the mob spawner uses this to count
|
||||
* ticks and creates a new spawn inside its implementation.
|
||||
*/
|
||||
@Override
|
||||
public void updateEntity()
|
||||
{
|
||||
if(this.firstUpdate)
|
||||
{
|
||||
//Update some variables
|
||||
BlockPipeWater conductorBlock = (BlockPipeWater)this.getBlockType();
|
||||
this.capacity = (conductorBlock).conductorCapacity();
|
||||
((BlockPipeWater)this.getBlockType()).updateConductorTileEntity(this.worldObj, this.xCoord, this.yCoord, this.zCoord);
|
||||
this.firstUpdate = false;
|
||||
}
|
||||
|
||||
//Spread the electricity to neighboring blocks
|
||||
byte connectedUnits = 0;
|
||||
byte connectedConductors = 1;
|
||||
int averageElectricity = this.waterStored;
|
||||
this.closestConsumer = null;
|
||||
|
||||
Vector3 currentPosition = new Vector3(this.xCoord, this.yCoord, this.zCoord);
|
||||
|
||||
//Find the connected unit with the least amount of electricity and give more to them
|
||||
for(byte i = 0; i < 6; i++)
|
||||
{
|
||||
if(connectedBlocks[i] != null)
|
||||
{
|
||||
if(connectedBlocks[i] instanceof IWaterConsumer)
|
||||
{
|
||||
connectedUnits ++;
|
||||
|
||||
if(connectedBlocks[i].getClass() == this.getClass())
|
||||
{
|
||||
averageElectricity += ((TileEntityPipeWater)connectedBlocks[i]).waterStored;
|
||||
|
||||
TileEntity tileEntity = ((TileEntityPipeWater)connectedBlocks[i]).closestConsumer;
|
||||
|
||||
if(tileEntity != null)
|
||||
{
|
||||
this.closestConsumer = tileEntity;
|
||||
}
|
||||
|
||||
connectedConductors ++;
|
||||
}
|
||||
else if(connectedBlocks[i] instanceof IWaterConsumer)
|
||||
{
|
||||
if(((IWaterConsumer)connectedBlocks[i]).canRecieveWater(UniversalElectricity.getOrientationFromSide(i, (byte)2)))
|
||||
{
|
||||
this.closestConsumer = connectedBlocks[i];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
averageElectricity = averageElectricity/connectedConductors;
|
||||
|
||||
|
||||
float averageWatt = 0;
|
||||
|
||||
if(connectedUnits > 0)
|
||||
{
|
||||
for(byte i = 0; i < 6; i++)
|
||||
{
|
||||
if(connectedBlocks[i] != null)
|
||||
{
|
||||
//Spread the electricity among the different blocks
|
||||
if(connectedBlocks[i] instanceof IWaterConsumer && this.waterStored > 0)
|
||||
{
|
||||
if(((IWaterConsumer)connectedBlocks[i]).canRecieveWater(UniversalElectricity.getOrientationFromSide(i, (byte) 2)))
|
||||
{
|
||||
int transferElectricityAmount = 0;
|
||||
IWaterConsumer connectedConsumer = ((IWaterConsumer)connectedBlocks[i]);
|
||||
|
||||
if(connectedBlocks[i].getClass() == this.getClass() && this.waterStored > ((TileEntityPipeWater)connectedConsumer).waterStored)
|
||||
{
|
||||
transferElectricityAmount = Math.max(Math.min(averageElectricity - ((TileEntityPipeWater)connectedConsumer).waterStored, this.waterStored), 0);
|
||||
}
|
||||
else if(!(connectedConsumer instanceof TileEntityPipeWater))
|
||||
{
|
||||
transferElectricityAmount = this.waterStored;
|
||||
}
|
||||
|
||||
int rejectedElectricity = connectedConsumer.onReceiveWater(transferElectricityAmount, UniversalElectricity.getOrientationFromSide(i, (byte)2));
|
||||
this.waterStored = Math.max(Math.min(this.waterStored - transferElectricityAmount + rejectedElectricity, this.capacity), 0);
|
||||
}
|
||||
}
|
||||
|
||||
if(connectedBlocks[i] instanceof IWaterProducer && this.waterStored < this.getWaterCapacity())
|
||||
{
|
||||
if(((IWaterProducer)connectedBlocks[i]).canProduceWater(UniversalElectricity.getOrientationFromSide(i, (byte)2)))
|
||||
{
|
||||
int gainedElectricity = ((IWaterProducer)connectedBlocks[i]).onProduceWater(this.capacity-this.waterStored, UniversalElectricity.getOrientationFromSide(i, (byte)2));
|
||||
this.waterStored = Math.max(Math.min(this.waterStored + gainedElectricity, this.capacity), 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Return the stored electricity in this consumer. Called by conductors to spread electricity to this unit.
|
||||
*/
|
||||
@Override
|
||||
public int getStoredWater()
|
||||
{
|
||||
return this.waterStored;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getWaterCapacity()
|
||||
{
|
||||
return this.capacity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Reads a tile entity from NBT.
|
||||
*/
|
||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
this.waterStored = par1NBTTagCompound.getInteger("waterStored");
|
||||
this.capacity = par1NBTTagCompound.getInteger("capacity");
|
||||
}
|
||||
|
||||
/**
|
||||
* Writes a tile entity to NBT.
|
||||
*/
|
||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound)
|
||||
{
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
par1NBTTagCompound.setInteger("waterStored", this.waterStored);
|
||||
par1NBTTagCompound.setInteger("capacity", this.capacity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canRecieveWater(byte side) {
|
||||
// TODO Auto-generated method stub
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in a new issue