Search in sources :

Example 1 with IGasAgent

use of ladysnake.gaspunk.api.IGasAgent in project Gaspunk by Ladysnake.

the class GasDeserializer method parseAgents.

private void parseAgents(JsonReader in, Gas.Builder builder) throws IOException {
    in.beginArray();
    while (in.hasNext()) {
        IGasAgent agent = null;
        double potency = 0;
        in.beginObject();
        while (in.hasNext()) {
            String name = in.nextName();
            switch(name) {
                case "agent":
                    String id = in.nextString();
                    agent = GasAgents.getAgent(new ResourceLocation(id));
                    if (agent == null)
                        throw new JsonParseException("Invalid agent provided: " + id + " " + in.getPath());
                    break;
                case "potency":
                    potency = in.nextDouble();
                    break;
            }
        }
        in.endObject();
        builder.addAgent(Objects.requireNonNull(agent, "no agent type provided"), (float) potency);
    }
    in.endArray();
}
Also used : IGasAgent(ladysnake.gaspunk.api.IGasAgent) ResourceLocation(net.minecraft.util.ResourceLocation) JsonParseException(com.google.gson.JsonParseException)

Example 2 with IGasAgent

use of ladysnake.gaspunk.api.IGasAgent in project Gaspunk by Ladysnake.

the class GasAgents method createDamageAgent.

public static IGasAgent createDamageAgent(String name) {
    IGasAgent ret = name(new DamageAgent(20), name);
    AGENT_MAP.put(new ResourceLocation(GasPunk.MOD_ID, name), ret);
    return ret;
}
Also used : IGasAgent(ladysnake.gaspunk.api.IGasAgent) ResourceLocation(net.minecraft.util.ResourceLocation) DamageAgent(ladysnake.gaspunk.gas.agent.DamageAgent)

Aggregations

IGasAgent (ladysnake.gaspunk.api.IGasAgent)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 JsonParseException (com.google.gson.JsonParseException)1 DamageAgent (ladysnake.gaspunk.gas.agent.DamageAgent)1