Partially implement/uncomment worldGeneratorOverride
This commit is contained in:
+44
@@ -0,0 +1,44 @@
|
||||
package com.seibel.lod.api.items.interfaces.override;
|
||||
|
||||
import com.seibel.lod.api.items.enums.worldGeneration.EDhApiWorldGenerationStep;
|
||||
import com.seibel.lod.api.items.enums.worldGeneration.EDhApiWorldGenThreadMode;
|
||||
import com.seibel.lod.api.items.interfaces.world.IDhApiChunkWrapper;
|
||||
import com.seibel.lod.api.items.interfaces.world.IDhApiLevelWrapper;
|
||||
import com.seibel.lod.core.api.external.coreImplementations.interfaces.override.worldGenerator.ICoreDhApiWorldGenerator;
|
||||
import com.seibel.lod.core.api.external.coreImplementations.interfaces.wrappers.world.ICoreDhApiLevelWrapper;
|
||||
import com.seibel.lod.core.api.external.coreImplementations.objects.converters.GenericEnumConverter;
|
||||
import com.seibel.lod.core.enums.worldGeneration.EWorldGenThreadMode;
|
||||
import com.seibel.lod.core.enums.worldGeneration.EWorldGenerationStep;
|
||||
import com.seibel.lod.core.wrapperInterfaces.chunk.IChunkWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-9-8
|
||||
*/
|
||||
public abstract class AbstractDhApiWorldGenerator implements ICoreDhApiWorldGenerator, IDhApiOverrideable
|
||||
{
|
||||
private final GenericEnumConverter<EWorldGenThreadMode, EDhApiWorldGenThreadMode> threadModeEnumConverter = new GenericEnumConverter<>(EWorldGenThreadMode.class, EDhApiWorldGenThreadMode.class);
|
||||
private final GenericEnumConverter<EWorldGenerationStep, EDhApiWorldGenerationStep> generationStepEnumConverter = new GenericEnumConverter<>(EWorldGenerationStep.class, EDhApiWorldGenerationStep.class);
|
||||
|
||||
|
||||
/** Returns which thread chunk generation requests can be created on. */
|
||||
public abstract EDhApiWorldGenThreadMode getThreadingMode();
|
||||
|
||||
@Override
|
||||
public EWorldGenThreadMode getCoreThreadingMode()
|
||||
{
|
||||
return threadModeEnumConverter.convertToCoreType(this.getThreadingMode());
|
||||
}
|
||||
|
||||
public abstract IDhApiChunkWrapper generateChunk(int chunkPosX, int chunkPosZ, IDhApiLevelWrapper serverLevelWrapper, EDhApiWorldGenerationStep maxStepToGenerate);
|
||||
|
||||
@Override
|
||||
public final IChunkWrapper generateCoreChunk(int chunkPosX, int chunkPosZ, ICoreDhApiLevelWrapper serverLevelWrapper, EWorldGenerationStep maxStepToGenerate)
|
||||
{
|
||||
// TODO probably need to change the return type
|
||||
return null; //generateChunk(chunkPosX, chunkPosZ, null, generationStepEnumConverter.convertToApiType(maxStepToGenerate));
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
-19
@@ -1,19 +0,0 @@
|
||||
package com.seibel.lod.api.items.interfaces.override;
|
||||
|
||||
import com.seibel.lod.core.api.external.coreImplementations.enums.worldGeneration.EDhApiWorldGenerationStep;
|
||||
import com.seibel.lod.core.api.external.coreImplementations.enums.worldGeneration.EDhApiWorldGenThreadMode;
|
||||
import com.seibel.lod.api.items.interfaces.world.IDhApiChunkWrapper;
|
||||
import com.seibel.lod.api.items.interfaces.world.IDhApiLevelWrapper;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-7-26
|
||||
*/
|
||||
public interface IDhApiWorldGenerator extends IDhApiOverrideable
|
||||
{
|
||||
/** Returns which thread chunk generation requests can be created on. */
|
||||
EDhApiWorldGenThreadMode getThreadingMode();
|
||||
|
||||
IDhApiChunkWrapper generateChunk(int chunkPosX, int chunkPosZ, IDhApiLevelWrapper serverLevelWrapper, EDhApiWorldGenerationStep maxStepToGenerate);
|
||||
|
||||
}
|
||||
+57
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* 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.items.objects.wrappers;
|
||||
|
||||
import com.seibel.lod.api.items.interfaces.IDhApiUnsafeWrapper;
|
||||
import com.seibel.lod.api.items.interfaces.world.IDhApiDimensionTypeWrapper;
|
||||
import com.seibel.lod.core.api.external.coreImplementations.interfaces.wrappers.ICoreDhApiUnsafeWrapper;
|
||||
import com.seibel.lod.core.api.external.coreImplementations.interfaces.wrappers.world.ICoreDhApiDimensionTypeWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.IDimensionTypeWrapper;
|
||||
|
||||
/**
|
||||
* @author James Seibel
|
||||
* @version 2022-9-8
|
||||
*/
|
||||
public class DhApiDimensionTypeWrapper implements IDhApiDimensionTypeWrapper
|
||||
{
|
||||
private final IDimensionTypeWrapper dimensionTypeWrapper;
|
||||
|
||||
|
||||
public DhApiDimensionTypeWrapper(IDimensionTypeWrapper newDimensionTypeWrapper)
|
||||
{
|
||||
this.dimensionTypeWrapper = newDimensionTypeWrapper;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String getDimensionName() { return this.dimensionTypeWrapper.getDimensionName(); }
|
||||
|
||||
@Override
|
||||
public boolean hasCeiling() { return this.dimensionTypeWrapper.hasCeiling(); }
|
||||
|
||||
@Override
|
||||
public boolean hasSkyLight() { return this.dimensionTypeWrapper.hasSkyLight(); }
|
||||
|
||||
|
||||
@Override
|
||||
public Object getWrappedMcObject_UNSAFE() { return this.dimensionTypeWrapper.getWrappedMcObject(); }
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
/*
|
||||
* 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.items.objects.wrappers;
|
||||
|
||||
import com.seibel.lod.api.items.enums.worldGeneration.EDhApiLevelType;
|
||||
import com.seibel.lod.api.items.interfaces.IDhApiUnsafeWrapper;
|
||||
import com.seibel.lod.api.items.interfaces.world.IDhApiDimensionTypeWrapper;
|
||||
import com.seibel.lod.api.items.interfaces.world.IDhApiLevelWrapper;
|
||||
import com.seibel.lod.core.api.external.coreImplementations.interfaces.wrappers.world.ICoreDhApiLevelWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.IClientLevelWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.IDimensionTypeWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.ILevelWrapper;
|
||||
import com.seibel.lod.core.wrapperInterfaces.world.IServerLevelWrapper;
|
||||
|
||||
/**
|
||||
* Can be either a Server or Client level.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-9-8
|
||||
*/
|
||||
public class DhApiLevelWrapper implements IDhApiLevelWrapper
|
||||
{
|
||||
private final ILevelWrapper levelWrapper;
|
||||
private final IDimensionTypeWrapper dimensionTypeWrapper;
|
||||
|
||||
|
||||
public DhApiLevelWrapper(ILevelWrapper newLevelWrapper)
|
||||
{
|
||||
this.levelWrapper = newLevelWrapper;
|
||||
this.dimensionTypeWrapper = this.levelWrapper.getDimensionType();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IDhApiDimensionTypeWrapper getDimensionType() { return new DhApiDimensionTypeWrapper(this.dimensionTypeWrapper); }
|
||||
|
||||
@Override
|
||||
public EDhApiLevelType getLevelType()
|
||||
{
|
||||
if (this.levelWrapper.getClass().isAssignableFrom(IClientLevelWrapper.class))
|
||||
{
|
||||
return EDhApiLevelType.CLIENT_LEVEL;
|
||||
}
|
||||
else if (this.levelWrapper.getClass().isAssignableFrom(IServerLevelWrapper.class))
|
||||
{
|
||||
return EDhApiLevelType.CLIENT_LEVEL;
|
||||
}
|
||||
else
|
||||
{
|
||||
// shouldn't normally happen, but just in case
|
||||
return EDhApiLevelType.UNKNOWN;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasCeiling() { return this.levelWrapper.hasCeiling(); }
|
||||
|
||||
@Override
|
||||
public boolean hasSkyLight() { return this.levelWrapper.hasSkyLight(); }
|
||||
|
||||
@Override
|
||||
public int getHeight() { return this.levelWrapper.getHeight(); }
|
||||
|
||||
@Override
|
||||
public int getMinHeight() { return this.levelWrapper.getMinHeight(); }
|
||||
|
||||
|
||||
@Override
|
||||
public Object getWrappedMcObject_UNSAFE() { return this.levelWrapper.unwrapLevel(); }
|
||||
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.seibel.lod.api.methods.events;
|
||||
|
||||
import com.seibel.lod.api.items.objects.DhApiResult;
|
||||
import com.seibel.lod.core.api.external.coreImplementations.interfaces.events.ICoreDhApiEvent;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.DhApiEventInjector;
|
||||
|
||||
@@ -7,44 +8,44 @@ import com.seibel.lod.core.handlers.dependencyInjection.DhApiEventInjector;
|
||||
* Handles adding/removing event handlers.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-7-16
|
||||
* @version 2022-9-8
|
||||
*/
|
||||
public class DhApiEventRegister
|
||||
{
|
||||
// /**
|
||||
// * Registers the given event handler. <Br>
|
||||
// * Only one eventHandler of a specific class can be registered at a time.
|
||||
// * If multiple of the same eventHandler are added DhApiResult will return
|
||||
// * the name of the already added handler and success = false.
|
||||
// */
|
||||
// public static DhApiResult on(Class<? extends ICoreDhApiEvent> eventInterface, ICoreDhApiEvent eventHandlerImplementation)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// DhApiEventInjector.INSTANCE.bind(eventInterface, eventHandlerImplementation);
|
||||
// return DhApiResult.createSuccess();
|
||||
// }
|
||||
// catch (IllegalStateException e)
|
||||
// {
|
||||
// return DhApiResult.createFail(e.getMessage());
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * Unregisters the given event handler for this event if one has been registered. <br>
|
||||
// * If no eventHandler of the given class has been registered the result will return
|
||||
// * success = false.
|
||||
// */
|
||||
// public static DhApiResult off(Class<? extends ICoreDhApiEvent> eventInterface, Class<ICoreDhApiEvent> eventHandlerClass)
|
||||
// {
|
||||
// if (DhApiEventInjector.INSTANCE.unbind(eventInterface, eventHandlerClass))
|
||||
// {
|
||||
// return DhApiResult.createSuccess();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// return DhApiResult.createFail("No event handler [" + eventHandlerClass.getSimpleName() + "] was bound for the event [" + eventInterface.getSimpleName() + "].");
|
||||
// }
|
||||
// }
|
||||
/**
|
||||
* Registers the given event handler. <Br>
|
||||
* Only one eventHandler of a specific class can be registered at a time.
|
||||
* If multiple of the same eventHandler are added DhApiResult will return
|
||||
* the name of the already added handler and success = false.
|
||||
*/
|
||||
public static DhApiResult on(Class<? extends ICoreDhApiEvent> eventInterface, ICoreDhApiEvent eventHandlerImplementation)
|
||||
{
|
||||
try
|
||||
{
|
||||
DhApiEventInjector.INSTANCE.bind(eventInterface, eventHandlerImplementation);
|
||||
return DhApiResult.createSuccess();
|
||||
}
|
||||
catch (IllegalStateException e)
|
||||
{
|
||||
return DhApiResult.createFail(e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters the given event handler for this event if one has been registered. <br>
|
||||
* If no eventHandler of the given class has been registered the result will return
|
||||
* success = false.
|
||||
*/
|
||||
public static DhApiResult off(Class<? extends ICoreDhApiEvent> eventInterface, Class<ICoreDhApiEvent> eventHandlerClass)
|
||||
{
|
||||
if (DhApiEventInjector.INSTANCE.unbind(eventInterface, eventHandlerClass))
|
||||
{
|
||||
return DhApiResult.createSuccess();
|
||||
}
|
||||
else
|
||||
{
|
||||
return DhApiResult.createFail("No event handler [" + eventHandlerClass.getSimpleName() + "] was bound for the event [" + eventInterface.getSimpleName() + "].");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,15 +1,15 @@
|
||||
package com.seibel.lod.api.override;
|
||||
|
||||
import com.seibel.lod.api.items.interfaces.override.IDhApiWorldGenerator;
|
||||
import com.seibel.lod.api.items.interfaces.world.IDhApiLevelWrapper;
|
||||
import com.seibel.lod.api.items.objects.DhApiResult;
|
||||
import com.seibel.lod.core.api.external.coreImplementations.interfaces.override.worldGenerator.ICoreDhApiWorldGenerator;
|
||||
import com.seibel.lod.core.handlers.dependencyInjection.WorldGeneratorInjector;
|
||||
|
||||
/**
|
||||
* Handles adding world generator overrides.
|
||||
*
|
||||
* @author James Seibel
|
||||
* @version 2022-8-15
|
||||
* @version 2022-9-8
|
||||
*/
|
||||
public class DhApiWorldGeneratorOverrideRegister
|
||||
{
|
||||
@@ -21,11 +21,11 @@ public class DhApiWorldGeneratorOverrideRegister
|
||||
* If another world generator has already been registered, DhApiResult will return
|
||||
* the name of the previously registered generator and success = false.
|
||||
*/
|
||||
public static DhApiResult registerWorldGeneratorOverride(IDhApiWorldGenerator worldGenerator)
|
||||
public static DhApiResult registerWorldGeneratorOverride(ICoreDhApiWorldGenerator worldGenerator)
|
||||
{
|
||||
try
|
||||
{
|
||||
// WorldGeneratorInjector.INSTANCE.bind(worldGenerator);
|
||||
WorldGeneratorInjector.INSTANCE.bind(worldGenerator);
|
||||
return DhApiResult.createSuccess();
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -41,7 +41,7 @@ public class DhApiWorldGeneratorOverrideRegister
|
||||
* If another world generator has already been registered, DhApiResult will return
|
||||
* the name of the previously registered generator and success = false.
|
||||
*/
|
||||
public static DhApiResult registerWorldGeneratorOverride(IDhApiLevelWrapper levelWrapper, IDhApiWorldGenerator worldGenerator)
|
||||
public static DhApiResult registerWorldGeneratorOverride(IDhApiLevelWrapper levelWrapper, ICoreDhApiWorldGenerator worldGenerator)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user