package blusunrize.immersiveengineering.common.blocks; import blusunrize.immersiveengineering.ImmersiveEngineering; import blusunrize.immersiveengineering.common.IEContent; import net.minecraft.block.material.Material; import net.minecraft.block.state.IBlockState; import net.minecraft.entity.Entity; import net.minecraft.entity.EntityLivingBase; import net.minecraft.item.ItemBlock; import net.minecraft.potion.PotionEffect; import net.minecraft.util.EnumFacing; import net.minecraft.util.math.BlockPos; import net.minecraft.world.IBlockAccess; import net.minecraft.world.World; import net.minecraftforge.fluids.BlockFluidClassic; import net.minecraftforge.fluids.Fluid; /** * @author BluSunrize - 04.08.2016 */ public class BlockIEFluid extends BlockFluidClassic { private int flammability = 0; private int fireSpread = 0; private PotionEffect[] potionEffects; public BlockIEFluid(String name, Fluid fluid, Material material) { super(fluid, material); this.setUnlocalizedName(ImmersiveEngineering.MODID + "." + name); this.setCreativeTab(ImmersiveEngineering.creativeTab); ImmersiveEngineering.registerBlock(this, ItemBlock.class, name); IEContent.registeredIEBlocks.add(this); } public BlockIEFluid setFlammability(int flammability, int fireSpread) { this.flammability = flammability; this.fireSpread = fireSpread; return this; } public BlockIEFluid setPotionEffects(PotionEffect... potionEffects) { this.potionEffects = potionEffects; return this; } @Override public int getFlammability(IBlockAccess world, BlockPos pos, EnumFacing face) { return this.flammability; } @Override public int getFireSpreadSpeed(IBlockAccess world, BlockPos pos, EnumFacing face) { return fireSpread; } @Override public boolean isFlammable(IBlockAccess world, BlockPos pos, EnumFacing face) { return this.flammability>0; } @Override public void onEntityCollidedWithBlock(World world, BlockPos pos, IBlockState state, Entity entity) { if(potionEffects!=null && entity instanceof EntityLivingBase) { for(PotionEffect effect : potionEffects) if(effect!=null) ((EntityLivingBase)entity).addPotionEffect(new PotionEffect(effect)); } } }