mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-10-26 05:50:39 +00:00
Structure Hooks
This commit is contained in:
1 parent
6c5e991051
commit
986c7f12cd
5 files changed
+132
-1
No files matched your search
@@ -21,6 +21,7 @@ package art.arcane.iris.engine.framework;
|
|||||||
import art.arcane.iris.core.loader.IrisData;
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
import art.arcane.iris.core.nms.INMS;
|
import art.arcane.iris.core.nms.INMS;
|
||||||
import art.arcane.iris.engine.object.IrisWorld;
|
import art.arcane.iris.engine.object.IrisWorld;
|
||||||
|
import art.arcane.iris.spi.IrisPlatforms;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
@@ -112,7 +113,7 @@ public final class StructureReachability {
|
|||||||
possible.add(key.toLowerCase());
|
possible.add(key.toLowerCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (String biomeKey : INMS.get().getStructureBiomeKeys(structureKey)) {
|
for (String biomeKey : IrisPlatforms.get().structureHooks().structureBiomeKeys(structureKey)) {
|
||||||
if (biomeKey != null && !possible.contains(biomeKey.toLowerCase())) {
|
if (biomeKey != null && !possible.contains(biomeKey.toLowerCase())) {
|
||||||
missing.add(biomeKey);
|
missing.add(biomeKey);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ import art.arcane.iris.spi.LogLevel;
|
|||||||
import art.arcane.iris.spi.PlatformCapabilities;
|
import art.arcane.iris.spi.PlatformCapabilities;
|
||||||
import art.arcane.iris.spi.PlatformRegistries;
|
import art.arcane.iris.spi.PlatformRegistries;
|
||||||
import art.arcane.iris.spi.PlatformScheduler;
|
import art.arcane.iris.spi.PlatformScheduler;
|
||||||
|
import art.arcane.iris.spi.PlatformStructureHooks;
|
||||||
|
import art.arcane.iris.spi.PlatformWorld;
|
||||||
import art.arcane.iris.util.common.scheduling.J;
|
import art.arcane.iris.util.common.scheduling.J;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@@ -44,6 +46,11 @@ public final class BukkitPlatform implements IrisPlatform {
|
|||||||
private final BukkitRegistries registries = new BukkitRegistries();
|
private final BukkitRegistries registries = new BukkitRegistries();
|
||||||
private final BukkitScheduler scheduler = new BukkitScheduler();
|
private final BukkitScheduler scheduler = new BukkitScheduler();
|
||||||
private final PlatformCapabilities capabilities = new BukkitCapabilities();
|
private final PlatformCapabilities capabilities = new BukkitCapabilities();
|
||||||
|
private final BukkitStructureHooks structureHooks = new BukkitStructureHooks();
|
||||||
|
|
||||||
|
public static World unwrapWorld(PlatformWorld world) {
|
||||||
|
return (World) world.nativeHandle();
|
||||||
|
}
|
||||||
|
|
||||||
public static Class<?> classifyMantleValue(Object value) {
|
public static Class<?> classifyMantleValue(Object value) {
|
||||||
if (value instanceof World) {
|
if (value instanceof World) {
|
||||||
@@ -104,6 +111,11 @@ public final class BukkitPlatform implements IrisPlatform {
|
|||||||
return capabilities;
|
return capabilities;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PlatformStructureHooks structureHooks() {
|
||||||
|
return structureHooks;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public File dataFolder() {
|
public File dataFolder() {
|
||||||
return Iris.instance.getDataFolder();
|
return Iris.instance.getDataFolder();
|
||||||
|
|||||||
@@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
|
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package art.arcane.iris.platform.bukkit;
|
||||||
|
|
||||||
|
import art.arcane.iris.core.nms.INMS;
|
||||||
|
import art.arcane.iris.spi.PlatformStructureHooks;
|
||||||
|
import art.arcane.iris.spi.PlatformWorld;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Bukkit adapter for structure and feature hooks backed by the active NMS binding.
|
||||||
|
*/
|
||||||
|
public final class BukkitStructureHooks implements PlatformStructureHooks {
|
||||||
|
@Override
|
||||||
|
public List<String> structureKeys() {
|
||||||
|
return new ArrayList<>(INMS.get().getStructureKeys());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> structureSetKeys() {
|
||||||
|
return new ArrayList<>(INMS.get().getStructureSetKeys());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> structureBiomeKeys(String structureKey) {
|
||||||
|
return new ArrayList<>(INMS.get().getStructureBiomeKeys(structureKey));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> objectFeatureKeys() {
|
||||||
|
return new ArrayList<>(INMS.get().getObjectFeatureKeys());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean placeFeature(PlatformWorld world, int x, int y, int z, String featureKey, long seed) {
|
||||||
|
return INMS.get().placeFeature(BukkitPlatform.unwrapWorld(world), x, y, z, featureKey, seed);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int[] placeStructure(PlatformWorld world, int chunkX, int chunkZ, String structureKey, long seed, int maxSpan) {
|
||||||
|
return INMS.get().placeStructure(BukkitPlatform.unwrapWorld(world), chunkX, chunkZ, structureKey, seed, maxSpan);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supportsStructurePlacement() {
|
||||||
|
Class<?> type = INMS.get().getClass();
|
||||||
|
while (type != null && type != Object.class) {
|
||||||
|
for (Method method : type.getDeclaredMethods()) {
|
||||||
|
if ("placeStructure".equals(method.getName())) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
type = type.getSuperclass();
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -34,6 +34,8 @@ public interface IrisPlatform {
|
|||||||
|
|
||||||
PlatformCapabilities capabilities();
|
PlatformCapabilities capabilities();
|
||||||
|
|
||||||
|
PlatformStructureHooks structureHooks();
|
||||||
|
|
||||||
File dataFolder();
|
File dataFolder();
|
||||||
|
|
||||||
void dispatchConsoleCommand(String command);
|
void dispatchConsoleCommand(String command);
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* Iris is a World Generator for Minecraft Bukkit Servers
|
||||||
|
* Copyright (c) 2026 Arcane Arts (Volmit Software)
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* 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 General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package art.arcane.iris.spi;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Neutral access to the host platform's structure, structure-set and configured-feature registries plus placement entry points.
|
||||||
|
*/
|
||||||
|
public interface PlatformStructureHooks {
|
||||||
|
List<String> structureKeys();
|
||||||
|
|
||||||
|
List<String> structureSetKeys();
|
||||||
|
|
||||||
|
List<String> structureBiomeKeys(String structureKey);
|
||||||
|
|
||||||
|
List<String> objectFeatureKeys();
|
||||||
|
|
||||||
|
boolean placeFeature(PlatformWorld world, int x, int y, int z, String featureKey, long seed);
|
||||||
|
|
||||||
|
int[] placeStructure(PlatformWorld world, int chunkX, int chunkZ, String structureKey, long seed, int maxSpan);
|
||||||
|
|
||||||
|
boolean supportsStructurePlacement();
|
||||||
|
}
|
||||||
Reference in new issue
Block a user