Search in sources :

Example 1 with FarmableVanillaMushroom

use of forestry.farming.logic.farmables.FarmableVanillaMushroom in project ForestryMC by ForestryMC.

the class ModuleFarming method preInit.

@Override
public void preInit() {
    ItemRegistryCore coreItems = ModuleCore.getItems();
    BlockRegistryFarming blocks = getBlocks();
    MinecraftForge.EVENT_BUS.register(this);
    IFarmRegistry registry = ForestryAPI.farmRegistry;
    registry.registerFarmables("farmArboreal", new FarmableVanillaSapling());
    if (ForestryAPI.enabledModules.contains(new ResourceLocation(Constants.MOD_ID, ForestryModuleUids.ARBORICULTURE))) {
        registry.registerFarmables("farmArboreal", new FarmableGE());
    }
    registry.registerFarmables("farmCrops", new FarmableAgingCrop(new ItemStack(Items.WHEAT_SEEDS), Blocks.WHEAT, BlockCrops.AGE, 7, 0), new FarmableAgingCrop(new ItemStack(Items.POTATO), Blocks.POTATOES, BlockCrops.AGE, 7, 0), new FarmableAgingCrop(new ItemStack(Items.CARROT), Blocks.CARROTS, BlockCrops.AGE, 7, 0), new FarmableAgingCrop(new ItemStack(Items.BEETROOT_SEEDS), Blocks.BEETROOTS, BlockBeetroot.BEETROOT_AGE, 3, 0));
    IBlockState plantedBrownMushroom = blocks.mushroom.getDefaultState().withProperty(BlockMushroom.VARIANT, BlockMushroom.MushroomType.BROWN);
    registry.registerFarmables("farmShroom", new FarmableVanillaMushroom(new ItemStack(Blocks.BROWN_MUSHROOM), plantedBrownMushroom, Blocks.BROWN_MUSHROOM_BLOCK));
    IBlockState plantedRedMushroom = blocks.mushroom.getDefaultState().withProperty(BlockMushroom.VARIANT, BlockMushroom.MushroomType.RED);
    registry.registerFarmables("farmShroom", new FarmableVanillaMushroom(new ItemStack(Blocks.RED_MUSHROOM), plantedRedMushroom, Blocks.RED_MUSHROOM_BLOCK));
    registry.registerFarmables("farmGourd", new FarmableGourd(new ItemStack(Items.PUMPKIN_SEEDS), Blocks.PUMPKIN_STEM, Blocks.PUMPKIN));
    registry.registerFarmables("farmGourd", new FarmableGourd(new ItemStack(Items.MELON_SEEDS), Blocks.MELON_STEM, Blocks.MELON_BLOCK));
    registry.registerFarmables("farmInfernal", new FarmableAgingCrop(new ItemStack(Items.NETHER_WART), Blocks.NETHER_WART, BlockNetherWart.AGE, 3));
    registry.registerFarmables("farmPoales", new FarmableStacked(new ItemStack(Items.REEDS), Blocks.REEDS, 3));
    registry.registerFarmables("farmSucculentes", new FarmableStacked(new ItemStack(Blocks.CACTUS), Blocks.CACTUS, 3));
    registry.registerFarmables("farmEnder", FarmableChorus.INSTANCE);
    // Forestry fertilizer
    registry.registerFertilizer(new ItemStack(coreItems.fertilizerCompound, 1, OreDictionary.WILDCARD_VALUE), 500);
    proxy.initializeModels();
    // Layouts
    ICircuitLayout layoutManaged = new CircuitLayout("farms.managed", CircuitSocketType.FARM);
    ChipsetManager.circuitRegistry.registerLayout(layoutManaged);
    ICircuitLayout layoutManual = new CircuitLayout("farms.manual", CircuitSocketType.FARM);
    ChipsetManager.circuitRegistry.registerLayout(layoutManual);
}
Also used : BlockRegistryFarming(forestry.farming.blocks.BlockRegistryFarming) FarmableGE(forestry.farming.logic.farmables.FarmableGE) IBlockState(net.minecraft.block.state.IBlockState) FarmableVanillaSapling(forestry.farming.logic.farmables.FarmableVanillaSapling) ICircuitLayout(forestry.api.circuits.ICircuitLayout) CircuitLayout(forestry.core.circuits.CircuitLayout) FarmableStacked(forestry.farming.logic.farmables.FarmableStacked) FarmableVanillaMushroom(forestry.farming.logic.farmables.FarmableVanillaMushroom) ICircuitLayout(forestry.api.circuits.ICircuitLayout) ItemRegistryCore(forestry.core.items.ItemRegistryCore) ResourceLocation(net.minecraft.util.ResourceLocation) FarmableGourd(forestry.farming.logic.farmables.FarmableGourd) IFarmRegistry(forestry.api.farming.IFarmRegistry) FarmableAgingCrop(forestry.farming.logic.farmables.FarmableAgingCrop) ItemStack(net.minecraft.item.ItemStack)

Example 2 with FarmableVanillaMushroom

use of forestry.farming.logic.farmables.FarmableVanillaMushroom in project ForestryMC by ForestryMC.

the class PluginNatura method registerItems.

