Worked on Trough Pipes

These are designed to be open pipes for very easily tech tiers
This commit is contained in:
DarkGuardsman 2013-12-30 20:21:46 -05:00
parent fba04c02f0
commit b7a88d1786
5 changed files with 87 additions and 56 deletions

View file

@ -155,7 +155,34 @@ public class ModelLargePipe extends ModelBase
FrontConnect.mirror = true; FrontConnect.mirror = true;
setRotation(FrontConnect, 0F, 0F, 0F); setRotation(FrontConnect, 0F, 0F, 0F);
} }
public void render(boolean[] side)
{
if (side[0])
{
renderBottom();
}
if (side[1])
{
renderTop();
}
if (side[3])
{
renderFront();
}
if (side[2])
{
renderBack();
}
if (side[5])
{
renderRight();
}
if (side[4])
{
renderLeft();
}
renderMiddle();
}
public void renderMiddle() public void renderMiddle()
{ {
Mid.render(0.0625F); Mid.render(0.0625F);

View file

@ -10,7 +10,7 @@ import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer; import net.minecraft.client.model.ModelRenderer;
import net.minecraft.entity.Entity; import net.minecraft.entity.Entity;
public class ModelOpenPipe extends ModelBase public class ModelOpenTrough extends ModelBase
{ {
//fields //fields
ModelRenderer base; ModelRenderer base;
@ -51,7 +51,7 @@ public class ModelOpenPipe extends ModelBase
ModelRenderer cornerFrontLeft; ModelRenderer cornerFrontLeft;
ModelRenderer cornerFrontRight; ModelRenderer cornerFrontRight;
public ModelOpenPipe() public ModelOpenTrough()
{ {
textureWidth = 128; textureWidth = 128;
textureHeight = 128; textureHeight = 128;
@ -280,9 +280,22 @@ public class ModelOpenPipe extends ModelBase
setRotation(cornerFrontRight, 0F, 0F, 0F); setRotation(cornerFrontRight, 0F, 0F, 0F);
} }
public void renderMiddle(boolean corners) public void render(boolean[] side, boolean stone)
{ {
base.render(0.0625F); if (side != null)
{
renderMiddle(!side[0], stone);
renderBack(side[2] ? PipeType.NORMAL : stone ? PipeType.SOLID : PipeType.MID_CAP);
renderFront(side[3] ? PipeType.NORMAL : stone ? PipeType.SOLID : PipeType.MID_CAP);
renderRight(side[4] ? PipeType.NORMAL : stone ? PipeType.SOLID : PipeType.MID_CAP);
renderLeft(side[5] ? PipeType.NORMAL : stone ? PipeType.SOLID : PipeType.MID_CAP);
}
}
public void renderMiddle(boolean bottom, boolean corners)
{
if (bottom)
base.render(0.0625F);
centerA.render(0.0625F); centerA.render(0.0625F);
centerB.render(0.0625F); centerB.render(0.0625F);
centerC.render(0.0625F); centerC.render(0.0625F);
@ -310,6 +323,7 @@ public class ModelOpenPipe extends ModelBase
if (type == PipeType.SOLID) if (type == PipeType.SOLID)
{ {
leftDoorB.render(0.0625F); leftDoorB.render(0.0625F);
leftDoorC.render(0.0625F);
} }
} }
} }
@ -333,6 +347,7 @@ public class ModelOpenPipe extends ModelBase
if (type == PipeType.SOLID) if (type == PipeType.SOLID)
{ {
rightDoorB.render(0.0625F); rightDoorB.render(0.0625F);
rightDoorC.render(0.0625F);
} }
} }
} }
@ -356,6 +371,7 @@ public class ModelOpenPipe extends ModelBase
if (type == PipeType.SOLID) if (type == PipeType.SOLID)
{ {
backDoorB.render(0.0625F); backDoorB.render(0.0625F);
backDoorC.render(0.0625F);
} }
} }
} }
@ -379,6 +395,7 @@ public class ModelOpenPipe extends ModelBase
if (type == PipeType.SOLID) if (type == PipeType.SOLID)
{ {
frontDoorB.render(0.0625F); frontDoorB.render(0.0625F);
frontDoorC.render(0.0625F);
} }
} }
} }

View file

