Put IrisApi on the modded adapters' classpath

The fabric, forge and neoforge builds resolved neither core's dependencies on
IrisApi nor the IrisApi types the adapters read (ResourceId, BlockTurn), so
none of them compiled. They apply the IrisApi source resolution like the root
build and compile against iris-api. NativeStructureReferenceRepairTest drops
the placement identity argument that NativeStructureStartPlan lost in batch 6.
This commit is contained in:
piexel committed 2026-10-28 03:29:45 +01:00
1 parent fe730fc8bd
commit 3e8c22422f
25 files changed
+15 -1310

No files matched your search

@@ -1,74 +0,0 @@
/*
* Iris is a World Generator for Minecraft 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.core.modules;
import art.arcane.iris.builtin.objects.ObjectPlacement;
import com.google.gson.Gson;
import com.google.gson.JsonElement;
import com.google.gson.TypeAdapter;
import com.google.gson.TypeAdapterFactory;
import com.google.gson.reflect.TypeToken;
import com.google.gson.stream.JsonReader;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.function.Supplier;
/**
* Reads the object placements an Iris resource nests, such as a mod's placement injectors, the way {@code iris:objects}
* reads its own: with the modules' Gson, keeping the JSON that declares the placement's module settings. Register it
* before the factory that resolves snippets: Gson asks later registrations first, so that factory reads a snippet
* reference and this one decodes the snippet's JSON.
*/
public final class ObjectPlacementSettingsReader implements TypeAdapterFactory {
private final Supplier<ModuleSettingsDecoder> decoder;
/** {@code decoder} is asked for on the first placement read, so reading no placement loads no modules. */
public ObjectPlacementSettingsReader(Supplier<ModuleSettingsDecoder> decoder) {
this.decoder = decoder;
}
@Override
@SuppressWarnings("unchecked") // The type is checked to be ObjectPlacement.
public <T> TypeAdapter<T> create(Gson gson, TypeToken<T> type) {
if (type.getRawType() != ObjectPlacement.class) {
return null;
}
TypeAdapter<JsonElement> elements = gson.getAdapter(JsonElement.class);
return (TypeAdapter<T>) new TypeAdapter<ObjectPlacement>() {
@Override
public void write(JsonWriter out, ObjectPlacement placement) throws IOException {
if (placement == null || placement.json() == null) {
out.nullValue();
return;
}
out.jsonValue(placement.json());
}
@Override
public ObjectPlacement read(JsonReader in) throws IOException {
JsonElement json = elements.read(in);
if (json == null || json.isJsonNull()) {
return null;
}
return decoder.get().decodeResource(ObjectPlacement.class, json.toString());
}
};
}
}
@@ -1,98 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.core.pack;
import art.arcane.volmlib.util.json.JSONObject;
import java.io.File;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
final class PackCaveProfileValidator {
private static final String CAVE_PROFILE_SNIPPET_FOLDER = "snippet/iris/carve/cave-profile";
private static final List<LegacyField> LEGACY_FIELDS = List.of(
new LegacyField("allowWater", "allowFluid"),
new LegacyField("waterMinDepthBelowSurface", "fluidMinDepthBelowSurface"),
new LegacyField("waterRequiresFloor", "fluidRequiresFloor")
);
private PackCaveProfileValidator() {
}
static List<String> validateLegacyFields(File packFolder) {
List<String> blockingErrors = new ArrayList<>();
if (packFolder == null || !packFolder.isDirectory()) {
return blockingErrors;
}
for (String folderName : PackValidator.STRUCTURE_HOST_FOLDERS) {
File resourceFolder = new File(packFolder, folderName);
if (!resourceFolder.isDirectory()) {
continue;
}
List<File> resourceFiles = PackValidationIo.listJsonRecursive(resourceFolder);
resourceFiles.sort(Comparator.comparing(File::getPath));
String resourceType = PackStructurePlacementValidator.structureHostType(folderName);
for (File resourceFile : resourceFiles) {
JSONObject resource = PackValidationIo.readJson(resourceFile);
if (resource == null) {
continue;
}
JSONObject caveProfile = resource.optJSONObject("caveProfile");
if (caveProfile == null) {
continue;
}
String resourceKey = PackValidationIo.deriveKey(resourceFolder, resourceFile);
validateFields(resourceType + " '" + resourceKey + "' caveProfile.", "caveProfile.", caveProfile,
blockingErrors);
}
}
File snippetFolder = new File(packFolder, CAVE_PROFILE_SNIPPET_FOLDER);
if (!snippetFolder.isDirectory()) {
return blockingErrors;
}
List<File> snippetFiles = PackValidationIo.listJsonRecursive(snippetFolder);
snippetFiles.sort(Comparator.comparing(File::getPath));
for (File snippetFile : snippetFiles) {
JSONObject caveProfile = PackValidationIo.readJson(snippetFile);
if (caveProfile == null) {
continue;
}
String snippetKey = PackValidationIo.deriveKey(snippetFolder, snippetFile);
validateFields("Cave-profile snippet '" + snippetKey + "' ", "", caveProfile, blockingErrors);
}
return blockingErrors;
}
private static void validateFields(String location, String replacementPrefix, JSONObject caveProfile,
List<String> blockingErrors) {
for (LegacyField field : LEGACY_FIELDS) {
if (caveProfile.has(field.oldName())) {
blockingErrors.add(location + field.oldName() + " was removed; use " + replacementPrefix
+ field.newName()
+ ". Cave aquifers use the dimension fluidPalette, which defaults to water.");
}
}
}
private record LegacyField(String oldName, String newName) {
}
}
@@ -1,158 +0,0 @@
package art.arcane.iris.engine.framework.placer;
import art.arcane.iris.platform.bukkit.BukkitBlockResolution;
import art.arcane.iris.core.loader.IrisData;
import art.arcane.iris.core.tools.IrisToolbelt;
import art.arcane.iris.engine.framework.Engine;
import art.arcane.iris.core.events.InventorySlotType;
import art.arcane.iris.core.events.IrisLootEvent;
import art.arcane.iris.engine.mantle.EngineMantle;
import art.arcane.iris.engine.platform.EngineBukkitOps;
import art.arcane.iris.engine.platform.PlatformChunkGenerator;
import art.arcane.iris.engine.object.placement.IObjectPlacer;
import art.arcane.iris.engine.object.prefab.TileData;
import art.arcane.iris.platform.bukkit.BukkitBlockState;
import art.arcane.iris.spi.IrisLogging;
import art.arcane.iris.spi.PlatformBlockState;
import art.arcane.iris.util.common.scheduling.J;
import art.arcane.volmlib.util.collection.KList;
import com.volmit.service.Loot;
import art.arcane.iris.util.common.data.IrisCustomData;
import art.arcane.volmlib.util.math.RNG;
import art.arcane.volmlib.util.matter.MatterCavern;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.inventory.InventoryHolder;
@Getter
@EqualsAndHashCode(exclude = {"engine", "mantle"})
public class WorldObjectPlacer implements IObjectPlacer {
private final World world;
private final Engine engine;
private final EngineMantle mantle;
public WorldObjectPlacer(World world) {
PlatformChunkGenerator a = IrisToolbelt.access(world);
if (a == null || a.getEngine() == null) throw new IllegalStateException(world.getName() + " is not an Iris World!");
this.world = world;
this.engine = a.getEngine();
this.mantle = engine.getMantle();
}
@Override
public int getHighest(int x, int z, IrisData data) {
return mantle.getHighest(x, z, data);
}
@Override
public int getHighest(int x, int z, IrisData data, boolean ignoreFluid) {
return mantle.getHighest(x, z, data, ignoreFluid);
}
@Override
public void set(int x, int y, int z, PlatformBlockState state) {
BlockData d = (BlockData) state.nativeHandle();
int worldY = y + world.getMinHeight();
if (worldY < world.getMinHeight() || worldY >= world.getMaxHeight()) return;
Block block = world.getBlockAt(x, worldY, z);
if (block.getType() == Material.BEDROCK) return;
boolean storageChest = BukkitBlockResolution.isStorageChest(d);
if (d instanceof IrisCustomData data) {
block.setBlockData(data.getBase(), false);
// Reached per block for every custom block in the pack; the pack is what needs changing, and
// one statement of that is enough.
IrisLogging.warnOnce("custom-block-placer", "Tried to place custom block at " + x + ", " + y + ", " + z + " which is not supported.");
} else block.setBlockData(d, false);
if (storageChest && !J.runRegion(world, x >> 4, z >> 4, () -> fillLoot(block), 1)) {
IrisLogging.warn("Failed to schedule loot resolution at " + x + ", " + worldY + ", " + z);
}
}
private void fillLoot(Block block) {
if (!BukkitBlockResolution.isStorageChest(block.getBlockData()) || !EngineBukkitOps.isCanonicalContainer(block)) {
return;
}
int x = block.getX();
int y = block.getY();
int z = block.getZ();
KList<Loot.Source> tables = EngineBukkitOps.getLootTables(engine, block);
try {
Bukkit.getPluginManager().callEvent(new IrisLootEvent(engine, block, InventorySlotType.STORAGE, tables));
if (tables.isEmpty()) {
return;
}
InventoryHolder holder = (InventoryHolder) block.getState();
EngineBukkitOps.addItems(engine, false, holder.getInventory(), tables, world, x, y, z);
} catch (Throwable e) {
IrisLogging.reportError(e);
}
}
@Override
public PlatformBlockState get(int x, int y, int z) {
return BukkitBlockState.of(world.getBlockAt(x, y + world.getMinHeight(), z).getBlockData());
}
@Override
public boolean isPreventingDecay() {
return mantle.isPreventingDecay();
}
@Override
public boolean isCarved(int x, int y, int z) {
return mantle.getMantle().get(x, y, z, MatterCavern.class) != null;
}
@Override
public boolean isSurfaceSolid(int x, int y, int z) {
return isSolid(x, y, z);
}
@Override
public boolean isSolid(int x, int y, int z) {
return world.getBlockAt(x, y + world.getMinHeight(), z).getType().isSolid();
}
@Override
public boolean isUnderwater(int x, int z) {
return mantle.isUnderwater(x, z);
}
@Override
public int getFluidHeight() {
return mantle.getFluidHeight();
}
@Override
public void setTile(int xx, int yy, int zz, TileData tile) {
int worldY = yy + world.getMinHeight();
if (worldY < world.getMinHeight() || worldY >= world.getMaxHeight()) return;
tile.toBukkitTry(world.getBlockAt(xx, worldY, zz));
}
@Override
public <T> void setData(int xx, int yy, int zz, T data) {
if (data == null || yy < 0 || yy >= engine.getHeight()) {
return;
}
mantle.getMantle().set(xx, yy, zz, data);
}
@Override
public <T> T getData(int xx, int yy, int zz, Class<T> t) {
if (yy < 0 || yy >= engine.getHeight()) {
return null;
}
return mantle.getMantle().get(xx, yy, zz, t);
}
}
@@ -1,115 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.engine.object.mod;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.region.IrisRegion;
import art.arcane.iris.core.loader.IrisRegistrant;
import art.arcane.iris.engine.object.annotations.ArrayType;
import art.arcane.iris.engine.object.annotations.Desc;
import art.arcane.iris.engine.object.annotations.MaxNumber;
import art.arcane.iris.engine.object.annotations.MinNumber;
import art.arcane.iris.engine.object.annotations.RegistryListResource;
import art.arcane.iris.engine.object.annotations.Required;
import art.arcane.volmlib.util.collection.KList;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Accessors(chain = true)
@AllArgsConstructor
@NoArgsConstructor
@Desc("Represents a pack modification schema")
@Data
@EqualsAndHashCode(callSuper = false)
public class IrisMod extends IrisRegistrant {
@MinNumber(2)
@Required
@Desc("The human-readable name of this pack modification")
private String name = "A Pack Modification";
@Desc("The optional dimension load key this modification targets. An empty value does not restrict the target.")
private String forDimension = "";
@MinNumber(-1)
@MaxNumber(512)
@Desc("Override the fluid height. Otherwise set it to -1")
private int overrideFluidHeight = -1;
@Desc("A list of biomes to remove")
@RegistryListResource(IrisBiome.class)
@ArrayType(type = String.class, min = 1)
private KList<String> removeBiomes = new KList<>();
@Desc("A list of objects to remove")
@RegistryListResource(IrisObject.class)
@ArrayType(type = String.class, min = 1)
private KList<String> removeObjects = new KList<>();
@Desc("A list of regions to remove")
@RegistryListResource(IrisRegion.class)
@ArrayType(type = String.class, min = 1)
private KList<String> removeRegions = new KList<>();
@Desc("A list of regions to inject")
@RegistryListResource(IrisRegion.class)
@ArrayType(type = String.class, min = 1)
private KList<String> injectRegions = new KList<>();
@ArrayType(min = 1, type = IrisModBiomeInjector.class)
@Desc("Inject biomes into existing regions")
private KList<IrisModBiomeInjector> biomeInjectors = new KList<>();
@ArrayType(min = 1, type = IrisModBiomeReplacer.class)
@Desc("Replace biomes with other biomes")
private KList<IrisModBiomeReplacer> biomeReplacers = new KList<>();
@ArrayType(min = 1, type = IrisModObjectReplacer.class)
@Desc("Replace objects with other objects")
private KList<IrisModObjectReplacer> objectReplacers = new KList<>();
@ArrayType(min = 1, type = IrisModObjectPlacementBiomeInjector.class)
@Desc("Inject placers into existing biomes")
private KList<IrisModObjectPlacementBiomeInjector> biomeObjectPlacementInjectors = new KList<>();
@ArrayType(min = 1, type = IrisModObjectPlacementRegionInjector.class)
@Desc("Inject placers into existing regions")
private KList<IrisModObjectPlacementRegionInjector> regionObjectPlacementInjectors = new KList<>();
@ArrayType(min = 1, type = IrisModRegionReplacer.class)
@Desc("Replace regions with other regions")
private KList<IrisModRegionReplacer> regionReplacers = new KList<>();
@ArrayType(min = 1, type = IrisModNoiseStyleReplacer.class)
@Desc("Replace noise styles with other styles")
private KList<IrisModNoiseStyleReplacer> styleReplacers = new KList<>();
@Override
public String getFolderName() {
return "mods";
}
@Override
public String getTypeName() {
return "Mod";
}
}
@@ -1,51 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.engine.object.mod;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.world.region.IrisRegion;
import art.arcane.iris.engine.object.annotations.ArrayType;
import art.arcane.iris.engine.object.annotations.Desc;
import art.arcane.iris.engine.object.annotations.RegistryListResource;
import art.arcane.iris.engine.object.annotations.Required;
import art.arcane.iris.engine.object.annotations.Snippet;
import art.arcane.volmlib.util.collection.KList;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("biome-injector")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("A biome injector")
@Data
public class IrisModBiomeInjector {
@Required
@Desc("The region to find")
@RegistryListResource(IrisRegion.class)
private String region = "";
@Required
@Desc("A biome to inject into the region")
@RegistryListResource(IrisBiome.class)
@ArrayType(type = String.class, min = 1)
private KList<String> inject = new KList<>();
}
@@ -1,50 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.engine.object.mod;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.annotations.ArrayType;
import art.arcane.iris.engine.object.annotations.Desc;
import art.arcane.iris.engine.object.annotations.RegistryListResource;
import art.arcane.iris.engine.object.annotations.Required;
import art.arcane.iris.engine.object.annotations.Snippet;
import art.arcane.volmlib.util.collection.KList;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("biome-replacer")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("A biome replacer")
@Data
public class IrisModBiomeReplacer {
@Required
@Desc("A list of biomes to find")
@RegistryListResource(IrisBiome.class)
@ArrayType(type = String.class, min = 1)
private KList<String> find = new KList<>();
@Required
@Desc("A biome to replace it with")
@RegistryListResource(IrisBiome.class)
private String replace = "";
}
@@ -1,49 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.engine.object.mod;
import art.arcane.iris.engine.object.noise.IrisGeneratorStyle;
import art.arcane.iris.engine.object.noise.NoiseStyle;
import art.arcane.iris.engine.object.annotations.Desc;
import art.arcane.iris.engine.object.annotations.Required;
import art.arcane.iris.engine.object.annotations.Snippet;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("noise-style-replacer")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("A noise style replacer")
@Data
public class IrisModNoiseStyleReplacer {
@Required
@Desc("A noise style to find")
private NoiseStyle find = NoiseStyle.IRIS;
@Required
@Desc("If replaceTypeOnly is set to true, Iris will keep the existing generator style and only replace the type itself. Otherwise it will use the replace tag for every style using the find type.")
private boolean replaceTypeOnly = false;
@Required
@Desc("A noise style to replace it with")
private IrisGeneratorStyle replace = new IrisGeneratorStyle();
}
@@ -1,50 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.engine.object.mod;
import art.arcane.iris.builtin.objects.ObjectPlacement;
import art.arcane.iris.engine.object.world.biome.IrisBiome;
import art.arcane.iris.engine.object.annotations.ArrayType;
import art.arcane.iris.engine.object.annotations.Desc;
import art.arcane.iris.engine.object.annotations.RegistryListResource;
import art.arcane.iris.engine.object.annotations.Required;
import art.arcane.iris.engine.object.annotations.Snippet;
import art.arcane.volmlib.util.collection.KList;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("object-placement-biome-injector")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("An object placement injector")
@Data
public class IrisModObjectPlacementBiomeInjector {
@Required
@Desc("The biome to find")
@RegistryListResource(IrisBiome.class)
private String biome = "";
@Required
@Desc("Object placements to inject into the biome")
@ArrayType(type = ObjectPlacement.class, min = 1)
private KList<ObjectPlacement> place = new KList<>();
}
@@ -1,50 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.engine.object.mod;
import art.arcane.iris.builtin.objects.ObjectPlacement;
import art.arcane.iris.engine.object.world.region.IrisRegion;
import art.arcane.iris.engine.object.annotations.ArrayType;
import art.arcane.iris.engine.object.annotations.Desc;
import art.arcane.iris.engine.object.annotations.RegistryListResource;
import art.arcane.iris.engine.object.annotations.Required;
import art.arcane.iris.engine.object.annotations.Snippet;
import art.arcane.volmlib.util.collection.KList;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("object-placement-region-injector")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("An object placement injector")
@Data
public class IrisModObjectPlacementRegionInjector {
@Required
@Desc("The region to find")
@RegistryListResource(IrisRegion.class)
private String biome = "";
@Required
@Desc("Object placements to inject into the region")
@ArrayType(type = ObjectPlacement.class, min = 1)
private KList<ObjectPlacement> place = new KList<>();
}
@@ -1,50 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.engine.object.mod;
import art.arcane.iris.engine.object.prefab.IrisObject;
import art.arcane.iris.engine.object.annotations.ArrayType;
import art.arcane.iris.engine.object.annotations.Desc;
import art.arcane.iris.engine.object.annotations.RegistryListResource;
import art.arcane.iris.engine.object.annotations.Required;
import art.arcane.iris.engine.object.annotations.Snippet;
import art.arcane.volmlib.util.collection.KList;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("object-replacer")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("An object replacer")
@Data
public class IrisModObjectReplacer {
@Required
@Desc("A list of objects to find")
@RegistryListResource(IrisObject.class)
@ArrayType(type = String.class, min = 1)
private KList<String> find = new KList<>();
@Required
@Desc("An object to replace it with")
@RegistryListResource(IrisObject.class)
private String replace = "";
}
@@ -1,50 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2022 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.engine.object.mod;
import art.arcane.iris.engine.object.world.region.IrisRegion;
import art.arcane.iris.engine.object.annotations.ArrayType;
import art.arcane.iris.engine.object.annotations.Desc;
import art.arcane.iris.engine.object.annotations.RegistryListResource;
import art.arcane.iris.engine.object.annotations.Required;
import art.arcane.iris.engine.object.annotations.Snippet;
import art.arcane.volmlib.util.collection.KList;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
@Snippet("region-replacer")
@Accessors(chain = true)
@NoArgsConstructor
@AllArgsConstructor
@Desc("A region replacer")
@Data
public class IrisModRegionReplacer {
@Required
@Desc("A list of regions to find")
@RegistryListResource(IrisRegion.class)
@ArrayType(type = String.class, min = 1)
private KList<String> find = new KList<>();
@Required
@Desc("A region to replace it with")
@RegistryListResource(IrisRegion.class)
private String replace = "";
}
@@ -1,67 +0,0 @@
package art.arcane.iris.core.pack;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class PackCaveProfileValidatorTest {
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Test
public void rejectsLegacyWaterFieldsAcrossEveryCaveProfileLocation() throws Exception {
File pack = temporaryFolder.newFolder("pack");
write(pack, "dimensions/main.json", "{\"caveProfile\":{\"allowWater\":false}}");
write(pack, "regions/nested/region.json", "{\"caveProfile\":{\"waterMinDepthBelowSurface\":20}}");
write(pack, "biomes/nested/biome.json", "{\"caveProfile\":{\"waterRequiresFloor\":true}}");
write(pack, "snippet/iris/carve/cave-profile/nested/profile.json", "{\"allowWater\":true}");
assertEquals(List.of(
"Dimension 'main' caveProfile.allowWater was removed; use caveProfile.allowFluid. Cave aquifers use the dimension fluidPalette, which defaults to water.",
"Region 'nested/region' caveProfile.waterMinDepthBelowSurface was removed; use caveProfile.fluidMinDepthBelowSurface. Cave aquifers use the dimension fluidPalette, which defaults to water.",
"Biome 'nested/biome' caveProfile.waterRequiresFloor was removed; use caveProfile.fluidRequiresFloor. Cave aquifers use the dimension fluidPalette, which defaults to water.",
"Cave-profile snippet 'nested/profile' allowWater was removed; use allowFluid. Cave aquifers use the dimension fluidPalette, which defaults to water."
), PackCaveProfileValidator.validateLegacyFields(pack));
}
@Test
public void acceptsGenericFluidFields() throws Exception {
File pack = temporaryFolder.newFolder("pack");
write(pack, "dimensions/main.json", "{\"caveProfile\":{\"allowFluid\":true,"
+ "\"fluidMinDepthBelowSurface\":20,\"fluidRequiresFloor\":true}}");
write(pack, "snippet/iris/carve/cave-profile/profile.json", "{\"allowFluid\":true,"
+ "\"fluidMinDepthBelowSurface\":20,\"fluidRequiresFloor\":true}");
assertTrue(PackCaveProfileValidator.validateLegacyFields(pack).isEmpty());
}
@Test
public void legacyFieldBlocksFullPackValidation() throws Exception {
File pack = temporaryFolder.newFolder("pack");
write(pack, "dimensions/main.json", "{\"regions\":[\"region\"]}");
write(pack, "regions/region.json", "{\"landBiomes\":[\"biome\"]}");
write(pack, "biomes/biome.json", "{\"name\":\"Biome\",\"caveProfile\":{\"allowWater\":false}}");
PackValidationResult result = PackValidator.validate(pack);
assertFalse(result.isLoadable());
assertTrue(result.getBlockingErrors().contains(
"Biome 'biome' caveProfile.allowWater was removed; use caveProfile.allowFluid. Cave aquifers use the dimension fluidPalette, which defaults to water."));
}
private void write(File root, String relative, String content) throws Exception {
Path path = root.toPath().resolve(relative);
Files.createDirectories(path.getParent());
Files.writeString(path, content, StandardCharsets.UTF_8);
}
}
@@ -1,54 +0,0 @@
package art.arcane.iris.core.pack;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
public class PackValidatorRemovedWorldgenFieldTest {
@Rule
public TemporaryFolder temporaryFolder = new TemporaryFolder();
@Test
public void rejectsFluidBodiesAcrossEveryFormerHost() throws Exception {
File pack = temporaryFolder.newFolder("pack");
write(pack, "dimensions/main.json", "{\"fluidBodies\":{}}");
write(pack, "regions/nested/region.json", "{\"fluidBodies\":null}");
write(pack, "biomes/nested/biome.json", "{\"fluidBodies\":{\"lakes\":[]}}");
assertEquals(List.of(
"Dimension 'main' declares removed field 'fluidBodies'. Remove it because fluid-body generation is not supported.",
"Region 'nested/region' declares removed field 'fluidBodies'. Remove it because fluid-body generation is not supported.",
"Biome 'nested/biome' declares removed field 'fluidBodies'. Remove it because fluid-body generation is not supported."
), PackObjectSurfaceValidator.validateRemovedWorldgenFields(pack));
}
@Test
public void removedFluidBodiesBlocksFullPackValidation() throws Exception {
File pack = temporaryFolder.newFolder("pack");
write(pack, "dimensions/main.json", "{\"regions\":[\"region\"]}");
write(pack, "regions/region.json", "{\"landBiomes\":[\"biome\"]}");
write(pack, "biomes/biome.json", "{\"name\":\"Biome\",\"fluidBodies\":{}}");
PackValidationResult result = PackValidator.validate(pack);
assertFalse(result.isLoadable());
assertTrue(result.getBlockingErrors().contains(
"Biome 'biome' declares removed field 'fluidBodies'. Remove it because fluid-body generation is not supported."));
}
private void write(File root, String relative, String content) throws Exception {
Path path = root.toPath().resolve(relative);
Files.createDirectories(path.getParent());
Files.writeString(path, content, StandardCharsets.UTF_8);
}
}