Jump to content

New enchantment hasn`t been added


RonMine

Recommended Posts

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;
        }

}
 

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.

Announcements



×
×
  • Create New...

Important Information

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