Example usage for com.google.gson JsonObject hashCode

List of usage examples for com.google.gson JsonObject hashCode

Introduction

In this page you can find the example usage for com.google.gson JsonObject hashCode.

Prototype

@Override
    public int hashCode() 

Source Link

Usage

From source file:net.minecraftforge.common.ForgeHooks.java

License:Open Source License

public static String readPoolName(JsonObject json) {
    LootTableContext ctx = ForgeHooks.getLootTableContext();
    ctx.resetPoolCtx();//w  ww  .ja v  a  2s  .c  o  m

    if (json.has("name"))
        return JsonUtils.getString(json, "name");

    if (ctx.custom)
        return "custom#" + json.hashCode(); //We don't care about custom ones modders shouldn't be editing them!

    ctx.poolCount++;

    if (!ctx.vanilla)
        throw new JsonParseException("Loot Table \"" + ctx.name.toString()
                + "\" Missing `name` entry for pool #" + (ctx.poolCount - 1));

    return ctx.poolCount == 1 ? "main" : "pool" + (ctx.poolCount - 1);
}

From source file:net.minecraftforge.common.ForgeHooks.java

License:Open Source License

public static String readLootEntryName(JsonObject json, String type) {
    LootTableContext ctx = ForgeHooks.getLootTableContext();
    ctx.entryCount++;//from w w  w .j ava  2 s  . co m

    if (json.has("entryName"))
        return ctx.validateEntryName(JsonUtils.getString(json, "entryName"));

    if (ctx.custom)
        return "custom#" + json.hashCode(); //We don't care about custom ones modders shouldn't be editing them!

    String name = null;
    if ("item".equals(type))
        name = JsonUtils.getString(json, "name");
    else if ("loot_table".equals(type))
        name = JsonUtils.getString(json, "name");
    else if ("empty".equals(type))
        name = "empty";

    return ctx.validateEntryName(name);
}