Making Changes for the better

Starting down the long road of making my mod even more compatable with
other mod's liquids. This will take some time, patience, and pain
killers.

Plan of action
*Release Valve will not store any liquids but rather direction output to
pipes from other TileEntities
*Release Valve will have a gui to restrict it to outputing one or more
types of Liquids that are predefined
*Pipes will go from being fully liquid restricted to color based(0-15)
and have a universal uncolor pipe that can accept all liquids
*Once a pipe is place a tool can be used to change its color just like
in other mods.
*Some colors will be restricted to select liquids for example Blue is
water, Red is Lava, Black is oil, Yellow Fuel, White Milk,
*Steam will have its own pipe made out of bronze to fit the machines it
goes too.
*Tanks will go in the same direction
*Pumps will still be liquid restricted but come with unique textures,
models, and animation per liquid type

Current issues to resolve that are broken with push
*Release valve doesn't work at all due to changes in progress
*back compatable must be added for pipes and old release valves
This commit is contained in:
Rseifert 2013-01-04 19:03:20 -05:00
parent cd45492d2d
commit 77de6e6353
38 changed files with 839 additions and 728 deletions

View file

@ -4,7 +4,7 @@ import liquidmechanics.common.handlers.LiquidData;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ITankContainer;
public interface ITankOutputer extends ITankContainer
public interface IPressure
{
/**
* @param type - Liquid type
@ -21,4 +21,8 @@ public interface ITankOutputer extends ITankContainer
* @return
*/
public boolean canPressureToo(LiquidData type, ForgeDirection dir);
/**
* gets the LiquidData linked to the TE
*/
public LiquidData getLiquidType();
}

View file

@ -22,7 +22,7 @@ public class TankHelper
* @param z
* @return an array of up to 6 tileEntities
*/
public static TileEntity[] getSourounding(World world, int x, int y, int z)
public static TileEntity[] getSurroundings(World world, int x, int y, int z)
{
TileEntity[] list = new TileEntity[] { null, null, null, null, null, null };
for (int i = 0; i < 6; i++)
@ -49,7 +49,7 @@ public class TankHelper
if (resource == null)
return 0;
LiquidStack liquid = resource.copy();
TileEntity[] connected = TankHelper.getSourounding(world, center.intX(), center.intY(), center.intZ());
TileEntity[] connected = TankHelper.getSurroundings(world, center.intX(), center.intY(), center.intZ());
LiquidData type = LiquidHandler.get(liquid);
ForgeDirection firstTrade = ForgeDirection.UP;
if (!LiquidData.getCanFloat(type))
@ -118,7 +118,7 @@ public class TankHelper
*/
public static int corner(TileEntity entity)
{
TileEntity[] en = getSourounding(entity.worldObj, entity.xCoord, entity.yCoord, entity.zCoord);
TileEntity[] en = getSurroundings(entity.worldObj, entity.xCoord, entity.yCoord, entity.zCoord);
if (en[4] != null && en[2] != null && en[5] == null && en[3] == null) { return 3; }
if (en[2] != null && en[5] != null && en[3] == null && en[4] == null) { return 4; }
if (en[5] != null && en[3] != null && en[4] == null && en[2] == null) { return 1; }

View file

@ -0,0 +1,103 @@
package liquidmechanics.client.gui;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import java.util.List;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.inventory.GuiContainer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.ContainerRepair;
import net.minecraft.inventory.ICrafting;
import net.minecraft.item.ItemStack;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.util.StatCollector;
import net.minecraft.world.World;
import org.lwjgl.input.Keyboard;
import org.lwjgl.opengl.GL11;
@SideOnly(Side.CLIENT)
public class GuiReleaseValve extends GuiContainer
{
private ContainerRepair field_82327_o;
private InventoryPlayer field_82325_q;
public GuiReleaseValve(InventoryPlayer par1, World par2World, int par3, int par4, int par5)
{
super(new ContainerRepair(par1, par2World, par3, par4, par5, Minecraft.getMinecraft().thePlayer));
this.field_82325_q = par1;
this.field_82327_o = (ContainerRepair)this.inventorySlots;
}
/**
* Adds the buttons (and other controls) to the screen in question.
*/
public void initGui()
{
super.initGui();
Keyboard.enableRepeatEvents(true);
int width = (this.width - this.xSize) / 2;
int height = (this.height - this.ySize) / 2;
}
/**
* Called when the screen is unloaded. Used to disable keyboard repeat events
*/
public void onGuiClosed()
{
super.onGuiClosed();
Keyboard.enableRepeatEvents(false);
}
/**
* Draw the foreground layer for the GuiContainer (everything in front of the items)
*/
protected void drawGuiContainerForegroundLayer(int par1, int par2)
{
GL11.glDisable(GL11.GL_LIGHTING);
this.fontRenderer.drawString(StatCollector.translateToLocal("container.repair"), 60, 6, 4210752);
GL11.glEnable(GL11.GL_LIGHTING);
}
/**
* Fired when a key is typed. This is the equivalent of KeyListener.keyTyped(KeyEvent e).
*/
protected void keyTyped(char par1, int par2)
{
super.keyTyped(par1, par2);
}
/**
* Called when the mouse is clicked.
*/
protected void mouseClicked(int par1, int par2, int par3)
{
super.mouseClicked(par1, par2, par3);
}
/**
* Draws the screen and all the components in it.
*/
public void drawScreen(int par1, int par2, float par3)
{
super.drawScreen(par1, par2, par3);
GL11.glDisable(GL11.GL_LIGHTING);
}
/**
* Draw the background layer for the GuiContainer (everything behind the items)
*/
protected void drawGuiContainerBackgroundLayer(float par1, int par2, int par3)
{
int tID = this.mc.renderEngine.getTexture("/gui/repair.png");
GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
this.mc.renderEngine.bindTexture(tID);
int width = (this.width - this.xSize) / 2;
int height = (this.height - this.ySize) / 2;
this.drawTexturedModalRect(width, height, 0, 0, this.xSize, this.ySize);
}
}

View file

@ -333,13 +333,9 @@ public class ModelLiquidTank extends ModelBase
setRotation(CCTop, 0F, 0F, 0F);
}
public void renderMain(TileEntity tee, float f5)
public void renderMain(float f5)
{
TileEntity[] ents = new TileEntity[6];
if (tee instanceof TileEntityTank)
{
ents = ((TileEntityTank) tee).cc;
}
// render regardless of sides
Mid.render(f5);
Corner.render(f5);
@ -356,63 +352,73 @@ public class ModelLiquidTank extends ModelBase
C2.render(f5);
CCTop.render(f5);
CCBottom.render(f5);
// Front
if (ents[2] instanceof TileEntityPipe)
{
CCFront.render(f5);
}
else
{
GuageT.render(f5);
GuageB.render(f5);
Guage.render(f5);
GuageR.render(f5);
// GuageGlass.render(f5);
GuageL.render(f5);
}
// back
if (ents[3] instanceof TileEntityPipe)
{
CCBack.render(f5);
}
else
{
GuageT3.render(f5);
Guage3.render(f5);
Guage3.render(f5);
GuageR3.render(f5);
// GuageGlass3.render(f5);
GuageL3.render(f5);
}
// right
if (ents[4] instanceof TileEntityPipe)
{
CCRight.render(f5);
}
else
{
GuageT4.render(f5);
Guage4.render(f5);
Guage4.render(f5);
GuageR4.render(f5);
// GuageGlass4.render(f5);
GuageL4.render(f5);
}
// left
if (ents[5] instanceof TileEntityPipe)
{
CCLeft.render(f5);
}
else
{
GuageT2.render(f5);
Guage2.render(f5);
Guage2.render(f5);
GuageR2.render(f5);
// GuageGlass2.render(f5);
GuageL2.render(f5);
}
public void renderMeter(TileEntity tee, float f5)
{
TileEntity[] ents = new TileEntity[6];
if (tee instanceof TileEntityTank)
{
ents = ((TileEntityTank) tee).cc;
}
// Front
if (ents[2] instanceof TileEntityPipe)
{
CCFront.render(f5);
}
else
{
GuageT.render(f5);
GuageB.render(f5);
Guage.render(f5);
GuageR.render(f5);
// GuageGlass.render(f5);
GuageL.render(f5);
}
// back
if (ents[3] instanceof TileEntityPipe)
{
CCBack.render(f5);
}
else
{
GuageT3.render(f5);
Guage3.render(f5);
Guage3.render(f5);
GuageR3.render(f5);
// GuageGlass3.render(f5);
GuageL3.render(f5);
}
// right
if (ents[4] instanceof TileEntityPipe)
{
CCRight.render(f5);
}
else
{
GuageT4.render(f5);
Guage4.render(f5);
Guage4.render(f5);
GuageR4.render(f5);
// GuageGlass4.render(f5);
GuageL4.render(f5);
}
// left
if (ents[5] instanceof TileEntityPipe)
{
CCLeft.render(f5);
}
else
{
GuageT2.render(f5);
Guage2.render(f5);
Guage2.render(f5);
GuageR2.render(f5);
// GuageGlass2.render(f5);
GuageL2.render(f5);
}
}
}
private void setRotation(ModelRenderer model, float x, float y, float z)

View file

@ -109,7 +109,8 @@ public class ItemRenderHelper implements IItemRenderer
{
GL11.glTranslatef(0.5F, -0.5F, 0.5F);
}
model.renderMain(null, 0.0625F);
model.renderMain(0.0625F);
model.renderMeter(null, 0.0625F);
GL11.glPopMatrix();
}
}

