Resolved #402 - Added different pipe materials and colors

This commit is contained in:
Calclavia 2014-03-08 18:04:45 -08:00
parent 9fa649312a
commit 207610916d
14 changed files with 195 additions and 437 deletions

View file

@ -146,11 +146,10 @@ public class TileGutter extends TilePressureNode
{ {
if (getInternalTank().getFluidAmount() > 0) if (getInternalTank().getFluidAmount() > 0)
{ {
int pressure = node.pressure;
for (int i = 2; i < 6; i++) for (int i = 2; i < 6; i++)
{ {
ForgeDirection dir = ForgeDirection.getOrientation(i); ForgeDirection dir = ForgeDirection.getOrientation(i);
int pressure = node.getPressure(dir);
Vector3 position = position().translate(dir); Vector3 position = position().translate(dir);
TileEntity checkTile = position.getTileEntity(world()); TileEntity checkTile = position.getTileEntity(world());

View file

@ -20,6 +20,7 @@ import resonantinduction.mechanical.energy.turbine.SchematicWaterTurbine;
import resonantinduction.mechanical.energy.turbine.SchematicWindTurbine; import resonantinduction.mechanical.energy.turbine.SchematicWindTurbine;
import resonantinduction.mechanical.energy.turbine.TileWaterTurbine; import resonantinduction.mechanical.energy.turbine.TileWaterTurbine;
import resonantinduction.mechanical.energy.turbine.TileWindTurbine; import resonantinduction.mechanical.energy.turbine.TileWindTurbine;
import resonantinduction.mechanical.fluid.pipe.EnumPipeMaterial;
import resonantinduction.mechanical.fluid.pipe.ItemPipe; import resonantinduction.mechanical.fluid.pipe.ItemPipe;
import resonantinduction.mechanical.fluid.transport.BlockPump; import resonantinduction.mechanical.fluid.transport.BlockPump;
import resonantinduction.mechanical.fluid.transport.TilePump; import resonantinduction.mechanical.fluid.transport.TilePump;
@ -173,8 +174,12 @@ public class Mechanical
GameRegistry.addRecipe(new ShapedOreRecipe(blockPump, "PPP", "GGG", "PPP", 'P', itemPipe, 'G', new ItemStack(itemGear, 1, 2))); GameRegistry.addRecipe(new ShapedOreRecipe(blockPump, "PPP", "GGG", "PPP", 'P', itemPipe, 'G', new ItemStack(itemGear, 1, 2)));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemPipe, 3), "BBB", " ", "BBB", 'B', Item.ingotIron)); GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemPipe, 1, EnumPipeMaterial.CERAMIC.ordinal()), "BBB", " ", "BBB", 'B', Item.brick));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemPipe, 4), "BBB", " ", "BBB", 'B', UniversalRecipe.SECONDARY_METAL.get())); GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemPipe, 1, EnumPipeMaterial.BRONZE.ordinal()), "BBB", " ", "BBB", 'B', "ingotBronze"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemPipe, 1, EnumPipeMaterial.PLASTIC.ordinal()), "BBB", " ", "BBB", 'B', "rubber"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemPipe, 1, EnumPipeMaterial.IRON.ordinal()), "BBB", " ", "BBB", 'B', Item.ingotIron));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemPipe, 1, EnumPipeMaterial.STEEL.ordinal()), "BBB", " ", "BBB", 'B', "ingotSteel"));
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(itemPipe, 1, EnumPipeMaterial.FIBERGLASS.ordinal()), "BBB", " ", "BBB", 'B', Item.diamond));
GameRegistry.addRecipe(new ShapedOreRecipe(blockGrinderWheel, "III", "LGL", "III", 'I', UniversalRecipe.PRIMARY_METAL.get(), 'L', "logWood", 'G', itemGear)); GameRegistry.addRecipe(new ShapedOreRecipe(blockGrinderWheel, "III", "LGL", "III", 'I', UniversalRecipe.PRIMARY_METAL.get(), 'L', "logWood", 'G', itemGear));
GameRegistry.addRecipe(new ShapedOreRecipe(blockPurifier, "IGI", "IGI", "IGI", 'I', UniversalRecipe.PRIMARY_METAL.get(), 'G', itemGear)); GameRegistry.addRecipe(new ShapedOreRecipe(blockPurifier, "IGI", "IGI", "IGI", 'I', UniversalRecipe.PRIMARY_METAL.get(), 'G', itemGear));

View file

