Recipes,Names, and Liquid tank fixes

Fixed: the pipes having the same name as eValves
Fixed: Liquid tank trading system
Fixed: Tank being full and not filling next tank
Fixed: empty version of things showing up for Liquid type default
Added: eValve recipes
CleanedUP: Recipes, and convered most # to enum data to make things
easier to read
This commit is contained in:
Rseifert 2012-12-23 04:26:36 -05:00
parent c93aa22dfe
commit b9b23fc63f
6 changed files with 178 additions and 120 deletions

View file

@ -29,6 +29,7 @@ import cpw.mods.fml.common.registry.GameRegistry;
import cpw.mods.fml.common.registry.LanguageRegistry;
import dark.BasicUtilities.Items.ItemGuage;
import dark.BasicUtilities.Items.ItemParts;
import dark.BasicUtilities.Items.ItemParts.basicParts;
import dark.BasicUtilities.Liquids.BlockOilFlowing;
import dark.BasicUtilities.Liquids.BlockOilStill;
import dark.BasicUtilities.Liquids.BlockSteam;
@ -93,7 +94,9 @@ public class BasicUtilitiesMain extends DummyModContainer
public static Item parts = new ItemParts(UniversalElectricity.CONFIGURATION.getItem("Parts", ITEM_ID_PREFIX).getInt());
public static Item itemPipes = new ItemPipe(UniversalElectricity.CONFIGURATION.getItem("PipeItem", ITEM_ID_PREFIX + 1).getInt());
//public static Item itemEValve = new ItemEValve(UniversalElectricity.CONFIGURATION.getItem("EValveItem", ITEM_ID_PREFIX + 2).getInt());
// public static Item itemEValve = new
// ItemEValve(UniversalElectricity.CONFIGURATION.getItem("EValveItem",
// ITEM_ID_PREFIX + 2).getInt());
public static Item gauge = new ItemGuage(UniversalElectricity.CONFIGURATION.getItem("PipeGuage", ITEM_ID_PREFIX + 3).getInt());
public static Item itemOilBucket = new ItemOilBucket(UniversalElectricity.CONFIGURATION.getItem("Oil Bucket", ITEM_ID_PREFIX + 4).getInt(), 4);
@ -110,7 +113,7 @@ public class BasicUtilitiesMain extends DummyModContainer
instance = this;
proxy.preInit();
GameRegistry.registerBlock(pipe, "multi pipe");
GameRegistry.registerBlock(eValve,ItemEValve.class, "eValve");
GameRegistry.registerBlock(eValve, ItemEValve.class, "eValve");
GameRegistry.registerBlock(rod, "mech rod");
GameRegistry.registerBlock(generator, "EU Generator");
GameRegistry.registerBlock(machine, ItemMachine.class, "Machines");
@ -135,19 +138,17 @@ public class BasicUtilitiesMain extends DummyModContainer
// Liquid Item/Block common name writer
for (int i = 0; i < Liquid.values().length; i++)
{
//pipes
LanguageRegistry.addName((new ItemStack(itemPipes, 1, i)),
Liquid.getLiquid(i).displayerName + " Pipe");
//eValves
LanguageRegistry.addName((new ItemStack(eValve, 1, i)),
Liquid.getLiquid(i).displayerName + "release Valve");
//Storage Tanks
LanguageRegistry.addName((new ItemStack(itemTank, 1, i)),
Liquid.getLiquid(i).displayerName + " Tank");
// eValves
LanguageRegistry.addName((new ItemStack(eValve, 1, i)), Liquid.getLiquid(i).displayerName + " release Valve");
// pipes
LanguageRegistry.addName((new ItemStack(itemPipes, 1, i)), Liquid.getLiquid(i).displayerName + " Pipe");
// Storage Tanks
LanguageRegistry.addName((new ItemStack(itemTank, 1, i)), Liquid.getLiquid(i).displayerName + " Tank");
}
for(int i =0; i < ItemParts.basicParts.values().length; i++)
for (int i = 0; i < ItemParts.basicParts.values().length; i++)
{
//parts
// parts
LanguageRegistry.addName((new ItemStack(parts, 1, i)),
ItemParts.basicParts.values()[i].name);
}
@ -166,106 +167,120 @@ public class BasicUtilitiesMain extends DummyModContainer
public void PostInit(FMLPostInitializationEvent event)
{
proxy.postInit();
CraftingManager
.getInstance()
.getRecipeList()
.add(new ShapedOreRecipe(new ItemStack(this.generator, 1),
new Object[]
{ "@T@", "OVO", "@T@", 'T',
new ItemStack(BasicUtilitiesMain.rod, 1), '@',
"plateSteel", 'O', "basicCircuit", 'V',
"motor" }));
GameRegistry.addRecipe(new ItemStack(this.gauge, 1, 0), new Object[]
{
"TVT", " T ", 'V', new ItemStack(parts, 1, 7), 'T',
new ItemStack(parts, 1, 1) });
// generator
CraftingManager.getInstance().getRecipeList().add(new ShapedOreRecipe(new ItemStack(this.generator, 1), new Object[] {
"@T@", "OVO", "@T@",
'T', new ItemStack(BasicUtilitiesMain.rod, 1),
'@', "plateSteel",
'O', "basicCircuit",
'V', "motor" }));
// pipe gauge
GameRegistry.addRecipe(new ItemStack(this.gauge, 1, 0), new Object[] {
"TVT", " T ",
'V', new ItemStack(parts, 1, 7),
'T', new ItemStack(parts, 1, basicParts.Iron.ordinal()) });
// iron tube
GameRegistry.addRecipe(new ItemStack(parts, 2, 1), new Object[]
{
"@@@", '@', Item.ingotIron });
GameRegistry.addRecipe(new ItemStack(parts, 2, basicParts.Bronze.ordinal()), new Object[] {
"@@@",
'@', Item.ingotIron });
// obby tube
GameRegistry.addRecipe(new ItemStack(parts, 2, 2), new Object[]
{
"@@@", '@', Block.obsidian });
GameRegistry.addRecipe(new ItemStack(parts, 2, basicParts.Obby.ordinal()), new Object[] {
"@@@",
'@', Block.obsidian });
// nether tube
GameRegistry
.addRecipe(new ItemStack(parts, 2, 3),
new Object[]
{ "N@N", 'N', Block.netherrack, '@',
new ItemStack(parts, 2, 2) });
GameRegistry.addRecipe(new ItemStack(parts, 2, basicParts.Nether.ordinal()), new Object[] {
"N@N",
'N', Block.netherrack,
'@', new ItemStack(parts, 2, basicParts.Obby.ordinal()) });
// seal
GameRegistry.addRecipe(new ItemStack(parts, 2, 4), new Object[]
{ "@@",
"@@", '@', Item.leather });
GameRegistry.addRecipe(new ItemStack(parts, 2, basicParts.Seal.ordinal()), new Object[] {
"@@", "@@",
'@', Item.leather });
// slime steal
GameRegistry.addShapelessRecipe(new ItemStack(parts, 1, 5),
new Object[]
{ new ItemStack(parts, 1, 4),
new ItemStack(Item.slimeBall, 1) });// stick seal
// crafting pipes
// {"black", "red", "green", "brown", "blue", "purple", "cyan",
// "silver", "gray", "pink", "lime", "yellow", "lightBlue", "magenta",
// "orange", "white"};
GameRegistry.addRecipe(new ItemStack(rod, 1), new Object[]
{ "I@I",
'I', Item.ingotIron, '@', new ItemStack(parts, 1, 1) });
// water
GameRegistry.addShapelessRecipe(new ItemStack(itemPipes, 1, 1),
new Object[]
{ new ItemStack(parts, 1, 1),
new ItemStack(parts, 1, 4),
new ItemStack(Item.dyePowder, 1, 4) });
// lava TODO change to use obby pipe and nether items
GameRegistry.addShapelessRecipe(new ItemStack(itemPipes, 1, 2),
new Object[]
{ new ItemStack(parts, 1, 2),
new ItemStack(Item.dyePowder, 1, 1) });
// oil
GameRegistry.addShapelessRecipe(new ItemStack(itemPipes, 1, 3),
new Object[]
{ new ItemStack(parts, 1, 1),
new ItemStack(parts, 1, 4),
new ItemStack(Item.dyePowder, 1, 0) });
// 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) });
GameRegistry.addRecipe(new ItemStack(parts, 1, 7), new Object[]
{
"T@T", 'T', new ItemStack(parts, 1, 1), '@', Block.lever });// valve
GameRegistry.addShapelessRecipe(new ItemStack(parts, 1, basicParts.SlimeSeal.ordinal()), new Object[] {
new ItemStack(parts, 1, basicParts.Seal.ordinal()),
new ItemStack(Item.slimeBall, 1) });
// part valve
GameRegistry.addRecipe(new ItemStack(parts, 1, basicParts.Valve.ordinal()), new Object[] {
"T@T",
'T', new ItemStack(parts, 1, basicParts.Iron.ordinal()),
'@', Block.lever });
GameRegistry.addRecipe(new ItemStack(parts, 1, 6), new Object[]
// unfinished tank
GameRegistry.addRecipe(new ItemStack(parts, 1, basicParts.Tank.ordinal()), new Object[] {
" @ ", "@ @", " @ ",
'@', Item.ingotIron });
// mechanical rod
GameRegistry.addRecipe(new ItemStack(rod, 1), new Object[] {
"I@I",
'I', Item.ingotIron,
'@', new ItemStack(parts, 1, basicParts.Iron.ordinal()) });
// steam pipe
GameRegistry.addShapelessRecipe(new ItemStack(itemPipes, 1, Liquid.STEAM.ordinal()), new Object[] {
new ItemStack(parts, 1, basicParts.Iron.ordinal()),
new ItemStack(parts, 1, basicParts.Seal.ordinal()) });
// water pipe
GameRegistry.addShapelessRecipe(new ItemStack(itemPipes, 1, Liquid.WATER.ordinal()), new Object[] {
new ItemStack(parts, 1, basicParts.Iron.ordinal()),
new ItemStack(parts, 1, basicParts.Seal.ordinal()),
new ItemStack(Item.dyePowder, 1, 4) });
// lava pipe
GameRegistry.addShapelessRecipe(new ItemStack(itemPipes, 1, Liquid.LAVA.ordinal()), new Object[] {
new ItemStack(parts, 1, basicParts.Obby.ordinal()),
new ItemStack(Item.dyePowder, 1, 1) });
// oil pipe
GameRegistry.addShapelessRecipe(new ItemStack(itemPipes, 1, Liquid.OIL.ordinal()), new Object[] {
new ItemStack(parts, 1, basicParts.Iron.ordinal()),
new ItemStack(parts, 1, basicParts.Seal.ordinal()),
new ItemStack(Item.dyePowder, 1, 0) });
// fuel pipe
GameRegistry.addShapelessRecipe(new ItemStack(itemPipes, 1, Liquid.FUEL.ordinal()), new Object[] {
new ItemStack(parts, 1, basicParts.Iron.ordinal()),
new ItemStack(parts, 1, basicParts.Seal.ordinal()),
new ItemStack(Item.dyePowder, 1, 11) });
// steam tank
GameRegistry.addShapelessRecipe(new ItemStack(itemTank, 1, Liquid.STEAM.ordinal()), new Object[] {
new ItemStack(parts, 1, basicParts.Tank.ordinal()),
new ItemStack(parts, 1, basicParts.Seal.ordinal()),
new ItemStack(Item.dyePowder, 1, 15) });
// water tank
GameRegistry.addShapelessRecipe(new ItemStack(itemTank, 1, Liquid.WATER.ordinal()), new Object[] {
new ItemStack(parts, 1, basicParts.Tank.ordinal()),
new ItemStack(parts, 1, basicParts.Seal.ordinal()),
new ItemStack(Item.dyePowder, 1, 4) });
// lava tank
GameRegistry.addShapelessRecipe(new ItemStack(itemTank, 1, Liquid.LAVA.ordinal()), new Object[] {
new ItemStack(parts, 1, basicParts.Tank.ordinal()),
Block.obsidian,
Block.obsidian,
Block.obsidian,
Block.obsidian });
// oil tank
GameRegistry.addShapelessRecipe(new ItemStack(itemTank, 1, Liquid.OIL.ordinal()), new Object[] {
new ItemStack(parts, 1, basicParts.Tank.ordinal()),
new ItemStack(parts, 1, basicParts.Seal.ordinal()),
new ItemStack(Item.dyePowder, 1, 0) });
// fuel tank
GameRegistry.addShapelessRecipe(new ItemStack(itemTank, 1, Liquid.FUEL.ordinal()), new Object[] {
new ItemStack(parts, 1, basicParts.Tank.ordinal()),
new ItemStack(parts, 1, basicParts.Seal.ordinal()),
new ItemStack(Item.dyePowder, 1, 11) });
// pump
GameRegistry.addRecipe(new ItemStack(machine, 1, 0), new Object[] {
"@T@", "BPB", "@P@",
'@', new ItemStack(Item.ingotIron, 2),
'B', new ItemStack(parts, 1, basicParts.Valve.ordinal()),
'P', new ItemStack(Block.pistonBase),
'T', new ItemStack(parts, 1, basicParts.Tank.ordinal()) });
// eVavles
for (int i = 0; i < Liquid.values().length - 1; i++)
{
" @ ", "@ @", " @ ", '@', Item.ingotIron });// tank
/**
* GameRegistry.addShapelessRecipe(new ItemStack(itemTank, 1, 0), new
* Object[] { new ItemStack(parts, 1, 6), new ItemStack(parts, 1, 4),
* new ItemStack(Item.dyePowder, 1, 15) });
* GameRegistry.addShapelessRecipe(new ItemStack(itemTank, 1, 1), new
* Object[] { new ItemStack(parts, 1, 6), new ItemStack(parts, 1, 4),
* new ItemStack(Item.dyePowder, 1, 4) }); // lava TODO change to use
* obby pipe and nether items GameRegistry.addShapelessRecipe(new
* ItemStack(itemTank, 1, 2), new Object[] { new ItemStack(parts, 1, 6),
* Block.obsidian, Block.obsidian, Block.obsidian, Block.obsidian }); //
* oil GameRegistry.addShapelessRecipe(new ItemStack(itemTank, 1, 3),
* new Object[] { new ItemStack(parts, 1, 6), new ItemStack(parts, 1,
* 4), new ItemStack(Item.dyePowder, 1, 0) }); // fuel
* GameRegistry.addShapelessRecipe( new ItemStack(itemTank, 1,
* Liquid.Fuel.ordinal()), new Object[] { new ItemStack(parts, 1,
* basicParts.Tank.ordinal()), new ItemStack(parts, 1, 4), new
* ItemStack(Item.dyePowder, 1, 11) });
*/
GameRegistry.addShapelessRecipe(new ItemStack(itemPipes, 1, 0),
new Object[]
{ new ItemStack(parts, 1, 1),
new ItemStack(parts, 1, 4) });
GameRegistry.addRecipe(new ItemStack(machine, 1, 0), new Object[]
{
"@T@", "BPB", "@P@", '@', new ItemStack(Item.ingotIron, 2),
'B', new ItemStack(parts, 1, 7), 'P',
new ItemStack(Block.pistonBase), 'T',
new ItemStack(parts, 1, 6) });
GameRegistry.addRecipe(new ItemStack(machine, 1, i), new Object[] {
" P ", "PVP", " P ",
'P', new ItemStack(itemPipes, 1, i),
'V', new ItemStack(parts, 1, basicParts.Valve.ordinal()), });
}
}
}