View file

@ -13,69 +13,71 @@ import net.minecraftforge.liquids.LiquidContainerRegistry;
import org.lwjgl.opengl.GL11;
public class RenderTank extends TileEntitySpecialRenderer
{
private LiquidData type = LiquidHandler.air;
private ModelLiquidTank model;
private ModelLiquidTankCorner modelC;
private int pos = 0;
private LiquidData type = LiquidHandler.air;
private ModelLiquidTank model;
private ModelLiquidTankCorner modelC;
private int pos = 0;
public RenderTank()
{
model = new ModelLiquidTank();
modelC = new ModelLiquidTankCorner();
}
public RenderTank()
{
model = new ModelLiquidTank();
modelC = new ModelLiquidTankCorner();
}
public void renderAModelAt(TileEntityTank te, double d, double d1, double d2, float f)
{
type = te.getType();
if (te.tank.getLiquid() != null)
pos = Math.min((te.tank.getLiquid().amount / LiquidContainerRegistry.BUCKET_VOLUME), 4);
GL11.glPushMatrix();
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);
if (TankHelper.corner(te) > 0)
{
bindTextureByName(LiquidMechanics.RESOURCE_PATH + "tanks/LiquidTankCorner.png");
int corner = TankHelper.corner(te);
switch (corner)
{
case 2:
GL11.glRotatef(270f, 0f, 1f, 0f);
break;
case 3:
GL11.glRotatef(0f, 0f, 1f, 0f);
break;
case 4:
GL11.glRotatef(90f, 0f, 1f, 0f);
break;
case 1:
GL11.glRotatef(180f, 0f, 1f, 0f);
break;
}
modelC.render(0.0625F);
}
else
{
switch (LiquidHandler.getMeta(type))
{
// case 0:
// bindTextureByName(BasicPipesMain.textureFile+"/pipes/SixSteamPipe.png");break;
default:
bindTextureByName(LiquidMechanics.RESOURCE_PATH + "tanks/LiquidTank" + pos + ".png");
break;
}
model.renderMain(te, 0.0625F);
}
GL11.glPopMatrix();
public void renderAModelAt(TileEntityTank te, double d, double d1, double d2, float f)
{
type = te.getType();
if (te.tank.getLiquid() != null)
pos = Math.min((te.tank.getLiquid().amount / LiquidContainerRegistry.BUCKET_VOLUME), 4);
GL11.glPushMatrix();
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);
if (TankHelper.corner(te) > 0)
{
if (type == LiquidHandler.water)
{
bindTextureByName(LiquidMechanics.RESOURCE_PATH + "tanks/LiquidTankCornerWater.png");
}
int corner = TankHelper.corner(te);
switch (corner)
{
case 2:
GL11.glRotatef(270f, 0f, 1f, 0f);
break;
case 3:
GL11.glRotatef(0f, 0f, 1f, 0f);
break;
case 4:
GL11.glRotatef(90f, 0f, 1f, 0f);
break;
case 1:
GL11.glRotatef(180f, 0f, 1f, 0f);
break;
}
modelC.render(0.0625F);
}
else
{
switch (LiquidHandler.getMeta(type))
{
// case 0:
// bindTextureByName(BasicPipesMain.textureFile+"/pipes/SixSteamPipe.png");break;
default:bindTextureByName(LiquidMechanics.RESOURCE_PATH + "tanks/LiquidTank" + pos + ".png");break;
}
model.renderMain(0.0625F);
model.renderMeter(te, 0.0625F);
}
GL11.glPopMatrix();
}
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8)
{
this.renderAModelAt((TileEntityTank) tileEntity, var2, var4, var6, var8);
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8)
{
this.renderAModelAt((TileEntityTank) tileEntity, var2, var4, var6, var8);
}
}

View file