@ -1,139 +1,30 @@
package resonantinduction.mechanical.fluid.pipe; package resonantinduction.mechanical.fluid.pipe;
import java.util.ArrayList; import java.awt.Color;
import java.util.List;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.fluids.FluidStack;
import resonantinduction.core.fluid.TileFluidDistribution;
/** /**
* Enum to hold info about each pipe material. Values are by default and some can change with pipe * Enumerator to hold info about each pipe material.
* upgrades.
* *
* @Note unsupportedFluids should only be used by filters. All pipes should allow all fluid types. * @author Calclavia
* 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.
*
* @author DarkGuardsman
*/ */
public enum EnumPipeMaterial public enum EnumPipeMaterial
{ {
/** Gas only pipe */ CERAMIC(5, 5, new Color(0xB3866F)), BRONZE(25, 25, new Color(0xD49568)),
GLASS("glass", true, false, false, 100, 300), PLASTIC(50, 30, new Color(0xDAF4F7)), IRON(40, 50, new Color(0x5C6362)),
/** Cheap fluid pipe */ STEEL(400, 100, new Color(0x888888)), FIBERGLASS(1000, 200, new Color(0x9F9691));
TIN("tin", false, true, false, 300, 1000),
/** Cheap fluid pipe */ public final int maxPressure;
COPPER("copper", false, true, false, 400, 1000),
/** First duel gas and fluid pipe */
IRON("iron", true, true, false, 500, 1000),
/** Fluid movement pipe that doesn't work well with pressure */
GOLD("gold", true, true, false, 200, 2000),
/** Cheap molten metal pipe */
OBSIDIAN("obsidian", false, true, true, 1000, 1000),
/** /**
* Very strong fluid and gas support pipe. Should also support molten metal as long as they * The max flow rate in liters of tick.
* don't stay in the pipe too long.
*/ */
STEEL("steel", true, true, false, 10000, 3000), public final int maxFlowRate;
/** Weaker equal to steel pipes. Should also support steam very well */ public final Color color;
BRONZE("bronze", true, true, false, 6000, 2000),
/**
* Hell fluids only. Meaning lava, and molten metals. Water should turn to steam, fuel and oil
* should cause an explosion around the pipe
*/
HELL("hell", true, true, true, 10000, 5000, "water", "fuel", "oil");
public String matName = "material";
List<String> unsupportedFluids = new ArrayList<String>();
public boolean canSupportGas = false;
public boolean canSupportFluids = false;
public boolean canSupportMoltenFluids = false;
public int maxPressure = 1000;
public int maxVolume = 2000;
/**
* Materials are stored as meta were there sub types are stored by NBT. Item versions of the
* pipes are still meta so there is a set spacing to allow for a large but defined range of sub
* pipes
*/
public static int spacing = 1000;
private EnumPipeMaterial() private EnumPipeMaterial(int maxFlowRate, int maxPressure, Color color)
{ {
this.canSupportGas = true; this.maxFlowRate = maxFlowRate;
this.canSupportFluids = true; this.maxPressure = maxPressure;
canSupportMoltenFluids = true; this.color = color;
}
private EnumPipeMaterial(String name, boolean gas, boolean fluid, boolean molten, String... strings)
{
this.matName = name;
this.canSupportGas = gas;
this.canSupportFluids = fluid;
this.canSupportMoltenFluids = molten;
}
private EnumPipeMaterial(String name, boolean gas, boolean fluid, boolean molten, int pressure, int volume, String... strings)
{
this(name, gas, fluid, molten, strings);
this.maxPressure = pressure;
this.maxVolume = volume;
}
public static EnumPipeMaterial get(World world, int x, int y, int z)
{
return get(world.getBlockMetadata(x, y, z));
}
public static EnumPipeMaterial get(int i)
{
if (i < EnumPipeMaterial.values().length)
{
return EnumPipeMaterial.values()[i];
}
return null;
}
public int getMeta(int typeID)
{
return (this.ordinal() * spacing) + typeID;
}
public int getMeta()
{
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)
{
int meta = world.getBlockMetadata(x, y, z);
TileEntity ent = world.getBlockTileEntity(x, y, z);
meta *= spacing;
if (ent instanceof TileFluidDistribution)
{
meta += ((TileFluidDistribution) ent).getSubID();
}
return meta;
}
public boolean canSupport(FluidStack fluid)
{
if (fluid != null && fluid.getFluid() != null)
{
if (fluid.getFluid().isGaseous(fluid) && this.canSupportGas)
{
return true;
}
else if (!fluid.getFluid().isGaseous(fluid) && this.canSupportFluids)
{
return true;
}
}
return false;
} }
} }

View file

