Updated Pump,and some textures

Again nothing major changed. Just a model for the pump and made it
possible to craft
This commit is contained in:
Rseifert 2012-09-03 19:30:24 -04:00
parent 18aef1ff28
commit dd410bb781
13 changed files with 403 additions and 15 deletions

View file

@ -74,8 +74,9 @@ public class BasicPipesMain{
{
//register
proxy.init();
GameRegistry.registerTileEntity(TileEntityPump.class, "pump");
//Names
LanguageRegistry.addName((new ItemStack(machine, 1, 0)), "WaterPump");
LanguageRegistry.addName((new ItemStack(gauge, 1, 0)), "PipeGuage");
LanguageRegistry.addName((new ItemStack(itemPipes, 1, 0)), "SteamPipe");
LanguageRegistry.addName((new ItemStack(itemPipes, 1, 1)), "WaterPipe");
@ -124,6 +125,15 @@ public class BasicPipesMain{
//fuel
GameRegistry.addShapelessRecipe(new ItemStack(itemPipes, 1,4), new Object[] { new ItemStack(parts, 1,1),new ItemStack(parts, 1,4),new ItemStack(Item.dyePowder, 1,11)});
//pump
GameRegistry.addRecipe(new ItemStack(machine, 1,0), new Object[] { "@T@","BPB","@M@"
, '@',BasicComponents.itemSteelPlate
, 'M',BasicComponents.itemMotor
, 'B',new ItemStack(parts, 1,7)
, 'P',new ItemStack(Block.pistonBase)
, 'C',BasicComponents.blockCopperWire
, 'V',new ItemStack(parts, 2,1)
});//bronze tube
}
}

View file

@ -1,6 +1,7 @@
package basicpipes;
import basicpipes.pipes.TileEntityPipe;
import basicpipes.pipes.TileEntityPump;
import net.minecraft.src.EntityPlayer;
import net.minecraft.src.TileEntity;
import net.minecraft.src.World;
@ -17,6 +18,7 @@ public class PipeProxy implements IGuiHandler
public void init()
{
GameRegistry.registerTileEntity(TileEntityPipe.class, "pipe");
GameRegistry.registerTileEntity(TileEntityPump.class, "pump");
}
public void postInit()
{

View file

@ -0,0 +1,174 @@
package basicpipes;
import basicpipes.pipes.api.ILiquidConsumer;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
public class TradeHelper {
/**
*
* @param entity - entity at center of search
* @return an Array containing found entities and nulls of nonEntities
*/
public static TileEntity[] getSourounding(TileEntity entity)
{
TileEntity[] list = new TileEntity[]{null,null,null,null,null,null};
for(int i =0; i< 6;i++)
{
int x = entity.xCoord;
int y = entity.yCoord;
int z = entity.zCoord;
switch(i)
{
case 0: y = y - 1;break;//down
case 1: y = y + 1;break;//up
case 2: z = z + 1;break;//north
case 3: z = z - 1;break;//south
case 4: x = x + 1;break;//east
case 5: x = x - 1;break;//west
}
TileEntity aEntity = entity.worldObj.getBlockTileEntity(x, y, z);
if(aEntity instanceof TileEntity)
{
list[i] = aEntity;
}
}
return list;
}
/**
* Only works for steam Power's boiler. Still needs recode to work for all things
* @param blockEntity - tile entity trading the liquid
* @param type - liquid type see chart for info
* @param rise - does the liquid rise up like a gas
* @return the remaining untraded liquid
*/
public static int shareLiquid(TileEntity blockEntity,int type,boolean rise)
{
TileEntity[] connectedBlocks = getSourounding(blockEntity);
ILiquidConsumer blockMachine = (ILiquidConsumer) blockEntity;
int wSum = ((ILiquidConsumer)blockEntity).getStoredLiquid(type);
int ammountStored = blockMachine.getStoredLiquid(type);
int tankCount = 1;
boolean bottom = false;
TileEntity firstEntity = null;
TileEntity secondEntity = null;
if(rise)
{
firstEntity = connectedBlocks[1];
secondEntity = connectedBlocks[0];
}
else
{
firstEntity = connectedBlocks[0];
secondEntity = connectedBlocks[1];
}
//checks wether or not the block bellow it is a tank to move liquid too
if(firstEntity instanceof ILiquidConsumer)
{
int bWater = ((ILiquidConsumer) firstEntity).getStoredLiquid(type);
int bMax = ((ILiquidConsumer) firstEntity).getLiquidCapacity(type);
//checks if that tank has room to get liquid.
if(bWater < bMax)
{
int tradeVol = 0;
int emptyVol = Math.max( bMax - bWater,0);
tradeVol = Math.min(emptyVol, ammountStored);
int rejected = ((ILiquidConsumer) firstEntity).onReceiveLiquid(type, tradeVol, ForgeDirection.getOrientation(1));
ammountStored = ammountStored + rejected - tradeVol;
wSum -= tradeVol;
}
else
{
bottom = true;
}
}
else
{
//there was no tank bellow this tank
bottom = true;
}
//if this is the bottom tank or bottom tank is full. Update average water ammount.
if(bottom)
{
//get average water around center tank
for(int i = 2; i<6;i++)
{
TileEntity entityA = connectedBlocks[i];
if(entityA instanceof ILiquidConsumer)
{
//if is a tank add to the sum
wSum += ((ILiquidConsumer) entityA).getStoredLiquid(type);
tankCount += 1;
}
}
//if this is the bottom tank or bottom tank is full then trade liquid with tanks around it.
for(int i = 2; i<6;i++)
{
int average = Math.round((float)wSum / (float)tankCount);// takes the sum and makes it an average
int tradeSum = 0;
TileEntity entity = connectedBlocks[i];
if(entity instanceof ILiquidConsumer)
{
int targetW = ((ILiquidConsumer) entity).getStoredLiquid(type);
if(targetW < average)
{
tradeSum = Math.min(average, ammountStored); //gets the ammount to give to the target tank
int rejectedAm = ((ILiquidConsumer) entity).onReceiveLiquid(type, tradeSum, ForgeDirection.getOrientation(i)); //send that ammount with safty incase some comes back
ammountStored =rejectedAm + ammountStored - tradeSum; //counts up current water sum after trade
}
}
}
if(secondEntity instanceof ILiquidConsumer)
{
int bWater = ((ILiquidConsumer) secondEntity).getStoredLiquid(type);
int bMax = ((ILiquidConsumer) secondEntity).getLiquidCapacity(type);
if(bottom && ammountStored > 0)
{
if(bWater < bMax)
{
int emptyVolS = Math.max( bMax - bWater,0);
int tradeVolS = Math.min(emptyVolS, ammountStored);
int rejectedS = ((ILiquidConsumer) secondEntity).onReceiveLiquid(type, tradeVolS, ForgeDirection.getOrientation(0));;
ammountStored =rejectedS + ammountStored - tradeVolS;
wSum -= tradeVolS;
}
}
}
}
return ammountStored;
}
/**
*
* @param entity - entity in question
* @return 1-4 if corner 0 if not a corner
* you have to figure out which is which depending on what your using this for
* 1 should be north east 2 south east
*/
public static int corner(TileEntity entity)
{
TileEntity[] en = getSourounding(entity);
if(en[4] != null && en[2] != null && en[5] == null && en[3] == null)
{
return 1;
}
if(en[2] != null && en[5] != null && en[3] == null && en[4] == null)
{
return 2;
}
if(en[5] != null && en[3] != null && en[4] == null && en[2] == null)
{
return 3;
}
if(en[3] != null && en[4] != null && en[2] == null && en[5] == null)
{
return 4;
}
return 0;
}
}

View file

@ -14,7 +14,7 @@ public class BlockMachine extends BlockContainer
this.setBlockName("Machine");
this.setCreativeTab(CreativeTabs.tabBlock);
this.setRequiresSelfNotify();
this.blockIndexInTexture = 19;
this.blockIndexInTexture = 26;
}
public boolean isOpaqueCube()
@ -33,7 +33,7 @@ public class BlockMachine extends BlockContainer
*/
public int getRenderType()
{
return 0;
return -1;
}
/**

View file

@ -1,7 +1,9 @@
package basicpipes.pipes;
import basicpipes.TradeHelper;
import basicpipes.pipes.api.ILiquidProducer;
import net.minecraft.src.Block;
import net.minecraft.src.TileEntity;
import net.minecraftforge.common.ForgeDirection;
import universalelectricity.electricity.TileEntityElectricUnit;
import universalelectricity.extend.IElectricUnit;
@ -12,6 +14,8 @@ public class TileEntityPump extends TileEntityElectricUnit implements ILiquidPro
float eMax = 2000;
int wStored = 0;
int wMax = 10;
public TileEntity[] sList = {null,null,null,null,null,null};
private int count = 0;
@Override
public void onDisable(int duration) {
dCount = duration;
@ -29,17 +33,23 @@ public class TileEntityPump extends TileEntityElectricUnit implements ILiquidPro
@Override
public void onUpdate(float watts, float voltage, ForgeDirection side) {
super.onUpdate(watts, voltage, side);
if (electricityRequest() > 0 && canConnect(side))
{
float rejectedElectricity = (float) Math.max((this.eStored + watts) - this.eMax, 0.0);
this.eStored = (float) Math.max(this.eStored + watts - rejectedElectricity, 0.0);
}
int bBlock = worldObj.getBlockId(xCoord, yCoord -1, zCoord);
if(bBlock == Block.waterStill.blockID && this.eStored > 1000 && this.wStored < this.wMax)
sList = TradeHelper.getSourounding(this);
if(!worldObj.isRemote)
{
eStored -= 1000;
wStored += 1;
worldObj.setBlockAndMetadataWithNotify(xCoord, yCoord-1, zCoord, 0, 0);
count++;
if (electricityRequest() > 0 && canConnect(side))
{
float rejectedElectricity = (float) Math.max((this.eStored + watts) - this.eMax, 0.0);
this.eStored = (float) Math.max(this.eStored + watts - rejectedElectricity, 0.0);
}
int bBlock = worldObj.getBlockId(xCoord, yCoord -1, zCoord);
if(bBlock == Block.waterStill.blockID && this.eStored > 500 && this.wStored < this.wMax && count>=2)
{
eStored -= 500;
wStored += 1;
worldObj.setBlockAndMetadataWithNotify(xCoord, yCoord-1, zCoord, 0, 0);
count = 0;
}
}
}
@ -64,7 +74,7 @@ public class TileEntityPump extends TileEntityElectricUnit implements ILiquidPro
@Override
public int getTickInterval() {
return 40;
return 10;
}
@Override

View file

@ -33,7 +33,7 @@ public class ItemMachine extends ItemBlock {
{
case 1: return 23;
case 2: return 22;
case 15: return 22;
case 15: return 25;
}
return this.iconIndex+par1;
}

View file

@ -0,0 +1,146 @@
// Date: 9/3/2012 6:12:15 PM
// Template version 1.1
// Java generated by Techne
// Keep in mind that you still need to fill in some blanks
// - ZeuX
package basicpipes;
import net.minecraft.src.Entity;
import net.minecraft.src.ModelBase;
import net.minecraft.src.ModelRenderer;
public class ModelPump extends ModelBase
{
//fields
ModelRenderer Main;
ModelRenderer sidePort;
ModelRenderer FrontPort;
ModelRenderer pivit;
ModelRenderer crank;
ModelRenderer Rope;
ModelRenderer pivit2;
ModelRenderer Piston;
ModelRenderer pPlate;
ModelRenderer Rope2;
ModelRenderer BackPort;
public ModelPump()
{
textureWidth = 128;
textureHeight = 128;
Main = new ModelRenderer(this, 0, 0);
Main.addBox(-5F, 0F, -5F, 10, 13, 10);
Main.setRotationPoint(1F, 11F, 0F);
Main.setTextureSize(128, 128);
Main.mirror = true;
setRotation(Main, 0F, 0F, 0F);
sidePort = new ModelRenderer(this, 0, 76);
sidePort.addBox(-6F, -3F, -3F, 6, 6, 6);
sidePort.setRotationPoint(8F, 16F, 0F);
sidePort.setTextureSize(128, 128);
sidePort.mirror = true;
setRotation(sidePort, 0F, 0F, 0F);
FrontPort = new ModelRenderer(this, 0, 63);
FrontPort.addBox(-3F, -3F, 0F, 6, 6, 6);
FrontPort.setRotationPoint(0F, 16F, -8F);
FrontPort.setTextureSize(128, 128);
FrontPort.mirror = true;
setRotation(FrontPort, 0F, 0F, 0F);
pivit = new ModelRenderer(this, 0, 40);
pivit.addBox(-1F, 0F, -1F, 2, 3, 1);
pivit.setRotationPoint(0F, 8F, 1F);
pivit.setTextureSize(128, 128);
pivit.mirror = true;
setRotation(pivit, 0F, 0F, 0F);
crank = new ModelRenderer(this, 48, 0);
crank.addBox(-8F, 0F, -1F, 14, 2, 1);
crank.setRotationPoint(0F, 7F, 0F);
crank.setTextureSize(128, 128);
crank.mirror = true;
setRotation(crank, 0F, 0F, 0F);
Rope = new ModelRenderer(this, 0, 28);
Rope.addBox(0F, 0F, 0F, 1, 7, 1);
Rope.setRotationPoint(4F, 8F, -1F);
Rope.setTextureSize(128, 128);
Rope.mirror = true;
setRotation(Rope, 0F, 0F, 0F);
pivit2 = new ModelRenderer(this, 0, 40);
pivit2.addBox(-1F, 0F, -1F, 2, 3, 1);
pivit2.setRotationPoint(0F, 8F, -1F);
pivit2.setTextureSize(128, 128);
pivit2.mirror = true;
setRotation(pivit2, 0F, 0F, 0F);
pPlate = new ModelRenderer(this, 34, 30);
pPlate.addBox(0F, 0F, 0F, 1, 12, 1);
pPlate.setRotationPoint(-5F, 12F, -1F);
pPlate.setTextureSize(128, 128);
pPlate.mirror = true;
setRotation(pPlate, 0F, 0F, 0F);
Piston = new ModelRenderer(this, 20, 30);
Piston.addBox(0F, 0F, 0F, 3, 12, 3);
Piston.setRotationPoint(-8F, 12F, -2F);
Piston.setTextureSize(128, 128);
Piston.mirror = true;
setRotation(Piston, 0F, 0F, 0F);
Rope2 = new ModelRenderer(this, 0, 28);
Rope2.addBox(0F, 0F, 0F, 1, 7, 1);
Rope2.setRotationPoint(-7F, 8F, -1F);
Rope2.setTextureSize(128, 128);
Rope2.mirror = true;
setRotation(Rope2, 0F, 0F, 0F);
BackPort = new ModelRenderer(this, 0, 50);
BackPort.addBox(-3F, -3F, -6F, 6, 6, 6);
BackPort.setRotationPoint(0F, 16F, 8F);
BackPort.setTextureSize(128, 128);
BackPort.mirror = true;
setRotation(BackPort, 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);
}
public void renderMain(float f5)
{
Main.render(f5);
pivit.render(f5);
crank.render(f5);
Rope.render(f5);
pivit2.render(f5);
Piston.render(f5);
pPlate.render(f5);
Rope2.render(f5);
}
public void renderC1(float f5)
{
sidePort.render(f5);
}
public void renderC2(float f5)
{
FrontPort.render(f5);
}
public void renderC3(float f5)
{
BackPort.render(f5);
}
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);
}
}

View file

@ -3,8 +3,10 @@ package basicpipes;
import steampower.SteamPowerMain;
import basicpipes.PipeProxy;
import basicpipes.pipes.TileEntityPipe;
import basicpipes.pipes.TileEntityPump;
import net.minecraftforge.client.MinecraftForgeClient;
import cpw.mods.fml.client.registry.ClientRegistry;
import cpw.mods.fml.common.registry.GameRegistry;
public class PipeClientProxy extends PipeProxy
{
@ -20,5 +22,6 @@ public class PipeClientProxy extends PipeProxy
public void init()
{
ClientRegistry.registerTileEntity(TileEntityPipe.class, "pipe", new RenderPipe());
ClientRegistry.registerTileEntity(TileEntityPump.class, "pump", new RenderPump());
}
}

View file

@ -0,0 +1,43 @@
package basicpipes;
import net.minecraft.src.TileEntity;
import net.minecraft.src.TileEntitySpecialRenderer;
import org.lwjgl.opengl.GL11;
import basicpipes.pipes.TileEntityPipe;
import basicpipes.pipes.TileEntityPump;
public class RenderPump extends TileEntitySpecialRenderer
{
int type = 0;
private ModelPump model;
public RenderPump()
{
model = new ModelPump();
}
public void renderAModelAt(TileEntityPump tileEntity, double d, double d1, double d2, float f)
{
bindTextureByName(BasicPipesMain.textureFile+"/Pump.png");
GL11.glPushMatrix();
GL11.glTranslatef((float) d + 0.5F, (float) d1 + 1.5F, (float) d2 + 0.5F);
GL11.glScalef(1.0F, -1F, -1F);
model.renderMain(0.0625F);
model.renderC1(0.0625F);
model.renderC2(0.0625F);
model.renderC3(0.0625F);
GL11.glPopMatrix();
}
@Override
public void renderTileEntityAt(TileEntity tileEntity, double var2, double var4, double var6, float var8) {
this.renderAModelAt((TileEntityPump)tileEntity, var2, var4, var6, var8);
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 30 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 733 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 3.7 KiB