@ -3,16 +3,13 @@ package liquidmechanics.common;
import java.io.File;
import liquidmechanics.common.block.BlockGenerator;
import liquidmechanics.common.block.BlockMachine;
import liquidmechanics.common.block.BlockLiquidMachine;
import liquidmechanics.common.block.BlockPipe;
import liquidmechanics.common.block.BlockReleaseValve;
import liquidmechanics.common.block.BlockRod;
import liquidmechanics.common.block.BlockSteam;
import liquidmechanics.common.handlers.LiquidData;
import liquidmechanics.common.handlers.LiquidHandler;
import liquidmechanics.common.item.ItemEValve;
import liquidmechanics.common.item.ItemGuage;
import liquidmechanics.common.item.ItemMachine;
import liquidmechanics.common.item.ItemParts;
import liquidmechanics.common.item.ItemParts.Parts;
import liquidmechanics.common.item.ItemPipe;
@ -33,6 +30,7 @@ import net.minecraftforge.liquids.LiquidDictionary;
import net.minecraftforge.liquids.LiquidStack;
import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.oredict.ShapedOreRecipe;
import universalelectricity.prefab.TranslationHelper;
import universalelectricity.prefab.network.PacketManager;
import cpw.mods.fml.common.DummyModContainer;
import cpw.mods.fml.common.Loader;
@ -47,7 +45,6 @@ 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;
/**
* Used in the creation of a new mod class
@ -60,7 +57,7 @@ import cpw.mods.fml.common.registry.LanguageRegistry;
public class LiquidMechanics extends DummyModContainer
{
// TODO Change in Version Release
public static final String VERSION = "0.2.3";
public static final String VERSION = "0.2.4";
// Constants
public static final String NAME = "Liquid Mechanics";
@ -70,6 +67,10 @@ public class LiquidMechanics extends DummyModContainer
public static final String RESOURCE_PATH = PATH + "resource/";
public static final String BLOCK_TEXTURE_FILE = RESOURCE_PATH + "blocks.png";
public static final String ITEM_TEXTURE_FILE = RESOURCE_PATH + "items.png";
public static final String LANGUAGE_PATH = RESOURCE_PATH + "lang/";
private static final String[] LANGUAGES_SUPPORTED = new String[] { "en_US"};
public static final Configuration CONFIGURATION = new Configuration(new File(Loader.instance().getConfigDir() + "/UniversalElectricity/", NAME + ".cfg"));
public final static int BLOCK_ID_PREFIX = 3100;
@ -106,7 +107,7 @@ public class LiquidMechanics extends DummyModContainer
// Blocks
blockPipe = new BlockPipe(this.CONFIGURATION.getBlock("Pipes", BLOCK_ID_PREFIX).getInt());
blockMachine = new BlockMachine(this.CONFIGURATION.getBlock("Machines", BLOCK_ID_PREFIX + 1).getInt());
blockMachine = new BlockLiquidMachine(this.CONFIGURATION.getBlock("Machines", BLOCK_ID_PREFIX + 1).getInt());
blockRod = new BlockRod(this.CONFIGURATION.getBlock("Mechanical Rod", BLOCK_ID_PREFIX + 3).getInt());
blockGenerator = new BlockGenerator((this.CONFIGURATION.getBlock("Generator", BLOCK_ID_PREFIX + 4).getInt()));
blockReleaseValve = new BlockReleaseValve((this.CONFIGURATION.getBlock("Release Valve", BLOCK_ID_PREFIX + 5).getInt()));
@ -130,10 +131,10 @@ public class LiquidMechanics extends DummyModContainer
// block registry
GameRegistry.registerBlock(blockPipe, "Pipe");
GameRegistry.registerBlock(blockReleaseValve, ItemEValve.class, "Electric Valve");
GameRegistry.registerBlock(blockRod, "Mechanical Rod");
GameRegistry.registerBlock(blockReleaseValve,"eValve");
GameRegistry.registerBlock(blockRod, "mechRod");
GameRegistry.registerBlock(blockGenerator, "Generator");
GameRegistry.registerBlock(blockMachine, ItemMachine.class, "Machines");
GameRegistry.registerBlock(blockMachine, "lmMachines");
GameRegistry.registerBlock(blockSteamBlock, "Steam");
}
@ -148,34 +149,9 @@ public class LiquidMechanics extends DummyModContainer
GameRegistry.registerTileEntity(TileEntityReleaseValve.class, "Valve");
GameRegistry.registerTileEntity(TileEntityTank.class, "Tank");
GameRegistry.registerTileEntity(TileEntityGenerator.class, "Generator");
System.out.println("Fluid Mechanics Loaded: " + TranslationHelper.loadLanguages(LANGUAGE_PATH, LANGUAGES_SUPPORTED) + " Languages.");
// Liquid Item/Block common name writer
for (int i = 0; i < LiquidHandler.allowedLiquids.size() - 1; i++)
{
// eValves
LanguageRegistry.addName((new ItemStack(blockReleaseValve, 1, i)),LiquidData.getName(LiquidHandler.getFromMeta(i)) + " Release Valve");
// pipes
LanguageRegistry.addName((new ItemStack(itemPipes, 1, i)), LiquidData.getName(LiquidHandler.getFromMeta(i)) + " Pipe");
// Storage Tanks
LanguageRegistry.addName((new ItemStack(itemTank, 1, i)), LiquidData.getName(LiquidHandler.getFromMeta(i)) + " Tank");
}
for (int i = 0; i < ItemParts.Parts.values().length; i++)
{
// parts
LanguageRegistry.addName((new ItemStack(itemParts, 1, i)), ItemParts.Parts.values()[i].name);
}
// machines
LanguageRegistry.addName((new ItemStack(blockMachine, 1, 0)), "Pump");
LanguageRegistry.addName((new ItemStack(blockMachine, 1, 4)), "Water Condensor");
LanguageRegistry.addName((new ItemStack(blockGenerator, 1)), "Generator");
// mechanical rod
LanguageRegistry.addName((new ItemStack(blockRod, 1)), "Geared Rod");
// Tools
LanguageRegistry.addName((new ItemStack(itemGauge, 1, 0)), "Pipe Gauge");
}
@PostInit
@ -285,6 +261,14 @@ public class LiquidMechanics extends DummyModContainer
//reg ore directory for parts
OreDictionary.registerOre("bronzeTube", new ItemStack(itemParts, 1, Parts.Bronze.ordinal()));
OreDictionary.registerOre("ironTube", new ItemStack(itemParts, 1, Parts.Iron.ordinal()));
OreDictionary.registerOre("netherTube", new ItemStack(itemParts, 1, Parts.Nether.ordinal()));
OreDictionary.registerOre("obbyTube", new ItemStack(itemParts, 1, Parts.Obby.ordinal()));
OreDictionary.registerOre("leatherSeal", new ItemStack(itemParts, 1, Parts.Seal.ordinal()));
OreDictionary.registerOre("leatherSlimeSeal", new ItemStack(itemParts, 1, Parts.SlimeSeal.ordinal()));
OreDictionary.registerOre("valvePart", new ItemStack(itemParts, 1, Parts.Valve.ordinal()));
OreDictionary.registerOre("bronzeTube", new ItemStack(itemParts, 1, Parts.Bronze.ordinal()));
OreDictionary.registerOre("unfinishedTank", new ItemStack(itemParts, 1, Parts.Tank.ordinal()));
//add Default Liquids to current list, done last to let other mods use there liquid data first if used
LiquidHandler.addDefaultLiquids();
}

View file

@ -1,6 +1,6 @@
package liquidmechanics.common;
public class MetaGroupingHelper
public class MetaGroup
{
public static int getFacingMeta(int metaData)

View file

@ -1,30 +1,33 @@
package liquidmechanics.common.block;
import universalelectricity.prefab.BlockMachine;
import universalelectricity.prefab.tile.TileEntityAdvanced;
import liquidmechanics.client.render.BlockRenderHelper;
import liquidmechanics.common.LiquidMechanics;
import liquidmechanics.common.MetaGroup;
import liquidmechanics.common.TabLiquidMechanics;
import liquidmechanics.common.handlers.LiquidHandler;
import liquidmechanics.common.tileentity.TileEntityPump;
import liquidmechanics.common.tileentity.TileEntityTank;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidStack;
public class BlockMachine extends BlockContainer
public class BlockLiquidMachine extends BlockMachine
{
public BlockMachine(int id)
public BlockLiquidMachine(int id)
{
super(id, Material.iron);
this.setBlockName("Machine");
this.setCreativeTab(TabLiquidMechanics.INSTANCE);
this.setRequiresSelfNotify();
super("lmMachines", id, Material.iron, TabLiquidMechanics.INSTANCE);
this.blockIndexInTexture = 26;
this.setHardness(1f);
this.setResistance(5f);
@ -128,30 +131,52 @@ public class BlockMachine extends BlockContainer
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
if (meta < 4)
new ItemStack(LiquidMechanics.blockMachine, 1, 0);
// if(meta == 4) ;
TileEntity ent = world.getBlockTileEntity(x, y, z);
if (ent instanceof TileEntityTank) return new ItemStack(LiquidMechanics.itemTank, 1, LiquidHandler.getMeta(((TileEntityTank) ent).type));
if (meta < 4)
{
new ItemStack(LiquidMechanics.blockMachine, 1, 0);
}
if (ent instanceof TileEntityTank) { return new ItemStack(LiquidMechanics.itemTank, 1, LiquidHandler.getMeta(((TileEntityTank) ent).type)); }
return null;
}
@Override
public void onBlockPlacedBy(World world, int x, int y, int z, EntityLiving par5EntityLiving)
{
int meta = world.getBlockMetadata(x, y, z);
int angle = MathHelper.floor_double((par5EntityLiving.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
TileEntity ent = world.getBlockTileEntity(x, y, z);
if (MetaGroup.getGrouping(meta) != 1)
{
world.setBlockMetadata(x, y, z, angle + MetaGroup.getGroupStartMeta(MetaGroup.getGrouping(meta)));
}
if (ent instanceof TileEntityAdvanced)
{
((TileEntityAdvanced) world.getBlockTileEntity(x, y, z)).initiate();
}
world.notifyBlocksOfNeighborChange(x, y, z, this.blockID);
}
@Override
public TileEntity createNewTileEntity(World var1, int meta)
{
if (meta < 4) { return new TileEntityPump(); }
if (meta == 4)
if (meta >= 12)
{
// return new TileEntityCondenser();
}
if (meta == 5) { return new TileEntityTank(); }
else if (meta >= 8)
{
}
else if (meta >= 4)
{
return new TileEntityTank();
}
else
{
return new TileEntityPump();
}
return null;
}
@Override
public TileEntity createNewTileEntity(World var1)
{
return null;
}
}

View file

@ -15,8 +15,7 @@ import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.World;
public class BlockPipe extends BlockContainer
{
{
public BlockPipe(int id)
{
super(id, Material.iron);

View file

@ -13,14 +13,14 @@ import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import universalelectricity.prefab.BlockMachine;
import universalelectricity.prefab.implement.IRedstoneReceptor;
public class BlockReleaseValve extends BlockContainer
public class BlockReleaseValve extends BlockMachine
{
public BlockReleaseValve(int par1)
{
super(par1, Material.iron);
this.setCreativeTab(TabLiquidMechanics.INSTANCE);
super("eValve",par1, Material.iron,TabLiquidMechanics.INSTANCE);
this.setHardness(1f);
this.setResistance(5f);
this.setTextureFile(LiquidMechanics.BLOCK_TEXTURE_FILE);
@ -53,7 +53,7 @@ public class BlockReleaseValve extends BlockContainer
@Override
public int getBlockTextureFromSideAndMetadata(int side, int meta)
{
return meta;
return 0;
}
@Override
@ -71,7 +71,7 @@ public class BlockReleaseValve extends BlockContainer
@Override
public int damageDropped(int meta)
{
return meta;
return 0;
}
@Override
@ -91,8 +91,7 @@ public class BlockReleaseValve extends BlockContainer
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
{
int meta = world.getBlockMetadata(x, y, z);
return new ItemStack(LiquidMechanics.blockReleaseValve, 1, meta);
return new ItemStack(LiquidMechanics.blockReleaseValve, 1, 0);
}
public static void checkForPower(World world, int x, int y, int z)

View file

@ -0,0 +1,19 @@
package liquidmechanics.common.handlers;
import liquidmechanics.common.tileentity.TileEntityPipe;
/**
* used to keep track of a pipe, its meta, and if Universal
*/
public class PipeInstance
{
public int color;
public TileEntityPipe pipe;
public boolean any;
public PipeInstance(int color, TileEntityPipe pipe, boolean any)
{
this.color = color;
this.pipe = pipe;
this.any = any;
}
}

