resonant-induction/minecraft/dark/BasicUtilities/Items/ItemEValve.java
Rseifert 5787f65148 Reformating, and rebalance of tanks, Final 1.4.5
Did some file changes to make finding things easier
Added: Custom creative tab
Changed: File root system, :p to many files
Changed: Tank liquid trade method to balance out instead of full trade
Changed: the packet update rate of the Tank to try to fix Render Lag
Fixed: Tank Render so Liquid levels can be seen
BugIgnorable: uneven levels of liquid will not show up on tank render
but are present
BugIgnorable: eValve names sometime glitch and call all instances Empty
XXX
TODO: Fix Textures, and add model for eValve
TODO: Finish One way valve
TODO: Finish OIL,STEAM,FUEL liquid/gas blocks
2012-12-23 05:28:26 -05:00

132 lines
No EOL
3.7 KiB
Java

package dark.BasicUtilities.Items;
import java.util.List;
import net.minecraft.block.Block;
import net.minecraft.creativetab.CreativeTabs;
import net.minecraft.entity.player.EntityPlayer;
import net.minecraft.item.ItemBlock;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MathHelper;
import net.minecraft.world.World;
import dark.BasicUtilities.BasicUtilitiesMain;
import dark.BasicUtilities.Tile.TileEntityEValve;
import dark.BasicUtilities.api.Liquid;
public class ItemEValve extends ItemBlock
{
int index = 32;// 32 + 4 rows alloted to pipes
private int spawnID;
public ItemEValve(int id)
{
super(id);
this.setMaxDamage(0);
this.setHasSubtypes(true);
this.setItemName("eValve");
this.setCreativeTab(CreativeTabs.tabRedstone);
}
@Override
public String getItemNameIS(ItemStack itemstack)
{
return "eValve";
}
@Override
public void getSubItems(int par1, CreativeTabs par2CreativeTabs, List par3List)
{
for (int i = 0; i < Liquid.values().length-1; i++)
{
par3List.add(new ItemStack(this, 1, i));
}
}
@Override
public String getTextureFile()
{
return BasicUtilitiesMain.BlOCK_PNG;
}
@Override
public String getItemName()
{
return "Pipes";
}
@Override
public boolean onItemUse(ItemStack itemstack, EntityPlayer player, World world, int x, int y, int z, int side, float par8, float par9, float par10)
{
int blockID = world.getBlockId(x, y, z);
spawnID = BasicUtilitiesMain.eValve.blockID;
int angle = MathHelper.floor_double((player.rotationYaw * 4.0F / 360.0F) + 0.5D) & 3;
if (blockID == Block.snow.blockID)
{
side = 1;
}
else if (blockID != Block.vine.blockID && blockID != Block.tallGrass.blockID && blockID != Block.deadBush.blockID)
{
if (side == 0)
{
--y;
}
if (side == 1)
{
++y;
}
if (side == 2)
{
--z;
}
if (side == 3)
{
++z;
}
if (side == 4)
{
--x;
}
if (side == 5)
{
++x;
}
}
if (BasicUtilitiesMain.pipe.canPlaceBlockAt(world, x, y, z))
{
Block var9 = Block.blocksList[this.spawnID];
world.editingBlocks = true;
if (world.setBlockWithNotify(x, y, z, var9.blockID))
{
if (world.getBlockId(x, y, z) == var9.blockID)
{
Block.blocksList[this.spawnID].onBlockAdded(world, x, y, z);
Block.blocksList[this.spawnID].onBlockPlacedBy(world, x, y, z, player);
TileEntity blockEntity = world.getBlockTileEntity(x, y, z);
if (blockEntity instanceof TileEntityEValve)
{
TileEntityEValve pipeEntity = (TileEntityEValve) blockEntity;
Liquid dm = Liquid.getLiquid(itemstack.getItemDamage());
pipeEntity.setType(dm);
pipeEntity.tank.setLiquid(Liquid.getStack(dm, 1));
world.setBlockMetadata(x, y, z, dm.ordinal() & 15);
}
}
--itemstack.stackSize;
world.editingBlocks = false;
return true;
}
}
world.editingBlocks = false;
return false;
}
}