Search in sources :

Example 1 with IGas

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)));
    }
}
Also used : ItemGasTube(ladysnake.gaspunk.item.ItemGasTube) IGas(ladysnake.gaspunk.api.IGas) ResourceLocation(net.minecraft.util.ResourceLocation) JsonObject(com.google.gson.JsonObject) JsonParseException(com.google.gson.JsonParseException) ItemStack(net.minecraft.item.ItemStack)

Example 2 with IGas

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);
    }
}
Also used : IGas(ladysnake.gaspunk.api.IGas) ModContainer(net.minecraftforge.fml.common.ModContainer) ResourceLocation(net.minecraft.util.ResourceLocation) AbstractGas(ladysnake.gaspunk.api.AbstractGas) IGas(ladysnake.gaspunk.api.IGas) Gas(ladysnake.gaspunk.gas.Gas) IOException(java.io.IOException) File(java.io.File) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Example 3 with IGas

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());
}
Also used : IGas(ladysnake.gaspunk.api.IGas) AspectList(thaumcraft.api.aspects.AspectList) ItemStack(net.minecraft.item.ItemStack)

Aggregations

IGas (ladysnake.gaspunk.api.IGas)3 ItemStack (net.minecraft.item.ItemStack)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 JsonObject (com.google.gson.JsonObject)1 JsonParseException (com.google.gson.JsonParseException)1 File (java.io.File)1 IOException (java.io.IOException)1 AbstractGas (ladysnake.gaspunk.api.AbstractGas)1 Gas (ladysnake.gaspunk.gas.Gas)1 ItemGasTube (ladysnake.gaspunk.item.ItemGasTube)1 ModContainer (net.minecraftforge.fml.common.ModContainer)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1 AspectList (thaumcraft.api.aspects.AspectList)1