View file

@ -1,133 +0,0 @@
package liquidmechanics.common.item;
import java.util.List;
import liquidmechanics.common.LiquidMechanics;
import liquidmechanics.common.handlers.LiquidData;
import liquidmechanics.common.handlers.LiquidHandler;
import liquidmechanics.common.tileentity.TileEntityReleaseValve;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class ItemEValve extends ItemBlock
{
int index = 32;// 32 + 4 rows alloted to pipes
private int spawnID;
public ItemEValve(int id)
{
super(id);
this.setMaxDamage(0);
this.setHasSubtypes(true);
this.setItemName("eValve");
this.setCreativeTab(CreativeTabs.tabRedstone);
}
@Override
public String getItemNameIS(ItemStack itemstack)
{
return "release Valve";
}
@Override
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for (int i = 0; i < LiquidHandler.allowedLiquids.size() -1; i++)
{
par3List.add(new ItemStack(this, 1, i));
}
}
@Override
public String getTextureFile()
{
return LiquidMechanics.BLOCK_TEXTURE_FILE;
}
@Override
public String getItemName()
{
return "Pipes";
}
@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10)
{
int blockID = world.getBlockId(x, y, z);
spawnID = LiquidMechanics.blockReleaseValve.blockID;
int angle = MathHelper.floor_double((player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
if (blockID == Block.snow.blockID)
{
side = 1;
}
else if (blockID != Block.vine.blockID && blockID != Block.tallGrass.blockID && blockID != Block.deadBush.blockID)
{
if (side == 0)
{
--y;
}
if (side == 1)
{
++y;
}
if (side == 2)
{
--z;
}
if (side == 3)
{
++z;
}
if (side == 4)
{
--x;
}
if (side == 5)
{
++x;
}
}
if (LiquidMechanics.blockPipe.canPlaceBlockAt(world, x, y, z))
{
Block var9 = Block.blocksList[this.spawnID];
world.editingBlocks = true;
if (world.setBlockWithNotify(x, y, z, var9.blockID))
{
if (world.getBlockId(x, y, z) == var9.blockID)
{
Block.blocksList[this.spawnID].onBlockAdded(world, x, y, z);
Block.blocksList[this.spawnID].onBlockPlacedBy(world, x, y, z, player);
TileEntity blockEntity = world.getBlockTileEntity(x, y, z);
if (blockEntity instanceof TileEntityReleaseValve)
{
TileEntityReleaseValve pipeEntity = (TileEntityReleaseValve) blockEntity;
LiquidData dm = LiquidHandler.getFromMeta(itemstack.getItemDamage());
pipeEntity.setType(dm);
world.setBlockMetadata(x, y, z, itemstack.getItemDamage() & 15);
pipeEntity.converted = true;
}
}
--itemstack.stackSize;
world.editingBlocks = false;
return true;
}
}
world.editingBlocks = false;
return false;
}
}

View file

@ -24,7 +24,7 @@ public class ItemGuage extends Item
this.setMaxDamage(0);
this.setHasSubtypes(true);
this.setIconIndex(10);
this.setItemName("guage");
this.setItemName("lmTool");
this.setCreativeTab(TabLiquidMechanics.INSTANCE);
this.setMaxStackSize(1);
this.setTextureFile(LiquidMechanics.ITEM_TEXTURE_FILE);

View file

@ -1,133 +0,0 @@
package liquidmechanics.common.item;
import java.util.List;
import liquidmechanics.common.LiquidMechanics;
import liquidmechanics.common.TabLiquidMechanics;
import liquidmechanics.common.tileentity.TileEntityTank;
import net.minecraft.block.Block;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
public class ItemMachine extends ItemBlock
{
int index = 26;
private int spawnID;
public ItemMachine(int id)
{
super(id);
this.setMaxDamage(0);
this.setHasSubtypes(true);
this.setIconIndex(10);
this.setItemName("Machine");
this.setCreativeTab(TabLiquidMechanics.INSTANCE);
}
@Override
public void addInformation(ItemStack itemstack, EntityPlayer entityplayer, List list, boolean flag)
{
if (itemstack.getItemDamage() == 5)
list.add("Max Vol of " + TileEntityTank.LMax);
}
@Override
public int getIconFromDamage(int par1)
{
return par1 + index;
}
@Override
public String getItemNameIS(ItemStack itemstack)
{
return itemstack.getItemDamage() == 0 ? "Pump" : "Conderser";// itemstack.getItemDamage() ==
// 4 ?
// "Condenser":"Unknown";
}
public String getTextureFile()
{
return LiquidMechanics.ITEM_TEXTURE_FILE;
}
@Override
public String getItemName()
{
return "Machines";
}
@Override
public boolean onItemUse(ItemStack itemStack, EntityPlayer player, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
{
int blockID = par3World.getBlockId(par4, par5, par6);
spawnID = LiquidMechanics.blockMachine.blockID;
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 (LiquidMechanics.blockPipe.canPlaceBlockAt(par3World, par4, par5, par6))
{
Block var9 = Block.blocksList[this.spawnID];
par3World.editingBlocks = true;
int angle = MathHelper.floor_double((double) (player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
if (par3World.setBlockAndMetadataWithNotify(par4, par5, par6, var9.blockID, angle + itemStack.getItemDamage()))
{
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, player);
TileEntity blockEntity = par3World.getBlockTileEntity(par4, par5, par6);
}
--itemStack.stackSize;
par3World.editingBlocks = false;
return true;
}
}
par3World.editingBlocks = false;
return false;
}
}

View file

@ -18,8 +18,8 @@ import net.minecraft.item.ItemStack;
public class ItemParts extends Item {
public enum Parts {
Bronze("Bronze Tube", 0), Iron("Iron Tube", 1), Obby("Obby Tube", 2), Nether(
"Nether Tube", 3), Seal("Seal", 16), SlimeSeal("Slime Seal", 17), Tank(
"Tank", 18), Valve("Valve", 19);
"Nether Tube", 3), Seal("Leather Seal", 16), SlimeSeal("Slime Seal", 17), Tank(
"Unfinished Tank", 18), Valve("Valve", 19);
public String name;
public int itemIndex;
@ -31,7 +31,7 @@ public class ItemParts extends Item {
public ItemParts(int par1) {
super(par1);
this.setItemName("Parts");
this.setItemName("parts");
this.setHasSubtypes(true);
this.setMaxDamage(0);
this.setMaxStackSize(64);

View file

@ -16,121 +16,121 @@ import net.minecraft.world.World;
public class ItemPipe extends Item
{
int index = 32;// 32 + 4 rows alloted to pipes
private int spawnID;
int index = 32;
private int spawnID;
public ItemPipe(int id)
{
super(id);
this.setMaxDamage(0);
this.setHasSubtypes(true);
this.setIconIndex(10);
this.setItemName("pipe");
this.setCreativeTab(TabLiquidMechanics.INSTANCE);
}
public ItemPipe(int id)
{
super(id);
this.setMaxDamage(0);
this.setHasSubtypes(true);
this.setIconIndex(10);
this.setItemName("itemPipe");
this.setCreativeTab(TabLiquidMechanics.INSTANCE);
}
@Override
public int getIconFromDamage(int par1)
{
@Override
public int getIconFromDamage(int par1)
{
return par1 + index;
}
return par1 + index;
}
@Override
public String getItemNameIS(ItemStack itemstack)
{
return "pipe";
}
@Override
public String getItemNameIS(ItemStack itemstack)
{
return "pipe";
}
@Override
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for (int i = 0; i < LiquidHandler.allowedLiquids.size() -1; i++)
@Override
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for (int i = 0; i < LiquidHandler.allowedLiquids.size() - 1; i++)
{
par3List.add(new ItemStack(this, 1, i));
}
}
}
public String getTextureFile()
{
return LiquidMechanics.ITEM_TEXTURE_FILE;
}
public String getTextureFile()
{
return LiquidMechanics.ITEM_TEXTURE_FILE;
}
@Override
public String getItemName()
{
return "Pipes";
}
@Override
public String getItemName()
{
return "Pipes";
}
@Override
public boolean onItemUse(ItemStack itemstack, 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 = LiquidMechanics.blockPipe.blockID;
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;
}
@Override
public boolean onItemUse(ItemStack itemstack, 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 = LiquidMechanics.blockPipe.blockID;
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 == 1)
{
++par5;
}
if (par7 == 2)
{
--par6;
}
if (par7 == 2)
{
--par6;
}
if (par7 == 3)
{
++par6;
}
if (par7 == 3)
{
++par6;
}
if (par7 == 4)
{
--par4;
}
if (par7 == 4)
{
--par4;
}
if (par7 == 5)
{
++par4;
}
}
if (par7 == 5)
{
++par4;
}
}
if (LiquidMechanics.blockPipe.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)
{
if (LiquidMechanics.blockPipe.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;
pipeEntity.setType(LiquidHandler.getFromMeta(itemstack.getItemDamage()));
pipeEntity.converted = true;
}
}
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;
pipeEntity.setType(LiquidHandler.getFromMeta(itemstack.getItemDamage()));
pipeEntity.converted = true;
}
}
--itemstack.stackSize;
par3World.editingBlocks = false;
return true;
}
}
par3World.editingBlocks = false;
return false;
}
--itemstack.stackSize;
par3World.editingBlocks = false;
return true;
}
}
par3World.editingBlocks = false;
return false;
}
}

