Advertisement
Guest User

EnchantmentMeltingCurse

a guest
Jul 30th, 2019
525
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. package arcanephysics.arkoddities.enchantments;
  2.  
  3. import arcanephysics.arkoddities.util.Reference;
  4. import net.minecraft.block.BlockLiquid;
  5. import net.minecraft.block.material.Material;
  6. import net.minecraft.block.state.IBlockState;
  7. import net.minecraft.enchantment.Enchantment;
  8. import net.minecraft.enchantment.EnumEnchantmentType;
  9. import net.minecraft.entity.Entity;
  10. import net.minecraft.entity.EntityLivingBase;
  11. import net.minecraft.init.Blocks;
  12. import net.minecraft.init.Enchantments;
  13. import net.minecraft.inventory.EntityEquipmentSlot;
  14. import net.minecraft.util.EnumFacing;
  15. import net.minecraft.util.math.BlockPos;
  16. import net.minecraft.util.math.MathHelper;
  17. import net.minecraft.world.World;
  18. import net.minecraftforge.fml.common.Mod;
  19.  
  20. public class EnchantmentMeltingCurse extends Enchantment
  21. {
  22. public EnchantmentMeltingCurse()
  23. {
  24. super(Rarity.RARE, EnumEnchantmentType.ARMOR_FEET, new EntityEquipmentSlot[] {EntityEquipmentSlot.FEET});
  25. this.setRegistryName("meltingCurse");
  26. this.setName("meltingCurse");
  27. }
  28.  
  29.  
  30. public int getMinEnchantability(int enchantmentLevel)
  31. {
  32. return enchantmentLevel * 10;
  33. }
  34.  
  35.  
  36. public int getMaxEnchantability(int enchantmentLevel)
  37. {
  38. return this.getMinEnchantability(enchantmentLevel) + 15;
  39. }
  40.  
  41. public boolean isTreasureEnchantment()
  42. {
  43. return true;
  44. }
  45.  
  46.  
  47. public int getMaxLevel()
  48. {
  49. return 2;
  50. }
  51.  
  52. public static void freezeNearby(EntityLivingBase living, World worldIn, BlockPos pos, int level)
  53. {
  54. if (living.onGround)
  55. {
  56. float f = (float)Math.min(16, 2 + level);
  57. BlockPos.MutableBlockPos blockpos$mutableblockpos = new BlockPos.MutableBlockPos(0, 0, 0);
  58.  
  59. for (BlockPos.MutableBlockPos blockpos$mutableblockpos1 : BlockPos.getAllInBoxMutable(pos.add((double)(-f), -1.0D, (double)(-f)), pos.add((double)f, -1.0D, (double)f)))
  60. {
  61. if (blockpos$mutableblockpos1.distanceSqToCenter(living.posX, living.posY, living.posZ) <= (double)(f * f))
  62. {
  63. blockpos$mutableblockpos.setPos(blockpos$mutableblockpos1.getX(), blockpos$mutableblockpos1.getY() + 1, blockpos$mutableblockpos1.getZ());
  64. IBlockState iblockstate = worldIn.getBlockState(blockpos$mutableblockpos);
  65.  
  66. if (iblockstate.getMaterial() == Material.AIR)
  67. {
  68. IBlockState iblockstate1 = worldIn.getBlockState(blockpos$mutableblockpos1);
  69.  
  70. if (iblockstate1.getMaterial() == Material.WATER && (iblockstate1.getBlock() == net.minecraft.init.Blocks.FROSTED_ICE || iblockstate1.getBlock() == net.minecraft.init.Blocks.FLOWING_WATER) && ((Integer)iblockstate1.getValue(BlockLiquid.LEVEL)).intValue() == 0 && worldIn.mayPlace(Blocks.FROSTED_ICE, blockpos$mutableblockpos1, false, EnumFacing.DOWN, (Entity)null))
  71. {
  72. worldIn.setBlockState(blockpos$mutableblockpos1, Blocks.FROSTED_ICE.getDefaultState());
  73. worldIn.scheduleUpdate(blockpos$mutableblockpos1.toImmutable(), Blocks.FROSTED_ICE, MathHelper.getInt(living.getRNG(), 60, 120));
  74. }
  75. }
  76. }
  77. }
  78. }
  79. }
  80.  
  81.  
  82. public boolean canApplyTogether(Enchantment ench)
  83. {
  84. return super.canApplyTogether(ench) && ench != Enchantments.DEPTH_STRIDER;
  85. }
  86.  
  87. public boolean isCurse()
  88. {
  89. return true;
  90. }
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement