add liquid types to pumps

fixed textures for some pipe types and pump will pump any liquid with a
block id linked too it. Which is oil,lava,water only ;/

also i moved some package around was getting hard to sort sh** out
This commit is contained in:
Rseifert 2012-09-23 05:59:20 -04:00
parent 1b6e69e7a5
commit f16047c2ad
21 changed files with 206 additions and 53 deletions

View file

@ -6,7 +6,7 @@ import net.minecraft.src.World;
import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.MinecraftForgeClient;
import basicpipes.BasicPipesMain; import basicpipes.BasicPipesMain;
import basicpipes.pipes.TileEntityPipe; import basicpipes.pipes.TileEntityPipe;
import basicpipes.pipes.TileEntityPump; import basicpipes.pumps.TileEntityPump;
import cpw.mods.fml.common.Side; import cpw.mods.fml.common.Side;
import cpw.mods.fml.common.asm.SideOnly; import cpw.mods.fml.common.asm.SideOnly;
import cpw.mods.fml.common.network.IGuiHandler; import cpw.mods.fml.common.network.IGuiHandler;

View file

@ -2,12 +2,12 @@ package basicpipes;
import java.io.File; import java.io.File;
import basicpipes.pipes.BlockPipe; import basicpipes.pipes.BlockPipe;
import basicpipes.pipes.BlockMachine;
import basicpipes.pipes.ItemGuage; import basicpipes.pipes.ItemGuage;
import basicpipes.pipes.ItemParts; import basicpipes.pipes.ItemParts;
import basicpipes.pipes.ItemPipe; import basicpipes.pipes.ItemPipe;
import basicpipes.pipes.TileEntityPump;
import basicpipes.pipes.api.Liquid; import basicpipes.pipes.api.Liquid;
import basicpipes.pumps.BlockMachine;
import basicpipes.pumps.TileEntityPump;
import net.minecraft.client.Minecraft; import net.minecraft.client.Minecraft;
import net.minecraft.src.Block; import net.minecraft.src.Block;
@ -41,7 +41,7 @@ public class BasicPipesMain{
public static int pipeID = configurationProperties(); public static int pipeID = configurationProperties();
private static int partID; private static int partID;
private static int ppipeID; private static int ppipeID;
private static int machineID; public static int machineID;
private static int toolID; private static int toolID;
public static Block pipe = new BlockPipe(pipeID).setBlockName("pipe"); public static Block pipe = new BlockPipe(pipeID).setBlockName("pipe");
public static Block machine = new BlockMachine(machineID).setBlockName("pump"); public static Block machine = new BlockMachine(machineID).setBlockName("pump");
@ -68,7 +68,7 @@ public class BasicPipesMain{
{ {
proxy.preInit(); proxy.preInit();
GameRegistry.registerBlock(pipe); GameRegistry.registerBlock(pipe);
GameRegistry.registerBlock(machine); GameRegistry.registerBlock(machine,basicpipes.pumps.ItemMachine.class);
} }
@Init @Init
public void load(FMLInitializationEvent evt) public void load(FMLInitializationEvent evt)

View file

@ -1,7 +1,7 @@
package basicpipes; package basicpipes;
import basicpipes.pipes.TileEntityPipe; import basicpipes.pipes.TileEntityPipe;
import basicpipes.pipes.TileEntityPump; import basicpipes.pumps.TileEntityPump;
import net.minecraft.src.EntityPlayer; import net.minecraft.src.EntityPlayer;
import net.minecraft.src.TileEntity; import net.minecraft.src.TileEntity;
import net.minecraft.src.World; import net.minecraft.src.World;

View file

@ -1,22 +0,0 @@
package basicpipes.pipes.api;
/**
* The IHeatConsumer interface is an interface that must be applied to all tile entities that can receive heat joules.
* @author Darkguardsman code sourced from Calclavia
*
*/
public interface IHeatConsumer
{
/**
* onRecieveSteam is called whenever a Steam transmitter sends a packet of electricity to the consumer (which is this block).
* @param vol - The amount of steam this block received
* @param side - The side of the block in which the electricity came from.
* @return vol - The amount of rejected steam to be sent to back
*/
public float onReceiveHeat(float jouls, int side);
/**
* @return Return the stored electricity in this consumer. Called by conductors to spread electricity to this unit.
*/
public float getStoredHeat();
}

View file

@ -1,5 +1,6 @@
package basicpipes.pipes.api; package basicpipes.pipes.api;
import universalelectricity.basiccomponents.BasicComponents; import universalelectricity.basiccomponents.BasicComponents;
import net.minecraft.src.Block; import net.minecraft.src.Block;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
@ -48,4 +49,15 @@ private Liquid(String name,boolean flame,boolean gas,int block, int Moving)
} }
return DEFUALT; return DEFUALT;
} }
public static Liquid getLiquidByBlock(int bBlock) {
for(int i = 0; i < Liquid.values().length;i++)
{
Liquid selected = Liquid.getLiquid(i);
if(bBlock == selected.Still)
{
return selected;
}
}
return Liquid.DEFUALT;
}
} }