View file

@ -21,7 +21,7 @@ public enum Liquid
WATER("Water", LiquidDictionary.getOrCreateLiquid("water", new LiquidStack(Block.waterStill, 1)), false, 32),
LAVA("Lava", LiquidDictionary.getOrCreateLiquid("lava", new LiquidStack(Block.lavaStill, 1)), false, 20),
OIL("Oil", LiquidDictionary.getOrCreateLiquid("oil", new LiquidStack(BasicUtilitiesMain.oilStill, 1)), true, 32),
Fuel("Fuel", LiquidDictionary.getOrCreateLiquid("oil", new LiquidStack(BasicUtilitiesMain.oilStill, 1)), false, 40),
FUEL("Fuel", LiquidDictionary.getOrCreateLiquid("oil", new LiquidStack(BasicUtilitiesMain.oilStill, 1)), false, 40),
DEFUALT("Empty", LiquidDictionary.getOrCreateLiquid("air", new LiquidStack(0, 1)), false, 0);
public final boolean doesFlaot;

View file

@ -132,7 +132,7 @@ public class TileEntityPump extends TileEntityElectricityReceiver implements IPa
{
joulesReceived -= this.WATTS_PER_TICK;
if (percentPumped++ == 20)
if (percentPumped++ >= 20)
{
this.drainBlock(new Vector3(xCoord, yCoord - 1, zCoord));
}

View file

@ -30,13 +30,13 @@ public class ItemEValve extends ItemBlock
@Override
public String getItemNameIS(ItemStack itemstack)
{
return itemstack.getItemDamage() < Liquid.values().length ? Liquid.getLiquid(itemstack.getItemDamage()).displayerName + " Pipe" : "Empty Pipe";
return "eValve";
}
@Override
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for (int i = 0; i < Liquid.values().length; i++)
for (int i = 0; i < Liquid.values().length-1; i++)
{
par3List.add(new ItemStack(this, 1, i));
}

View file

@ -43,7 +43,7 @@ public class ItemPipe extends Item
@Override
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for (int i = 0; i < Liquid.values().length; i++)
for (int i = 0; i < Liquid.values().length-1; i++)
{
par3List.add(new ItemStack(this, 1, i));
}

View file

@ -6,8 +6,10 @@ import net.minecraft.network.INetworkManager;
import net.minecraft.network.packet.Packet;
import net.minecraft.network.packet.Packet250CustomPayload;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.world.World;
import net.minecraftforge.common.ForgeDirection;
import net.minecraftforge.liquids.ILiquidTank;
import net.minecraftforge.liquids.ITankContainer;
import net.minecraftforge.liquids.LiquidContainerRegistry;
import net.minecraftforge.liquids.LiquidStack;
import net.minecraftforge.liquids.LiquidTank;
@ -49,7 +51,8 @@ public class TileEntityLTank extends TileEntity implements IPacketReceiver, IRea
this.cc = MHelper.getSourounding(worldObj, xCoord, yCoord, zCoord);
if (!worldObj.isRemote)
{
this.tank.drain(MHelper.shareLiquid(worldObj, new Vector3(this), liquid), true);
this.tradeDown();
this.tradeArround();
if (doUpdate || count2 >= 20)
{
this.doUpdate = false;
@ -139,10 +142,24 @@ public class TileEntityLTank extends TileEntity implements IPacketReceiver, IRea
public int fill(int tankIndex, LiquidStack resource, boolean doFill)
{
if (resource == null || tankIndex != 0) return 0;
return this.getTank(true).tank.fill(resource, doFill);
if (this.isFull())
{
int change = 1;
if (Liquid.getLiquid(resource).doesFlaot) change = -1;
TileEntity tank = worldObj.getBlockTileEntity(xCoord, yCoord + change, zCoord);
if (tank instanceof TileEntityLTank) { return ((TileEntityLTank) tank).tank.fill(resource, doFill); }
}
return this.tank.fill(resource, doFill);
}
public TileEntityLTank getTank(boolean top)
public boolean isFull()
{
if (this.tank.getLiquid() == null) return false;
if (this.tank.getLiquid().amount > 0 && this.tank.getLiquid().amount < this.tank.getCapacity()) return false;
return true;
}
public TileEntityLTank getFillAbleTank(boolean top)
{
TileEntityLTank tank = this;
boolean stop = false;
@ -158,7 +175,7 @@ public class TileEntityLTank extends TileEntity implements IPacketReceiver, IRea
y -= 1;
}
TileEntity ent = tank.worldObj.getBlockTileEntity(xCoord, y, zCoord);
if (ent instanceof TileEntityLTank && ((TileEntityLTank) ent).getType() == this.type)
if (ent instanceof TileEntityLTank && ((TileEntityLTank) ent).getType() == this.type && !((TileEntityLTank) ent).isFull())
{
tank = (TileEntityLTank) ent;
}
@ -179,8 +196,8 @@ public class TileEntityLTank extends TileEntity implements IPacketReceiver, IRea
@Override
public LiquidStack drain(int tankIndex, int maxDrain, boolean doDrain)
{
if(tankIndex != 0)return null;
return this.getTank(false).tank.getLiquid();
if (tankIndex != 0) return null;
return this.tank.getLiquid();
}
@Override
@ -216,4 +233,30 @@ public class TileEntityLTank extends TileEntity implements IPacketReceiver, IRea
}
return false;
}
public void tradeDown()
{
if (this.tank.getLiquid() == null || this.tank.getLiquid().amount <= 0) return;
TileEntity ent = worldObj.getBlockTileEntity(xCoord, yCoord - 1, zCoord);
if (ent instanceof TileEntityLTank && ((TileEntityLTank) ent).type == this.type && !((TileEntityLTank) ent).isFull())
{
int f = ((TileEntityLTank) ent).tank.fill(this.tank.getLiquid(), true);
this.tank.drain(f, true);
}
}
public void tradeArround()
{
if (this.tank.getLiquid() == null || this.tank.getLiquid().amount <= 0) return;
TileEntity[] ents = MHelper.getSourounding(worldObj, xCoord, yCoord, zCoord);
for (int i = 2; i < 6; i++)
{
if (ents[i] instanceof TileEntityLTank && ((TileEntityLTank) ents[i]).type == this.type && !((TileEntityLTank) ents[i]).isFull())
{
int f = ((TileEntityLTank) ents[i]).tank.fill(this.tank.getLiquid(), true);
this.tank.drain(f, true);
}
if (this.tank.getLiquid() == null || this.tank.getLiquid().amount <= 0) break;
}
}
}