BiomesOPlenty/src/minecraft/biomesoplenty/liquids/BlockFluidSpringWater.java

122 lines
3.3 KiB
Java
Raw Normal View History

2013-05-25 02:33:57 +00:00
package biomesoplenty.liquids;
import java.util.Random;
import net.minecraft.block.Block;
2013-05-25 02:33:57 +00:00
import net.minecraft.block.material.Material;
import net.minecraft.client.renderer.texture.IconRegister;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLiving;
import net.minecraft.entity.player.EntityPlayer;
2013-05-25 02:33:57 +00:00
import net.minecraft.potion.Potion;
import net.minecraft.potion.PotionEffect;
import net.minecraft.util.Icon;
import net.minecraft.world.IBlockAccess;
2013-05-25 02:33:57 +00:00
import net.minecraft.world.World;
import net.minecraftforge.fluids.BlockFluidClassic;
import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidContainerRegistry;
import net.minecraftforge.fluids.FluidStack;
import net.minecraftforge.liquids.ILiquid;
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Liquids;
import biomesoplenty.api.Potions;
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
2013-05-25 02:33:57 +00:00
public class BlockFluidSpringWater extends BlockFluidClassic implements ILiquid
2013-05-25 02:33:57 +00:00
{
public static Icon springWaterStillIcon;
public static Icon springWaterFlowingIcon;
2013-05-31 10:34:02 +00:00
public BlockFluidSpringWater(int id, Fluid fluid, Material material)
{
super(id, fluid, material);
2013-05-31 10:34:02 +00:00
stack = new FluidStack(fluid, FluidContainerRegistry.BUCKET_VOLUME);
for (int i = 8; i < 11; i++)
{
2013-05-31 10:34:02 +00:00
displacementIds.put(i, false);
}
2013-05-31 10:34:02 +00:00
displacementIds.put(Liquids.liquidPoison.get().blockID, false);
}
2013-05-31 10:34:02 +00:00
@Override
@SideOnly(Side.CLIENT)
2013-05-31 10:34:02 +00:00
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
super.randomDisplayTick(par1World, par2, par3, par4, par5Random);
if (par5Random.nextInt(1) == 0)
{
BiomesOPlenty.proxy.spawnParticle("steam", par2 + par5Random.nextFloat(), par3 + 1.0F, par4 + par5Random.nextFloat());
}
}
@Override
2013-05-31 10:34:02 +00:00
public boolean canDisplace(IBlockAccess world, int x, int y, int z) {
int bId = world.getBlockId(x, y, z);
if (bId == 0)
return true;
if (bId == blockID)
return false;
if (displacementIds.containsKey(bId))
return displacementIds.get(bId);
Material material = Block.blocksList[bId].blockMaterial;
if (material.blocksMovement() || material == Material.water || material == Material.lava || material == Material.portal)
return false;
return true;
}
@Override
public void onEntityCollidedWithBlock(World par1World, int x, int y, int z, Entity par5Entity)
{
int meta = par1World.getBlockMetadata(x, y, z);
if (par5Entity instanceof EntityLiving) {
((EntityLiving)par5Entity).addPotionEffect(new PotionEffect(Potion.regeneration.id, 1));
}
if (par5Entity instanceof EntityPlayer) {
((EntityPlayer)par5Entity).addPotionEffect(new PotionEffect(Potions.nourishment.get().id, 1));
}
}
2013-05-25 02:33:57 +00:00
@Override
@SideOnly(Side.CLIENT)
2013-05-31 10:34:02 +00:00
public void registerIcons(IconRegister iconRegister)
2013-05-25 02:33:57 +00:00
{
2013-05-31 10:34:02 +00:00
springWaterStillIcon = iconRegister.registerIcon("BiomesOPlenty:spring_water_still");
springWaterFlowingIcon = iconRegister.registerIcon("BiomesOPlenty:spring_water_flowing");
2013-05-25 02:33:57 +00:00
}
2013-05-31 10:34:02 +00:00
@Override
@SideOnly(Side.CLIENT)
2013-05-31 10:34:02 +00:00
public Icon getIcon(int par1, int par2)
{
return par1 != 0 && par1 != 1 ? springWaterFlowingIcon : springWaterStillIcon;
}
@Override
public int stillLiquidId()
{
return this.blockID;
}
@Override
public boolean isMetaSensitive()
{
return false;
}
@Override
public int stillLiquidMeta()
{
return 0;
}
2013-05-25 02:33:57 +00:00
}