@ -119,7 +119,7 @@ public class ItemBlockFluidContainer extends ItemBlock
@Override @Override
public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata) public boolean placeBlockAt(ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side, float hitX, float hitY, float hitZ, int metadata)
{ {
if (super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, (metadata / EnumPipeMaterial.spacing))) if (super.placeBlockAt(stack, player, world, x, y, z, side, hitX, hitY, hitZ, metadata))
{ {
TileEntity tile = world.getBlockTileEntity(x, y, z); TileEntity tile = world.getBlockTileEntity(x, y, z);
if (tile instanceof TileFluidDistribution) if (tile instanceof TileFluidDistribution)

View file

@ -1,5 +1,15 @@
package resonantinduction.mechanical.fluid.pipe; package resonantinduction.mechanical.fluid.pipe;
import java.util.List;
import org.lwjgl.input.Keyboard;
import resonantinduction.electrical.wire.EnumWireMaterial;
import universalelectricity.api.energy.UnitDisplay;
import universalelectricity.api.energy.UnitDisplay.Unit;
import calclavia.lib.render.EnumColor;
import calclavia.lib.utility.LanguageUtility;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.world.World; import net.minecraft.world.World;
@ -31,14 +41,34 @@ public class ItemPipe extends JItemMultiPart
{ {
return damage; return damage;
} }
/*
* @Override @Override
* public void getSubItems(int itemID, CreativeTabs tab, List listToAddTo) public String getUnlocalizedName(ItemStack itemStack)
* { {
* for (EnumPipeMaterial material : EnumPipeMaterial.values()) return super.getUnlocalizedName(itemStack) + "." + LanguageUtility.underscoreToCamel(EnumPipeMaterial.values()[itemStack.getItemDamage()].name());
* { }
* listToAddTo.add(new ItemStack(itemID, 1, material.ordinal()));
* } @Override
* } @SuppressWarnings("unchecked")
*/ public void addInformation(ItemStack itemstack, EntityPlayer player, List list, boolean par4)
{
if (!Keyboard.isKeyDown(Keyboard.KEY_LSHIFT))
{
list.add(LanguageUtility.getLocal("tooltip.noShift").replace("%0", EnumColor.AQUA.toString()).replace("%1", EnumColor.GREY.toString()));
}
else
{
list.add(EnumColor.AQUA + LanguageUtility.getLocal("tooltip.pipe.rate").replace("%v", "" + EnumColor.ORANGE + UnitDisplay.getDisplay(EnumPipeMaterial.values()[itemstack.getItemDamage()].maxFlowRate * 20, Unit.LITER) + "/s"));
list.add(EnumColor.AQUA + LanguageUtility.getLocal("tooltip.pipe.pressure").replace("%v", "" + EnumColor.ORANGE + EnumPipeMaterial.values()[itemstack.getItemDamage()].maxPressure + " Pa"));
}
}
@Override
public void getSubItems(int itemID, CreativeTabs tab, List listToAddTo)
{
for (EnumPipeMaterial material : EnumPipeMaterial.values())
{
listToAddTo.add(new ItemStack(itemID, 1, material.ordinal()));
}
}
} }

View file

@ -1,227 +0,0 @@
package resonantinduction.mechanical.fluid.pipe;
import net.minecraft.client.model.ModelBase;
import net.minecraft.client.model.ModelRenderer;
import net.minecraftforge.common.ForgeDirection;
import calclavia.lib.utility.WorldUtility;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
@SideOnly(Side.CLIENT)
public class ModelPipe extends ModelBase
{
// fields
ModelRenderer Mid;
ModelRenderer RightPipe;
ModelRenderer RightInter;
ModelRenderer RightConnect;
ModelRenderer LeftInter;
ModelRenderer LeftPipe;
ModelRenderer LeftConnect;
ModelRenderer TopInter;
ModelRenderer TopPipe;
ModelRenderer TopConnect;
ModelRenderer BottomPipe;
ModelRenderer BottomInter;
ModelRenderer BottomConnect;
ModelRenderer BackPipe;
ModelRenderer BackInter;
ModelRenderer BackConnect;
ModelRenderer FrontInter;
ModelRenderer FrontPipe;
ModelRenderer FrontConnect;
public ModelPipe()
{
textureWidth = 128;
textureHeight = 32;
Mid = new ModelRenderer(this, 50, 13);
Mid.addBox(-3F, -3F, -3F, 6, 6, 6);
Mid.setRotationPoint(0F, 16F, 0F);
Mid.setTextureSize(128, 32);
Mid.mirror = true;
setRotation(Mid, 0F, 0F, 0F);
RightPipe = new ModelRenderer(this, 25, 0);
RightPipe.addBox(0F, -3F, -3F, 4, 6, 6);
RightPipe.setRotationPoint(3F, 16F, 0F);
RightPipe.setTextureSize(128, 32);
RightPipe.mirror = true;
setRotation(RightPipe, 0F, 0F, 0F);
RightInter = new ModelRenderer(this, 98, 0);
RightInter.addBox(0F, -4F, -4F, 1, 8, 8);
RightInter.setRotationPoint(2F, 16F, 0F);
RightInter.setTextureSize(128, 32);
RightInter.mirror = true;
setRotation(RightInter, 0F, 0F, 0F);
RightConnect = new ModelRenderer(this, 98, 0);
RightConnect.addBox(0F, -4F, -4F, 1, 8, 8);
RightConnect.setRotationPoint(7F, 16F, 0F);
RightConnect.setTextureSize(128, 32);
RightConnect.mirror = true;
setRotation(RightConnect, 0F, 0F, 0F);
LeftInter = new ModelRenderer(this, 98, 0);
LeftInter.addBox(-1F, -4F, -4F, 1, 8, 8);
LeftInter.setRotationPoint(-2F, 16F, 0F);
LeftInter.setTextureSize(128, 32);
LeftInter.mirror = true;
setRotation(LeftInter, 0F, 0F, 0F);
LeftPipe = new ModelRenderer(this, 25, 0);
LeftPipe.addBox(-4F, -3F, -3F, 4, 6, 6);
LeftPipe.setRotationPoint(-3F, 16F, 0F);
LeftPipe.setTextureSize(128, 32);
LeftPipe.mirror = true;
setRotation(LeftPipe, 0F, 0F, 0F);
LeftConnect = new ModelRenderer(this, 98, 0);
LeftConnect.addBox(-1F, -4F, -4F, 1, 8, 8);
LeftConnect.setRotationPoint(-7F, 16F, 0F);
LeftConnect.setTextureSize(128, 32);
LeftConnect.mirror = true;
setRotation(LeftConnect, 0F, 0F, 0F);
TopInter = new ModelRenderer(this, 77, 17);
TopInter.addBox(-4F, -1F, -4F, 8, 1, 8);
TopInter.setRotationPoint(0F, 14F, 0F);
TopInter.setTextureSize(128, 32);
TopInter.mirror = true;
setRotation(TopInter, 0F, 0F, 0F);
TopPipe = new ModelRenderer(this, 50, 0);
TopPipe.addBox(-3F, -4F, -3F, 6, 4, 6);
TopPipe.setRotationPoint(0F, 13F, 0F);
TopPipe.setTextureSize(128, 32);
TopPipe.mirror = true;
setRotation(TopPipe, 0F, 0F, 0F);
TopConnect = new ModelRenderer(this, 77, 17);
TopConnect.addBox(-4F, -1F, -4F, 8, 1, 8);
TopConnect.setRotationPoint(0F, 9F, 0F);
TopConnect.setTextureSize(128, 32);
TopConnect.mirror = true;
setRotation(TopConnect, 0F, 0F, 0F);
BottomPipe = new ModelRenderer(this, 50, 0);
BottomPipe.addBox(-3F, 0F, -3F, 6, 4, 6);
BottomPipe.setRotationPoint(0F, 19F, 0F);
BottomPipe.setTextureSize(128, 32);
BottomPipe.mirror = true;
setRotation(BottomPipe, 0F, 0F, 0F);
BottomInter = new ModelRenderer(this, 77, 17);
BottomInter.addBox(-4F, 0F, -4F, 8, 1, 8);
BottomInter.setRotationPoint(0F, 18F, 0F);
BottomInter.setTextureSize(128, 32);
BottomInter.mirror = true;
setRotation(BottomInter, 0F, 0F, 0F);
BottomConnect = new ModelRenderer(this, 77, 17);
BottomConnect.addBox(-4F, 0F, -4F, 8, 1, 8);
BottomConnect.setRotationPoint(0F, 23F, 0F);
BottomConnect.setTextureSize(128, 32);
BottomConnect.mirror = true;
setRotation(BottomConnect, 0F, 0F, 0F);
BackPipe = new ModelRenderer(this, 0, 0);
BackPipe.addBox(-3F, -3F, 0F, 6, 6, 4);
BackPipe.setRotationPoint(0F, 16F, 3F);
BackPipe.setTextureSize(128, 32);
BackPipe.mirror = true;
setRotation(BackPipe, 0F, 0F, 0F);
BackInter = new ModelRenderer(this, 0, 23);
BackInter.addBox(-4F, -4F, 0F, 8, 8, 1);
BackInter.setRotationPoint(0F, 16F, 2F);
BackInter.setTextureSize(128, 32);
BackInter.mirror = true;
setRotation(BackInter, 0F, 0F, 0F);
BackConnect = new ModelRenderer(this, 0, 23);
BackConnect.addBox(-4F, -4F, 0F, 8, 8, 1);
BackConnect.setRotationPoint(0F, 16F, 7F);
BackConnect.setTextureSize(128, 32);
BackConnect.mirror = true;
setRotation(BackConnect, 0F, 0F, 0F);
FrontInter = new ModelRenderer(this, 0, 23);
FrontInter.addBox(-4F, -4F, -1F, 8, 8, 1);
FrontInter.setRotationPoint(0F, 16F, -2F);
FrontInter.setTextureSize(128, 32);
FrontInter.mirror = true;
setRotation(FrontInter, 0F, 0F, 0F);
FrontPipe = new ModelRenderer(this, 0, 0);
FrontPipe.addBox(-3F, -3F, -4F, 6, 6, 4);
FrontPipe.setRotationPoint(0F, 16F, -3F);
FrontPipe.setTextureSize(128, 32);
FrontPipe.mirror = true;
setRotation(FrontPipe, 0F, 0F, 0F);
FrontConnect = new ModelRenderer(this, 0, 23);
FrontConnect.addBox(-4F, -4F, -1F, 8, 8, 1);
FrontConnect.setRotationPoint(0F, 16F, -7F);
FrontConnect.setTextureSize(128, 32);
FrontConnect.mirror = true;
setRotation(FrontConnect, 0F, 0F, 0F);
}
public void render(byte side)
{
if (WorldUtility.isEnabledSide(side, ForgeDirection.DOWN))
renderBottom();
if (WorldUtility.isEnabledSide(side, ForgeDirection.UP))
renderUp();
if (WorldUtility.isEnabledSide(side, ForgeDirection.NORTH))
renderSouth();
if (WorldUtility.isEnabledSide(side, ForgeDirection.SOUTH))
renderNorth();
if (WorldUtility.isEnabledSide(side, ForgeDirection.WEST))
renderEast();
if (WorldUtility.isEnabledSide(side, ForgeDirection.EAST))
renderWest();
renderMiddle();
}
public void renderMiddle()
{
Mid.render(0.0625F);
}
public void renderBottom()
{
BottomPipe.render(0.0625F);
BottomConnect.render(0.0625F);
BottomInter.render(0.0625F);
}
public void renderUp()
{
TopPipe.render(0.0625F);
TopConnect.render(0.0625F);
TopInter.render(0.0625F);
}
public void renderEast()
{
LeftPipe.render(0.0625F);
LeftConnect.render(0.0625F);
LeftInter.render(0.0625F);
}
public void renderWest()
{
RightPipe.render(0.0625F);
RightConnect.render(0.0625F);
RightInter.render(0.0625F);
}
public void renderSouth()
{
BackPipe.render(0.0625F);
BackConnect.render(0.0625F);
BackInter.render(0.0625F);
}
public void renderNorth()
{
FrontPipe.render(0.0625F);
FrontConnect.render(0.0625F);
FrontInter.render(0.0625F);
}
private void setRotation(ModelRenderer model, float x, float y, float z)
{
model.rotateAngleX = x;
model.rotateAngleY = y;
model.rotateAngleZ = z;
}
}

View file

@ -1,6 +1,5 @@
package resonantinduction.mechanical.fluid.pipe; package resonantinduction.mechanical.fluid.pipe;
import calclavia.lib.utility.WorldUtility;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound; import net.minecraft.nbt.NBTTagCompound;
@ -13,11 +12,11 @@ import net.minecraftforge.fluids.FluidTank;
import net.minecraftforge.fluids.FluidTankInfo; import net.minecraftforge.fluids.FluidTankInfo;
import net.minecraftforge.fluids.IFluidHandler; import net.minecraftforge.fluids.IFluidHandler;
import resonantinduction.core.ResonantInduction; import resonantinduction.core.ResonantInduction;
import resonantinduction.core.grid.Node;
import resonantinduction.core.grid.fluid.IPressureNodeProvider; import resonantinduction.core.grid.fluid.IPressureNodeProvider;
import resonantinduction.core.grid.fluid.PressureNode; import resonantinduction.core.grid.fluid.PressureNode;
import resonantinduction.core.prefab.part.PartFramedNode; import resonantinduction.core.prefab.part.PartFramedNode;
import resonantinduction.mechanical.Mechanical; import resonantinduction.mechanical.Mechanical;
import calclavia.lib.utility.WorldUtility;
import codechicken.lib.data.MCDataInput; import codechicken.lib.data.MCDataInput;
import codechicken.lib.render.CCRenderState; import codechicken.lib.render.CCRenderState;
import codechicken.lib.render.IconTransformation; import codechicken.lib.render.IconTransformation;
@ -26,7 +25,6 @@ import codechicken.lib.vec.Translation;
import codechicken.microblock.IHollowConnect; import codechicken.microblock.IHollowConnect;
import codechicken.multipart.JNormalOcclusion; import codechicken.multipart.JNormalOcclusion;
import codechicken.multipart.TSlottedPart; import codechicken.multipart.TSlottedPart;
import codechicken.multipart.TileMultipart;
import cpw.mods.fml.relauncher.Side; import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly; import cpw.mods.fml.relauncher.SideOnly;
@ -92,21 +90,24 @@ public class PartPipe extends PartFramedNode<EnumPipeMaterial, PressureNode, IPr
@Override @Override
public boolean canConnect(ForgeDirection from, Object source) public boolean canConnect(ForgeDirection from, Object source)
{ {
if (source instanceof PressureNode)
{
PressureNode otherNode = (PressureNode) source;
if (otherNode.parent instanceof PartPipe)
{
PartPipe otherPipe = (PartPipe) otherNode.parent;
if (getMaterial() == otherPipe.getMaterial())
{
return getColor() == otherPipe.getColor() || (getColor() == DEFAULT_COLOR || otherPipe.getColor() == DEFAULT_COLOR);
}
return false;
}
}
return super.canConnect(from, source); return super.canConnect(from, source);
/*
* Object obj = tile instanceof TileMultipart ? ((TileMultipart)
* tile).partMap(ForgeDirection.UNKNOWN.ordinal()) : tile;
* if (obj instanceof PartPipe)
* {
* if (this.getMaterial() == ((PartPipe) obj).getMaterial())
* {
* return getColor() == ((PartPipe) obj).getColor() || (getColor() == DEFAULT_COLOR
* || ((PartPipe) obj).getColor() == DEFAULT_COLOR);
* }
* return false;
* }
* return tile instanceof IFluidHandler;
*/
} }
@Override @Override
@ -115,11 +116,14 @@ public class PartPipe extends PartFramedNode<EnumPipeMaterial, PressureNode, IPr
return 100; return 100;
} }
}; };
node.maxFlowRate = getMaterial().maxFlowRate;
node.maxPressure = getMaterial().maxPressure;
} }
public PartPipe() public PartPipe()
{ {
this(EnumPipeMaterial.COPPER.ordinal()); this(0);
} }
@Override @Override
@ -177,7 +181,7 @@ public class PartPipe extends PartFramedNode<EnumPipeMaterial, PressureNode, IPr
@Override @Override
protected ItemStack getItem() protected ItemStack getItem()
{ {
return new ItemStack(Mechanical.itemPipe); return new ItemStack(Mechanical.itemPipe, 1, getMaterialID());
} }
@Override @Override
@ -264,5 +268,7 @@ public class PartPipe extends PartFramedNode<EnumPipeMaterial, PressureNode, IPr
{ {
super.load(nbt); super.load(nbt);
tank.readFromNBT(nbt); tank.readFromNBT(nbt);
node.maxFlowRate = getMaterial().maxFlowRate;
node.maxPressure = getMaterial().maxPressure;
} }
} }

