use of com.infinityraider.agricraft.api.v1.plant.AgriPlantIngredient in project AgriCraft by AgriCraft.
the class AgriPlantIngredientSerializer method parse.
@Nonnull
@Override
public AgriPlantIngredient parse(PacketBuffer buffer) {
String id = buffer.readString();
IAgriPlant plant = AgriApi.getPlantRegistry().get(id).orElse(AgriApi.getPlantRegistry().getNoPlant());
if (plant.isPlant()) {
return new AgriPlantIngredient(plant);
} else {
return new AgriLazyPlantIngredient(id);
}
}
use of com.infinityraider.agricraft.api.v1.plant.AgriPlantIngredient in project AgriCraft by AgriCraft.
the class AgriPlantIngredientSerializer method parse.
@Nonnull
@Override
public AgriPlantIngredient parse(JsonObject json) {
if (!json.has("plant")) {
throw new JsonParseException("Agricraft plant ingredient must have a \"plant\" property!");
}
String id = json.get("plant").getAsString();
IAgriPlant plant = AgriApi.getPlantRegistry().get(id).orElse(AgriApi.getPlantRegistry().getNoPlant());
if (plant.isPlant()) {
return new AgriPlantIngredient(plant);
} else {
return new AgriLazyPlantIngredient(id);
}
}
Aggregations