mirror of
https://github.com/Ellpeck/NaturesAura.git
synced 2024-11-25 12:58:33 +01:00
made the API instance be set internally
This commit is contained in:
parent
43481bda17
commit
b280ede21e
3 changed files with 12 additions and 18 deletions
|
@ -62,7 +62,6 @@ public final class NaturesAura {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void preInit(FMLCommonSetupEvent event) {
|
private void preInit(FMLCommonSetupEvent event) {
|
||||||
NaturesAuraAPI.setInstance(new InternalHooks());
|
|
||||||
Helper.registerCap(IAuraContainer.class);
|
Helper.registerCap(IAuraContainer.class);
|
||||||
Helper.registerCap(IAuraRecharge.class);
|
Helper.registerCap(IAuraRecharge.class);
|
||||||
Helper.registerCap(IAuraChunk.class);
|
Helper.registerCap(IAuraChunk.class);
|
||||||
|
|
|
@ -20,7 +20,6 @@ import net.minecraft.util.Tuple;
|
||||||
import net.minecraft.util.math.AxisAlignedBB;
|
import net.minecraft.util.math.AxisAlignedBB;
|
||||||
import net.minecraft.util.math.BlockPos;
|
import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.util.math.vector.Vector3d;
|
import net.minecraft.util.math.vector.Vector3d;
|
||||||
import net.minecraft.world.DimensionType;
|
|
||||||
import net.minecraft.world.IWorld;
|
import net.minecraft.world.IWorld;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraftforge.common.capabilities.Capability;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
|
@ -124,28 +123,24 @@ public final class NaturesAuraAPI {
|
||||||
*/
|
*/
|
||||||
@CapabilityInject(IWorldData.class)
|
@CapabilityInject(IWorldData.class)
|
||||||
public static Capability<IWorldData> capWorldData;
|
public static Capability<IWorldData> capWorldData;
|
||||||
private static IInternalHooks instance;
|
private static final IInternalHooks INSTANCE;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
INSTANCE = (IInternalHooks) Class.forName("de.ellpeck.naturesaura.InternalHooks").newInstance();
|
||||||
|
} catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This method returns the active {@link IInternalHooks} instance which can
|
* This method returns the active {@link IInternalHooks} instance which can
|
||||||
* be used to hook into the mod's internal functionalities.This will be
|
* be used to hook into the mod's internal functionalities.
|
||||||
* overriden to a proper implementation. If you want to use this instance,
|
|
||||||
* use it after Nature's Aura's preInit phase.
|
|
||||||
*
|
*
|
||||||
* @return The active {@link IInternalHooks} instance
|
* @return The active {@link IInternalHooks} instance
|
||||||
*/
|
*/
|
||||||
public static IInternalHooks instance() {
|
public static IInternalHooks instance() {
|
||||||
return instance;
|
return INSTANCE;
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This is an internal function. Do not use.
|
|
||||||
*/
|
|
||||||
public static void setInstance(IInternalHooks inst) {
|
|
||||||
if (instance == null)
|
|
||||||
instance = inst;
|
|
||||||
else
|
|
||||||
throw new IllegalStateException();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -14,7 +14,7 @@ import java.util.function.BiConsumer;
|
||||||
/**
|
/**
|
||||||
* A class whose instances hold information about the aura present in any given
|
* A class whose instances hold information about the aura present in any given
|
||||||
* {@link Chunk}. To get an instance for a chunk, use {@link
|
* {@link Chunk}. To get an instance for a chunk, use {@link
|
||||||
* #getAuraChunk(World, BlockPos)}.
|
* #getAuraChunk(IWorld, BlockPos)}.
|
||||||
* <p>
|
* <p>
|
||||||
* It is not intended for API users to create custom implementation of this
|
* It is not intended for API users to create custom implementation of this
|
||||||
* class.
|
* class.
|
||||||
|
|
Loading…
Reference in a new issue