@SubscribeEvent
public void registerItems(RegistryEvent<Item> itemRegistryEvent) {
    final ItemStack potashApple = findPotashAppleInRegistry();
    boolean hasMushroom = blueLargeGlowshroomBlock != null && greenLargeGlowshroomBlock != null && purpleLargeGlowshroomBlock != null;
    ForgeRegistries.ITEMS.forEach(item -> {
        final ResourceLocation registryName = item.getRegistryName();
        if (registryName == null || !registryName.getResourceDomain().equals(MOD_ID)) {
            return;
        }
        final String itemName = registryName.getResourcePath();
        if (itemName.matches("^.*_sapling\\d?$")) {
            consumeSubItems(item, "saplings", saplings);
            RecipeUtil.addFermenterRecipes(new ItemStack(item, 1, OreDictionary.WILDCARD_VALUE), ForestryAPI.activeMode.getIntegerSetting("fermenter.yield.sapling"), Fluids.BIOMASS);
            ItemStack[] windfall = new ItemStack[] {};
            // add potash apple as windfall for darkwood (nether_sapling:2)
            if (itemName.endsWith("nether_sapling")) {
                windfall = new ItemStack[] { potashApple };
            }
            FarmRegistry.getInstance().registerFarmables("farmArboreal", new FarmableSapling(new ItemStack(item), windfall));
            return;
        }
        if (hasMushroom && itemName.matches("^.*nether_glowshroom\\d?$")) {
            complexConsumeSubItems(item, "shrooms", subItem -> {
                shrooms.add(subItem);
                // find large shroom block that matches subItem
                final Block largeShroomBlock;
                if (subItem.getMetadata() == blueLargeGlowshroomBlock.damageDropped(blueLargeGlowshroomBlock.getDefaultState())) {
                    largeShroomBlock = blueLargeGlowshroomBlock;
                } else if (subItem.getMetadata() == greenLargeGlowshroomBlock.damageDropped(greenLargeGlowshroomBlock.getDefaultState())) {
                    largeShroomBlock = greenLargeGlowshroomBlock;
                } else {
                    largeShroomBlock = purpleLargeGlowshroomBlock;
                }
                // block representing planted glowshroom
                final Block smallShroomBlock = Block.getBlockFromItem(subItem.getItem());
                FarmRegistry.getInstance().registerFarmables("farmShroom", new FarmableVanillaMushroom(subItem, smallShroomBlock.getStateFromMeta(subItem.getMetadata()), largeShroomBlock));
            });
            return;
        }
        if (itemName.matches("^edibles|.*fruit_item|soups$")) {
            complexConsumeSubItems(item, "edibles", subitem -> {
                final String subItemName = subitem.getUnlocalizedName();
                if (subItemName.matches("^.*berry$")) {
                    berries.add(subitem);
                    return;
                }
                if (subItemName.matches("^.*(fruit_item|apple)$")) {
                    fruits.add(subitem);
                    return;
                }
                if (subItemName.matches("^.*stew$")) {
                    soups.add(subitem);
                    return;
                }
                edibles.add(subitem);
            });
        }
        if (itemName.matches("^.*_seeds$")) {
            consumeSubItems(item, "seeds", seeds);
            return;
        }
        if (itemName.matches("^.*_logs\\d?$")) {
            consumeSubItems(item, "logs", logs);
            return;
        }
        if (itemName.matches("^.*_crop\\d?$")) {
            consumeSubItems(item, "cropBlocks", cropBlocks);
            return;
        }
        if (itemName.matches("^materials$")) {
            complexConsumeSubItems(item, "materials", subitem -> {
                final String subItemName = subitem.getUnlocalizedName();
                if (subItemName.matches("^.*(barley|cotton)$")) {
                    crops.add(subitem);
                    return;
                }
                materials.add(subitem);
            });
        }
    });
}
Also used : ResourceLocation(net.minecraft.util.ResourceLocation) Block(net.minecraft.block.Block) ItemStack(net.minecraft.item.ItemStack) FarmableSapling(forestry.farming.logic.farmables.FarmableSapling) FarmableVanillaMushroom(forestry.farming.logic.farmables.FarmableVanillaMushroom) SubscribeEvent(net.minecraftforge.fml.common.eventhandler.SubscribeEvent)

Aggregations

FarmableVanillaMushroom (forestry.farming.logic.farmables.FarmableVanillaMushroom)2 ItemStack (net.minecraft.item.ItemStack)2 ResourceLocation (net.minecraft.util.ResourceLocation)2 ICircuitLayout (forestry.api.circuits.ICircuitLayout)1 IFarmRegistry (forestry.api.farming.IFarmRegistry)1 CircuitLayout (forestry.core.circuits.CircuitLayout)1 ItemRegistryCore (forestry.core.items.ItemRegistryCore)1 BlockRegistryFarming (forestry.farming.blocks.BlockRegistryFarming)1 FarmableAgingCrop (forestry.farming.logic.farmables.FarmableAgingCrop)1 FarmableGE (forestry.farming.logic.farmables.FarmableGE)1 FarmableGourd (forestry.farming.logic.farmables.FarmableGourd)1 FarmableSapling (forestry.farming.logic.farmables.FarmableSapling)1 FarmableStacked (forestry.farming.logic.farmables.FarmableStacked)1 FarmableVanillaSapling (forestry.farming.logic.farmables.FarmableVanillaSapling)1 Block (net.minecraft.block.Block)1 IBlockState (net.minecraft.block.state.IBlockState)1 SubscribeEvent (net.minecraftforge.fml.common.eventhandler.SubscribeEvent)1