Started work on fixing up pipes
As well changing and broading the range of support pipes
This commit is contained in:
parent
dff9f952fa
commit
85e57658d6
2 changed files with 135 additions and 140 deletions
|
@ -4,14 +4,13 @@ import net.minecraft.block.Block;
|
|||
import net.minecraft.item.Item;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraftforge.oredict.ShapedOreRecipe;
|
||||
import net.minecraftforge.oredict.ShapelessOreRecipe;
|
||||
import cpw.mods.fml.common.registry.GameRegistry;
|
||||
import dark.api.ColorCode;
|
||||
import dark.core.common.CoreRecipeLoader;
|
||||
import dark.core.common.RecipeLoader;
|
||||
import dark.core.common.items.EnumMaterial;
|
||||
import dark.core.common.items.EnumOrePart;
|
||||
import dark.core.common.items.ItemParts.Parts;
|
||||
import dark.fluid.common.pipes.BlockPipe.PipeData;
|
||||
import dark.fluid.common.pipes.BlockPipe.PipeMaterial;
|
||||
|
||||
public class FMRecipeLoader extends RecipeLoader
|
||||
{
|
||||
|
@ -36,22 +35,14 @@ public class FMRecipeLoader extends RecipeLoader
|
|||
@Override
|
||||
public void loadRecipes()
|
||||
{
|
||||
for (PipeData data : PipeData.values())
|
||||
{
|
||||
data.itemStack = new ItemStack(blockPipe.blockID, 1, data.ordinal());
|
||||
}
|
||||
super.loadRecipes();
|
||||
this.registerPipes();
|
||||
this.registerTanks();
|
||||
|
||||
// generator
|
||||
//GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(FMRecipeLoader.blockGenerator, 1), new Object[] { "@T@", "OVO", "@T@", 'T', new ItemStack(blockRod, 1), '@', "plateSteel", 'O', "basicCircuit", 'V', "motor" }));
|
||||
// mechanical rod
|
||||
//GameRegistry.addRecipe(new ItemStack(blockRod, 1), new Object[] { "I@I", 'I', Item.ingotIron, '@', new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.Iron.ordinal()) });
|
||||
|
||||
// pump
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockPumpMachine, 1, 0), new Object[] { "C@C", "BMB", "@X@", '@', "plateSteel", 'X', new ItemStack(blockPipe, 1), 'B', new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.Valve.ordinal()), 'C', "basicCircuit", 'M', "motor" }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockPumpMachine, 1, 0), new Object[] { "C@C", "BMB", "@X@", '@', steelPlate, 'X', new ItemStack(blockPipe, 1), 'B', new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.Valve.ordinal()), 'C', circuit, 'M', "motor" }));
|
||||
// construction pump
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockConPump, 1, 0), new Object[] { "@C@", "BMB", "@@@", '@', "plateSteel", 'B', new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.Valve.ordinal()), 'C', "advancedCircuit", 'M', "motor" }));
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(new ItemStack(blockConPump, 1, 0), new Object[] { "@C@", "BMB", "@@@", '@', steelPlate, 'B', new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.Valve.ordinal()), 'C', "advancedCircuit", 'M', "motor" }));
|
||||
// Drain
|
||||
GameRegistry.addRecipe(new ItemStack(blockDrain, 1, 0), new Object[] { "IGI", "SVS", " P ", 'I', Item.ingotIron, 'G', Block.dispenser, 'S', Block.stone, 'P', new ItemStack(blockPipe, 1), 'V', new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.Valve.ordinal()) });
|
||||
|
||||
|
@ -63,40 +54,40 @@ public class FMRecipeLoader extends RecipeLoader
|
|||
|
||||
public void registerTanks()
|
||||
{
|
||||
// lava tank
|
||||
new RecipeGrid(new ItemStack(blockTank, 4, ColorCode.RED.ordinal())).setRowOne(Block.netherrack, Block.obsidian, Block.netherrack).setRowTwo(Block.obsidian, null, Block.obsidian).setRowThree(Block.netherrack, Block.obsidian, Block.netherrack).RegisterRecipe();
|
||||
// water tank
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(blockTank, 1, ColorCode.BLUE.ordinal()), new Object[] { new ItemStack(blockTank, 4, 15), new ItemStack(Item.dyePowder, 1, ColorCode.BLUE.ordinal()) });
|
||||
// milk tank
|
||||
new RecipeGrid(new ItemStack(blockTank, 4, ColorCode.WHITE.ordinal())).setRowOne(Block.planks, Block.glass, Block.planks).setRowTwo(Block.glass, null, Block.glass).setRowThree(Block.planks, Block.glass, Block.planks).RegisterRecipe();
|
||||
// generic Tank
|
||||
new RecipeGrid(new ItemStack(blockTank, 4, 15)).setRowOne(Item.ingotIron, Block.glass, Item.ingotIron).setRowTwo(Block.glass, null, Block.glass).setRowThree(Item.ingotIron, Block.glass, Item.ingotIron).RegisterRecipe();
|
||||
GameRegistry.addRecipe(new ItemStack(blockPumpMachine, 1, 0), new Object[] { "IXI", "X X", "IXI", 'I', Item.ingotIron, 'X', Block.glass });
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public void registerPipes()
|
||||
{
|
||||
// Iron Pipe
|
||||
GameRegistry.addShapelessRecipe(PipeData.IRON_PIPE.itemStack, new Object[] { EnumMaterial.getStack(EnumMaterial.IRON, EnumOrePart.TUBE, 1), CoreRecipeLoader.leatherSeal });
|
||||
// Lava Tube
|
||||
new RecipeGrid(new ItemStack(blockPipe, 1, ColorCode.RED.ordinal()), 3, 1).setRowOne(Block.netherrack, EnumMaterial.getStack(EnumMaterial.OBBY, EnumOrePart.TUBE, 1), Block.netherrack).RegisterRecipe();
|
||||
// fuel pipe
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(blockPipe, 4, ColorCode.YELLOW.ordinal()), new Object[] { PipeData.YELLOW_PIPE.itemStack, PipeData.YELLOW_PIPE.itemStack, PipeData.YELLOW_PIPE.itemStack, PipeData.YELLOW_PIPE.itemStack, new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.SlimeSeal.ordinal()) });
|
||||
|
||||
// oil pipe
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(blockPipe, 4, ColorCode.BLACK.ordinal()), new Object[] { PipeData.BLACK_PIPE.itemStack, PipeData.BLACK_PIPE.itemStack, PipeData.BLACK_PIPE.itemStack, PipeData.BLACK_PIPE.itemStack, new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.SlimeSeal.ordinal()) });
|
||||
|
||||
// water pipe
|
||||
GameRegistry.addShapelessRecipe(new ItemStack(blockPipe, 4, ColorCode.BLUE.ordinal()), new Object[] { PipeData.BLUE_PIPE.itemStack, PipeData.BLUE_PIPE.itemStack, PipeData.BLUE_PIPE.itemStack, PipeData.BLUE_PIPE.itemStack, new ItemStack(CoreRecipeLoader.itemParts, 1, Parts.SlimeSeal.ordinal()) });
|
||||
|
||||
// bronze pipes
|
||||
//GameRegistry.addShapelessRecipe(PipeData., new Object[] { CoreRecipeLoader.bronzeTube, CoreRecipeLoader.slimeSeal });
|
||||
// generic pipe crafting
|
||||
for (int pipeMeta = 0; pipeMeta < 15; pipeMeta++)
|
||||
for (PipeMaterial mat : PipeMaterial.values())
|
||||
{
|
||||
new RecipeGrid(new ItemStack(blockPipe, 4, pipeMeta)).setRowOne(null, blockPipe, null).setRowTwo(blockPipe, new ItemStack(Item.dyePowder, 1, pipeMeta), blockPipe).setRowOne(null, blockPipe, null).RegisterRecipe();
|
||||
if (mat.canSupportFluids && !mat.canSupportGas && !mat.canSupportMoltenFluids)
|
||||
{
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(mat.getStack(2), new Object[] { mat.matName + "tube", "LetherSeal" }));
|
||||
}
|
||||
else if (mat.canSupportGas)
|
||||
{
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(mat.getStack(2), new Object[] { mat.matName + "tube", "GasSeal" }));
|
||||
}
|
||||
else if (mat.canSupportMoltenFluids)
|
||||
{
|
||||
if (mat == PipeMaterial.OBBY)
|
||||
{
|
||||
GameRegistry.addRecipe(new ShapelessOreRecipe(mat.getStack(2), new Object[] { mat.matName + "tube", Block.netherBrick, Block.netherBrick }));
|
||||
}
|
||||
if (mat == PipeMaterial.HELL)
|
||||
{
|
||||
GameRegistry.addRecipe(new ShapedOreRecipe(mat.getStack(4), new Object[] { "OOO", "BNB", "OOO", 'N', Block.netherBrick, 'B', Item.blazeRod, 'O', Block.obsidian }));
|
||||
}
|
||||
}
|
||||
for (ColorCode color : ColorCode.values())
|
||||
{
|
||||
GameRegistry.addRecipe(mat.getStack(color), new Object[] { " X ", "XIX", " X ", 'I', new ItemStack(Item.dyePowder, 1, color.ordinal()), 'X', blockPipe });
|
||||
new RecipeGrid(mat.getStack(), 1, 1).setRowOne(mat.getStack(color)).RegisterRecipe();
|
||||
}
|
||||
|
||||
}
|
||||
new RecipeGrid(PipeData.IRON_PIPE.itemStack, 1, 1).setRowOne(blockPipe).RegisterRecipe();
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package dark.fluid.common.pipes;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
|
@ -22,6 +23,7 @@ import dark.api.ColorCode;
|
|||
import dark.api.ColorCode.IColorCoded;
|
||||
import dark.core.prefab.helpers.FluidHelper;
|
||||
import dark.fluid.common.BlockFM;
|
||||
import dark.fluid.common.FMRecipeLoader;
|
||||
|
||||
public class BlockPipe extends BlockFM
|
||||
{
|
||||
|
@ -44,7 +46,6 @@ public class BlockPipe extends BlockFM
|
|||
}
|
||||
|
||||
@Override
|
||||
@SideOnly(Side.CLIENT)
|
||||
public boolean renderAsNormalBlock()
|
||||
{
|
||||
return false;
|
||||
|
@ -66,31 +67,15 @@ public class BlockPipe extends BlockFM
|
|||
@Override
|
||||
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
TileEntity tile = world.getBlockTileEntity(x, y, z);
|
||||
if (tile instanceof TileEntityPipe)
|
||||
{
|
||||
meta = ((TileEntityPipe) tile).pipeData.ordinal();
|
||||
}
|
||||
|
||||
return new ItemStack(blockID, 1, meta & 32);
|
||||
return PipeMaterial.getDropItem(world, x, y, z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void getSubBlocks(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
||||
{
|
||||
for (PipeData data : PipeData.values())
|
||||
for (PipeMaterial data : PipeMaterial.values())
|
||||
{
|
||||
if (data.restrictedCode != null)
|
||||
{
|
||||
data.enabled = FluidHelper.hasRestrictedStack(data.restrictedCode.ordinal());
|
||||
}
|
||||
if (data.enabled)
|
||||
{
|
||||
data.itemStack = new ItemStack(par1, 1, data.ordinal());
|
||||
par3List.add(data.itemStack);
|
||||
|
||||
}
|
||||
par3List.add(data.getStack());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -150,92 +135,111 @@ public class BlockPipe extends BlockFM
|
|||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dropBlockAsItemWithChance(World par1World, int par2, int par3, int par4, int par5, float par6, int par7)
|
||||
/** Enum to hold info about each pipe material. Values are by default and some can change with
|
||||
* pipe upgrades.
|
||||
*
|
||||
* @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 the pipe to leak. No molten support should cause the pipe to take damage.
|
||||
*
|
||||
* @author DarkGuardsman */
|
||||
public static enum PipeMaterial
|
||||
{
|
||||
if (!par1World.isRemote)
|
||||
/** Simple water only pipe. Should render open toped when it can */
|
||||
WOOD("wood", false, true, false, 50, 200),
|
||||
/** Gas only pipe */
|
||||
GLASS("wood", true, false, false, 100, 300),
|
||||
/** Another version of the wooden pipe */
|
||||
STONE("wood", false, true, false, 200, 1000),
|
||||
/** Cheap fluid pipe */
|
||||
TIN("wood", false, true, false, 300, 1000),
|
||||
/** Cheap fluid pipe */
|
||||
COPPER("wood", false, true, false, 400, 1000),
|
||||
/** First duel gas and fluid pipe */
|
||||
IRON("wood", true, true, false, 500, 1000),
|
||||
/** Fluid movement pipe that doesn't work well with pressure */
|
||||
GOLD("wood", true, true, false, 200, 2000),
|
||||
/** Cheap molten metal pipe */
|
||||
OBBY("wood", false, true, true, 1000, 1000),
|
||||
/** Very strong fluid and gas support pipe. Should also support molten metal as long as they
|
||||
* don't stay in the pipe too long. */
|
||||
STEEL("wood", true, true, false, 10000, 3000),
|
||||
/** Weaker equal to steel pipes. Should also support steam very well */
|
||||
BRONZE("wood", 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("wood", true, true, true, 10000, 5000, "water", "fuel", "oil");
|
||||
public String matName = "material";
|
||||
List<String> unsupportedFluids = new ArrayList<String>();
|
||||
public boolean supportsAllFluids = false;
|
||||
public boolean supportsAllGas = false;
|
||||
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 PipeMaterial()
|
||||
{
|
||||
if (par1World.rand.nextFloat() <= par6)
|
||||
supportsAllFluids = true;
|
||||
supportsAllGas = true;
|
||||
canSupportMoltenFluids = true;
|
||||
}
|
||||
|
||||
private PipeMaterial(String name, boolean gas, boolean fluid, boolean molten, String... strings)
|
||||
{
|
||||
this.matName = name;
|
||||
this.canSupportGas = gas;
|
||||
this.canSupportFluids = fluid;
|
||||
this.canSupportMoltenFluids = molten;
|
||||
}
|
||||
|
||||
private PipeMaterial(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 ItemStack getStack()
|
||||
{
|
||||
return getStack(1);
|
||||
}
|
||||
|
||||
public ItemStack getStack(ColorCode color)
|
||||
{
|
||||
return getStack(1, color);
|
||||
}
|
||||
|
||||
public ItemStack getStack(int s)
|
||||
{
|
||||
return new ItemStack(FMRecipeLoader.blockPipe, s, (this.ordinal() * spacing));
|
||||
}
|
||||
|
||||
public ItemStack getStack(int s, ColorCode color)
|
||||
{
|
||||
return new ItemStack(FMRecipeLoader.blockPipe, s, (this.ordinal() * spacing) + color.ordinal());
|
||||
}
|
||||
|
||||
public static ItemStack getDropItem(World world, int x, int y, int z)
|
||||
{
|
||||
int meta = world.getBlockMetadata(x, y, z);
|
||||
TileEntity ent = world.getBlockTileEntity(x, y, z);
|
||||
if (ent instanceof IColorCoded)
|
||||
{
|
||||
int meta = 0;
|
||||
TileEntity tile = par1World.getBlockTileEntity(par2, par3, par4);
|
||||
if (tile instanceof TileEntityPipe)
|
||||
{
|
||||
this.dropBlockAsItem_do(par1World, par2, par3, par4, ((TileEntityPipe) tile).pipeData.itemStack);
|
||||
return;
|
||||
}
|
||||
this.dropBlockAsItem_do(par1World, par2, par3, par4, new ItemStack(this.blockID, 1, meta));
|
||||
meta += ((IColorCoded) ent).getColor().ordinal();
|
||||
}
|
||||
return new ItemStack(FMRecipeLoader.blockPipe, 1, meta);
|
||||
}
|
||||
}
|
||||
|
||||
public static enum PipeData
|
||||
public static enum PipeSubType
|
||||
{
|
||||
BLACK_PIPE(ColorCode.BLACK),
|
||||
RED_PIPE(ColorCode.RED),
|
||||
GREEN_PIPE(ColorCode.GREEN),
|
||||
BROWN_PIPE(ColorCode.BROWN),
|
||||
BLUE_PIPE(ColorCode.BLUE),
|
||||
PURPLE_PIPE(ColorCode.PURPLE),
|
||||
CYAN_PIPE(ColorCode.CYAN),
|
||||
SILVER_PIPE(ColorCode.SILVER),
|
||||
GREY_PIPE(ColorCode.GREY),
|
||||
PINK_PIPE(ColorCode.PINK),
|
||||
LIME_PIPE(ColorCode.LIME),
|
||||
YELLOW_PIPE(ColorCode.YELLOW),
|
||||
LIGHTBLUE_PIPE(ColorCode.LIGHTBLUE),
|
||||
MAGENTA_PIPE(ColorCode.MAGENTA),
|
||||
ORANGE_PIPE(ColorCode.ORANGE),
|
||||
WHITE_PIPE(ColorCode.WHITE),
|
||||
OIL_PIPE(true, ColorCode.BLACK),
|
||||
FUEL_PIPE(true, ColorCode.YELLOW),
|
||||
LAVA_PIPE(true, ColorCode.RED),
|
||||
WATER_PIPE(true, ColorCode.BLUE),
|
||||
WASTE_PIPE(true, ColorCode.BROWN),
|
||||
PIPE6(false),
|
||||
PIPE7(false),
|
||||
PIPE8(false),
|
||||
PIPE9(false),
|
||||
PIPE10(false),
|
||||
PIPE11(false),
|
||||
PIPE12(false),
|
||||
PIPE13(false),
|
||||
PIPE14(false),
|
||||
IRON_PIPE();
|
||||
|
||||
public boolean enabled = true;
|
||||
public ColorCode colorCode, restrictedCode;
|
||||
public ItemStack itemStack;
|
||||
|
||||
private PipeData(ColorCode color)
|
||||
{
|
||||
this.colorCode = color;
|
||||
}
|
||||
|
||||
private PipeData()
|
||||
{
|
||||
this(ColorCode.UNKOWN);
|
||||
}
|
||||
|
||||
private PipeData(Boolean enabled)
|
||||
{
|
||||
this(ColorCode.UNKOWN);
|
||||
this.enabled = true;
|
||||
}
|
||||
|
||||
private PipeData(Boolean enabled, ColorCode restrictedCode)
|
||||
{
|
||||
this(enabled);
|
||||
this.restrictedCode = restrictedCode;
|
||||
}
|
||||
|
||||
public static PipeData get(Object obj)
|
||||
{
|
||||
if (obj instanceof Integer && ((Integer) obj) < PipeData.values().length)
|
||||
{
|
||||
return PipeData.values()[((Integer) obj)];
|
||||
}
|
||||
return IRON_PIPE;
|
||||
}
|
||||
//TODO list sub types then create an enum interface to have each sub handle its own metadata
|
||||
COLOR();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue