Java Code Examples for net.minecraft.enchantment.EnchantmentHelper#getLevel()
The following examples show how to use
net.minecraft.enchantment.EnchantmentHelper#getLevel() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AutoFishHack.java From Wurst7 with GNU General Public License v3.0 | 6 votes |
private int getRodValue(ItemStack stack) { if(stack.isEmpty() || !(stack.getItem() instanceof FishingRodItem)) return -1; int luckOTSLvl = EnchantmentHelper.getLevel(Enchantments.LUCK_OF_THE_SEA, stack); int lureLvl = EnchantmentHelper.getLevel(Enchantments.LURE, stack); int unbreakingLvl = EnchantmentHelper.getLevel(Enchantments.UNBREAKING, stack); int mendingBonus = EnchantmentHelper.getLevel(Enchantments.MENDING, stack); int noVanishBonus = EnchantmentHelper.hasVanishingCurse(stack) ? 0 : 1; return luckOTSLvl * 9 + lureLvl * 9 + unbreakingLvl * 2 + mendingBonus + noVanishBonus; }
Example 2
Source File: HallowedInfestedBlock.java From the-hallow with MIT License | 5 votes |
@Override public void onStacksDropped(BlockState state, World world, BlockPos pos, ItemStack stack) { if (!world.isClient && world.getGameRules().getBoolean(GameRules.DO_TILE_DROPS) && EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, stack) == 0) { EndermiteEntity endermite = (EndermiteEntity) EntityType.ENDERMITE.create(world); endermite.updatePositionAndAngles(pos.getX() + 0.5D, pos.getY(), pos.getZ() + 0.5D, 0.0F, 0.0F); world.spawnEntity(endermite); endermite.playSpawnEffects(); } }
Example 3
Source File: CongealedBloodBlock.java From the-hallow with MIT License | 5 votes |
@Override public void afterBreak(World world, PlayerEntity player, BlockPos pos, BlockState state, BlockEntity be, ItemStack stack) { super.afterBreak(world, player, pos, state, be, stack); if (EnchantmentHelper.getLevel(Enchantments.SILK_TOUCH, stack) == 0) { Material material = world.getBlockState(pos.down()).getMaterial(); if (material.blocksMovement() || material.isLiquid()) { world.setBlockState(pos, HallowedBlocks.BLOOD_BLOCK.getDefaultState()); } } }
Example 4
Source File: AutoToolHack.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
private float getMiningSpeed(ItemStack stack, BlockState state) { float speed = stack.getMiningSpeedMultiplier(state); if(speed > 1) { int efficiency = EnchantmentHelper.getLevel(Enchantments.EFFICIENCY, stack); if(efficiency > 0 && !stack.isEmpty()) speed += efficiency * efficiency + 1; } return speed; }
Example 5
Source File: AutoArmorHack.java From Wurst7 with GNU General Public License v3.0 | 5 votes |
private int getArmorValue(ArmorItem item, ItemStack stack) { int armorPoints = item.getProtection(); int prtPoints = 0; int armorToughness = (int)((IArmorItem)item).getToughness(); int armorType = item.getMaterial().getProtectionAmount(EquipmentSlot.LEGS); if(useEnchantments.isChecked()) { Enchantment protection = Enchantments.PROTECTION; int prtLvl = EnchantmentHelper.getLevel(protection, stack); ClientPlayerEntity player = MC.player; DamageSource dmgSource = DamageSource.player(player); prtPoints = protection.getProtectionAmount(prtLvl, dmgSource); } return armorPoints * 5 + prtPoints * 3 + armorToughness + armorType; }
Example 6
Source File: MixinItemStack.java From Sandbox with GNU Lesser General Public License v3.0 | 4 votes |
public int sbx$getLevel(Enchantment enchantment) { return EnchantmentHelper.getLevel(WrappingUtil.convert(enchantment), (net.minecraft.item.ItemStack) (Object) this); }