resonant-induction/minecraft/liquidmechanics/common/block/BlockReleaseValve.java
Rseifert 77de6e6353 Making Changes for the better
Starting down the long road of making my mod even more compatable with
other mod's liquids. This will take some time, patience, and pain
killers.

Plan of action
*Release Valve will not store any liquids but rather direction output to
pipes from other TileEntities
*Release Valve will have a gui to restrict it to outputing one or more
types of Liquids that are predefined
*Pipes will go from being fully liquid restricted to color based(0-15)
and have a universal uncolor pipe that can accept all liquids
*Once a pipe is place a tool can be used to change its color just like
in other mods.
*Some colors will be restricted to select liquids for example Blue is
water, Red is Lava, Black is oil, Yellow Fuel, White Milk,
*Steam will have its own pipe made out of bronze to fit the machines it
goes too.
*Tanks will go in the same direction
*Pumps will still be liquid restricted but come with unique textures,
models, and animation per liquid type

Current issues to resolve that are broken with push
*Release valve doesn't work at all due to changes in progress
*back compatable must be added for pipes and old release valves
2013-01-04 19:03:34 -05:00

116 lines
2.6 KiB
Java

package liquidmechanics.common.block;
import java.util.Random;
import liquidmechanics.common.LiquidMechanics;
import liquidmechanics.common.TabLiquidMechanics;
import liquidmechanics.common.tileentity.TileEntityReleaseValve;
import net.minecraft.block.BlockContainer;
import net.minecraft.block.material.Material;
import net.minecraft.item.ItemStack;
import net.minecraft.tileentity.TileEntity;
import net.minecraft.util.MovingObjectPosition;
import net.minecraft.world.IBlockAccess;
import net.minecraft.world.World;
import universalelectricity.prefab.BlockMachine;
import universalelectricity.prefab.implement.IRedstoneReceptor;
public class BlockReleaseValve extends BlockMachine
{
public BlockReleaseValve(int par1)
{
super("eValve",par1, Material.iron,TabLiquidMechanics.INSTANCE);
this.setHardness(1f);
this.setResistance(5f);
this.setTextureFile(LiquidMechanics.BLOCK_TEXTURE_FILE);
}
@Override
public TileEntity createNewTileEntity(World var1)
{
return new TileEntityReleaseValve();
}
@Override
public void onBlockAdded(World par1World, int x, int y, int z)
{
this.checkForPower(par1World, x, y, z);
}
@Override
public boolean canConnectRedstone(IBlockAccess world, int x, int y, int z, int side)
{
return true;
}
@Override
public boolean isOpaqueCube()
{
return false;
}
@Override
public int getBlockTextureFromSideAndMetadata(int side, int meta)
{
return 0;
}
@Override
public boolean renderAsNormalBlock()
{
return true;
}
@Override
public int getRenderType()
{
return 0;
}
@Override
public int damageDropped(int meta)
{
return 0;
}
@Override
public int quantityDropped(Random par1Random)
{
return 1;
}
@Override
public void onNeighborBlockChange(World par1World, int x, int y, int z, int side)
{
super.onNeighborBlockChange(par1World, x, y, z, side);
this.checkForPower(par1World, x, y, z);
}
@Override
public ItemStack getPickBlock(MovingObjectPosition target, World world, int x, int y, int z)
{
return new ItemStack(LiquidMechanics.blockReleaseValve, 1, 0);
}
public static void checkForPower(World world, int x, int y, int z)
{
TileEntity tileEntity = world.getBlockTileEntity(x, y, z);
if (tileEntity instanceof TileEntityReleaseValve)
{
boolean powered = ((TileEntityReleaseValve) tileEntity).isPowered;
boolean beingPowered = world.isBlockIndirectlyGettingPowered(x, y, z) || world.isBlockGettingPowered(x, y, z);
if (powered && !beingPowered)
{
((IRedstoneReceptor) world.getBlockTileEntity(x, y, z)).onPowerOff();
}
else if (!powered && beingPowered)
{
((IRedstoneReceptor) world.getBlockTileEntity(x, y, z)).onPowerOn();
}
}
}
}