net.minecraft.block.Block.getEnchantPowerBonus()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(1.8k)|赞(0)|评价(0)|浏览(132)

本文整理了Java中net.minecraft.block.Block.getEnchantPowerBonus()方法的一些代码示例,展示了Block.getEnchantPowerBonus()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Block.getEnchantPowerBonus()方法的具体详情如下:
包路径:net.minecraft.block.Block
类名称:Block
方法名:getEnchantPowerBonus

Block.getEnchantPowerBonus介绍

暂无

代码示例

代码示例来源:origin: SlimeKnights/TinkersConstruct

@SubscribeEvent
public void onInteract(PlayerInteractEvent.RightClickBlock event) {
 // does the player clicks on an echanting table with moss with 5 levels?
 if(ItemStack.areItemsEqual(event.getItemStack(), TinkerCommons.matMoss)) {
  World world = event.getWorld();
  BlockPos pos = event.getPos();
  if(world.getBlockState(pos).getBlock().getEnchantPowerBonus(world, pos) >= 1.0f) {
   EntityPlayer player = event.getEntityPlayer();
   if(event.getEntityPlayer().experienceLevel >= ModMendingMoss.MENDING_MOSS_LEVELS) {
    // convert moss to mending moss
    player.playSound(SoundEvents.ENTITY_EXPERIENCE_ORB_PICKUP, 1f, 1f);
    if(!event.getWorld().isRemote) {
     event.getItemStack().shrink(1);
     player.onEnchant(null, ModMendingMoss.MENDING_MOSS_LEVELS);
     ItemHandlerHelper.giveItemToPlayer(player, TinkerCommons.matMendingMoss.copy());
     event.setUseBlock(Event.Result.DENY);
     event.setUseItem(Event.Result.DENY);
     event.setCanceled(true);
    }
   }
   else {
    player.sendStatusMessage(new TextComponentTranslation("message.mending_moss.not_enough_levels", ModMendingMoss.MENDING_MOSS_LEVELS), true);
   }
  }
 }
}

代码示例来源:origin: RS485/LogisticsPipes

@Override
@ModDependentMethod(modId = LPConstants.mcmpModID)
public float getEnchantPowerBonus(World world, BlockPos pos) {
  Block block = mcmpBlockAccess.getBlock();
  return block != null ? block.getEnchantPowerBonus(world, pos) : super.getEnchantPowerBonus(world, pos);
}

代码示例来源:origin: amadornes/MCMultiPart

public default float getEnchantPowerBonus(IPartInfo part) {
  return part.getState().getBlock().getEnchantPowerBonus(part.getPartWorld(), part.getPartPos());
}

相关文章

Block类方法