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

105 lines
3.2 KiB
Java
Raw Normal View History

2013-05-25 02:33:57 +00:00
package biomesoplenty.liquids;
import java.util.Random;
2013-05-25 02:33:57 +00:00
import cpw.mods.fml.relauncher.Side;
import cpw.mods.fml.relauncher.SideOnly;
import net.minecraft.block.BlockStationary;
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.liquids.ILiquid;
2013-05-25 02:33:57 +00:00
import biomesoplenty.BiomesOPlenty;
import biomesoplenty.api.Liquids;
2013-05-25 09:33:37 +00:00
import biomesoplenty.api.Potions;
import biomesoplenty.configuration.BOPPotions;
2013-05-25 02:33:57 +00:00
public class BlockSpringWaterStill extends BlockStationary implements ILiquid
2013-05-25 02:33:57 +00:00
{
public BlockSpringWaterStill(int id)
{
super(id, Material.water);
this.blockHardness = 100F;
this.setLightOpacity(0);
2013-05-25 02:33:57 +00:00
this.disableStats();
}
@Override
public int colorMultiplier(IBlockAccess par1IBlockAccess, int par2, int par3, int par4)
{
return 16777215;
}
/**
* A randomly called display update to be able to add particles or other items for display
*/
public void randomDisplayTick(World par1World, int par2, int par3, int par4, Random par5Random)
{
super.randomDisplayTick(par1World, par2, par3, par4, par5Random);
if (par5Random.nextInt(6) == 0)
{
par1World.spawnParticle("smoke", (double)((float)par2 + par5Random.nextFloat()), (double)((float)par3 + 1.0F), (double)((float)par4 + par5Random.nextFloat()), 0.0D, 0.0D, 0.0D);
}
}
@Override
public void onBlockAdded(World par1World, int x, int y, int z)
{
this.setSpringWaterNotStationary(par1World, x, y, z);;
}
public void setSpringWaterNotStationary(World par1World, int par2, int par3, int par4)
{
int l = par1World.getBlockMetadata(par2, par3, par4);
par1World.setBlock(par2, par3, par4, this.blockID - 1, l, 2);
par1World.scheduleBlockUpdate(par2, par3, par4, this.blockID - 1, this.tickRate(par1World));
}
2013-05-25 02:33:57 +00:00
@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)
public void registerIcons(IconRegister iconRegister)
{
this.theIcon = new Icon[]{iconRegister.registerIcon("BiomesOPlenty:spring_water_still"), iconRegister.registerIcon("BiomesOPlenty:spring_water_flowing")};
}
@Override
public int stillLiquidId()
{
return Liquids.springWaterStill.get().blockID;
}
@Override
public boolean isMetaSensitive()
{
return false;
}
@Override
public int stillLiquidMeta()
{
return 0;
}
2013-05-25 02:33:57 +00:00
}