mirror of
https://github.com/GTNewHorizons/ForestryMC.git
synced 2026-11-22 12:59:44 +00:00
Add PreInit Event to the Api
This commit is contained in:
1 parent
5df7b9252b
commit
db49d305f4
4 files changed
+31
-6
No files matched your search
@@ -32,6 +32,7 @@ import net.minecraftforge.fml.common.network.NetworkRegistry;
|
||||
import net.minecraftforge.fml.common.registry.GameRegistry;
|
||||
|
||||
import forestry.api.core.ForestryAPI;
|
||||
import forestry.api.core.ForestryEvent;
|
||||
import forestry.core.EventHandlerCore;
|
||||
import forestry.core.climate.ClimateStates;
|
||||
import forestry.core.config.Config;
|
||||
@@ -104,6 +105,8 @@ public class Forestry {
|
||||
configFolder = new File(event.getModConfigurationDirectory(), Constants.MOD_ID);
|
||||
Config.load(event.getSide());
|
||||
|
||||
MinecraftForge.EVENT_BUS.post(new ForestryEvent.PreInit(this, event));
|
||||
|
||||
PluginManager.runSetup(event);
|
||||
|
||||
String gameMode = Config.gameMode;
|
||||
|
||||
@@ -5,13 +5,17 @@
|
||||
******************************************************************************/
|
||||
package forestry.api.core;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
|
||||
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
import forestry.api.genetics.IAlleleSpecies;
|
||||
import forestry.api.genetics.IBreedingTracker;
|
||||
import forestry.api.genetics.IMutation;
|
||||
import forestry.api.genetics.ISpeciesRoot;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraftforge.fml.common.eventhandler.Event;
|
||||
|
||||
public abstract class ForestryEvent extends Event {
|
||||
|
||||
@@ -53,6 +57,21 @@ public abstract class ForestryEvent extends Event {
|
||||
this.tracker = tracker;
|
||||
this.player = player;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Posted before forestry registers all items and blocks.
|
||||
*/
|
||||
public static class PreInit extends ForestryEvent{
|
||||
/**
|
||||
* The main mod instance for Forestry.
|
||||
*/
|
||||
public Object instance;
|
||||
public final FMLPreInitializationEvent event;
|
||||
|
||||
public PreInit(Object instance, FMLPreInitializationEvent event) {
|
||||
this.instance = instance;
|
||||
this.event = event;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -5,10 +5,11 @@
|
||||
******************************************************************************/
|
||||
@ParametersAreNonnullByDefault
|
||||
@MethodsReturnNonnullByDefault
|
||||
@API(apiVersion = "5.1.0", owner = "Forestry", provides = "ForestryAPI|core")
|
||||
@API(apiVersion = "5.2.0", owner = "Forestry", provides = "ForestryAPI|core")
|
||||
package forestry.api.core;
|
||||
|
||||
import javax.annotation.ParametersAreNonnullByDefault;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
import net.minecraftforge.fml.common.API;
|
||||
|
||||
import mcp.MethodsReturnNonnullByDefault;
|
||||
+4
-2
@@ -50,8 +50,8 @@ import forestry.greenhouse.network.packets.PacketGreenhouseData;
|
||||
|
||||
public class GreenhouseProviderServer extends GreenhouseProvider {
|
||||
private static final List<IGreenhouseBlockHandler> HANDLERS = new ArrayList<>();
|
||||
private static final int TIME_BETWEEN_UPDATES = 25;
|
||||
private static final int UPDATE_DELAY = 50;
|
||||
private static final int TIME_BETWEEN_UPDATES = 75;
|
||||
private static final int UPDATE_DELAY = 150;
|
||||
|
||||
private final Set<Long> unloadedChunks;
|
||||
|
||||
@@ -231,6 +231,7 @@ public class GreenhouseProviderServer extends GreenhouseProvider {
|
||||
IErrorState errorState = handler.checkNeighborBlocks(storage, blockToCheck, newBlocksToCheck);
|
||||
if (errorState != null) {
|
||||
errorLogic.setCondition(true, errorState);
|
||||
break;
|
||||
}
|
||||
blocksToCheck.addAll(newBlocksToCheck);
|
||||
if (blockToCheck instanceof IBlankBlock) {
|
||||
@@ -239,6 +240,7 @@ public class GreenhouseProviderServer extends GreenhouseProvider {
|
||||
if (positionHeight == -1) {
|
||||
errorLogic.setCondition(true, EnumErrorCode.NOT_CLOSED);
|
||||
//throw new GreenhouseException(Translator.translateToLocalFormatted("for.multiblock.greenhouse.error.roof.notclosed", position.getX(), position.getY(), position.getZ())).setPos(position);
|
||||
break;
|
||||
}
|
||||
if (positionHeight > greenhouseHeight) {
|
||||
greenhouseHeight = positionHeight;
|
||||
|
||||
Reference in new issue
Block a user