Add IDhApiWorldProxy

This commit is contained in:
James Seibel
2022-11-20 20:39:52 -06:00
parent a935c648e2
commit 1b5a10591b
6 changed files with 215 additions and 3 deletions
@@ -3,6 +3,7 @@ package com.seibel.lod.api;
import com.seibel.lod.api.interfaces.config.IDhApiConfig;
import com.seibel.lod.api.interfaces.override.IDhApiOverrideable;
import com.seibel.lod.api.interfaces.override.worldGenerator.IDhApiWorldGeneratorOverrideRegister;
import com.seibel.lod.api.interfaces.world.IDhApiWorldProxy;
import com.seibel.lod.api.methods.override.DhApiWorldGeneratorOverrideRegister;
import com.seibel.lod.core.DependencyInjection.DhApiEventInjector;
import com.seibel.lod.core.DependencyInjection.OverrideInjector;
@@ -24,7 +25,7 @@ import com.seibel.lod.core.interfaces.dependencyInjection.IOverrideInjector;
* the concrete object we replaced, there would be issues.
*
* @author James Seibel
* @version 2022-11-12
* @version 2022-11-20
*/
public class DhApiMain
{
@@ -52,6 +53,19 @@ public class DhApiMain
*/
public static IDhApiTerrainDataRepo terrainRepo = null;
/**
* <strong>WARNING:</strong> will be null until after DH initializes for the first time. <br><br>
*
* Use a {@link com.seibel.lod.api.methods.events.abstractEvents.DhApiAfterDhInitEvent DhApiAfterDhInitEvent}
* along with the {@link DhApiMain#events ApiCoreInjectors.events} to be notified when this can
* be safely used. <br><br>
*
* Used to interact with Distant Horizons' currently loaded world and
* get levels to use with the {@link DhApiMain#terrainRepo}.
*/
public static IDhApiWorldProxy worldProxy = null;
// always available //
@@ -43,7 +43,7 @@ public interface IDhApiLevelWrapper extends IDhApiUnsafeWrapper
/**
* Returns the lowest possible block position for the level. <br>
* For MC versions before 1.19 this will return 0.
* For MC versions before 1.18 this will return 0.
*/
default int getMinHeight() { return 0; }
@@ -0,0 +1,62 @@
/*
* This file is part of the Distant Horizons mod (formerly the LOD Mod),
* licensed under the GNU LGPL v3 License.
*
* Copyright (C) 2020-2022 James Seibel
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, version 3.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.seibel.lod.api.interfaces.world;
import com.seibel.lod.api.interfaces.IDhApiUnsafeWrapper;
/**
* Used to interact with Distant Horizons current world.
*
* @author James Seibel
* @version 2022-11-20
*/
public interface IDhApiWorldProxy
{
/** Returns true if a world is loaded. */
boolean worldLoaded();
/**
* In singleplayer this will return the level the player is currently in. <br>
* In multiplayer this will return null.
*
* @throws IllegalStateException if no world is loaded
*/
IDhApiLevelWrapper getSinglePlayerLevel() throws IllegalStateException;
/** @throws IllegalStateException if no world is loaded */
Iterable<IDhApiLevelWrapper> getAllLoadedLevelWrappers() throws IllegalStateException;
/**
* In the case of servers running multiverse there may be multiple levels for the same dimensionType.
*
* @throws IllegalStateException if no world is loaded
*/
Iterable<IDhApiLevelWrapper> getAllLoadedLevelsForDimensionType(IDhApiDimensionTypeWrapper dimensionTypeWrapper) throws IllegalStateException;
/**
* Returns any dimensions that have names containing the given string (case-insensitive). <br>
* In the case of servers running multiverse there may be multiple levels for the same dimensionType.
*
* @throws IllegalStateException if no world is loaded
*/
Iterable<IDhApiLevelWrapper> getAllLoadedLevelsWithDimensionNameLike(String dimensionName) throws IllegalStateException;
}