Jump to content
View in the app

A better way to browse. Learn more.

Forge Forums

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Featured Replies

Posted

package com.hamedalgim.newmod.enchantment;

import net.minecraft.block.BlockLiquid;
import net.minecraft.block.material.Material;
import net.minecraft.block.state.IBlockState;
import net.minecraft.enchantment.Enchantment;
import net.minecraft.enchantment.EnchantmentFireAspect;
import net.minecraft.enchantment.EnchantmentFrostWalker;
import net.minecraft.enchantment.EnumEnchantmentType;
import net.minecraft.entity.Entity;
import net.minecraft.entity.EntityLivingBase;
import net.minecraft.init.Blocks;
import net.minecraft.init.Enchantments;
import net.minecraft.inventory.EntityEquipmentSlot;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.math.MathHelper;
import net.minecraft.world.World;

public class EnchantmentFirstEnchant extends Enchantment {
    
     public EnchantmentFirstEnchant(Enchantment.Rarity rarityIn, EntityEquipmentSlot... slots)
        {
            super(rarityIn, EnumEnchantmentType.ARMOR_FEET, slots);
            this.setName("FirstEnchant");
        }

        /**
         * Returns the minimal value of enchantability needed on the enchantment level passed.
         */
        public int getMinEnchantability(int enchantmentLevel)
        {
            return enchantmentLevel * 10;
        }

        /**
         * Returns the maximum value of enchantability nedded on the enchantment level passed.
         */
        public int getMaxEnchantability(int enchantmentLevel)
        {
            return this.getMinEnchantability(enchantmentLevel) + 25;
        }

        public boolean isTreasureEnchantment()
        {
            return true;
        }

        /**
         * Returns the maximum level that the enchantment can have.
         */
        public int getMaxLevel()
        {
            return 2;
        }

        public static void freezeNearby(EntityLivingBase living, World worldIn, BlockPos pos, int level)
        {
            if (living.onGround)
            {
                float f = (float)Math.min(16, 2 + level);
                BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(0, 0, 0);

                for (BlockPos.MutableBlockPos blockpos$mutableblockpos1 : BlockPos.getAllInBoxMutable(pos.add((double)(-f), -1.0D, (double)(-f)), pos.add((double)f, -1.0D, (double)f)))
                {
                    if (blockpos$mutableblockpos1.distanceSqToCenter(living.posX, living.posY, living.posZ) <= (double)(f * f))
                    {
                        blockpos$mutableblockpos.setPos(blockpos$mutableblockpos1.getX(), blockpos$mutableblockpos1.getY() + 1, blockpos$mutableblockpos1.getZ());
                        IBlockState iblockstate = worldIn.getBlockState(blockpos$mutableblockpos);

                        if (iblockstate.getMaterial() == Material.AIR)
                        {
                            IBlockState iblockstate1 = worldIn.getBlockState(blockpos$mutableblockpos1);

                            if (iblockstate1.getMaterial() == Material.LAVA && (iblockstate1.getBlock() == net.minecraft.init.Blocks.LAVA || iblockstate1.getBlock() == net.minecraft.init.Blocks.FLOWING_LAVA) && ((Integer)iblockstate1.getValue(BlockLiquid.LEVEL)).intValue() == 0 && worldIn.mayPlace(Blocks.DIAMOND_BLOCK, blockpos$mutableblockpos1, false, EnumFacing.DOWN, (Entity)null))
                            {
                                worldIn.setBlockState(blockpos$mutableblockpos1, Blocks.DIAMOND_BLOCK.getDefaultState());
                                worldIn.scheduleUpdate(blockpos$mutableblockpos1.toImmutable(), Blocks.DIAMOND_BLOCK, MathHelper.getInt(living.getRNG(), 20, 10));
                            }
                        }
                    }
                }
            }
        }

        /**
         * Determines if the enchantment passed can be applyied together with this enchantment.
         */
        public boolean canApplyTogether(Enchantment ench)
        {
            return super.canApplyTogether(ench) && ench != Enchantments.FROST_WALKER;
        }

}
 

Guest
This topic is now closed to further replies.

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.