Move some classes to the api and fix broken api classes

This commit is contained in:
Nedelosk committed 2017-11-03 16:09:17 +01:00
1 parent e7766d3ad9
commit a0e15f76ca
58 files changed
+306 -182

No files matched your search

@@ -5,9 +5,10 @@
******************************************************************************/
package forestry.api.arboriculture;
import net.minecraft.util.text.translation.I18n;
import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IFruitFamily;
import forestry.core.utils.Translator;
public enum EnumFruitFamily implements IFruitFamily {
PRUNES("prunes", "Prunus domestica"),
@@ -37,12 +38,12 @@ public enum EnumFruitFamily implements IFruitFamily {
@Override
public String getName() {
return Translator.translateToLocal("for.family." + uid);
return I18n.translateToLocal("for.family." + uid);
}
@Override
public String getDescription() {
return Translator.translateToLocal("for.family." + uid + ".description");
return I18n.translateToLocal("for.family." + uid + ".description");
}
}
@@ -11,7 +11,7 @@ import net.minecraft.world.World;
public interface IClimateManager {
/**
* @deprecated Use {@link IClimateStates#create(float, float)}
* @deprecated Use {@link IClimateStates#create(float, float, ClimateStateType)}
*/
@Deprecated
IClimateInfo createInfo(float temperature, float humidity);
@@ -17,7 +17,8 @@ import forestry.api.climate.IClimateStates;
import forestry.api.farming.IFarmRegistry;
import forestry.api.farming.IFarmable;
import forestry.api.farming.ISimpleFarmLogic;
import forestry.greenhouse.api.climate.IClimateFactory;
import forestry.api.modules.IModuleContainer;
import forestry.api.modules.IModuleManager;
/**
* Forestry's API is divided into several subcategories to make it easier to understand.
@@ -54,12 +55,12 @@ public class ForestryAPI {
public static IModelManager modelManager;
public static IClimateManager climateManager;
/**
* A factory to create climate related things.
* @since 5.3.4
* Instance of the module manager of forestry.
* This can be used to register {@link IModuleContainer}s in the constructor of your mod.
*/
public static IClimateFactory climateFactory;
public static IModuleManager moduleManager;
/**
*
@@ -61,7 +61,10 @@ public abstract class ForestryEvent extends Event {
/**
* Posted before forestry registers all items and blocks.
*
* @deprecated removed in 1.13
*/
@Deprecated
public static class PreInit extends ForestryEvent{
/**
* The main mod instance for Forestry.
@@ -1,8 +1,13 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.core;
/**
* The alignment of the text in a text gui element.
*/
public enum GuiElementAlignment {
LEFT, CENTER, RIGHT;
LEFT, CENTER, RIGHT
}
@@ -1,3 +1,8 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.core;
import javax.annotation.Nullable;
@@ -1,3 +1,8 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.core;
import net.minecraftforge.fml.relauncher.Side;
@@ -1,3 +1,8 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.core;
import java.util.function.Function;
@@ -1,3 +1,8 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.core;
import java.util.Collection;
@@ -1,3 +1,8 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.core;
import java.util.Collection;
@@ -1,3 +1,8 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.genetics;
import javax.annotation.Nullable;
@@ -3,13 +3,14 @@
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.modules;
package forestry.api.modules;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
/**
* Annotation to provide additional information on IForestryModules. This information will be available via the "/forestry module info {@link #moduleID()}" command ingame.
* Any class annotated by this and implementing {@link IForestryModule} will be loaded by the model manager of Forestry.
*
* @author Nedelosk
*/
@@ -0,0 +1,99 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.modules;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.Set;
import net.minecraft.command.ICommand;
import net.minecraft.util.ResourceLocation;
/**
* Defines a Forestry module.
* Any class implementing this interface and annotated by {@link ForestryModule} to be loaded by
* the model manager of Forestry.
*/
public interface IForestryModule {
default boolean isAvailable() {
return true;
}
default boolean canBeDisabled() {
return true;
}
default String getFailMessage() {
return "";
}
/**
* The ForestryModule.moduleID()s of any other modules this module depends on.
*/
default Set<ResourceLocation> getDependencyUids(){
return Collections.emptySet();
}
/**
* Can be used to setup the api.
* Will only be called if the module is active if not {@link #disabledSetupAPI()} will be called.
*/
default void setupAPI() {
}
/**
* Called to setup the api if this module is disabled in the config or has missing dependencies.
*/
default void disabledSetupAPI() {
}
/**
* Can be used to register items and blocks. Called before {@link #preInit()}.
*/
default void registerItemsAndBlocks() {
}
default void preInit() {
}
/**
* Can be used to register Buildcraft triggers.
*/
default void registerTriggers() {
}
/**
* Can be used to register items to the backpack via the {@link forestry.api.storage.IBackpackInterface}.
*/
default void registerBackpackItems() {
}
/**
* Can be used to register crates via the {@link forestry.api.storage.ICrateRegistry}.
*/
default void registerCrates() {
}
default void doInit() {
}
/**
* Can be used to register recipes. Called after {@link #doInit()}.
*/
default void registerRecipes(){
}
default void addLootPoolNames(Set<String> lootPoolNames){
}
default void postInit(){
}
@Nullable
default ICommand[] getConsoleCommands(){
return null;
}
}
@@ -1,4 +1,9 @@
package forestry.modules;
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.modules;
import net.minecraftforge.common.config.Configuration;
@@ -1,9 +1,17 @@
package forestry.modules;
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
package forestry.api.modules;
import java.util.Collection;
import net.minecraft.util.ResourceLocation;
/**
* The module manager of Forestry.
*/
public interface IModuleManager {
default boolean isModuleEnabled(String containerID, String moduleID){
@@ -0,0 +1,15 @@
/*******************************************************************************
* Copyright 2011-2014 SirSengir
*
* This work (the API) is licensed under the "MIT" License, see LICENSE.txt for details.
******************************************************************************/
@ParametersAreNonnullByDefault
@MethodsReturnNonnullByDefault
@API(apiVersion = "5.7.0", owner = "ForestryAPI|core", provides = "ForestryAPI|modules")
package forestry.api.modules;
import javax.annotation.ParametersAreNonnullByDefault;
import net.minecraftforge.fml.common.API;
import mcp.MethodsReturnNonnullByDefault;
@@ -21,7 +21,6 @@ import java.util.Objects;
import java.util.Random;
import java.util.Set;
import net.minecraft.advancements.critereon.ItemPredicate;
import net.minecraft.block.BlockFlower;
import net.minecraft.block.state.IBlockState;
import net.minecraft.client.renderer.texture.TextureAtlasSprite;
@@ -29,7 +28,6 @@ import net.minecraft.entity.passive.EntityVillager;
import net.minecraft.init.Blocks;
import net.minecraft.init.Items;
import net.minecraft.init.PotionTypes;
import net.minecraft.inventory.IInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.potion.PotionUtils;
import net.minecraft.util.NonNullList;
@@ -43,7 +41,6 @@ import net.minecraft.world.storage.loot.LootTableList;
import net.minecraftforge.client.event.TextureStitchEvent;
import net.minecraftforge.common.BiomeDictionary;
import net.minecraftforge.common.ForgeHooks;
import net.minecraftforge.common.MinecraftForge;
import net.minecraftforge.common.brewing.BrewingRecipeRegistry;
import net.minecraftforge.common.capabilities.CapabilityManager;
@@ -73,6 +70,7 @@ import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IClassification;
import forestry.api.genetics.IClassification.EnumClassLevel;
import forestry.api.genetics.IFlowerAcceptableRule;
import forestry.api.modules.ForestryModule;
import forestry.api.recipes.RecipeManagers;
import forestry.api.storage.ICrateRegistry;
import forestry.api.storage.StorageManager;
@@ -134,7 +132,6 @@ import forestry.core.utils.VillagerTradeLists;
import forestry.food.ModuleFood;
import forestry.food.items.ItemRegistryFood;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@ForestryModule(containerID = Constants.MOD_ID, moduleID = ForestryModuleUids.APICULTURE, name = "Apiculture", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.module.apiculture.description", lootTable = "apiculture")
@@ -66,6 +66,7 @@ import forestry.api.genetics.AlleleManager;
import forestry.api.genetics.IBlockTranslator;
import forestry.api.genetics.IIndividual;
import forestry.api.genetics.IItemTranslator;
import forestry.api.modules.ForestryModule;
import forestry.api.recipes.RecipeManagers;
import forestry.api.storage.ICrateRegistry;
import forestry.api.storage.StorageManager;
@@ -108,7 +109,6 @@ import forestry.core.utils.IMCUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.core.utils.VillagerTradeLists;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@ForestryModule(containerID = Constants.MOD_ID, moduleID = ForestryModuleUids.ARBORICULTURE, name = "Arboriculture", author = "Binnie & SirSengir", url = Constants.URL, unlocalizedDescription = "for.module.arboriculture.description", lootTable = "arboriculture")
@@ -9,6 +9,7 @@ import net.minecraft.init.Items;
import net.minecraft.item.ItemStack;
import forestry.api.arboriculture.TreeManager;
import forestry.api.modules.ForestryModule;
import forestry.arboriculture.blocks.BlockRegistryCharcoal;
import forestry.arboriculture.charcoal.CharcoalPileWall;
import forestry.core.ModuleCore;
@@ -17,7 +18,6 @@ import forestry.core.items.ItemRegistryCore;
import forestry.core.recipes.RecipeUtil;
import forestry.core.utils.OreDictUtil;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@ForestryModule(containerID = Constants.MOD_ID, moduleID = ForestryModuleUids.CHARCOAL, name = "Charcoal", author = "Nedelosk", url = Constants.URL, unlocalizedDescription = "for.module.charcoal.description")
+3 -3
View File
@@ -39,6 +39,7 @@ import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.circuits.ChipsetManager;
import forestry.api.core.ForestryAPI;
import forestry.api.genetics.AlleleManager;
import forestry.api.modules.ForestryModule;
import forestry.api.multiblock.MultiblockManager;
import forestry.api.recipes.RecipeManagers;
import forestry.api.storage.ICrateRegistry;
@@ -48,7 +49,6 @@ import forestry.core.blocks.BlockRegistryCore;
import forestry.core.blocks.EnumResourceType;
import forestry.core.circuits.CircuitRegistry;
import forestry.core.circuits.SolderManager;
import forestry.core.climate.ClimateFactory;
import forestry.core.climate.ClimateManager;
import forestry.core.commands.CommandModules;
import forestry.core.commands.RootCommand;
@@ -75,7 +75,6 @@ import forestry.core.utils.ForestryModEnvWarningCallable;
import forestry.core.utils.OreDictUtil;
import forestry.core.utils.World2ObjectMap;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@ForestryModule(containerID = Constants.MOD_ID, moduleID = ForestryModuleUids.CORE, name = "Core", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.module.core.description", coreModule = true)
@@ -122,7 +121,8 @@ public class ModuleCore extends BlankForestryModule {
MultiblockManager.logicFactory = new MultiblockLogicFactory();
ForestryAPI.climateManager = ClimateManager.getInstance();
ForestryAPI.climateFactory = new ClimateFactory();
//TODO: Greenhouse Api
//ForestryAPI.climateFactory = new ClimateFactory();
}
@Override
@@ -29,6 +29,7 @@ import net.minecraftforge.fml.common.registry.ForgeRegistries;
import forestry.api.core.ForestryAPI;
import forestry.api.fuels.FuelManager;
import forestry.api.fuels.GeneratorFuel;
import forestry.api.modules.ForestryModule;
import forestry.api.recipes.RecipeManagers;
import forestry.core.config.Config;
import forestry.core.config.Constants;
@@ -40,7 +41,6 @@ import forestry.core.proxy.Proxies;
import forestry.core.recipes.RecipeUtil;
import forestry.core.utils.Log;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@ForestryModule(containerID = Constants.MOD_ID, moduleID = ForestryModuleUids.FLUIDS, name = "Fluids", author = "mezz", url = Constants.URL, unlocalizedDescription = "for.module.fluids.description")
@@ -19,9 +19,9 @@ import net.minecraft.server.MinecraftServer;
import net.minecraft.util.math.BlockPos;
import net.minecraft.util.text.TextFormatting;
import forestry.api.modules.ForestryModule;
import forestry.api.modules.IForestryModule;
import forestry.core.utils.Translator;
import forestry.modules.ForestryModule;
import forestry.modules.IForestryModule;
import forestry.modules.ModuleManager;
/**
@@ -19,9 +19,9 @@ import java.util.Set;
import net.minecraftforge.fml.common.FMLCommonHandler;
import net.minecraftforge.fml.common.ICrashCallable;
import forestry.api.modules.ForestryModule;
import forestry.api.modules.IForestryModule;
import forestry.core.config.Constants;
import forestry.modules.ForestryModule;
import forestry.modules.IForestryModule;
import forestry.modules.ModuleManager;
/**
@@ -4,6 +4,7 @@ import com.google.common.base.Preconditions;
import javax.annotation.Nullable;
import forestry.api.modules.ForestryModule;
import forestry.core.ModuleCore;
import forestry.core.config.Constants;
import forestry.core.items.ItemRegistryCore;
@@ -12,7 +13,6 @@ import forestry.core.recipes.RecipeUtil;
import forestry.database.blocks.BlockRegistryDatabase;
import forestry.database.network.PacketRegistryDatabase;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@ForestryModule(containerID = Constants.MOD_ID, moduleID = ForestryModuleUids.DATABASE, name = "Database", author = "Nedelosk", url = Constants.URL, unlocalizedDescription = "for.module.database.description")
@@ -21,12 +21,12 @@ import net.minecraft.item.ItemStack;
import net.minecraftforge.fml.common.SidedProxy;
import forestry.api.core.ForestryAPI;
import forestry.api.modules.ForestryModule;
import forestry.core.config.Constants;
import forestry.core.recipes.RecipeUtil;
import forestry.energy.blocks.BlockRegistryEnergy;
import forestry.energy.proxy.ProxyEnergy;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@ForestryModule(containerID = Constants.MOD_ID, moduleID = ForestryModuleUids.ENERGY, name = "Energy", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.module.energy.description")
@@ -40,7 +40,7 @@ public enum BlockTypeEngine implements IBlockTypeTesr {
}
protected static IMachinePropertiesTesr<?> createEngineProperties(Class<? extends TileEngine> teClass, String name, String textureName) {
MachinePropertiesTesr<? extends TileEngine> machinePropertiesEngine = new MachinePropertiesTesr<>(teClass, name, Constants.MOD_ID + ":blocks" + textureName + ".0");
MachinePropertiesTesr<? extends TileEngine> machinePropertiesEngine = new MachinePropertiesTesr<>(teClass, name, Constants.MOD_ID + ":blocks" + textureName + ".0", false);
ModuleEnergy.proxy.setRenderDefaultEngine(machinePropertiesEngine, Constants.TEXTURE_PATH_BLOCKS + textureName + "_");
return machinePropertiesEngine;
}
@@ -38,6 +38,7 @@ import forestry.api.fuels.FermenterFuel;
import forestry.api.fuels.FuelManager;
import forestry.api.fuels.MoistenerFuel;
import forestry.api.fuels.RainSubstrate;
import forestry.api.modules.ForestryModule;
import forestry.api.recipes.RecipeManagers;
import forestry.apiculture.ModuleApiculture;
import forestry.apiculture.items.ItemRegistryApiculture;
@@ -72,7 +73,6 @@ import forestry.factory.recipes.MoistenerRecipeManager;
import forestry.factory.recipes.SqueezerRecipeManager;
import forestry.factory.recipes.StillRecipeManager;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
import forestry.storage.ModuleCrates;
@@ -43,6 +43,7 @@ import forestry.api.circuits.CircuitSocketType;
import forestry.api.circuits.ICircuitLayout;
import forestry.api.core.ForestryAPI;
import forestry.api.farming.IFarmRegistry;
import forestry.api.modules.ForestryModule;
import forestry.core.ModuleCore;
import forestry.core.circuits.CircuitLayout;
import forestry.core.circuits.Circuits;
@@ -83,7 +84,6 @@ import forestry.farming.tiles.TileFarmPlain;
import forestry.farming.tiles.TileFarmValve;
import forestry.farming.triggers.FarmingTriggers;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@ForestryModule(containerID = Constants.MOD_ID, moduleID = ForestryModuleUids.FARMING, name = "Farming", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.module.farming.description")
+1 -1
View File
@@ -14,10 +14,10 @@ import com.google.common.base.Preconditions;
import javax.annotation.Nullable;
import forestry.api.modules.ForestryModule;
import forestry.core.config.Constants;
import forestry.food.items.ItemRegistryFood;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@ForestryModule(containerID = Constants.MOD_ID, moduleID = ForestryModuleUids.FOOD, name = "Food", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.module.food.description")
@@ -32,6 +32,7 @@ import forestry.api.climate.ClimateType;
import forestry.api.core.CamouflageManager;
import forestry.api.core.ForestryAPI;
import forestry.api.core.Tabs;
import forestry.api.modules.ForestryModule;
import forestry.core.CreativeTabForestry;
import forestry.core.ModuleCore;
import forestry.core.circuits.CircuitLayout;
@@ -72,7 +73,6 @@ import forestry.greenhouse.tiles.TileHeater;
import forestry.greenhouse.tiles.TileHumidifier;
import forestry.greenhouse.tiles.TileHygroregulator;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@ForestryModule(containerID = Constants.MOD_ID, moduleID = ForestryModuleUids.GREENHOUSE, name = "Greenhouse", author = "Nedelosk", url = Constants.URL, unlocalizedDescription = "for.module.greenhouse.description")
@@ -9,6 +9,13 @@ import forestry.api.greenhouse.IClimateHousing;
public interface IClimateFactory {
//Add this to the api
/**
* A factory to create climate related things.
* @since 5.3.4
*/
//public static IClimateFactory climateFactory;
/**
* @param climatedRegion
* @return Creates a climate container.
@@ -52,6 +52,7 @@ import forestry.api.genetics.IAllele;
import forestry.api.lepidopterology.ButterflyManager;
import forestry.api.lepidopterology.IAlleleButterflyCocoon;
import forestry.api.lepidopterology.IAlleleButterflySpecies;
import forestry.api.modules.ForestryModule;
import forestry.core.ModuleCore;
import forestry.core.config.Constants;
import forestry.core.config.LocalizedConfiguration;
@@ -77,7 +78,6 @@ import forestry.lepidopterology.render.ModelButterflyItem;
import forestry.lepidopterology.tiles.TileCocoon;
import forestry.lepidopterology.worldgen.CocoonDecorator;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@ForestryModule(containerID = Constants.MOD_ID, moduleID = ForestryModuleUids.LEPIDOPTEROLOGY, name = "Lepidopterology", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.module.lepidopterology.description")
+1 -1
View File
@@ -26,6 +26,7 @@ import forestry.api.circuits.ICircuit;
import forestry.api.core.ForestryAPI;
import forestry.api.mail.EnumAddressee;
import forestry.api.mail.PostManager;
import forestry.api.modules.ForestryModule;
import forestry.api.recipes.RecipeManagers;
import forestry.apiculture.ModuleApiculture;
import forestry.apiculture.items.ItemRegistryApiculture;
@@ -47,7 +48,6 @@ import forestry.mail.items.EnumStampDefinition;
import forestry.mail.items.ItemRegistryMail;
import forestry.mail.network.PacketRegistryMail;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@ForestryModule(containerID = Constants.MOD_ID, moduleID = ForestryModuleUids.MAIL, name = "Mail", author = "SirSengir", url = Constants.URL, unlocalizedDescription = "for.module.mail.description")
@@ -2,11 +2,26 @@ package forestry.modules;
import com.google.common.collect.ImmutableSet;
import javax.annotation.Nullable;
import java.util.List;
import java.util.Random;
import java.util.Set;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import forestry.api.modules.ForestryModule;
import forestry.api.modules.IForestryModule;
import forestry.core.IPickupHandler;
import forestry.core.IResupplyHandler;
import forestry.core.ISaveEventHandler;
import forestry.core.config.Constants;
import forestry.core.network.IPacketRegistry;
public class BlankForestryModule implements IForestryModule {
@@ -25,4 +40,43 @@ public class BlankForestryModule implements IForestryModule {
}
return forestryModule.name() + " Module";
}
public boolean processIMCMessage(FMLInterModComms.IMCMessage message){
return false;
}
public void populateChunk(IChunkGenerator chunkGenerator, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated){
}
public void populateChunkRetroGen(World world, Random rand, int chunkX, int chunkZ){
}
public void decorateBiome(World world, Random rand, BlockPos pos){
}
/**
* Can be used to hide items in JEI.
*/
public void getHiddenItems(List<ItemStack> hiddenItems){
}
@Nullable
public ISaveEventHandler getSaveEventHandler(){
return null;
}
@Nullable
public IPacketRegistry getPacketRegistry(){
return null;
}
@Nullable
public IPickupHandler getPickupHandler(){
return null;
}
@Nullable
public IResupplyHandler getResupplyHandler(){
return null;
}
}
@@ -6,6 +6,9 @@ import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import forestry.Forestry;
import forestry.api.modules.ForestryModule;
import forestry.api.modules.IForestryModule;
import forestry.api.modules.IModuleContainer;
import forestry.core.config.Constants;
public class ForestryModules implements IModuleContainer {
@@ -12,6 +12,8 @@ import net.minecraft.util.text.translation.I18n;
import net.minecraftforge.fml.common.discovery.ASMDataTable;
import forestry.api.modules.ForestryModule;
import forestry.api.modules.IForestryModule;
import forestry.core.utils.Log;
public class ForestryPluginUtil {
@@ -1,116 +0,0 @@
package forestry.modules;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
import java.util.Random;
import java.util.Set;
import net.minecraft.command.ICommand;
import net.minecraft.item.ItemStack;
import net.minecraft.util.ResourceLocation;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import net.minecraft.world.gen.IChunkGenerator;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import forestry.core.IPickupHandler;
import forestry.core.IResupplyHandler;
import forestry.core.ISaveEventHandler;
import forestry.core.network.IPacketRegistry;
public interface IForestryModule {
default boolean isAvailable() {
return true;
}
default boolean canBeDisabled() {
return true;
}
default String getFailMessage() {
return "";
}
/**
* The ForestryModule.moduleID()s of any other modules this module depends on.
*/
default Set<ResourceLocation> getDependencyUids(){
return Collections.emptySet();
}
default void setupAPI() {
}
default void disabledSetupAPI() {
}
default void registerItemsAndBlocks() {
}
default void preInit() {
}
default void registerTriggers() {
}
default void registerBackpackItems() {
}
default void registerCrates() {
}
default void doInit() {
}
default void registerRecipes(){
}
default void addLootPoolNames(Set<String> lootPoolNames){
}
default void postInit(){
}
default boolean processIMCMessage(FMLInterModComms.IMCMessage message){
return false;
}
default void populateChunk(IChunkGenerator chunkGenerator, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated){
}
default void populateChunkRetroGen(World world, Random rand, int chunkX, int chunkZ){
}
default void decorateBiome(World world, Random rand, BlockPos pos){
}
default void getHiddenItems(List<ItemStack> hiddenItems){
}
@Nullable
default ISaveEventHandler getSaveEventHandler(){
return null;
}
@Nullable
default IPacketRegistry getPacketRegistry(){
return null;
}
@Nullable
default IPickupHandler getPickupHandler(){
return null;
}
@Nullable
default IResupplyHandler getResupplyHandler(){
return null;
}
@Nullable
default ICommand[] getConsoleCommands(){
return null;
}
}
@@ -46,6 +46,10 @@ import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
import net.minecraftforge.fml.relauncher.Side;
import forestry.api.core.ForestryAPI;
import forestry.api.modules.ForestryModule;
import forestry.api.modules.IForestryModule;
import forestry.api.modules.IModuleContainer;
import forestry.api.modules.IModuleManager;
import forestry.core.IPickupHandler;
import forestry.core.IResupplyHandler;
import forestry.core.ISaveEventHandler;
@@ -53,7 +57,7 @@ import forestry.core.config.Constants;
import forestry.core.network.IPacketRegistry;
import forestry.core.utils.Log;
public class ModuleManager implements IModuleManager{
public class ModuleManager implements IModuleManager {
private static final String CONFIG_CATEGORY = "modules";
private static ModuleManager ourInstance = new ModuleManager();
@@ -64,6 +68,7 @@ public class ModuleManager implements IModuleManager{
private static final HashMap<ResourceLocation, IForestryModule> sortedModules = new LinkedHashMap<>();
private static final Set<IForestryModule> loadedModules = new LinkedHashSet<>();
private static final Set<BlankForestryModule> internalModules = new LinkedHashSet<>();
private static final Set<IForestryModule> unloadedModules = new LinkedHashSet<>();
private static final HashMap<String, IModuleContainer> moduleContainers = new HashMap<>();
public static final Set<IForestryModule> configDisabledModules = new HashSet<>();
@@ -113,7 +118,7 @@ public class ModuleManager implements IModuleManager{
return ImmutableSet.copyOf(sortedModules.values());
}
private static void registerHandlers(IForestryModule module, Side side) {
private static void registerHandlers(BlankForestryModule module, Side side) {
Log.debug("Registering Handlers for Module: {}", module);
IPacketRegistry packetRegistry = module.getPacketRegistry();
@@ -256,6 +261,7 @@ public class ModuleManager implements IModuleManager{
}
loadedModules.addAll(sortedModules.values());
sortedModules.values().stream().filter((m)->m instanceof BlankForestryModule).forEach((IForestryModule m)->internalModules.add((BlankForestryModule) m));
unloadedModules.addAll(allModules);
unloadedModules.removeAll(sortedModules.values());
@@ -301,7 +307,10 @@ public class ModuleManager implements IModuleManager{
stage = Stage.PRE_INIT;
for (IForestryModule module : loadedModules) {
Log.debug("Pre-Init Start: {}", module);
registerHandlers(module, side);
if(module instanceof BlankForestryModule) {
BlankForestryModule moduleInternal = (BlankForestryModule) module;
registerHandlers(moduleInternal, side);
}
module.preInit();
if (getInstance().isModuleEnabled(Constants.MOD_ID, ForestryModuleUids.BUILDCRAFT_STATEMENTS)) {
module.registerTriggers();
@@ -359,7 +368,7 @@ public class ModuleManager implements IModuleManager{
public static void processIMCMessages(ImmutableList<FMLInterModComms.IMCMessage> messages) {
for (FMLInterModComms.IMCMessage message : messages) {
for (IForestryModule module : loadedModules) {
for (BlankForestryModule module : internalModules) {
if (module.processIMCMessage(message)) {
break;
}
@@ -368,19 +377,19 @@ public class ModuleManager implements IModuleManager{
}
public static void populateChunk(IChunkGenerator chunkProvider, World world, Random rand, int chunkX, int chunkZ, boolean hasVillageGenerated) {
for (IForestryModule module : loadedModules) {
for (BlankForestryModule module : internalModules) {
module.populateChunk(chunkProvider, world, rand, chunkX, chunkZ, hasVillageGenerated);
}
}
public static void decorateBiome(World world, Random rand, BlockPos pos) {
for (IForestryModule module : loadedModules) {
for (BlankForestryModule module : internalModules) {
module.decorateBiome(world, rand, pos);
}
}
public static void populateChunkRetroGen(World world, Random rand, int chunkX, int chunkZ) {
for (IForestryModule module : loadedModules) {
for (BlankForestryModule module : internalModules) {
module.populateChunkRetroGen(world, rand, chunkX, chunkZ);
}
}
@@ -388,7 +397,7 @@ public class ModuleManager implements IModuleManager{
public static List<ItemStack> getHiddenItems() {
List<ItemStack> hiddenItems = new ArrayList<>();
for (IForestryModule module : loadedModules) {
for (BlankForestryModule module : internalModules) {
module.getHiddenItems(hiddenItems);
}
return hiddenItems;
@@ -3,11 +3,11 @@ package forestry.plugins;
import net.minecraftforge.common.config.Configuration;
import net.minecraftforge.common.config.Property;
import forestry.modules.ForestryModule;
import forestry.api.modules.ForestryModule;
import forestry.api.modules.IForestryModule;
import forestry.api.modules.IModuleContainer;
import forestry.modules.ForestryModules;
import forestry.modules.ForestryPluginUtil;
import forestry.modules.IForestryModule;
import forestry.modules.IModuleContainer;
public class ForestryCompatPlugins implements IModuleContainer {
private static final String MODULE_CONFIG_FILE_NAME = "modules.cfg";
@@ -13,11 +13,11 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fluids.FluidStack;
import forestry.api.core.ForestryAPI;
import forestry.api.modules.ForestryModule;
import forestry.api.recipes.RecipeManagers;
import forestry.core.config.Constants;
import forestry.core.fluids.Fluids;
import forestry.farming.logic.FarmableAgingCrop;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@SuppressWarnings("unused")
@@ -9,11 +9,11 @@ import net.minecraft.item.ItemStack;
import forestry.api.core.ForestryAPI;
import forestry.api.farming.IFarmRegistry;
import forestry.api.modules.ForestryModule;
import forestry.api.recipes.RecipeManagers;
import forestry.core.config.Constants;
import forestry.core.fluids.Fluids;
import forestry.farming.logic.FarmableDoubleCrop;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@SuppressWarnings("unused")
@@ -25,6 +25,7 @@ import net.minecraftforge.oredict.OreDictionary;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import forestry.api.core.ForestryAPI;
import forestry.api.modules.ForestryModule;
import forestry.api.recipes.RecipeManagers;
import forestry.api.storage.BackpackManager;
import forestry.core.ModuleCore;
@@ -32,7 +33,6 @@ import forestry.core.config.Constants;
import forestry.core.fluids.Fluids;
import forestry.core.recipes.RecipeUtil;
import forestry.core.utils.ItemStackUtil;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@SuppressWarnings("unused")
@@ -10,10 +10,10 @@
******************************************************************************/
package forestry.plugins;
import forestry.api.modules.ForestryModule;
import forestry.core.config.Constants;
import forestry.core.utils.ModUtil;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
// TODO: Buildcraft for 1.9
@@ -12,10 +12,10 @@ package forestry.plugins;
import net.minecraftforge.fml.common.Optional;
import forestry.api.modules.ForestryModule;
import forestry.core.config.Constants;
import forestry.core.utils.ModUtil;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@@ -12,10 +12,10 @@ package forestry.plugins;
import net.minecraftforge.fml.common.Optional;
import forestry.api.modules.ForestryModule;
import forestry.core.config.Constants;
import forestry.core.utils.ModUtil;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@ForestryModule(containerID = ForestryCompatPlugins.ID, moduleID = ForestryModuleUids.BUILDCRAFT_STATEMENTS, name = "BuildCraft 6 Statements", author = "mezz", url = Constants.URL, unlocalizedDescription = "for.module.buildcraft6.description")
@@ -16,13 +16,13 @@ import net.minecraft.util.ResourceLocation;
import net.minecraftforge.fml.common.registry.ForgeRegistries;
import forestry.api.modules.ForestryModule;
import forestry.core.ModuleCore;
import forestry.core.config.Constants;
import forestry.core.recipes.RecipeUtil;
import forestry.core.utils.Log;
import forestry.core.utils.ModUtil;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@ForestryModule(containerID = ForestryCompatPlugins.ID, moduleID = ForestryModuleUids.BUILDCRAFT_TRANSPORT, name = "BuildCraft 6 Transport", author = "mezz", url = Constants.URL, unlocalizedDescription = "for.module.buildcraft6.description")
@@ -14,11 +14,11 @@ import com.google.common.collect.ImmutableList;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import forestry.api.modules.ForestryModule;
import forestry.api.storage.BackpackManager;
import forestry.core.config.Constants;
import forestry.core.utils.ModUtil;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@ForestryModule(containerID = ForestryCompatPlugins.ID, moduleID = ForestryModuleUids.CHISEL, name = "Chisel", author = "Nirek", url = Constants.URL, unlocalizedDescription = "for.module.chisel.description")
@@ -7,11 +7,11 @@ import net.minecraftforge.fluids.Fluid;
import net.minecraftforge.fml.common.event.FMLInterModComms;
import forestry.api.core.ForestryAPI;
import forestry.api.modules.ForestryModule;
import forestry.core.config.Constants;
import forestry.core.fluids.Fluids;
import forestry.core.utils.ModUtil;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@ForestryModule(containerID = ForestryCompatPlugins.ID, moduleID = ForestryModuleUids.ENDER_IO, name = "EnderIO", author = "mezz", url = Constants.URL, unlocalizedDescription = "for.module.enderIO.description")
@@ -26,6 +26,7 @@ import forestry.api.circuits.ChipsetManager;
import forestry.api.circuits.ICircuit;
import forestry.api.circuits.ICircuitLayout;
import forestry.api.core.ForestryAPI;
import forestry.api.modules.ForestryModule;
import forestry.core.ModuleCore;
import forestry.core.circuits.Circuits;
import forestry.core.config.Config;
@@ -39,7 +40,6 @@ import forestry.farming.circuits.CircuitFarmLogic;
import forestry.farming.logic.FarmLogicExU;
import forestry.farming.logic.FarmableAgingCrop;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@SuppressWarnings("unused")
@@ -22,6 +22,7 @@ import forestry.api.core.ForestryAPI;
import forestry.api.farming.IFarmRegistry;
import forestry.api.fuels.FuelManager;
import forestry.api.fuels.MoistenerFuel;
import forestry.api.modules.ForestryModule;
import forestry.api.recipes.RecipeManagers;
import forestry.core.ModuleCore;
import forestry.core.ModuleFluids;
@@ -30,7 +31,6 @@ import forestry.core.fluids.Fluids;
import forestry.core.items.ItemRegistryCore;
import forestry.core.recipes.RecipeUtil;
import forestry.farming.logic.FarmableAgingCrop;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@SuppressWarnings("unused")
@@ -33,6 +33,7 @@ import forestry.api.circuits.ICircuitLayout;
import forestry.api.core.ForestryAPI;
import forestry.api.fuels.EngineBronzeFuel;
import forestry.api.fuels.FuelManager;
import forestry.api.modules.ForestryModule;
import forestry.api.recipes.RecipeManagers;
import forestry.api.storage.BackpackManager;
import forestry.api.storage.ICrateRegistry;
@@ -62,7 +63,6 @@ import forestry.farming.circuits.CircuitFarmLogic;
import forestry.farming.logic.FarmLogicRubber;
import forestry.farming.logic.FarmableBasicIC2Crop;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
import ic2.api.item.IC2Items;
@@ -18,11 +18,11 @@ import forestry.api.core.ForestryAPI;
import forestry.api.farming.IFarmRegistry;
import forestry.api.fuels.FuelManager;
import forestry.api.fuels.GeneratorFuel;
import forestry.api.modules.ForestryModule;
import forestry.api.recipes.RecipeManagers;
import forestry.core.config.Constants;
import forestry.core.fluids.Fluids;
import forestry.farming.logic.FarmableDoubleCrop;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@SuppressWarnings("unused")
@@ -9,11 +9,11 @@ import net.minecraft.util.ResourceLocation;
import forestry.api.core.ForestryAPI;
import forestry.api.farming.IFarmRegistry;
import forestry.api.modules.ForestryModule;
import forestry.api.recipes.RecipeManagers;
import forestry.core.config.Constants;
import forestry.core.fluids.Fluids;
import forestry.farming.logic.FarmableAgingCrop;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@SuppressWarnings("unused")
@@ -36,6 +36,7 @@ import forestry.api.core.ForestryAPI;
import forestry.api.farming.IFarmLogic;
import forestry.api.fuels.FuelManager;
import forestry.api.fuels.MoistenerFuel;
import forestry.api.modules.ForestryModule;
import forestry.api.recipes.RecipeManagers;
import forestry.api.storage.ICrateRegistry;
import forestry.api.storage.StorageManager;
@@ -50,7 +51,6 @@ import forestry.farming.FarmRegistry;
import forestry.farming.logic.FarmableAgingCrop;
import forestry.farming.logic.FarmableSapling;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@SuppressWarnings("unused")
@@ -8,11 +8,11 @@ import net.minecraft.item.ItemStack;
import forestry.api.core.ForestryAPI;
import forestry.api.farming.IFarmRegistry;
import forestry.api.modules.ForestryModule;
import forestry.api.recipes.RecipeManagers;
import forestry.core.config.Constants;
import forestry.core.fluids.Fluids;
import forestry.farming.logic.FarmableAgingCrop;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@SuppressWarnings("unused")
@@ -8,13 +8,13 @@ import net.minecraft.item.ItemStack;
import forestry.api.core.ForestryAPI;
import forestry.api.farming.IFarmRegistry;
import forestry.api.modules.ForestryModule;
import forestry.api.recipes.RecipeManagers;
import forestry.core.config.Constants;
import forestry.core.fluids.Fluids;
import forestry.farming.logic.FarmableAgingCrop;
import forestry.farming.logic.FarmableRusticGrape;
import forestry.farming.logic.FarmableRusticSapling;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
@SuppressWarnings("unused")
@@ -41,6 +41,7 @@ import net.minecraftforge.fml.common.event.FMLInterModComms.IMCMessage;
import forestry.Forestry;
import forestry.api.core.ForestryAPI;
import forestry.api.modules.ForestryModule;
import forestry.api.recipes.RecipeManagers;
import forestry.api.storage.BackpackManager;
import forestry.api.storage.IBackpackDefinition;
@@ -63,7 +64,6 @@ import forestry.core.utils.Translator;
import forestry.lepidopterology.ModuleLepidopterology;
import forestry.lepidopterology.blocks.BlockRegistryLepidopterology;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
import forestry.storage.items.ItemRegistryBackpacks;
@@ -23,11 +23,11 @@ import net.minecraftforge.fml.relauncher.Side;
import net.minecraftforge.fml.relauncher.SideOnly;
import forestry.api.core.ForestryAPI;
import forestry.api.modules.ForestryModule;
import forestry.api.recipes.RecipeManagers;
import forestry.api.storage.StorageManager;
import forestry.core.config.Constants;
import forestry.modules.BlankForestryModule;
import forestry.modules.ForestryModule;
import forestry.modules.ForestryModuleUids;
import forestry.storage.items.ItemCrated;
import forestry.storage.items.ItemRegistryCrates;