a3c43609ea
What i have is not much diffrent but its a start to allowing more liquid types without having to add them myself. The current method has 3 defualt liquids that are preset. The new system also uses String names to ID liquid instead of Enums. A new class Called LiquidData will keep track of the data need to ID, and use the Liquids. In the process i also fixed a few crafting recipes that were removed/messed up in a patch a while back. Plan for new system *Have default liquid type that come with textures/renders *Have several univeral pipes that can accept all Liquid types *Have a way of placeing a universal pipe and then converting to a regulated pipe, pipe that only take one liquid type *Have a tool for doing the above *Change the release Valve to be univeral with a GUI to restrict flow and Liquid type extracted
136 lines
No EOL
3 KiB
Java
136 lines
No EOL
3 KiB
Java
package liquidmechanics.common.item;
|
|
|
|
import java.util.List;
|
|
|
|
import liquidmechanics.common.LiquidMechanics;
|
|
import liquidmechanics.common.TabLiquidMechanics;
|
|
import liquidmechanics.common.handlers.LiquidHandler;
|
|
import liquidmechanics.common.tileentity.TileEntityPipe;
|
|
import net.minecraft.block.Block;
|
|
import net.minecraft.creativetab.CreativeTabs;
|
|
import net.minecraft.entity.player.EntityPlayer;
|
|
import net.minecraft.item.Item;
|
|
import net.minecraft.item.ItemStack;
|
|
import net.minecraft.tileentity.TileEntity;
|
|
import net.minecraft.world.World;
|
|
|
|
public class ItemPipe extends Item
|
|
{
|
|
int index = 32;// 32 + 4 rows alloted to pipes
|
|
private int spawnID;
|
|
|
|
public ItemPipe(int id)
|
|
{
|
|
super(id);
|
|
this.setMaxDamage(0);
|
|
this.setHasSubtypes(true);
|
|
this.setIconIndex(10);
|
|
this.setItemName("pipe");
|
|
this.setCreativeTab(TabLiquidMechanics.INSTANCE);
|
|
}
|
|
|
|
@Override
|
|
public int getIconFromDamage(int par1)
|
|
{
|
|
|
|
return par1 + index;
|
|
}
|
|
|
|
@Override
|
|
public String getItemNameIS(ItemStack itemstack)
|
|
{
|
|
return "pipe";
|
|
}
|
|
|
|
@Override
|
|
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
|
|
{
|
|
for (int i = 0; i < LiquidHandler.allowedLiquids.size() -1; i++)
|
|
{
|
|
par3List.add(new ItemStack(this, 1, i));
|
|
}
|
|
}
|
|
|
|
public String getTextureFile()
|
|
{
|
|
return LiquidMechanics.ITEM_TEXTURE_FILE;
|
|
}
|
|
|
|
@Override
|
|
public String getItemName()
|
|
{
|
|
return "Pipes";
|
|
}
|
|
|
|
@Override
|
|
public boolean onItemUse(ItemStack itemstack, EntityPlayer par2EntityPlayer, World par3World, int par4, int par5, int par6, int par7, float par8, float par9, float par10)
|
|
{
|
|
int blockID = par3World.getBlockId(par4, par5, par6);
|
|
spawnID = LiquidMechanics.blockPipe.blockID;
|
|
if (blockID == Block.snow.blockID)
|
|
{
|
|
par7 = 1;
|
|
}
|
|
else if (blockID != Block.vine.blockID && blockID != Block.tallGrass.blockID && blockID != Block.deadBush.blockID)
|
|
{
|
|
if (par7 == 0)
|
|
{
|
|
--par5;
|
|
}
|
|
|
|
if (par7 == 1)
|
|
{
|
|
++par5;
|
|
}
|
|
|
|
if (par7 == 2)
|
|
{
|
|
--par6;
|
|
}
|
|
|
|
if (par7 == 3)
|
|
{
|
|
++par6;
|
|
}
|
|
|
|
if (par7 == 4)
|
|
{
|
|
--par4;
|
|
}
|
|
|
|
if (par7 == 5)
|
|
{
|
|
++par4;
|
|
}
|
|
}
|
|
|
|
if (LiquidMechanics.blockPipe.canPlaceBlockAt(par3World, par4, par5, par6))
|
|
{
|
|
Block var9 = Block.blocksList[this.spawnID];
|
|
par3World.editingBlocks = true;
|
|
if (par3World.setBlockWithNotify(par4, par5, par6, var9.blockID))
|
|
{
|
|
if (par3World.getBlockId(par4, par5, par6) == var9.blockID)
|
|
{
|
|
|
|
Block.blocksList[this.spawnID].onBlockAdded(par3World, par4, par5, par6);
|
|
Block.blocksList[this.spawnID].onBlockPlacedBy(par3World, par4, par5, par6, par2EntityPlayer);
|
|
TileEntity blockEntity = par3World.getBlockTileEntity(par4, par5, par6);
|
|
if (blockEntity instanceof TileEntityPipe)
|
|
{
|
|
TileEntityPipe pipeEntity = (TileEntityPipe) blockEntity;
|
|
pipeEntity.setType(LiquidHandler.getFromMeta(itemstack.getItemDamage()));
|
|
pipeEntity.converted = true;
|
|
}
|
|
}
|
|
|
|
--itemstack.stackSize;
|
|
par3World.editingBlocks = false;
|
|
return true;
|
|
}
|
|
}
|
|
par3World.editingBlocks = false;
|
|
return false;
|
|
}
|
|
|
|
} |