View file

@ -5,13 +5,13 @@ import java.awt.Color;
import net.minecraft.item.ItemDye; import net.minecraft.item.ItemDye;
import net.minecraft.item.ItemStack; import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation; import net.minecraft.util.ResourceLocation;
import net.minecraftforge.client.model.AdvancedModelLoader;
import net.minecraftforge.client.model.IModelCustom;
import net.minecraftforge.common.ForgeDirection; import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.fluids.FluidStack; import net.minecraftforge.fluids.FluidStack;
import org.lwjgl.opengl.GL11; import org.lwjgl.opengl.GL11;
import codechicken.lib.colour.Colour;
import codechicken.lib.colour.ColourARGB;
import resonantinduction.core.Reference; import resonantinduction.core.Reference;
import calclavia.lib.render.FluidRenderUtility; import calclavia.lib.render.FluidRenderUtility;
import calclavia.lib.render.RenderUtility; import calclavia.lib.render.RenderUtility;
@ -25,26 +25,14 @@ public class RenderPipe implements ISimpleItemRenderer
{ {
public static final RenderPipe INSTANCE = new RenderPipe(); public static final RenderPipe INSTANCE = new RenderPipe();
public static ModelPipe MODEL_PIPE = new ModelPipe(); public static final IModelCustom MODEL = AdvancedModelLoader.loadModel(Reference.MODEL_DIRECTORY + "pipe.tcn");
public static ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "pipe.png"); public static ResourceLocation TEXTURE = new ResourceLocation(Reference.DOMAIN, Reference.MODEL_PATH + "pipe.png");
public void render(PartPipe part, double x, double y, double z, float f) public void render(PartPipe part, double x, double y, double z, float f)
{ {
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F); GL11.glTranslated(x + 0.5, y + 0.5, z + 0.5);
GL11.glScalef(1.0F, -1F, -1F); render(part.getMaterialID(), part.getColor() > 0 ? ItemDye.dyeColors[part.getColor()] : -1, part.getAllCurrentConnections());
if (part.getColor() > 0)
{
Color insulationColour = new Color(ItemDye.dyeColors[part.getColor()]);
GL11.glColor4f(insulationColour.getRed() / 255f, insulationColour.getGreen() / 255f, insulationColour.getBlue() / 255f, 1);
}
else
{
GL11.glColor4f(1, 1, 1, 1);
}
render(0, part.getAllCurrentConnections());
GL11.glPopMatrix(); GL11.glPopMatrix();
GL11.glPushMatrix(); GL11.glPushMatrix();
@ -121,11 +109,60 @@ public class RenderPipe implements ISimpleItemRenderer
} }
public static void render(int meta, byte sides) @SuppressWarnings("incomplete-switch")
public static void render(int meta, int colorCode, byte sides)
{ {
RenderUtility.enableBlending(); RenderUtility.enableBlending();
RenderUtility.bind(TEXTURE); RenderUtility.bind(TEXTURE);
MODEL_PIPE.render(sides); EnumPipeMaterial material = EnumPipeMaterial.values()[meta];
GL11.glColor4f(material.color.getRed() / 255f, material.color.getGreen() / 255f, material.color.getBlue() / 255f, 1);
MODEL.renderOnly("Mid");
/**
* Render each side
*/
for (ForgeDirection dir : ForgeDirection.VALID_DIRECTIONS)
{
if (WorldUtility.isEnabledSide(sides, dir))
{
GL11.glColor4f(material.color.getRed() / 255f, material.color.getGreen() / 255f, material.color.getBlue() / 255f, 1);
String prefix = null;
switch (dir)
{
case DOWN:
prefix = "Bottom";
break;
case UP:
prefix = "Top";
break;
case NORTH:
prefix = "Front";
break;
case SOUTH:
prefix = "Back";
break;
case WEST:
prefix = "Right";
break;
case EAST:
prefix = "Left";
break;
}
MODEL.renderOnly(prefix + "Inter", prefix + "Connect");
if (colorCode > 0)
{
Color color = new Color(colorCode);
GL11.glColor4f(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f, 1);
}
MODEL.renderOnly(prefix + "Pipe");
}
}
RenderUtility.disableBlending(); RenderUtility.disableBlending();
} }
@ -133,9 +170,8 @@ public class RenderPipe implements ISimpleItemRenderer
public void renderInventoryItem(ItemStack itemStack) public void renderInventoryItem(ItemStack itemStack)
{ {
GL11.glPushMatrix(); GL11.glPushMatrix();
GL11.glTranslatef(0.5F, 1.5F, 0.5F); GL11.glTranslatef(0.5f, 0.5f, 0.5f);
GL11.glScalef(1.0F, -1F, -1F); render(itemStack.getItemDamage(), -1, Byte.parseByte("001100", 2));
render(itemStack.getItemDamage(), Byte.parseByte("001100", 2));
GL11.glPopMatrix(); GL11.glPopMatrix();
} }
} }

