コード例 #1
0
  @SubscribeEvent
  public void breakBlock(BlockEvent.BreakEvent event) {
    if (event.getPlayer() == null) return;

    if (!event.world.isRemote) {
      if (event.block instanceof BlockRiftNode) {
        DiscoveryManager.unlockCategory(
            QADiscoveries.Category.BLOCKS.get().getKey(), event.getPlayer());
        DiscoveryManager.unlockItem(
            QADiscoveries.Item.NODE.get().getKey(), event.getPlayer(), false);
      } else if (event.block == Blocks.obsidian && RandomUtils.nextInt(0, 5) == 0) {
        DiscoveryManager.unlockItem(
            QADiscoveries.Item.ETCHED_STONE.get().getKey(), event.getPlayer(), false);
        DiscoveryManager.unlockItem(
            QADiscoveries.Item.ETCHED_CORNER.get().getKey(), event.getPlayer(), false);
      } else if (event.block == Blocks.diamond_ore) {
        DiscoveryManager.unlockItem(
            QADiscoveries.Item.PICKAXE.get().getKey(), event.getPlayer(), false);
      } else if (event.block == Blocks.log && RandomUtils.rnd.nextInt(4) == 0) {
        DiscoveryManager.unlockItem(
            QADiscoveries.Item.AXE.get().getKey(), event.getPlayer(), false);
      } else if (event.block == Blocks.mycelium) {
        DiscoveryManager.unlockItem(
            QADiscoveries.Item.SHOVEL.get().getKey(), event.getPlayer(), false);
      }
    }
  }
コード例 #2
0
  @SubscribeEvent
  public void craftEvent(PlayerEvent.ItemCraftedEvent event) {
    if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT) return;

    if (RandomUtils.nextInt(0, 4) == 0) {
      DiscoveryManager.unlockItem(
          QADiscoveries.Item.ARRANGEMENT.get().getKey(), event.player, false);
    }

    if (event.crafting.getItem() == QAItems.JOURNAL.getItem())
      DiscoveryManager.unlockItem(QADiscoveries.Item.DISCOVERY.get().getKey(), event.player, false);

    if (event.crafting.getItem() == Item.getItemFromBlock(Blocks.ender_chest))
      DiscoveryManager.unlockItem(QADiscoveries.Item.PLAYER.get().getKey(), event.player, false);
  }