Search in sources :

Example 1 with InteractiveFluidBlock

use of com.mcmoddev.lib.block.InteractiveFluidBlock 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)

Example 2 with InteractiveFluidBlock

use of com.mcmoddev.lib.block.InteractiveFluidBlock in project BaseMetals by MinecraftModDevelopmentMods.

the class Materials method init.

/**
 */
public static void init(final MMDLibRegisterMaterials event) {
    final List<String> rareMaterials = Arrays.asList(MaterialNames.ADAMANTINE, MaterialNames.COLDIRON, MaterialNames.PLATINUM, MaterialNames.STARSTEEL);
    final List<String> materials = Arrays.asList(MaterialNames.ANTIMONY, MaterialNames.BISMUTH, MaterialNames.COPPER, MaterialNames.LEAD, MaterialNames.NICKEL, MaterialNames.SILVER, MaterialNames.TIN, MaterialNames.ZINC);
    final List<String> rareAlloyMaterials = Arrays.asList(MaterialNames.AQUARIUM, MaterialNames.MITHRIL);
    final List<String> alloyMaterials = Arrays.asList(MaterialNames.BRASS, MaterialNames.BRONZE, MaterialNames.CUPRONICKEL, MaterialNames.ELECTRUM, MaterialNames.INVAR, MaterialNames.PEWTER, MaterialNames.STEEL);
    materials.stream().filter(Options::isMaterialEnabled).forEach(name -> createMaterial(name, MaterialType.METAL, getHardness(name), getStrength(name), getMagic(name), getColor(name)));
    alloyMaterials.stream().filter(Options::isMaterialEnabled).forEach(name -> createAlloyMaterial(name, MaterialType.METAL, getHardness(name), getStrength(name), getMagic(name), getColor(name)));
    rareMaterials.stream().filter(Options::isMaterialEnabled).forEach(name -> createRareMaterial(name, MaterialType.METAL, getHardness(name), getStrength(name), getMagic(name), getColor(name)));
    rareAlloyMaterials.stream().filter(Options::isMaterialEnabled).forEach(name -> createRareAlloyMaterial(name, MaterialType.METAL, getHardness(name), getStrength(name), getMagic(name), getColor(name)));
    if (Options.isMaterialEnabled(MaterialNames.MERCURY)) {
        createMaterial(MaterialNames.MERCURY, MaterialType.METAL, 1.0d, 1.0d, 1.0d, 0xFFE2E2E2, true);
        Materials.getMaterialByName(MaterialNames.MERCURY).setFluidBlockGetter(new IFluidBlockGetter() {

            public BlockFluidClassic apply(String fluidName) {
                return new InteractiveFluidBlock(FluidRegistry.getFluid(MaterialNames.MERCURY), false, (final World w, final EntityLivingBase e) -> {
                    if (w.rand.nextInt(32) == 0) {
                        e.addPotionEffect(new PotionEffect(MobEffects.NAUSEA, 30 * 20, 2));
                    }
                });
            }
        });
    }
    // Mod Materials
    if (hasMaterial(MaterialNames.ADAMANTINE)) {
        getMaterialByName(MaterialNames.ADAMANTINE).setBlastResistance(2000f).setSpawnSize(4).setDefaultDimension(-1);
    }
    if (hasMaterial(MaterialNames.STARSTEEL)) {
        getMaterialByName(MaterialNames.STARSTEEL).setBlastResistance(2000f).setSpawnSize(6).setDefaultDimension(1).setRegenerates(true);
    }
}
Also used : BlockFluidClassic(net.minecraftforge.fluids.BlockFluidClassic) PotionEffect(net.minecraft.potion.PotionEffect) InteractiveFluidBlock(com.mcmoddev.lib.block.InteractiveFluidBlock) EntityLivingBase(net.minecraft.entity.EntityLivingBase) IFluidBlockGetter(com.mcmoddev.lib.material.IFluidBlockGetter) World(net.minecraft.world.World)

Aggregations

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