View file

@ -95,6 +95,13 @@ public abstract class Node<P extends INodeProvider, G extends Grid, N>
return connections; return connections;
} }
/**
* Can this node connect with the source?
*
* @param from - Direction coming from.
* @param source - Object trying to connect with this node. This should either extend Node or be
* an object that can interface with the node.
*/
public boolean canConnect(ForgeDirection from, Object source) public boolean canConnect(ForgeDirection from, Object source)
{ {
return false; return false;

View file

@ -18,7 +18,9 @@ import codechicken.multipart.TMultiPart;
public class PressureNode extends Node<IPressureNodeProvider, TickingGrid, Object> public class PressureNode extends Node<IPressureNodeProvider, TickingGrid, Object>
{ {
protected byte connectionMap = Byte.parseByte("111111", 2); protected byte connectionMap = Byte.parseByte("111111", 2);
public int pressure = 0; private int pressure = 0;
public int maxFlowRate = 10;
public int maxPressure = 10;
public PressureNode(IPressureNodeProvider parent) public PressureNode(IPressureNodeProvider parent)
{ {
@ -65,7 +67,7 @@ public class PressureNode extends Node<IPressureNodeProvider, TickingGrid, Objec
if (findCount == 0) if (findCount == 0)
{ {
pressure = 0; setPressure(0);
} }
else else
{ {
@ -77,7 +79,7 @@ public class PressureNode extends Node<IPressureNodeProvider, TickingGrid, Objec
if (maxPressure > 0) if (maxPressure > 0)
maxPressure -= 1; maxPressure -= 1;
pressure = Math.max(minPressure, Math.min(maxPressure, totalPressure / findCount + Integer.signum(totalPressure))); setPressure(Math.max(minPressure, Math.min(maxPressure, totalPressure / findCount + Integer.signum(totalPressure))));
} }
} }
@ -172,7 +174,15 @@ public class PressureNode extends Node<IPressureNodeProvider, TickingGrid, Objec
public int getMaxFlowRate() public int getMaxFlowRate()
{ {
return 10; return maxFlowRate;
}
public void setPressure(int newPressure)
{
if (newPressure > 0)
pressure = Math.min(maxPressure, newPressure);
else
pressure = Math.max(-maxPressure, newPressure);
} }
public int getPressure(ForgeDirection dir) public int getPressure(ForgeDirection dir)
@ -216,6 +226,7 @@ public class PressureNode extends Node<IPressureNodeProvider, TickingGrid, Objec
return parent instanceof TMultiPart ? new Vector3(((TMultiPart) parent).x(), ((TMultiPart) parent).y(), ((TMultiPart) parent).z()) : parent instanceof TileEntity ? new Vector3((TileEntity) parent) : null; return parent instanceof TMultiPart ? new Vector3(((TMultiPart) parent).x(), ((TMultiPart) parent).y(), ((TMultiPart) parent).z()) : parent instanceof TileEntity ? new Vector3((TileEntity) parent) : null;
} }
@Override
public boolean canConnect(ForgeDirection from, Object source) public boolean canConnect(ForgeDirection from, Object source)
{ {
return (source instanceof PressureNode) && (connectionMap & (1 << from.ordinal())) != 0; return (source instanceof PressureNode) && (connectionMap & (1 << from.ordinal())) != 0;

View file

@ -7,6 +7,7 @@ import java.util.Set;
import net.minecraft.client.particle.EffectRenderer; import net.minecraft.client.particle.EffectRenderer;
import net.minecraft.client.renderer.RenderBlocks; import net.minecraft.client.renderer.RenderBlocks;
import net.minecraft.entity.player.EntityPlayer; import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.tileentity.TileEntity; import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.Icon; import net.minecraft.util.Icon;
import net.minecraft.util.MovingObjectPosition; import net.minecraft.util.MovingObjectPosition;
@ -287,4 +288,18 @@ public abstract class PartFramedNode<M extends Enum, N extends Node, T extends I
return (N) node; return (N) node;
return null; return null;
} }
@Override
public void save(NBTTagCompound nbt)
{
super.save(nbt);
node.save(nbt);
}
@Override
public void load(NBTTagCompound nbt)
{
super.load(nbt);
node.load(nbt);
}
} }

