1package com.osroyale.util.parser.impl;
3import com.google.gson.JsonObject;
4import com.osroyale.game.world.entity.mob.npc.drop.NpcDrop;
5import com.osroyale.game.world.entity.mob.npc.drop.NpcDropChance;
6import com.osroyale.game.world.entity.mob.npc.drop.NpcDropManager;
7import com.osroyale.game.world.entity.mob.npc.drop.NpcDropTable;
8import com.osroyale.game.world.items.ItemDefinition;
9import com.osroyale.util.parser.GsonParser;
10import it.unimi.dsi.fastutil.ints.IntOpenHashSet;
11import it.unimi.dsi.fastutil.ints.IntSet;
12import org.jire.tarnishps.OldToNew;
14import java.util.Arrays;
15import java.util.LinkedList;
52 public NpcDropParser() {
53 super(
"def/npc/npc_drops",
false);
57 protected void parse(JsonObject data) {
58 int[] npcIds =
builder.fromJson(data.get(
"id"),
int[].class);
59 IntSet newNpcIds =
new IntOpenHashSet(npcIds.length);
60 for (
int id : npcIds) {
61 int newId = OldToNew.get(
id);
68 npcIds = newNpcIds.toIntArray();
70 boolean rareDropTable = data.get(
"rare_table").getAsBoolean();
73 List<NpcDrop> always =
new LinkedList<>();
74 List<NpcDrop> common =
new LinkedList<>();
75 List<NpcDrop> uncommon =
new LinkedList<>();
76 List<NpcDrop> rare =
new LinkedList<>();
77 List<NpcDrop> veryRare =
new LinkedList<>();
82 if (itemDefinition ==
null)
85 if (drop.id == 12073) {
91 if (drop.id == 2722) {
97 if (drop.id == 2801) {
103 if (drop.id == 2677) {
109 if (drop.id == 11942) {
115 if (drop.id == 1436) {
119 if (drop.id == 1437) {
146 Arrays.sort(npcDrops);
150 if (data.has(
"roll-data")) {
151 int[] rollData =
builder.fromJson(data.get(
"roll-data"),
int[].class);
152 table.setRollData(rollData);
155 for (
int id : npcIds) {
156 NpcDropManager.NPC_DROPS.put(
id, table);
static ItemDefinition get(int id)
void parse(JsonObject data)