Search in sources :

Example 1 with BlockFluidClassic

use of net.minecraftforge.fluids.BlockFluidClassic in project BaseMetals by MinecraftModDevelopmentMods.

the class Fluids method addFluidBlock.

@Nullable
protected static BlockFluidClassic addFluidBlock(@Nonnull final MMDMaterial material) {
    if (material.getFluidBlock() != null) {
        return material.getFluidBlock();
    }
    BlockFluidClassic block;
    String name = material.getName();
    if (name == null) {
        return null;
    }
    if (!name.equals(MaterialNames.MERCURY)) {
        block = new BlockFluidClassic(material.getFluid(), Material.LAVA);
    } else {
        block = new InteractiveFluidBlock(getFluidByName(name), false, (World w, EntityLivingBase e) -> {
            if (w.rand.nextInt(32) == 0) {
                e.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, 30 * 20, 2));
            }
        });
    }
    // fullName
    block.setRegistryName(name);
    block.setUnlocalizedName(block.getRegistryName().getResourceDomain() + "." + name);
    material.addNewBlock("fluid", block);
    block.setCreativeTab(CreativeTabs.MISC);
    final ItemBlock itemBlock = new ItemBlock(block);
    // fullName
    itemBlock.setRegistryName(name);
    itemBlock.setUnlocalizedName(block.getRegistryName().getResourceDomain() + "." + name);
    material.addNewItem("fluidItemBlock", itemBlock);
    material.setFluidBlock(block);
    return fluidBlockRegistry.put(name, block);
}
Also used : BlockFluidClassic(net.minecraftforge.fluids.BlockFluidClassic) PotionEffect(net.minecraft.potion.PotionEffect) InteractiveFluidBlock(com.mcmoddev.lib.block.InteractiveFluidBlock) EntityLivingBase(net.minecraft.entity.EntityLivingBase) World(net.minecraft.world.World) ItemBlock(net.minecraft.item.ItemBlock) Nullable(javax.annotation.Nullable)

Aggregations

InteractiveFluidBlock (com.mcmoddev.lib.block.InteractiveFluidBlock)1 Nullable (javax.annotation.Nullable)1 EntityLivingBase (net.minecraft.entity.EntityLivingBase)1 ItemBlock (net.minecraft.item.ItemBlock)1 PotionEffect (net.minecraft.potion.PotionEffect)1 World (net.minecraft.world.World)1 BlockFluidClassic (net.minecraftforge.fluids.BlockFluidClassic)1