View file

@ -1,4 +1,4 @@
package basicpipes.pipes; package basicpipes.pumps;
import java.util.ArrayList; import java.util.ArrayList;
import net.minecraft.src.*; import net.minecraft.src.*;
@ -48,14 +48,8 @@ public class BlockMachine extends BlockContainer
//Per tick //Per tick
public int conductorCapacity() public int conductorCapacity()
{ {
return 10; return 1;
} }
public void addCreativeItems(ArrayList itemList)
{
itemList.add(new ItemStack(this, 1,0));
}
@Override @Override
public TileEntity createNewTileEntity(World var1,int meta) { public TileEntity createNewTileEntity(World var1,int meta) {
// TODO Auto-generated method stub // TODO Auto-generated method stub

View file

@ -0,0 +1,125 @@
package basicpipes.pumps;
import java.util.List;
import basicpipes.BasicPipesMain;
import net.minecraft.src.Block;
import net.minecraft.src.CreativeTabs;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.Item;
import net.minecraft.src.ItemBlock;
import net.minecraft.src.ItemStack;
import net.minecraft.src.MathHelper;
import net.minecraft.src.TileEntity;
import net.minecraft.src.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.setTabToDisplayOn(CreativeTabs.tabRedstone);
}
@Override
public int getIconFromDamage(int par1)
{
return par1+index;
}
@Override
public String getItemNameIS(ItemStack itemstack)
{
return itemstack.getItemDamage() == 0 ? "Pump" :"Condenser";
}
@Override
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
par3List.add(new ItemStack(this, 1, 0));
}
public String getTextureFile() {
return BasicPipesMain.textureFile+"/Items.png";
}
@Override
public String getItemName()
{
return "Machines";
}
@Override
public boolean tryPlaceIntoWorld(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 = BasicPipesMain.machineID;
if (blockID == Block.snow.blockID)
{
par7 = 1;
}
else if (blockID != Block.vine.blockID && blockID != Block.tallGrass.blockID && blockID != Block.deadBush.blockID)
{
if (par7 == 0)
{
--par5;
}
if (par7 == 1)
{
++par5;
}
if (par7 == 2)
{
--par6;
}
if (par7 == 3)
{
++par6;
}
if (par7 == 4)
{
--par4;
}
if (par7 == 5)
{
++par4;
}
}
if (BasicPipesMain.pipe.canPlaceBlockAt(par3World,par4,par5,par6))
{
Block var9 = Block.blocksList[this.spawnID];
par3World.editingBlocks = true;
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

@ -1,4 +1,4 @@
package basicpipes.pipes; package basicpipes.pumps;
import basicpipes.pipes.api.ILiquidProducer; import basicpipes.pipes.api.ILiquidProducer;
import basicpipes.pipes.api.Liquid; import basicpipes.pipes.api.Liquid;

View file

@ -1,4 +1,4 @@
package basicpipes.pipes; package basicpipes.pumps;
import basicpipes.TradeHelper; import basicpipes.TradeHelper;
import basicpipes.pipes.api.ILiquidProducer; import basicpipes.pipes.api.ILiquidProducer;
@ -13,8 +13,9 @@ public class TileEntityPump extends TileEntityElectricUnit implements ILiquidPro
int dCount = 0; int dCount = 0;
float eStored = 0; float eStored = 0;
float eMax = 2000; float eMax = 2000;
int wStored = 0; int lStored = 0;
int wMax = 10; int wMax = 10;
public Liquid type = Liquid.DEFUALT;
public TileEntity[] sList = {null,null,null,null,null,null}; public TileEntity[] sList = {null,null,null,null,null,null};
private int count = 0; private int count = 0;
@Override @Override
@ -35,6 +36,12 @@ public class TileEntityPump extends TileEntityElectricUnit implements ILiquidPro
public void onUpdate(float watts, float voltage, ForgeDirection side) { public void onUpdate(float watts, float voltage, ForgeDirection side) {
super.onUpdate(watts, voltage, side); super.onUpdate(watts, voltage, side);
sList = TradeHelper.getSourounding(this); sList = TradeHelper.getSourounding(this);
int bBlock = worldObj.getBlockId(xCoord, yCoord -1, zCoord);
Liquid bellow = Liquid.getLiquidByBlock(bBlock);
if(bellow != null && this.lStored <= 0)
{
this.type = bellow;
}
if(!worldObj.isRemote) if(!worldObj.isRemote)
{ {
count++; count++;
@ -43,11 +50,11 @@ public class TileEntityPump extends TileEntityElectricUnit implements ILiquidPro
float rejectedElectricity = (float) Math.max((this.eStored + watts) - this.eMax, 0.0); float rejectedElectricity = (float) Math.max((this.eStored + watts) - this.eMax, 0.0);
this.eStored = (float) Math.max(this.eStored + watts - rejectedElectricity, 0.0); this.eStored = (float) Math.max(this.eStored + watts - rejectedElectricity, 0.0);
} }
int bBlock = worldObj.getBlockId(xCoord, yCoord -1, zCoord);
if(bBlock == Block.waterStill.blockID && this.eStored > 500 && this.wStored < this.wMax && count>=2) if(bBlock == type.Still && this.eStored > 200 && this.lStored < this.wMax && count>=2)
{ {
eStored -= 500; eStored -= 200;
wStored += 1; lStored += 1;
worldObj.setBlockAndMetadataWithNotify(xCoord, yCoord-1, zCoord, 0, 0); worldObj.setBlockAndMetadataWithNotify(xCoord, yCoord-1, zCoord, 0, 0);
count = 0; count = 0;
} }
@ -80,10 +87,10 @@ public class TileEntityPump extends TileEntityElectricUnit implements ILiquidPro
@Override @Override
public int onProduceLiquid(Liquid type, int maxVol, ForgeDirection side) { public int onProduceLiquid(Liquid type, int maxVol, ForgeDirection side) {
if(type == Liquid.WATER && wStored > 0) if(type == this.type && lStored > 0)
{ {
int tradeW = Math.min(maxVol, wStored); int tradeW = Math.min(maxVol, lStored);
wStored -= tradeW; lStored -= tradeW;
return tradeW; return tradeW;
} }
return 0; return 0;
@ -91,7 +98,17 @@ public class TileEntityPump extends TileEntityElectricUnit implements ILiquidPro
@Override @Override
public boolean canProduceLiquid(Liquid type, ForgeDirection side) { public boolean canProduceLiquid(Liquid type, ForgeDirection side) {
if(type == Liquid.WATER && side != ForgeDirection.DOWN) int meta = worldObj.getBlockMetadata(xCoord, yCoord, zCoord);
int facing = 0;
switch(meta)
{
case 0: facing = 2;break;
case 1: facing = 5;break;
case 2: facing = 3;break;
case 3: facing = 4;break;
}
if(type == this.type && side != ForgeDirection.DOWN && side != ForgeDirection.UP && side != ForgeDirection.getOrientation(facing).getOpposite())
{ {
return true; return true;
} }
@ -103,13 +120,21 @@ public class TileEntityPump extends TileEntityElectricUnit implements ILiquidPro
if(type == Liquid.WATER) if(type == Liquid.WATER)
{ {
return 32; return 32;
}else
if(type == Liquid.LAVA)
{
return 10;
}else
if(type == this.type)
{
return 50;
} }
return 0; return 0;
} }
@Override @Override
public boolean canProducePresure(Liquid type, ForgeDirection side) { public boolean canProducePresure(Liquid type, ForgeDirection side) {
if(type == Liquid.WATER) if(type == this.type)
{ {
return true; return true;
} }

View file

@ -3,7 +3,7 @@ package basicpipes;
import steampower.SteamPowerMain; import steampower.SteamPowerMain;
import basicpipes.PipeProxy; import basicpipes.PipeProxy;
import basicpipes.pipes.TileEntityPipe; import basicpipes.pipes.TileEntityPipe;
import basicpipes.pipes.TileEntityPump; import basicpipes.pumps.TileEntityPump;
import net.minecraftforge.client.MinecraftForgeClient; import net.minecraftforge.client.MinecraftForgeClient;
import cpw.mods.fml.client.registry.ClientRegistry; import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.registry.GameRegistry; import cpw.mods.fml.common.registry.GameRegistry;

View file

@ -57,6 +57,9 @@ public class RenderPipe extends TileEntitySpecialRenderer
switch(type.ordinal()) switch(type.ordinal())
{ {
case 0: bindTextureByName(BasicPipesMain.textureFile+"/pipes/SixSteamPipe.png");break; case 0: bindTextureByName(BasicPipesMain.textureFile+"/pipes/SixSteamPipe.png");break;
case 1: bindTextureByName(BasicPipesMain.textureFile+"/pipes/SixWaterPipe.png");break;
case 2: bindTextureByName(BasicPipesMain.textureFile+"/pipes/SixLavaPipe.png");break;
case 3: bindTextureByName(BasicPipesMain.textureFile+"/pipes/SixOilPipe.png");break;
default:bindTextureByName(BasicPipesMain.textureFile+"/pipes/DefaultPipe.png"); break; default:bindTextureByName(BasicPipesMain.textureFile+"/pipes/DefaultPipe.png"); break;
} }
if(tileEntity.connectedBlocks[0] != null) SixPipe.renderBottom(); if(tileEntity.connectedBlocks[0] != null) SixPipe.renderBottom();

View file

@ -6,7 +6,8 @@ import net.minecraft.src.TileEntitySpecialRenderer;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import basicpipes.pipes.TileEntityPipe; import basicpipes.pipes.TileEntityPipe;
import basicpipes.pipes.TileEntityPump; import basicpipes.pipes.api.Liquid;
import basicpipes.pumps.TileEntityPump;
public class RenderPump extends TileEntitySpecialRenderer public class RenderPump extends TileEntitySpecialRenderer
@ -21,12 +22,27 @@ public class RenderPump extends TileEntitySpecialRenderer
public void renderAModelAt(TileEntityPump tileEntity, double d, double d1, double d2, float f) public void renderAModelAt(TileEntityPump tileEntity, double d, double d1, double d2, float f)
{ {
Liquid type = tileEntity.type;
bindTextureByName(BasicPipesMain.textureFile+"/Pump.png"); int meta = tileEntity.worldObj.getBlockMetadata(tileEntity.xCoord, tileEntity.yCoord, tileEntity.zCoord);
switch(type.ordinal())
{
default: bindTextureByName("/textures/pumps/Pump.png");break;
//case 0://steam
case 1:bindTextureByName("/textures/pumps/WaterPump.png");break;//water
case 2:bindTextureByName("/textures/pumps/LavaPump.png");break;//lava
case 3:bindTextureByName("/textures/pumps/OilPump.png");break;//oil
//case 4://fuel
}
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F); GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
GL11.glScalef(1.0F, -1F, -1F); GL11.glScalef(1.0F, -1F, -1F);
switch(meta)
{
case 1:GL11.glRotatef(0f, 0f, 1f, 0f);break;
case 2:GL11.glRotatef(90f, 0f, 1f, 0f);break;
case 3:GL11.glRotatef(180f, 0f, 1f, 0f);break;
case 0:GL11.glRotatef(270f, 0f, 1f, 0f);break;
}
model.renderMain(0.0625F); model.renderMain(0.0625F);
model.renderC1(0.0625F); model.renderC1(0.0625F);
model.renderC2(0.0625F); model.renderC2(0.0625F);

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 796 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 782 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 791 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 740 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 727 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 735 B

View file

Before

Width:  |  Height:  |  Size: 733 B

After

Width:  |  Height:  |  Size: 733 B