View file

@ -26,7 +26,7 @@ public class ItemTank extends Item
this.setMaxDamage(0);
this.setHasSubtypes(true);
this.setIconIndex(10);
this.setItemName("tank");
this.setItemName("itemTank");
this.setCreativeTab(TabLiquidMechanics.INSTANCE);
}

View file

@ -0,0 +1,54 @@
package liquidmechanics.common.tileentity;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.entity.player.InventoryPlayer;
import net.minecraft.inventory.Container;
import net.minecraft.inventory.Slot;
import net.minecraft.inventory.SlotFurnace;
import net.minecraft.item.ItemStack;
public class ContainerReleaseValve extends Container
{
private TileEntityReleaseValve valve;
private int lastCookTime = 0;
private int lastBurnTime = 0;
private int lastItemBurnTime = 0;
public ContainerReleaseValve(InventoryPlayer par1InventoryPlayer, TileEntityReleaseValve par2TileEntityFurnace)
{
this.valve = par2TileEntityFurnace;
int var3;
for (var3 = 0; var3 < 3; ++var3)
{
for (int var4 = 0; var4 < 9; ++var4)
{
this.addSlotToContainer(new Slot(par1InventoryPlayer, var4 + var3 * 9 + 9, 8 + var4 * 18, 84 + var3 * 18));
}
}
for (var3 = 0; var3 < 9; ++var3)
{
this.addSlotToContainer(new Slot(par1InventoryPlayer, var3, 8 + var3 * 18, 142));
}
}
public boolean canInteractWith(EntityPlayer par1EntityPlayer)
{
return this.valve.isUseableByPlayer(par1EntityPlayer);
}
/**
* Called when a player shift-clicks on a slot. You must override this or you will crash when someone does that.
*/
public ItemStack transferStackInSlot(EntityPlayer par1EntityPlayer, int par2)
{
ItemStack var3 = null;
Slot var4 = (Slot)this.inventorySlots.get(par2);
return var3;
}
}

View file

