use of ladysnake.gaspunk.api.IGas in project Gaspunk by Ladysnake.
the class GasRecipeDeserializer method deserializeRecipe.
private static void deserializeRecipe(JsonObject json, JsonContext context) {
String resultName = JsonUtils.getString(json, "result");
IGas result = ModGases.REGISTRY.getValue(new ResourceLocation(resultName));
if (result == null)
throw new JsonParseException("Unrecognized gas: " + resultName);
JsonObject jsInput = JsonUtils.getJsonObject(json, "input");
ItemStack in;
if (jsInput.has("gas"))
in = getBottle(ModGases.REGISTRY.getValue(new ResourceLocation(JsonUtils.getString(jsInput, "gas"))));
else
in = CraftingHelper.getItemStack(jsInput, context);
JsonObject jsIngredient = JsonUtils.getJsonObject(json, "ingredient");
String type = JsonUtils.getString(jsIngredient, "type", "minecraft:item");
if ("forge:ore_dict".equals(type)) {
String ingredient = JsonUtils.getString(jsIngredient, "ore");
BrewingRecipeRegistry.addRecipe(new GasBrewingOreRecipe(in, ingredient, ((ItemGasTube) ModItems.GAS_TUBE).getItemStackFor(result)));
} else if ("minecraft:item".equals(type)) {
ItemStack ingredient = CraftingHelper.getItemStack(jsIngredient, context);
BrewingRecipeRegistry.addRecipe(new GasBrewingRecipe(in, ingredient, ((ItemGasTube) ModItems.GAS_TUBE).getItemStackFor(result)));
}
}
use of ladysnake.gaspunk.api.IGas in project Gaspunk by Ladysnake.
the class GasDeserializer method loadGases.
@SubscribeEvent
public static void loadGases(RegistryEvent.Register<IGas> event) {
ModContainer gaspunkContainer = Loader.instance().activeModContainer();
Loader.instance().getActiveModList().forEach(GasDeserializer::loadGases);
Loader.instance().setActiveModContainer(gaspunkContainer);
File configFolder = new File(Loader.instance().getConfigDir(), GasPunk.MOD_ID + "/custom_gases");
// if the config folder was just created or couldn't be created, no need to search it
try {
if (!configFolder.mkdirs() && configFolder.exists()) {
Files.walk(configFolder.toPath()).forEach(path -> loadGases(configFolder.toPath(), path));
} else if (configFolder.exists()) {
// generate an example gas file
IGas exampleGas = new Gas.Builder().addAgent(GasAgents.getAgent(new ResourceLocation(GasPunk.MOD_ID, "lachrymator")), 0.5f).addAgent(GasAgents.getAgent(new ResourceLocation(GasPunk.MOD_ID, "nerve")), 0.375f).setColor(0x55CAFE66).setBottleColor(0x75DADD10).setType(GasTypes.GAS).addTooltipLine("For more examples, check the technical wiki:").addTooltipLine("https://github.com/Ladysnake/Gaspunk/wiki").build();
Files.write(configFolder.toPath().resolve("_example.json"), GSON.toJson(exampleGas).getBytes(), StandardOpenOption.CREATE_NEW);
}
} catch (IOException e) {
GasPunk.LOGGER.error("Error while loading gases from config", e);
}
}
use of ladysnake.gaspunk.api.IGas in project Gaspunk by Ladysnake.
the class ThaumcraftCompat method registerAspects.
public static void registerAspects() {
ThaumcraftApi.registerObjectTag(new ItemStack(ModItems.SULFUR), new AspectList().add(Aspect.FIRE, 10).add(Aspect.EARTH, 8).add(Aspect.ENTROPY, 2));
ThaumcraftApi.registerObjectTag(new ItemStack(ModItems.ASH), new AspectList().add(Aspect.FIRE, 7).add(Aspect.ENTROPY, 5).add(Aspect.DEATH, 10));
ThaumcraftApi.registerObjectTag(new ItemStack(ModItems.GRENADE), new AspectList(new ItemStack(ModItems.DIFFUSER)).add(Aspect.ALCHEMY, 5).add(Aspect.ENERGY, 7).add(Aspect.AIR, 7));
ThaumcraftApi.registerObjectTag(new ItemStack(ModItems.SMOKE_POWDER), new AspectList().add(divide(AspectHelper.getObjectAspects(new ItemStack(Items.GUNPOWDER)), 1.5)).add(Aspect.SENSES, 10).add(Aspect.AIR, 6));
ThaumcraftApi.registerObjectTag(new ItemStack(ModItems.EMPTY_GRENADE), new AspectList(new ItemStack(ModItems.DIFFUSER)).add(Aspect.VOID, 8));
// register the aspects for smoke first
registerGasAspect(ModGases.SMOKE, new AspectList());
for (IGas gas : ModGases.REGISTRY.getValues()) registerGasAspect(gas, new AspectList());
}
Aggregations