@ -21,7 +21,6 @@ import cpw.mods.fml.relauncher.SideOnly;
public class ItemPipeRenderer implements IItemRenderer public class ItemPipeRenderer implements IItemRenderer
{ {
private ModelReleaseValve valve = new ModelReleaseValve(); private ModelReleaseValve valve = new ModelReleaseValve();
private RenderPipe pipe = new RenderPipe();
@Override @Override
public boolean handleRenderType(ItemStack item, ItemRenderType type) public boolean handleRenderType(ItemStack item, ItemRenderType type)
@ -44,55 +43,46 @@ public class ItemPipeRenderer implements IItemRenderer
} }
if (item.itemID == ALRecipeLoader.blockReleaseValve.blockID) if (item.itemID == ALRecipeLoader.blockReleaseValve.blockID)
{ {
this.renderReleaseValve((RenderBlocks) data[0], item.getItemDamage(), type == ItemRenderType.EQUIPPED); this.renderReleaseValve((RenderBlocks) data[0], type == ItemRenderType.EQUIPPED);
} }
} }
public void renderPipeItem(RenderBlocks renderer, ItemStack item, boolean equ) public void renderPipeItem(RenderBlocks renderer, ItemStack item, boolean equ)
{ {
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glRotatef(180f, 0f, 0f, 1f);
FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderPipe.getTexture(FluidPartsMaterial.getFromItemMeta(item.getItemDamage()), item.getItemDamage() % FluidPartsMaterial.spacing)); FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderPipe.getTexture(item.getItemDamage()));
if (!equ) if (!equ)
{ {
GL11.glTranslatef(0.5F, -0.5F, 0.5F); GL11.glTranslatef(0.5F, -0.5F, 0.5F);
pipe.SixPipe.renderRight(); RenderPipe.render(item.getItemDamage(), new boolean[] { false, false, false, false, true, true });
pipe.SixPipe.renderLeft();
pipe.SixPipe.renderMiddle();
} }
else else
{ {
GL11.glTranslatef(0.5F, -0.5F, 0.5F); GL11.glTranslatef(0.5F, -0.5F, 0.5F);
pipe.SixPipe.renderFront(); RenderPipe.render(item.getItemDamage(), new boolean[] { false, false, true, true, false, false });
pipe.SixPipe.renderBack();
pipe.SixPipe.renderMiddle();
} }
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
public void renderReleaseValve(RenderBlocks renderer, int meta, boolean equ) public void renderReleaseValve(RenderBlocks renderer, boolean equ)
{ {
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glRotatef(180f, 0f, 0f, 1f);
FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderPipe.getTexture(FluidPartsMaterial.STEEL, 0)); FMLClientHandler.instance().getClient().renderEngine.bindTexture(RenderPipe.getTexture(FluidPartsMaterial.STEEL, 0));
if (!equ) if (!equ)
{ {
GL11.glTranslatef(0.5F, -0.5F, 0.5F); GL11.glTranslatef(0.5F, -0.5F, 0.5F);
pipe.SixPipe.renderRight(); RenderPipe.render(FluidPartsMaterial.IRON, 0, new boolean[] { false, false, false, false, true, true });
pipe.SixPipe.renderLeft();
pipe.SixPipe.renderMiddle();
} }
else else
{ {
GL11.glTranslatef(0.5F, -0.5F, 0.5F); GL11.glTranslatef(0.5F, -0.5F, 0.5F);
pipe.SixPipe.renderFront(); RenderPipe.render(FluidPartsMaterial.IRON, 0, new boolean[] { false, false, true, true, false, false });
pipe.SixPipe.renderBack();
pipe.SixPipe.renderMiddle();
} }
FMLClientHandler.instance().getClient().renderEngine.bindTexture(new ResourceLocation(AssemblyLine.DOMAIN, DarkCore.MODEL_DIRECTORY + "ReleaseValve.png")); FMLClientHandler.instance().getClient().renderEngine.bindTexture(new ResourceLocation(AssemblyLine.DOMAIN, DarkCore.MODEL_DIRECTORY + "ReleaseValve.png"));
GL11.glRotatef(180f, 0f, 0f, 1f);
if (!equ) if (!equ)
{ {
GL11.glTranslatef(0, -2.0F, 0); GL11.glTranslatef(0, -2.0F, 0);
@ -104,5 +94,4 @@ public class ItemPipeRenderer implements IItemRenderer
valve.render(); valve.render();
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
} }

View file

@ -10,6 +10,7 @@ import org.lwjgl.opengl.GL11;
import com.builtbroken.assemblyline.AssemblyLine; import com.builtbroken.assemblyline.AssemblyLine;
import com.builtbroken.assemblyline.client.model.ModelLargePipe; import com.builtbroken.assemblyline.client.model.ModelLargePipe;
import com.builtbroken.assemblyline.client.model.ModelOpenTrough;
import com.builtbroken.assemblyline.fluid.pipes.EnumPipeType; import com.builtbroken.assemblyline.fluid.pipes.EnumPipeType;
import com.builtbroken.assemblyline.fluid.pipes.FluidPartsMaterial; import com.builtbroken.assemblyline.fluid.pipes.FluidPartsMaterial;
import com.builtbroken.assemblyline.fluid.pipes.TileEntityPipe; import com.builtbroken.assemblyline.fluid.pipes.TileEntityPipe;
@ -22,15 +23,11 @@ import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT) @SideOnly(Side.CLIENT)
public class RenderPipe extends TileEntitySpecialRenderer public class RenderPipe extends TileEntitySpecialRenderer
{ {
public ModelLargePipe SixPipe; public static ModelLargePipe MODEL_PIPE = new ModelLargePipe();
public static ModelOpenTrough MODEL_TROUGH_PIPE = new ModelOpenTrough();
private static HashMap<Pair<FluidPartsMaterial, Integer>, ResourceLocation> TEXTURES = new HashMap<Pair<FluidPartsMaterial, Integer>, ResourceLocation>(); private static HashMap<Pair<FluidPartsMaterial, Integer>, ResourceLocation> TEXTURES = new HashMap<Pair<FluidPartsMaterial, Integer>, ResourceLocation>();
public static ResourceLocation TEXTURE = new ResourceLocation(AssemblyLine.DOMAIN, DarkCore.MODEL_DIRECTORY + "pipes/Pipe.png"); public static ResourceLocation TEXTURE = new ResourceLocation(AssemblyLine.DOMAIN, DarkCore.MODEL_DIRECTORY + "pipes/Pipe.png");
public RenderPipe()
{
SixPipe = new ModelLargePipe();
}
@Override @Override
public void renderTileEntityAt(TileEntity te, double d, double d1, double d2, float f) public void renderTileEntityAt(TileEntity te, double d, double d1, double d2, float f)
{ {
@ -44,7 +41,7 @@ public class RenderPipe extends TileEntitySpecialRenderer
{ {
mat = FluidPartsMaterial.values()[te.getBlockMetadata()]; mat = FluidPartsMaterial.values()[te.getBlockMetadata()];
} }
bindTexture(RenderPipe.getTexture(mat, 0));
if (te instanceof TileEntityPipe) if (te instanceof TileEntityPipe)
{ {
this.render(mat, ((TileEntityPipe) te).getSubID(), ((TileEntityPipe) te).renderConnection); this.render(mat, ((TileEntityPipe) te).getSubID(), ((TileEntityPipe) te).renderConnection);
@ -76,34 +73,30 @@ public class RenderPipe extends TileEntitySpecialRenderer
return TEXTURE; return TEXTURE;
} }
public void render(FluidPartsMaterial mat, int pipeID, boolean[] side) public static ResourceLocation getTexture(int meta)
{ {
bindTexture(RenderPipe.getTexture(mat, pipeID)); return getTexture(FluidPartsMaterial.getFromItemMeta(meta), FluidPartsMaterial.getType(meta));
if (side[0]) }
public static void render(FluidPartsMaterial mat, int pipeID, boolean[] side)
{
if (mat == FluidPartsMaterial.WOOD)
{ {
SixPipe.renderBottom(); MODEL_TROUGH_PIPE.render(side, false);
} }
if (side[1]) else if (mat == FluidPartsMaterial.STONE)
{ {
SixPipe.renderTop(); MODEL_TROUGH_PIPE.render(side, true);
} }
if (side[3]) else
{ {
SixPipe.renderFront(); MODEL_PIPE.render(side);
} }
if (side[2]) }
{
SixPipe.renderBack(); public static void render(int meta, boolean[] bs)
} {
if (side[5]) render(FluidPartsMaterial.getFromItemMeta(meta), FluidPartsMaterial.getType(meta), bs);
{
SixPipe.renderRight();
}
if (side[4])
{
SixPipe.renderLeft();
}
SixPipe.renderMiddle();
} }
} }

View file

@ -14,11 +14,11 @@ import com.builtbroken.minecraft.helpers.ColorCode;
/** Enum to hold info about each pipe material. Values are by default and some can change with pipe /** Enum to hold info about each pipe material. Values are by default and some can change with pipe
* upgrades. * upgrades.
* *
* @Note unsupportedFluids should only be used by filters. All pipes should allow all fluid types. * @Note unsupportedFluids should only be used by filters. All pipes should allow all fluid types.
* However, pipes that can't support the fluid should have an effect. Eg no gas support should cause * However, pipes that can't support the fluid should have an effect. Eg no gas support should cause
* the pipe to leak. No molten support should cause the pipe to take damage. * the pipe to leak. No molten support should cause the pipe to take damage.
* *
* @author DarkGuardsman */ * @author DarkGuardsman */
public enum FluidPartsMaterial public enum FluidPartsMaterial
{ {
@ -143,6 +143,11 @@ public enum FluidPartsMaterial
return this.getMeta(0); return this.getMeta(0);
} }
public static int getType(int meta)
{
return meta / spacing;
}
public static int getDropItemMeta(World world, int x, int y, int z) public static int getDropItemMeta(World world, int x, int y, int z)
{ {
int meta = world.getBlockMetadata(x, y, z); int meta = world.getBlockMetadata(x, y, z);