@ -6,7 +6,7 @@ import liquidmechanics.api.IForce;
import liquidmechanics.api.IReadOut;
import liquidmechanics.api.helpers.TankHelper;
import liquidmechanics.common.LiquidMechanics;
import liquidmechanics.common.MetaGroupingHelper;
import liquidmechanics.common.MetaGroup;
import liquidmechanics.common.block.BlockGenerator;
import net.minecraft.entity.player.EntityPlayer;
@ -55,7 +55,7 @@ public class TileEntityGenerator extends TileEntityElectricityProducer implement
public void registerConnections()
{
int notchMeta = MetaGroupingHelper.getFacingMeta(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
int notchMeta = MetaGroup.getFacingMeta(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
ForgeDirection facing = ForgeDirection.getOrientation(notchMeta).getOpposite();
ForgeDirection[] dirs = new ForgeDirection[] { ForgeDirection.UNKNOWN, ForgeDirection.UNKNOWN, ForgeDirection.UNKNOWN, ForgeDirection.UNKNOWN, ForgeDirection.UNKNOWN, ForgeDirection.UNKNOWN };
ElectricityConnections.registerConnector(this, EnumSet.of(facing.getOpposite()));
@ -76,7 +76,7 @@ public class TileEntityGenerator extends TileEntityElectricityProducer implement
this.genAmmount = Math.abs(force / this.getVoltage());
// wire count update
int wireCount = 0;
TileEntity[] ents = TankHelper.getSourounding(worldObj, xCoord, yCoord, zCoord);
TileEntity[] ents = TankHelper.getSurroundings(worldObj, xCoord, yCoord, zCoord);
this.wires = new IConductor[6];
for (int i = 0; i < ents.length; i++)
{
@ -99,7 +99,7 @@ public class TileEntityGenerator extends TileEntityElectricityProducer implement
pos = 0;
}
}
int notchMeta = MetaGroupingHelper.getFacingMeta(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
int notchMeta = MetaGroup.getFacingMeta(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
facing = ForgeDirection.getOrientation(notchMeta).getOpposite();
TileEntity ent = worldObj.getBlockTileEntity(xCoord + facing.offsetX, yCoord + facing.offsetY, zCoord + facing.offsetZ);

View file

@ -1,7 +1,7 @@
package liquidmechanics.common.tileentity;
import liquidmechanics.api.IReadOut;
import liquidmechanics.api.ITankOutputer;
import liquidmechanics.api.IPressure;
import liquidmechanics.api.helpers.TankHelper;
import liquidmechanics.common.LiquidMechanics;
import liquidmechanics.common.handlers.LiquidData;
@ -27,12 +27,16 @@ import com.google.common.io.ByteArrayDataInput;
public class TileEntityPipe extends TileEntity implements ITankContainer, IPacketReceiver, IReadOut
{
public LiquidData type = LiquidHandler.air;
private int count = 20;
private int count2, presure = 0;
public boolean converted = false;
protected boolean firstUpdate = true;
public boolean isUniversal = false;
public TileEntity[] connectedBlocks = { null, null, null, null, null, null };
public LiquidTank stored = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME * 3);
@Override
@ -41,10 +45,10 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IPacke
if (++count >= 40)
{
count = 0;
this.connectedBlocks = TankHelper.getSourounding(worldObj, xCoord, yCoord, zCoord);
this.connectedBlocks = TankHelper.getSurroundings(worldObj, xCoord, yCoord, zCoord);
for (int e = 0; e < 6; e++)
{
if (connectedBlocks[e] instanceof ITankContainer)
if (connectedBlocks[e] instanceof ITankContainer || connectedBlocks[e] instanceof IPressure)
{
if (connectedBlocks[e] instanceof TileEntityPipe && ((TileEntityPipe) connectedBlocks[e]).type != this.type)
{
@ -236,7 +240,7 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IPacke
/**
* Used to determan pipe connection rules
*/
public boolean canConntect(TileEntity entity)
public boolean canConnect(TileEntity entity)
{
if (entity instanceof TileEntityPipe)
{
@ -260,17 +264,17 @@ public class TileEntityPipe extends TileEntity implements ITankContainer, IPacke
{
ForgeDirection dir = ForgeDirection.getOrientation(i);
if (connectedBlocks[i] instanceof TileEntityPipe && ((TileEntityPipe) connectedBlocks[i]).canConntect(this))
if (connectedBlocks[i] instanceof TileEntityPipe && ((TileEntityPipe) connectedBlocks[i]).canConnect(this))
{
if (((TileEntityPipe) connectedBlocks[i]).getPressure() > highestPressure)
{
highestPressure = ((TileEntityPipe) connectedBlocks[i]).getPressure();
}
}
if (connectedBlocks[i] instanceof ITankOutputer && ((ITankOutputer) connectedBlocks[i]).canPressureToo(this.type, dir))
if (connectedBlocks[i] instanceof IPressure && ((IPressure) connectedBlocks[i]).canPressureToo(this.type, dir))
{
int p = ((ITankOutputer) connectedBlocks[i]).presureOutput(this.type, dir);
int p = ((IPressure) connectedBlocks[i]).presureOutput(this.type, dir);
if (p > highestPressure)
highestPressure = p;
}

View file

@ -3,9 +3,9 @@ package liquidmechanics.common.tileentity;
import java.util.EnumSet;
import liquidmechanics.api.IReadOut;
import liquidmechanics.api.ITankOutputer;
import liquidmechanics.api.IPressure;
import liquidmechanics.common.LiquidMechanics;
import liquidmechanics.common.MetaGroupingHelper;
import liquidmechanics.common.MetaGroup;
import liquidmechanics.common.handlers.LiquidData;
import liquidmechanics.common.handlers.LiquidHandler;
@ -31,18 +31,18 @@ import universalelectricity.prefab.tile.TileEntityElectricityReceiver;
import com.google.common.io.ByteArrayDataInput;
public class TileEntityPump extends TileEntityElectricityReceiver implements IPacketReceiver, IReadOut, ITankOutputer
public class TileEntityPump extends TileEntityElectricityReceiver implements IPacketReceiver, IReadOut, IPressure,ITankContainer
{
public final double WATTS_PER_TICK = 400;
public final double WATTS_PER_TICK = 400;
double percentPumped = 0.0;
double joulesReceived = 0;
int wMax = LiquidContainerRegistry.BUCKET_VOLUME * 2;
int disableTimer = 0;
int count = 0;
private boolean converted = false;
public LiquidData type = LiquidHandler.air;
public LiquidTank tank = new LiquidTank(wMax);
@ -55,7 +55,7 @@ public class TileEntityPump extends TileEntityElectricityReceiver implements IPa
public void registerConnections()
{
int notchMeta = MetaGroupingHelper.getFacingMeta(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
int notchMeta = MetaGroup.getFacingMeta(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
ForgeDirection facing = ForgeDirection.getOrientation(notchMeta).getOpposite();
ForgeDirection[] dirs = new ForgeDirection[] { ForgeDirection.UNKNOWN, ForgeDirection.UNKNOWN, ForgeDirection.UNKNOWN, ForgeDirection.UNKNOWN, ForgeDirection.UNKNOWN, ForgeDirection.UNKNOWN };
ElectricityConnections.registerConnector(this, EnumSet.of(facing.getOpposite()));
@ -105,55 +105,16 @@ public class TileEntityPump extends TileEntityElectricityReceiver implements IPa
}
count = 40;
}
if (this.tank.getLiquid() == null)
{
this.tank.setLiquid(LiquidHandler.getStack(this.type, 1));
}
LiquidStack stack = tank.getLiquid();
if (stack != null)
{
for (int i = 0; i < 6; i++)
{
ForgeDirection dir = ForgeDirection.getOrientation(i);
TileEntity tile = worldObj.getBlockTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
if (tile instanceof ITankContainer)
{
int moved = ((ITankContainer) tile).fill(dir.getOpposite(), stack, true);
tank.drain(moved, true);
if (stack.amount <= 0)
break;
}
}
}
int notchMeta = MetaGroupingHelper.getFacingMeta(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
ForgeDirection facing = ForgeDirection.getOrientation(notchMeta).getOpposite();
for (int i = 2; i < 6; i++)
{
ForgeDirection dir = ForgeDirection.getOrientation(i);
if (dir != facing)
{
TileEntity inputTile = Vector3.getTileEntityFromSide(this.worldObj, new Vector3(this), dir);
ElectricityNetwork network = ElectricityNetwork.getNetworkFromTileEntity(inputTile, dir);
if (network != null)
{
if (this.canPump(xCoord, yCoord - 1, zCoord))
{
network.startRequesting(this, WATTS_PER_TICK / this.getVoltage(), this.getVoltage());
this.joulesReceived = Math.max(Math.min(this.joulesReceived + network.consumeElectricity(this).getWatts(), WATTS_PER_TICK), 0);
}
else
{
network.stopRequesting(this);
}
}
}
}
//consume/give away stored units
this.fillSurroundings();
this.chargeUp();
if (this.joulesReceived >= this.WATTS_PER_TICK - 50 && this.canPump(xCoord, yCoord - 1, zCoord))
{
@ -174,7 +135,63 @@ public class TileEntityPump extends TileEntityElectricityReceiver implements IPa
}
}
}
/**
* Cause this to empty its internal tank to surrounding tanks
*/
public void fillSurroundings()
{
LiquidStack stack = tank.getLiquid();
if (stack != null && stack.amount > 1)
{
for (int i = 0; i < 6; i++)
{
ForgeDirection dir = ForgeDirection.getOrientation(i);
TileEntity tile = worldObj.getBlockTileEntity(xCoord + dir.offsetX, yCoord + dir.offsetY, zCoord + dir.offsetZ);
if (tile instanceof ITankContainer)
{
int moved = ((ITankContainer) tile).fill(dir.getOpposite(), stack, true);
tank.drain(moved, true);
if (stack.amount <= 0)
break;
}
}
}
}
/**
* causes this to request/drain energy from connected networks
*/
public void chargeUp()
{
this.joulesReceived += this.WATTS_PER_TICK; //TODO remove after testing
int notchMeta = MetaGroup.getFacingMeta(worldObj.getBlockMetadata(xCoord, yCoord, zCoord));
ForgeDirection facing = ForgeDirection.getOrientation(notchMeta).getOpposite();
for (int i = 2; i < 6; i++)
{
ForgeDirection dir = ForgeDirection.getOrientation(i);
if (dir != facing)
{
TileEntity inputTile = Vector3.getTileEntityFromSide(this.worldObj, new Vector3(this), dir);
ElectricityNetwork network = ElectricityNetwork.getNetworkFromTileEntity(inputTile, dir);
if (network != null)
{
if (this.canPump(xCoord, yCoord - 1, zCoord))
{
network.startRequesting(this, WATTS_PER_TICK / this.getVoltage(), this.getVoltage());
this.joulesReceived = Math.max(Math.min(this.joulesReceived + network.consumeElectricity(this).getWatts(), WATTS_PER_TICK), 0);
}
else
{
network.stopRequesting(this);
}
}
}
}
}
public boolean canPump(int x, int y, int z)
{
// if (this.tank.getLiquid() == null) return false;
@ -182,7 +199,7 @@ public class TileEntityPump extends TileEntityElectricityReceiver implements IPa
return false;
if (this.isDisabled())
return false;
if (!this.isValidLiquid(Block.blocksList[worldObj.getBlockId(x, y, z)]))
if ((LiquidHandler.getFromBlockID(worldObj.getBlockId(x, y, z)) == null || LiquidHandler.getFromBlockID(worldObj.getBlockId(x, y, z)) == LiquidHandler.air))
return false;
return true;
}
@ -202,7 +219,7 @@ public class TileEntityPump extends TileEntityElectricityReceiver implements IPa
return false;
if (bBlock == Block.lavaMoving.blockID || (bBlock == Block.lavaStill.blockID && meta != 0))
return false;
if (bBlock == LiquidData.getStack(type).itemID && this.isValidLiquid(Block.blocksList[bBlock]))
if (bBlock == LiquidData.getStack(type).itemID)
{
// FMLLog.info("pumping " + bellow.displayerName + " blockID:" +
// bBlock + " Meta:" +
@ -341,15 +358,10 @@ public class TileEntityPump extends TileEntityElectricityReceiver implements IPa
return false;
}
/**
* Checks to see if the given block type is valid for pumping
*
* @param block
* @return
*/
private boolean isValidLiquid(Block block)
@Override
public LiquidData getLiquidType()
{
return LiquidHandler.getFromBlockID(block.blockID) != null;
return this.type;
}
}

View file

@ -1,12 +1,18 @@
package liquidmechanics.common.tileentity;
import java.util.ArrayList;
import java.util.List;
import liquidmechanics.api.IPressure;
import liquidmechanics.api.IReadOut;
import liquidmechanics.api.ITankOutputer;
import liquidmechanics.api.helpers.TankHelper;
import liquidmechanics.common.block.BlockReleaseValve;
import liquidmechanics.common.handlers.LiquidData;
import liquidmechanics.common.handlers.LiquidHandler;
import liquidmechanics.common.handlers.PipeInstance;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
@ -17,100 +23,108 @@ import net.minecraftforge.liquids.LiquidStack;
import net.minecraftforge.liquids.LiquidTank;
import universalelectricity.prefab.implement.IRedstoneReceptor;
public class TileEntityReleaseValve extends TileEntity implements ITankOutputer, IReadOut, IRedstoneReceptor
public class TileEntityReleaseValve extends TileEntity implements IPressure, IReadOut, IRedstoneReceptor, IInventory
{
public LiquidData type = LiquidHandler.air;
public LiquidTank tank = new LiquidTank(LiquidContainerRegistry.BUCKET_VOLUME);
public TileEntity[] connected = new TileEntity[6];
private int count = 0;
private List<PipeInstance> output = new ArrayList<PipeInstance>();
private List<ILiquidTank> input = new ArrayList<ILiquidTank>();
private int ticks = 0;
public boolean isPowered = false;
public boolean converted = false;
public boolean isRestricted = false;
private ItemStack[] inventory = new ItemStack[0];
@Override
public void updateEntity()
{
super.updateEntity();
this.connected = TankHelper.getSourounding(worldObj, xCoord, yCoord, zCoord);
if (!this.worldObj.isRemote && count++ == 10)
if (!this.worldObj.isRemote && ticks++ == 10)
{
BlockReleaseValve.checkForPower(worldObj, xCoord, yCoord, zCoord);
if (tank.getLiquid() == null)
validateNBuildList();
}
}
/**
* Collects info about the surrounding 6 tiles and orders them into
* drain-able(ITankContainer) and fill-able(TileEntityPipes) instances
*/
public void validateNBuildList()
{
// cleanup
this.connected = TankHelper.getSurroundings(worldObj, xCoord, yCoord, zCoord);
this.input.clear();
this.output.clear();
// read surroundings
for (int i = 0; i < 6; i++)
{
ForgeDirection dir = ForgeDirection.getOrientation(i);
TileEntity ent = connected[i];
if (ent instanceof TileEntityPipe)
{
tank.setLiquid(LiquidHandler.getStack(this.type, 1));
}
if (tank.getLiquid() != null && tank.getLiquid().amount < tank.getCapacity() && !isPowered)
{
for (int i = 0; i < 6; i++)
TileEntityPipe pipe = (TileEntityPipe) ent;
if (this.isRestricted && pipe.type != this.type)
{
ForgeDirection dir = ForgeDirection.getOrientation(i);
if (connected[i] instanceof ITankContainer && !(connected[i] instanceof TileEntityPipe))
connected[i] = null;
}
else if (pipe.stored.getLiquid() != null && pipe.stored.getLiquid().amount >= pipe.stored.getCapacity())
{
connected[i] = null;
}
else
{
this.output.add(new PipeInstance(LiquidHandler.getMeta(pipe.type), pipe, pipe.isUniversal));
}
}
else if (ent instanceof ITankContainer)
{
ILiquidTank[] tanks = ((ITankContainer) connected[i]).getTanks(dir);
for (int t = 0; t < tanks.length; t++)
{
LiquidStack ll = tanks[t].getLiquid();
if (ll != null && ll.amount > 0 && ll.amount < tanks[t].getCapacity())
{
ILiquidTank[] tanks = ((ITankContainer) connected[i]).getTanks(dir);
for (int t = 0; t < tanks.length; t++)
// if restricted check for type match
if (this.isRestricted)
{
LiquidStack ll = tanks[t].getLiquid();
if (ll != null && LiquidHandler.isEqual(ll, this.type))
if (LiquidHandler.isEqual(ll, this.type))
{
int drainVol = tank.getCapacity() - tank.getLiquid().amount - 1;
LiquidStack drained = ((ITankContainer) connected[i]).drain(t, drainVol, true);
int f = this.tank.fill(drained, true);
this.input.add(tanks[t]);
}
}
else
{
this.input.add(tanks[t]);
}
}
}
}
count = 0;
LiquidStack stack = tank.getLiquid();
if (stack != null && !isPowered)
for (int i = 0; i < 6; i++)
{
if (connected[i] instanceof TileEntityPipe)
{
int ee = ((TileEntityPipe) connected[i]).fill(ForgeDirection.getOrientation(i), stack, true);
this.tank.drain(ee, true);
}
}
else
{
connected[i] = null;
}
}
}
@Override
public int fill(ForgeDirection from, LiquidStack resource, boolean doFill)
/**
* removes liquid from a tank and fills it to a pipe
*
* @param pipe
* - pipe being filled
* @param drainee
* - LiquidTank being drained
*/
public void drainTo(TileEntityPipe pipe, LiquidTank drainee)
{
return 0;
}
@Override
public int fill(int tankIndex, LiquidStack resource, boolean doFill)
{
if (tankIndex != 0 || resource == null)
return 0;
return tank.fill(resource, doFill);
}
@Override
public LiquidStack drain(ForgeDirection from, int maxDrain, boolean doDrain)
{
return null;
}
@Override
public LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain)
{
return null;
}
@Override
public ILiquidTank[] getTanks(ForgeDirection direction)
{
return new ILiquidTank[] { this.tank };
}
@Override
public ILiquidTank getTank(ForgeDirection direction, LiquidStack type)
{
return null;
}
@Override
@ -133,12 +147,22 @@ public class TileEntityReleaseValve extends TileEntity implements ITankOutputer,
{
if (type == null) return "Error: No Type";
String output = "";
LiquidStack stack = tank.getLiquid();
if (stack != null)
output += (stack.amount / LiquidContainerRegistry.BUCKET_VOLUME) + " " + LiquidData.getName(type) + " on = " + !this.isPowered;
if (stack != null)
return output;
return "0/0 " + LiquidData.getName(type) + " on = " + !this.isPowered;
if (this.isRestricted)
{
output +="Outputting: "+ LiquidData.getName(type)+" ||";
}else
{
output += " Outputting: All ||";
}
if (!this.isPowered)
{
output += " Running ";
}
else
{
output += " Offline ";
}
return output;
}
@Override
@ -146,16 +170,7 @@ public class TileEntityReleaseValve extends TileEntity implements ITankOutputer,
{
super.readFromNBT(nbt);
this.type = LiquidHandler.get(nbt.getString("name"));
this.converted = nbt.getBoolean("converted");
if (!converted)
{
int t = nbt.getInteger("type");
this.type = LiquidHandler.getFromMeta(t);
this.converted = true;
}
if (this.type == null) type = LiquidHandler.air;
int vol = nbt.getInteger("liquid");
this.tank.setLiquid(LiquidHandler.getStack(type, vol));
this.isRestricted = nbt.getBoolean("restricted");
}
/**
@ -165,11 +180,7 @@ public class TileEntityReleaseValve extends TileEntity implements ITankOutputer,
public void writeToNBT(NBTTagCompound nbt)
{
super.writeToNBT(nbt);
nbt.setBoolean("converted", this.converted);
int s = 0;
if (tank.getLiquid() != null) s = tank.getLiquid().amount;
nbt.setInteger("liquid", s);
nbt.setBoolean("restricted", this.isRestricted);
nbt.setString("name", LiquidData.getName(type));
}
@ -193,4 +204,121 @@ public class TileEntityReleaseValve extends TileEntity implements ITankOutputer,
}
public int getSizeInventory()
{
return this.inventory.length;
}
/**
* Returns the stack in slot i
*/
public ItemStack getStackInSlot(int par1)
{
return this.inventory[par1];
}
/**
* Removes from an inventory slot (first arg) up to a specified number
* (second arg) of items and returns them in a new stack.
*/
public ItemStack decrStackSize(int par1, int par2)
{
if (this.inventory[par1] != null)
{
ItemStack var3;
if (this.inventory[par1].stackSize <= par2)
{
var3 = this.inventory[par1];
this.inventory[par1] = null;
return var3;
}
else
{
var3 = this.inventory[par1].splitStack(par2);
if (this.inventory[par1].stackSize == 0)
{
this.inventory[par1] = null;
}
return var3;
}
}
else
{
return null;
}
}
/**
* When some containers are closed they call this on each slot, then drop
* whatever it returns as an EntityItem - like when you close a workbench
* GUI.
*/
public ItemStack getStackInSlotOnClosing(int par1)
{
if (this.inventory[par1] != null)
{
ItemStack var2 = this.inventory[par1];
this.inventory[par1] = null;
return var2;
}
else
{
return null;
}
}
/**
* Sets the given item stack to the specified slot in the inventory (can be
* crafting or armor sections).
*/
public void setInventorySlotContents(int par1, ItemStack par2ItemStack)
{
this.inventory[par1] = par2ItemStack;
if (par2ItemStack != null && par2ItemStack.stackSize > this.getInventoryStackLimit())
{
par2ItemStack.stackSize = this.getInventoryStackLimit();
}
}
@Override
public String getInvName()
{
return "Release Valve";
}
@Override
public int getInventoryStackLimit()
{
return 0;
}
@Override
public boolean isUseableByPlayer(EntityPlayer var1)
{
return this.worldObj.getBlockTileEntity(this.xCoord, this.yCoord, this.zCoord) != this ? false : var1.getDistanceSq((double) this.xCoord + 0.5D, (double) this.yCoord + 0.5D, (double) this.zCoord + 0.5D) <= 64.0D;
}
@Override
public void openChest()
{
}
@Override
public void closeChest()
{
}
@Override
public LiquidData getLiquidType()
{
return this.type;
}
}

View file

@ -1,7 +1,7 @@
package liquidmechanics.common.tileentity;
import liquidmechanics.api.IReadOut;
import liquidmechanics.api.ITankOutputer;
import liquidmechanics.api.IPressure;
import liquidmechanics.api.helpers.TankHelper;
import liquidmechanics.common.LiquidMechanics;
import liquidmechanics.common.handlers.LiquidData;
@ -14,6 +14,7 @@ import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.tileentity.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.ITankContainer;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidStack;
import net.minecraftforge.liquids.LiquidTank;
@ -23,7 +24,7 @@ import universalelectricity.prefab.network.PacketManager;
import com.google.common.io.ByteArrayDataInput;
public class TileEntityTank extends TileEntity implements IPacketReceiver, IReadOut, ITankOutputer
public class TileEntityTank extends TileEntity implements IPacketReceiver, IReadOut, IPressure,ITankContainer
{
public TileEntity[] cc = { null, null, null, null, null, null };
public LiquidData type = LiquidHandler.air;
@ -46,7 +47,7 @@ public class TileEntityTank extends TileEntity implements IPacketReceiver, IRead
if (++count >= 20 && liquid != null)
{
count = 0;
this.cc = TankHelper.getSourounding(worldObj, xCoord, yCoord, zCoord);
this.cc = TankHelper.getSurroundings(worldObj, xCoord, yCoord, zCoord);
if (!worldObj.isRemote)
{
this.tradeDown();
@ -292,7 +293,7 @@ public class TileEntityTank extends TileEntity implements IPacketReceiver, IRead
{
if (this.tank.getLiquid() == null || this.tank.getLiquid().amount <= 0)
return;
TileEntity[] ents = TankHelper.getSourounding(worldObj, xCoord, yCoord, zCoord);
TileEntity[] ents = TankHelper.getSurroundings(worldObj, xCoord, yCoord, zCoord);
int commonVol = this.tank.getLiquid().amount;
int tanks = 1;
for (int i = 2; i < 6; i++)
@ -334,4 +335,10 @@ public class TileEntityTank extends TileEntity implements IPacketReceiver, IRead
}
}
@Override
public LiquidData getLiquidType()
{
return this.type;
}
}

View file

@ -0,0 +1,30 @@
# FluidMechanics Language Properties
# @author DarkGuardsman
# Blocks
tile.Generator.name=Generator
tile.lmMachines.0.name=Pump
tile.lmMachines.4.name=Condensor
tile.MechanicRod.name=Geared Rod
tile.eValve.name=Release Valve
# Items
item.lmTool.0.name=Pipe Guage
item.parts.0.name=Bronze Tube
item.parts.1.name=Iron Tube
item.parts.2.name=Obby Tube
item.parts.3.name=Nether Tube
item.parts.4.name=Leather Seal
item.parts.5.name=Slime Seal
item.parts.6.name=Unfinished Tank
item.parts.7.name=Valve
item.itemPipe.0.name=Steam Pipe
item.itemPipe.1.name=Water Pipe
item.itemPipe.2.name=Lava Pipe
item.itemTank.0.name=Steam Tank
item.itemTank.1.name=Water Tank
item.itemTank.2.name=Lava Tank

Binary file not shown.

Before

Width:  |  Height:  |  Size: 614 B

After

Width:  |  Height:  |  Size: 487 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 596 B

After

Width:  |  Height:  |  Size: 494 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 630 B

After

Width:  |  Height:  |  Size: 563 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 623 B

After

Width:  |  Height:  |  Size: 514 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 621 B

After

Width:  |  Height:  |  Size: 504 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 593 B

After

Width:  |  Height:  |  Size: 476 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 446 B

After

Width:  |  Height:  |  Size: 426 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 431 B

Binary file not shown.

BIN
resources/models/Pump2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 690 B

BIN
resources/models/Pump2.xcf Normal file

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

BIN
resources/models/PumpV2.tcn Normal file

Binary file not shown.