View file

@ -62,8 +62,6 @@ tile.resonantinduction\:turntable.name=Turntable
tile.resonantinduction\:crate.0.name=Wooden Crate tile.resonantinduction\:crate.0.name=Wooden Crate
tile.resonantinduction\:crate.1.name=Iron Crate tile.resonantinduction\:crate.1.name=Iron Crate
tile.resonantinduction\:crate.2.name=Steel Crate tile.resonantinduction\:crate.2.name=Steel Crate
tile.resonantinduction\:fluidPipe.0.name=Wood Trough
tile.resonantinduction\:fluidPipe.1.name=Stone Trough
### Mechanical Module ### Mechanical Module
## Energy ## Energy
@ -87,8 +85,12 @@ tile.resonantinduction\:waterTurbine.2.name=Metal Water Turbine
tile.resonantinduction\:waterTurbine.2.tooltip=The metal water turbine is strong and agile. tile.resonantinduction\:waterTurbine.2.tooltip=The metal water turbine is strong and agile.
## Transport ## Transport
tile.resonantinduction\:releaseValve.name=Release Valve item.resonantinduction\:pipe.ceramic.name=Ceramic Pipe
tile.resonantinduction\:fluidPipe.name=Pipe item.resonantinduction\:pipe.bronze.name=Bronze Pipe
item.resonantinduction\:pipe.plastic.name=Plastic Pipe
item.resonantinduction\:pipe.iron.name=Iron Pipe
item.resonantinduction\:pipe.steel.name=Steel Pipe
item.resonantinduction\:pipe.fiberglass.name=Fiberglass Pipe
tile.resonantinduction\:pump.name=Pump tile.resonantinduction\:pump.name=Pump
tile.resonantinduction\:grate.name=Grate tile.resonantinduction\:grate.name=Grate
tile.resonantinduction\:conveyorBelt.name=Conveyor Belt tile.resonantinduction\:conveyorBelt.name=Conveyor Belt
@ -100,24 +102,6 @@ tile.resonantinduction\:manipulator.name=Manipulator
tile.resonantinduction\:rejector.name=Rejector tile.resonantinduction\:rejector.name=Rejector
tile.resonantinduction\:sorter.name=Sorter tile.resonantinduction\:sorter.name=Sorter
# Fluid pipes
item.resonantinduction\:pipeGauge.name=Pipe Gauge
item.resonantinduction\:pipe.name=Pipe
tile.resonantinduction\:fluidPipe.3.name=Green Wood Trough
tile.resonantinduction\:fluidPipe.4.name=Brown Wood Trough
tile.resonantinduction\:fluidPipe.5.name=Blue Wood Trough
tile.resonantinduction\:fluidPipe.6.name=Purple Wood Trough
tile.resonantinduction\:fluidPipe.7.name=Cyan Wood Trough
tile.resonantinduction\:fluidPipe.8.name=Silver Wood Trough
tile.resonantinduction\:fluidPipe.9.name=Grey Wood Trough
tile.resonantinduction\:fluidPipe.10.name=Pink Wood Trough
tile.resonantinduction\:fluidPipe.11.name=Lime Wood Trough
tile.resonantinduction\:fluidPipe.12.name=Yellow Wood Trough
tile.resonantinduction\:fluidPipe.13.name=Light Blue Wood Trough
tile.resonantinduction\:fluidPipe.14.name=Magenta Wood Trough
tile.resonantinduction\:fluidPipe.15.name=Orange Wood Trough
tile.resonantinduction\:fluidPipe.16.name=White Wood Trough
## Machines and Processing ## Machines and Processing
tile.resonantinduction\:mixer.name=Mixer tile.resonantinduction\:mixer.name=Mixer
tile.resonantinduction\:mixer.tooltip=The mixer mixes dusts with water to wash and refine the ore dust. Mixer prefers more angular velocity (spin) to process dusts. tile.resonantinduction\:mixer.tooltip=The mixer mixes dusts with water to wash and refine the ore dust. Mixer prefers more angular velocity (spin) to process dusts.
@ -168,8 +152,9 @@ tile.resonantinduction\:glyph.2.name=Trigon Glyph
tile.resonantinduction\:glyph.3.name=Tetragon Glyph tile.resonantinduction\:glyph.3.name=Tetragon Glyph
## Tool-tips ## Tool-tips
tooltip.transformer.stepUp=Step Up tooltip.pipe.rate=Flow Rate: %v
tooltip.transformer.stepDown=Step Down tooltip.pipe.pressure=Max Pressure: %v
tooltip.wire.resistance=Resistance: %v tooltip.wire.resistance=Resistance: %v
tooltip.wire.current=Current: %v tooltip.wire.current=Current: %v
tooltip.wire.damage=Damage: %v tooltip.wire.damage=Damage: %v

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB