mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-12-02 02:34:24 +00:00
Merge branch 'wave3/l' into feat/irisapi-host
This commit is contained in:
commit
b60ca588fe
74 files changed
+4776
-1538
No files matched your search
+4
-6
@@ -36,15 +36,12 @@ import art.arcane.iris.core.structure.FeatureImporter;
|
|||||||
import art.arcane.iris.core.structure.StructureImporter;
|
import art.arcane.iris.core.structure.StructureImporter;
|
||||||
import art.arcane.iris.core.tools.IrisToolbelt;
|
import art.arcane.iris.core.tools.IrisToolbelt;
|
||||||
import art.arcane.iris.engine.framework.Engine;
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
import art.arcane.iris.engine.object.loot.InventorySlotType;
|
|
||||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||||
import art.arcane.iris.engine.terrain.BiomeLayers;
|
import art.arcane.iris.engine.terrain.BiomeLayers;
|
||||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||||
import art.arcane.iris.engine.object.entity.IrisEntity;
|
|
||||||
import art.arcane.iris.engine.platform.BukkitEntitySpawner;
|
import art.arcane.iris.engine.platform.BukkitEntitySpawner;
|
||||||
import art.arcane.iris.engine.object.terrain.IrisGenerator;
|
import art.arcane.iris.engine.object.terrain.IrisGenerator;
|
||||||
import art.arcane.iris.engine.object.noise.IrisInterpolator;
|
import art.arcane.iris.engine.object.noise.IrisInterpolator;
|
||||||
import art.arcane.iris.engine.object.loot.IrisLootTable;
|
|
||||||
import art.arcane.iris.engine.object.noise.IrisNoiseGenerator;
|
import art.arcane.iris.engine.object.noise.IrisNoiseGenerator;
|
||||||
import art.arcane.iris.engine.object.prefab.IrisObject;
|
import art.arcane.iris.engine.object.prefab.IrisObject;
|
||||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||||
@@ -57,6 +54,7 @@ import art.arcane.volmlib.util.collection.KSet;
|
|||||||
import art.arcane.iris.util.common.director.DirectorExecutor;
|
import art.arcane.iris.util.common.director.DirectorExecutor;
|
||||||
import art.arcane.iris.util.common.director.handlers.DimensionHandler;
|
import art.arcane.iris.util.common.director.handlers.DimensionHandler;
|
||||||
import art.arcane.iris.util.common.director.specialhandlers.NullableDimensionHandler;
|
import art.arcane.iris.util.common.director.specialhandlers.NullableDimensionHandler;
|
||||||
|
import art.arcane.iris.util.common.director.specialhandlers.EntityKeyHandler;
|
||||||
import art.arcane.volmlib.util.director.DirectorOrigin;
|
import art.arcane.volmlib.util.director.DirectorOrigin;
|
||||||
import art.arcane.volmlib.util.director.annotations.Director;
|
import art.arcane.volmlib.util.director.annotations.Director;
|
||||||
import art.arcane.volmlib.util.director.annotations.Param;
|
import art.arcane.volmlib.util.director.annotations.Param;
|
||||||
@@ -648,8 +646,8 @@ public class CommandStudio implements DirectorExecutor {
|
|||||||
|
|
||||||
@Director(description = "Spawn an Iris entity", descriptionKey = "iris.director.commandstudio.director.spawn_iris_entity", aliases = "summon", origin = DirectorOrigin.PLAYER)
|
@Director(description = "Spawn an Iris entity", descriptionKey = "iris.director.commandstudio.director.spawn_iris_entity", aliases = "summon", origin = DirectorOrigin.PLAYER)
|
||||||
public void spawn(
|
public void spawn(
|
||||||
@Param(description = "The entity to spawn", descriptionKey = "iris.director.commandstudio.param.entity_spawn")
|
@Param(description = "The entity to spawn", descriptionKey = "iris.director.commandstudio.param.entity_spawn", customHandler = EntityKeyHandler.class)
|
||||||
IrisEntity entity,
|
String entity,
|
||||||
@Param(description = "The location to spawn the entity at", descriptionKey = "iris.director.commandstudio.param.location_spawn_entity_at", contextual = true, contextualOverride = true)
|
@Param(description = "The location to spawn the entity at", descriptionKey = "iris.director.commandstudio.param.location_spawn_entity_at", contextual = true, contextualOverride = true)
|
||||||
Vector location
|
Vector location
|
||||||
) {
|
) {
|
||||||
@@ -662,7 +660,7 @@ public class CommandStudio implements DirectorExecutor {
|
|||||||
|
|
||||||
// Entity creation must run on the thread owning the destination chunk.
|
// Entity creation must run on the thread owning the destination chunk.
|
||||||
Location at = new Location(world(), location.getX(), location.getY(), location.getZ());
|
Location at = new Location(world(), location.getX(), location.getY(), location.getZ());
|
||||||
if (!J.runAt(at, () -> BukkitEntitySpawner.spawnByKey(spawnEngine, entity.getLoadKey(), at))) {
|
if (!J.runAt(at, () -> BukkitEntitySpawner.spawnByKey(spawnEngine, entity, at))) {
|
||||||
Iris.warn("Could not schedule the entity spawn at " + at.getBlockX() + ", " + at.getBlockY() + ", " + at.getBlockZ() + ".");
|
Iris.warn("Could not schedule the entity spawn at " + at.getBlockX() + ", " + at.getBlockY() + ", " + at.getBlockZ() + ".");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-83
@@ -18,21 +18,13 @@
|
|||||||
|
|
||||||
package art.arcane.iris.modded;
|
package art.arcane.iris.modded;
|
||||||
|
|
||||||
import art.arcane.iris.engine.spawn.SpawnResources;
|
import art.arcane.iris.core.content.ContentLoot;
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
import art.arcane.iris.core.content.ContentServices;
|
||||||
|
import art.arcane.iris.core.content.ContentSpawns;
|
||||||
import art.arcane.iris.engine.framework.Engine;
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
import art.arcane.iris.engine.framework.LootResolver;
|
|
||||||
import art.arcane.iris.engine.framework.TreeBlockMaterial;
|
import art.arcane.iris.engine.framework.TreeBlockMaterial;
|
||||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
|
||||||
import art.arcane.iris.engine.object.material.IrisBlockData;
|
|
||||||
import art.arcane.iris.engine.object.loot.IrisBlockDrops;
|
|
||||||
import art.arcane.iris.engine.object.loot.IrisLoot;
|
|
||||||
import art.arcane.iris.engine.object.marker.IrisMarker;
|
|
||||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
|
||||||
import art.arcane.iris.spi.PlatformBlockState;
|
|
||||||
import art.arcane.iris.modded.service.ModdedTreeFellerService;
|
import art.arcane.iris.modded.service.ModdedTreeFellerService;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
|
||||||
import art.arcane.volmlib.util.matter.MatterMarker;
|
import art.arcane.volmlib.util.matter.MatterMarker;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
@@ -204,26 +196,13 @@ public final class ModdedBlockBreakHandler {
|
|||||||
BlockState brokenState,
|
BlockState brokenState,
|
||||||
Engine engine
|
Engine engine
|
||||||
) {
|
) {
|
||||||
KList<IrisBlockDrops> providers = providers(engine, position, brokenState);
|
ContentLoot.BlockDrops dropped = ContentServices.blockDrops(engine, position.getX(), position.getY(), position.getZ(),
|
||||||
if (providers.isEmpty()) {
|
ModdedBlockState.serialize(brokenState));
|
||||||
|
if (dropped.drops().isEmpty() && !dropped.replacesVanillaDrops()) {
|
||||||
return Result.empty();
|
return Result.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
KList<ItemStack> drops = new KList<>();
|
return new Result(ModdedItemTranslator.stacks(dropped.drops(), level), dropped.replacesVanillaDrops(), null);
|
||||||
boolean replaceVanillaDrops = false;
|
|
||||||
for (IrisBlockDrops provider : providers) {
|
|
||||||
replaceVanillaDrops |= provider.isReplaceVanillaDrops();
|
|
||||||
for (IrisLoot loot : provider.getDrops()) {
|
|
||||||
if (!LootResolver.oneIn(RNG.r, loot.getRarity())) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ItemStack stack = ModdedItemTranslator.stack(loot, RNG.r, level);
|
|
||||||
if (stack != null && !stack.isEmpty()) {
|
|
||||||
drops.add(stack);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new Result(drops, replaceVanillaDrops, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void removeMarker(Engine engine, BlockPos position) {
|
private static void removeMarker(Engine engine, BlockPos position) {
|
||||||
@@ -236,8 +215,7 @@ public final class ModdedBlockBreakHandler {
|
|||||||
if ("cave_floor".equals(tag) || "cave_ceiling".equals(tag)) {
|
if ("cave_floor".equals(tag) || "cave_ceiling".equals(tag)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IrisMarker configured = SpawnResources.marker(engine.getData(), tag);
|
if (ContentServices.markerRule(engine, tag).map(ContentSpawns.MarkerRule::removeOnChange).orElse(true)) {
|
||||||
if (configured == null || configured.isRemoveOnChange()) {
|
|
||||||
engine.getMantle().getMantle().remove(position.getX(), mantleY, position.getZ(), MatterMarker.class);
|
engine.getMantle().getMantle().remove(position.getX(), mantleY, position.getZ(), MatterMarker.class);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -248,59 +226,6 @@ public final class ModdedBlockBreakHandler {
|
|||||||
engine.getMantle().getMantle().remove(position.getX(), mantleY, position.getZ(), TreeBlockMaterial.class);
|
engine.getMantle().getMantle().remove(position.getX(), mantleY, position.getZ(), TreeBlockMaterial.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static KList<IrisBlockDrops> providers(Engine engine, BlockPos position, BlockState brokenState) {
|
|
||||||
KList<IrisBlockDrops> providers = new KList<>();
|
|
||||||
IrisData data = engine.getData();
|
|
||||||
int relativeY = position.getY() - engine.getMinHeight();
|
|
||||||
IrisBiome biome = engine.getBiome(position.getX(), relativeY, position.getZ());
|
|
||||||
if (biome != null) {
|
|
||||||
addMatching(providers, biome.getBlockDrops(), brokenState, data);
|
|
||||||
}
|
|
||||||
if (skipsParents(providers)) {
|
|
||||||
return providers;
|
|
||||||
}
|
|
||||||
IrisRegion region = engine.getRegion(position.getX(), position.getZ());
|
|
||||||
if (region != null) {
|
|
||||||
addMatching(providers, region.getBlockDrops(), brokenState, data);
|
|
||||||
}
|
|
||||||
addMatching(providers, engine.getDimension().getBlockDrops(), brokenState, data);
|
|
||||||
return providers;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void addMatching(KList<IrisBlockDrops> matches, KList<IrisBlockDrops> candidates, BlockState brokenState, IrisData data) {
|
|
||||||
for (IrisBlockDrops candidate : candidates) {
|
|
||||||
if (matches(candidate, brokenState, data)) {
|
|
||||||
matches.add(candidate);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean skipsParents(KList<IrisBlockDrops> providers) {
|
|
||||||
for (IrisBlockDrops provider : providers) {
|
|
||||||
if (provider.isSkipParents()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean matches(IrisBlockDrops provider, BlockState brokenState, IrisData data) {
|
|
||||||
for (IrisBlockData configuredBlock : provider.getBlocks()) {
|
|
||||||
PlatformBlockState resolved = configuredBlock.getBlockData(data);
|
|
||||||
if (resolved == null || !(resolved.nativeHandle() instanceof BlockState configuredState)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (matchesState(configuredState, brokenState, provider.isExactBlocks())) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean matchesState(BlockState configuredState, BlockState brokenState, boolean exact) {
|
|
||||||
return exact ? configuredState.equals(brokenState) : configuredState.getBlock() == brokenState.getBlock();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Engine engineFor(ServerLevel level) {
|
public static Engine engineFor(ServerLevel level) {
|
||||||
ChunkGenerator generator = level.getChunkSource().getGenerator();
|
ChunkGenerator generator = level.getChunkSource().getGenerator();
|
||||||
if (!(generator instanceof IrisModdedChunkGenerator irisGenerator)) {
|
if (!(generator instanceof IrisModdedChunkGenerator irisGenerator)) {
|
||||||
|
|||||||
@@ -18,10 +18,8 @@
|
|||||||
|
|
||||||
package art.arcane.iris.modded;
|
package art.arcane.iris.modded;
|
||||||
|
|
||||||
import art.arcane.iris.engine.loot.LootResources;
|
import art.arcane.iris.core.content.ContentServices;
|
||||||
import art.arcane.iris.engine.framework.Engine;
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
import art.arcane.iris.engine.object.loot.InventorySlotType;
|
|
||||||
import art.arcane.iris.engine.object.loot.IrisLootTable;
|
|
||||||
import art.arcane.iris.spi.IrisLogging;
|
import art.arcane.iris.spi.IrisLogging;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
@@ -34,22 +32,23 @@ import net.minecraft.world.entity.vehicle.ContainerEntity;
|
|||||||
import net.minecraft.world.item.ItemStack;
|
import net.minecraft.world.item.ItemStack;
|
||||||
import net.minecraft.world.level.chunk.ChunkGenerator;
|
import net.minecraft.world.level.chunk.ChunkGenerator;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
public final class ModdedDeathLoot {
|
public final class ModdedDeathLoot {
|
||||||
private static final String TAG_PREFIX = "iris_loot|";
|
private static final String TAG_PREFIX = "iris_loot|";
|
||||||
private static final Set<String> WARNED_TABLES = ConcurrentHashMap.newKeySet();
|
|
||||||
private static final Set<String> WARNED_ENTITY_TYPES = ConcurrentHashMap.newKeySet();
|
private static final Set<String> WARNED_ENTITY_TYPES = ConcurrentHashMap.newKeySet();
|
||||||
|
|
||||||
private ModdedDeathLoot() {
|
private ModdedDeathLoot() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void bind(Engine engine, Entity entity, KList<String> tableKeys, int spawnX, int spawnY, int spawnZ, RNG rng) {
|
/** Makes the loot of the pack's tables {@code tableKeys} the loot {@code entity} drops, or holds if it is a container; {@code shuffleSeed} seeds how a container's loot is shuffled. */
|
||||||
|
public static void bind(Engine engine, Entity entity, List<String> tableKeys, int spawnX, int spawnY, int spawnZ, long shuffleSeed) {
|
||||||
if (engine == null || entity == null || tableKeys == null || tableKeys.isEmpty()) {
|
if (engine == null || entity == null || tableKeys == null || tableKeys.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
LootBinding binding = new LootBinding(rng.getSeed(), spawnX, spawnY, spawnZ, new KList<>(tableKeys));
|
LootBinding binding = new LootBinding(shuffleSeed, spawnX, spawnY, spawnZ, new KList<>(tableKeys));
|
||||||
if (entity instanceof Mob) {
|
if (entity instanceof Mob) {
|
||||||
entity.addTag(encode(binding));
|
entity.addTag(encode(binding));
|
||||||
return;
|
return;
|
||||||
@@ -105,15 +104,8 @@ public final class ModdedDeathLoot {
|
|||||||
private static KList<ItemStack> resolve(Engine engine, ServerLevel level, LootBinding binding) {
|
private static KList<ItemStack> resolve(Engine engine, ServerLevel level, LootBinding binding) {
|
||||||
KList<ItemStack> drops = new KList<>();
|
KList<ItemStack> drops = new KList<>();
|
||||||
for (String key : binding.tableKeys()) {
|
for (String key : binding.tableKeys()) {
|
||||||
IrisLootTable table = LootResources.table(engine.getData(), key);
|
drops.addAll(ModdedItemTranslator.stacks(
|
||||||
if (table == null) {
|
ContentServices.tableItems(engine, binding.spawnX(), binding.spawnY(), binding.spawnZ(), key), level));
|
||||||
if (WARNED_TABLES.add(key)) {
|
|
||||||
IrisLogging.warn("Iris death loot: unknown loot table '" + key + "'");
|
|
||||||
}
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
drops.addAll(ModdedItemTranslator.loot(table, engine.getSeedManager().getLoot(), InventorySlotType.STORAGE, level,
|
|
||||||
binding.spawnX(), binding.spawnY(), binding.spawnZ()));
|
|
||||||
}
|
}
|
||||||
return drops;
|
return drops;
|
||||||
}
|
}
|
||||||
|
|||||||
+53
-104
@@ -19,14 +19,11 @@
|
|||||||
package art.arcane.iris.modded;
|
package art.arcane.iris.modded;
|
||||||
|
|
||||||
import art.arcane.iris.core.IrisSettings;
|
import art.arcane.iris.core.IrisSettings;
|
||||||
|
import art.arcane.iris.core.content.ContentEffect;
|
||||||
|
import art.arcane.iris.core.content.ContentServices;
|
||||||
import art.arcane.iris.engine.framework.Engine;
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
import art.arcane.iris.engine.framework.EngineAssignedComponent;
|
import art.arcane.iris.engine.framework.EngineAssignedComponent;
|
||||||
import art.arcane.iris.engine.framework.EngineEffects;
|
import art.arcane.iris.engine.framework.EngineEffects;
|
||||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
|
||||||
import art.arcane.iris.engine.object.marker.IrisCommand;
|
|
||||||
import art.arcane.iris.engine.object.marker.IrisCommandRegistry;
|
|
||||||
import art.arcane.iris.engine.object.entity.IrisEffect;
|
|
||||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
|
||||||
import art.arcane.iris.spi.IrisLogging;
|
import art.arcane.iris.spi.IrisLogging;
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
@@ -194,17 +191,16 @@ public final class ModdedEngineEffects extends EngineAssignedComponent implement
|
|||||||
}
|
}
|
||||||
|
|
||||||
samplePlayer(state);
|
samplePlayer(state);
|
||||||
if (!IrisSettings.get().getWorld().isEffectSystem()) {
|
if (!IrisSettings.get().getWorld().isEffectSystem() || !state.sampled()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
IrisRegion region = state.region();
|
for (ContentEffect effect : ContentServices.ambientEffects(getEngine(), state.sampledX(), state.sampledY(), state.sampledZ())) {
|
||||||
if (region != null) {
|
try {
|
||||||
applyEffects(level, player, region.getEffects());
|
applyEffect(level, player, effect);
|
||||||
}
|
} catch (Throwable error) {
|
||||||
IrisBiome biome = state.biome();
|
IrisLogging.reportError(error);
|
||||||
if (biome != null) {
|
}
|
||||||
applyEffects(level, player, biome.getEffects());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -222,36 +218,24 @@ public final class ModdedEngineEffects extends EngineAssignedComponent implement
|
|||||||
state.sampled(true);
|
state.sampled(true);
|
||||||
state.lastPosition(player.getX(), player.getY(), player.getZ());
|
state.lastPosition(player.getX(), player.getY(), player.getZ());
|
||||||
state.lastSample(now);
|
state.lastSample(now);
|
||||||
int blockX = floor(player.getX());
|
state.sampledAt(floor(player.getX()), floor(player.getY()), floor(player.getZ()));
|
||||||
int blockY = floor(player.getY()) - getEngine().getWorld().minHeight();
|
|
||||||
int blockZ = floor(player.getZ());
|
|
||||||
state.biome(getEngine().getBiome(blockX, blockY, blockZ));
|
|
||||||
state.region(getEngine().getRegion(blockX, blockZ));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyEffects(ServerLevel level, ServerPlayer player, Iterable<IrisEffect> effects) {
|
private void applyEffect(ServerLevel level, ServerPlayer player, ContentEffect effect) {
|
||||||
for (IrisEffect effect : effects) {
|
if (effect.sound() != null) {
|
||||||
try {
|
applySound(player, effect.sound());
|
||||||
applyEffect(level, player, effect);
|
}
|
||||||
} catch (Throwable error) {
|
if (effect.particles() != null) {
|
||||||
IrisLogging.reportError(error);
|
applyParticles(level, player, effect.particles());
|
||||||
}
|
}
|
||||||
|
applyCommands(level, player, effect.commands());
|
||||||
|
if (effect.potion() != null) {
|
||||||
|
applyPotion(player, effect.potion());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyEffect(ServerLevel level, ServerPlayer player, IrisEffect effect) {
|
private void applySound(ServerPlayer player, ContentEffect.Sound effect) {
|
||||||
if (!effect.shouldApplyNow()) {
|
String key = normalizeRegistryKey(effect.key());
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
applySound(player, effect);
|
|
||||||
applyParticles(level, player, effect);
|
|
||||||
applyCommands(level, player, effect.getCommandRegistry());
|
|
||||||
applyPotion(player, effect);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void applySound(ServerPlayer player, IrisEffect effect) {
|
|
||||||
String key = normalizeRegistryKey(effect.getSoundKey());
|
|
||||||
if (key == null) {
|
if (key == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -264,18 +248,13 @@ public final class ModdedEngineEffects extends EngineAssignedComponent implement
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int distance = effect.getSoundDistance();
|
|
||||||
double x = player.getX() + RNG.r.i(-distance, distance);
|
|
||||||
double y = player.getY() + RNG.r.i(-distance, distance);
|
|
||||||
double z = player.getZ() + RNG.r.i(-distance, distance);
|
|
||||||
float volume = (float) effect.getVolume();
|
|
||||||
float pitch = (float) RNG.r.d(effect.getMinPitch(), effect.getMaxPitch());
|
|
||||||
player.connection.send(new ClientboundSoundPacket(
|
player.connection.send(new ClientboundSoundPacket(
|
||||||
sound.get(), SoundSource.MASTER, x, y, z, volume, pitch, ThreadLocalRandom.current().nextLong()));
|
sound.get(), SoundSource.MASTER, player.getX() + effect.offsetX(), player.getY() + effect.offsetY(),
|
||||||
|
player.getZ() + effect.offsetZ(), effect.volume(), effect.pitch(), ThreadLocalRandom.current().nextLong()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyParticles(ServerLevel level, ServerPlayer player, IrisEffect effect) {
|
private void applyParticles(ServerLevel level, ServerPlayer player, ContentEffect.Particles effect) {
|
||||||
String key = normalizeRegistryKey(effect.getParticleEffectKey());
|
String key = normalizeRegistryKey(effect.key());
|
||||||
if (key == null) {
|
if (key == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -295,59 +274,34 @@ public final class ModdedEngineEffects extends EngineAssignedComponent implement
|
|||||||
}
|
}
|
||||||
|
|
||||||
Vec3 direction = player.getLookAngle();
|
Vec3 direction = player.getLookAngle();
|
||||||
double forward = RNG.r.i(effect.getParticleDistance()) + effect.getParticleAway();
|
double surfaceX = player.getX() + direction.x * effect.forward() + direction.z * effect.sideways();
|
||||||
double sideways = RNG.r.d(-effect.getParticleDistanceWidth(), effect.getParticleDistanceWidth());
|
double surfaceZ = player.getZ() + direction.z * effect.forward() - direction.x * effect.sideways();
|
||||||
double surfaceX = player.getX() + direction.x * forward + direction.z * sideways;
|
|
||||||
double surfaceZ = player.getZ() + direction.z * forward - direction.x * sideways;
|
|
||||||
int surfaceY = getEngine().getHeight(floor(surfaceX), floor(surfaceZ));
|
int surfaceY = getEngine().getHeight(floor(surfaceX), floor(surfaceZ));
|
||||||
double x = surfaceX + RNG.r.d();
|
double x = surfaceX + effect.jitterX();
|
||||||
double y = surfaceY + 1.0D + level.getMinY() + RNG.r.i(effect.getParticleOffset());
|
double y = surfaceY + 1.0D + level.getMinY() + effect.lift();
|
||||||
double z = surfaceZ + RNG.r.d();
|
double z = surfaceZ + effect.jitterZ();
|
||||||
double altX = randomized(effect.getParticleAltX(), effect.isRandomAltX());
|
|
||||||
double altY = randomized(effect.getParticleAltY(), effect.isRandomAltY());
|
|
||||||
double altZ = randomized(effect.getParticleAltZ(), effect.isRandomAltZ());
|
|
||||||
level.sendParticles(player, simpleParticle, false, false,
|
level.sendParticles(player, simpleParticle, false, false,
|
||||||
x, y, z, effect.getParticleCount(), altX, altY, altZ, effect.getExtra());
|
x, y, z, effect.count(), effect.altX(), effect.altY(), effect.altZ(), effect.extra());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyCommands(ServerLevel level, ServerPlayer player, IrisCommandRegistry registry) {
|
private void applyCommands(ServerLevel level, ServerPlayer player, List<ContentEffect.Command> commands) {
|
||||||
if (registry == null || registry.getRawCommands() == null || registry.getRawCommands().isEmpty()) {
|
for (ContentEffect.Command command : commands) {
|
||||||
return;
|
ModdedEntityCommandRunner.run(List.of(command.command()), level, floor(player.getX() + command.offsetX()),
|
||||||
}
|
floor(player.getY() + command.offsetY()), floor(player.getZ() + command.offsetZ()));
|
||||||
|
|
||||||
ModdedPlatformWorld world = new ModdedPlatformWorld(level);
|
|
||||||
double x = commandCoordinate(player.getX(), registry.getCommandOffsetX(), registry.isCommandRandomAltX());
|
|
||||||
double y = commandCoordinate(player.getY(), registry.getCommandOffsetY(), registry.isCommandRandomAltY());
|
|
||||||
double z = commandCoordinate(player.getZ(), registry.getCommandOffsetZ(), registry.isCommandRandomAltZ());
|
|
||||||
for (IrisCommand command : registry.getRawCommands()) {
|
|
||||||
command.run(world, floor(x), floor(y), floor(z));
|
|
||||||
if (registry.isCommandAllRandomLocations()) {
|
|
||||||
x = commandCoordinate(player.getX(), registry.getCommandOffsetX(), registry.isCommandRandomAltX());
|
|
||||||
y = commandCoordinate(player.getY(), registry.getCommandOffsetY(), registry.isCommandRandomAltY());
|
|
||||||
z = commandCoordinate(player.getZ(), registry.getCommandOffsetZ(), registry.isCommandRandomAltZ());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyPotion(ServerPlayer player, IrisEffect effect) {
|
private void applyPotion(ServerPlayer player, ContentEffect.Potion effect) {
|
||||||
int strength = effect.getPotionStrength();
|
Holder<MobEffect> type = resolvePotion(effect.key());
|
||||||
if (strength < 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Holder<MobEffect> type = resolvePotion(effect.getPotionEffect());
|
|
||||||
MobEffectInstance current = player.getEffect(type);
|
MobEffectInstance current = player.getEffect(type);
|
||||||
if (current != null && !shouldReplacePotionEffect(current.getAmplifier(), strength)) {
|
if (current != null && !shouldReplacePotionEffect(current.getAmplifier(), effect.strength())) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (current != null) {
|
if (current != null) {
|
||||||
player.removeEffect(type);
|
player.removeEffect(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
int minimum = Math.min(effect.getPotionTicksMin(), effect.getPotionTicksMax());
|
player.addEffect(new MobEffectInstance(type, effect.ticks(), effect.strength(), true, false, false));
|
||||||
int maximum = Math.max(effect.getPotionTicksMin(), effect.getPotionTicksMax());
|
|
||||||
int duration = RNG.r.i(minimum, maximum);
|
|
||||||
player.addEffect(new MobEffectInstance(type, duration, strength, true, false, false));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Holder<MobEffect> resolvePotion(String rawKey) {
|
private Holder<MobEffect> resolvePotion(String rawKey) {
|
||||||
@@ -405,14 +359,6 @@ public final class ModdedEngineEffects extends EngineAssignedComponent implement
|
|||||||
return (int) Math.floor(value);
|
return (int) Math.floor(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double randomized(double value, boolean random) {
|
|
||||||
return random ? RNG.r.d(-value, value) : value;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static double commandCoordinate(double base, double offset, boolean random) {
|
|
||||||
return base + randomized(offset, random);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void warnUnknown(Set<String> warned, String type, String key) {
|
private static void warnUnknown(Set<String> warned, String type, String key) {
|
||||||
if (warned.add(key)) {
|
if (warned.add(key)) {
|
||||||
IrisLogging.warn("Unknown " + type + " type: \"" + key + "\".");
|
IrisLogging.warn("Unknown " + type + " type: \"" + key + "\".");
|
||||||
@@ -421,8 +367,9 @@ public final class ModdedEngineEffects extends EngineAssignedComponent implement
|
|||||||
|
|
||||||
private static final class PlayerState {
|
private static final class PlayerState {
|
||||||
private ServerPlayer player;
|
private ServerPlayer player;
|
||||||
private IrisBiome biome;
|
private int sampledX;
|
||||||
private IrisRegion region;
|
private int sampledY;
|
||||||
|
private int sampledZ;
|
||||||
private double lastX;
|
private double lastX;
|
||||||
private double lastY;
|
private double lastY;
|
||||||
private double lastZ;
|
private double lastZ;
|
||||||
@@ -446,20 +393,22 @@ public final class ModdedEngineEffects extends EngineAssignedComponent implement
|
|||||||
this.player = player;
|
this.player = player;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisBiome biome() {
|
private int sampledX() {
|
||||||
return biome;
|
return sampledX;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void biome(IrisBiome biome) {
|
private int sampledY() {
|
||||||
this.biome = biome;
|
return sampledY;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisRegion region() {
|
private int sampledZ() {
|
||||||
return region;
|
return sampledZ;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void region(IrisRegion region) {
|
private void sampledAt(int x, int y, int z) {
|
||||||
this.region = region;
|
sampledX = x;
|
||||||
|
sampledY = y;
|
||||||
|
sampledZ = z;
|
||||||
}
|
}
|
||||||
|
|
||||||
private double lastX() {
|
private double lastX() {
|
||||||
|
|||||||
+11
-13
@@ -1,16 +1,18 @@
|
|||||||
package art.arcane.iris.modded;
|
package art.arcane.iris.modded;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.marker.IrisCommand;
|
import art.arcane.iris.core.content.ContentEntity;
|
||||||
import art.arcane.iris.spi.IrisLogging;
|
import art.arcane.iris.spi.IrisLogging;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
|
||||||
import net.minecraft.server.MinecraftServer;
|
import net.minecraft.server.MinecraftServer;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
final class ModdedEntityCommandRunner {
|
final class ModdedEntityCommandRunner {
|
||||||
private ModdedEntityCommandRunner() {
|
private ModdedEntityCommandRunner() {
|
||||||
}
|
}
|
||||||
|
|
||||||
static void run(KList<IrisCommand> commands, ServerLevel level, int blockX, int blockY, int blockZ) {
|
/** Schedules the commands, which a module already checked against the time and weather, at the block. */
|
||||||
|
static void run(List<ContentEntity.Command> commands, ServerLevel level, int blockX, int blockY, int blockZ) {
|
||||||
if (commands.isEmpty()) {
|
if (commands.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -21,24 +23,20 @@ final class ModdedEntityCommandRunner {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ModdedPlatformWorld world = new ModdedPlatformWorld(level);
|
for (ContentEntity.Command command : commands) {
|
||||||
for (IrisCommand command : commands) {
|
|
||||||
if (command == null || !command.isValid(world)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
schedule(command, server, scheduler, blockX, blockY, blockZ);
|
schedule(command, server, scheduler, blockX, blockY, blockZ);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void schedule(IrisCommand command, MinecraftServer server, ModdedScheduler scheduler, int blockX, int blockY, int blockZ) {
|
private static void schedule(ContentEntity.Command command, MinecraftServer server, ModdedScheduler scheduler, int blockX, int blockY, int blockZ) {
|
||||||
int delay = clampDelay(command.getDelay(), 0);
|
int delay = clampDelay(command.delay(), 0);
|
||||||
int repeatDelay = clampDelay(command.getRepeatDelay(), 1);
|
int repeatDelay = clampDelay(command.repeatDelay(), 1);
|
||||||
for (String raw : command.getCommands()) {
|
for (String raw : command.commands()) {
|
||||||
String prepared = prepareCommand(raw, blockX, blockY, blockZ);
|
String prepared = prepareCommand(raw, blockX, blockY, blockZ);
|
||||||
if (prepared == null) {
|
if (prepared == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (command.isRepeat()) {
|
if (command.repeat()) {
|
||||||
scheduler.laterGlobal(() -> new RepeatingCommand(server, scheduler, prepared, repeatDelay).run(), delay);
|
scheduler.laterGlobal(() -> new RepeatingCommand(server, scheduler, prepared, repeatDelay).run(), delay);
|
||||||
} else {
|
} else {
|
||||||
scheduler.laterGlobal(() -> ModdedServerCommands.dispatch(server, prepared), delay);
|
scheduler.laterGlobal(() -> ModdedServerCommands.dispatch(server, prepared), delay);
|
||||||
|
|||||||
+81
-90
@@ -20,14 +20,10 @@ package art.arcane.iris.modded;
|
|||||||
|
|
||||||
import art.arcane.iris.core.IrisSettings;
|
import art.arcane.iris.core.IrisSettings;
|
||||||
import art.arcane.iris.engine.framework.Engine;
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
import art.arcane.iris.engine.framework.LootResolver;
|
import art.arcane.iris.core.content.ContentEntity;
|
||||||
import art.arcane.iris.engine.object.entity.IrisAttributeModifier;
|
import art.arcane.iris.core.content.ContentItem;
|
||||||
import art.arcane.iris.engine.object.entity.IrisEntity;
|
|
||||||
import art.arcane.iris.engine.object.entity.IrisEffect;
|
|
||||||
import art.arcane.iris.engine.object.loot.IrisLoot;
|
|
||||||
import art.arcane.iris.modded.api.ModdedCustomContentRegistry;
|
import art.arcane.iris.modded.api.ModdedCustomContentRegistry;
|
||||||
import art.arcane.iris.spi.IrisLogging;
|
import art.arcane.iris.spi.IrisLogging;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
@@ -82,8 +78,9 @@ public final class ModdedEntitySpawner {
|
|||||||
private ModdedEntitySpawner() {
|
private ModdedEntitySpawner() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Entity spawn(Engine engine, IrisEntity irisEntity, ServerLevel level, int blockX, int blockY, int blockZ, RNG rng) {
|
/** Spawns {@code entity}, whose every random choice a module made, at the block; null when it cannot appear. */
|
||||||
if (engine == null || irisEntity == null || level == null) {
|
public static Entity spawn(Engine engine, ContentEntity entity, ServerLevel level, int blockX, int blockY, int blockZ) {
|
||||||
|
if (engine == null || entity == null || level == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
if (!chunksSafe(level, blockX >> 4, blockZ >> 4)) {
|
if (!chunksSafe(level, blockX >> 4, blockZ >> 4)) {
|
||||||
@@ -93,73 +90,71 @@ public final class ModdedEntitySpawner {
|
|||||||
double x = blockX + 0.5;
|
double x = blockX + 0.5;
|
||||||
double y = blockY + 0.5;
|
double y = blockY + 0.5;
|
||||||
double z = blockZ + 0.5;
|
double z = blockZ + 0.5;
|
||||||
boolean riseEffectActive = irisEntity.isSpawnEffectRiseOutOfGround() && hasPlayersNearby(level, x, y, z);
|
boolean riseEffectActive = entity.riseOutOfGround() && hasPlayersNearby(level, x, y, z);
|
||||||
int spawnBlockY = riseEffectActive ? blockY - 5 : blockY;
|
int spawnBlockY = riseEffectActive ? blockY - 5 : blockY;
|
||||||
double spawnY = spawnBlockY + 0.5;
|
double spawnY = spawnBlockY + 0.5;
|
||||||
|
|
||||||
Entity created = create(irisEntity, level, x, spawnY, z);
|
Entity created = create(entity, level, x, spawnY, z);
|
||||||
if (created == null) {
|
if (created == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (irisEntity.isSpecialType() && !irisEntity.isApplySettingsToCustomMobAnyways()) {
|
if (entity.isSpecial() && !entity.applySettingsToSpecial()) {
|
||||||
return created;
|
return created;
|
||||||
}
|
}
|
||||||
|
|
||||||
applyConfig(engine, irisEntity, created, level, blockX, spawnBlockY, blockZ, rng, riseEffectActive);
|
applyConfig(engine, entity, created, level, blockX, spawnBlockY, blockZ, riseEffectActive);
|
||||||
return created;
|
return created;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Entity create(IrisEntity irisEntity, ServerLevel level, double x, double y, double z) {
|
private static Entity create(ContentEntity entity, ServerLevel level, double x, double y, double z) {
|
||||||
if (irisEntity.isSpecialType()) {
|
if (entity.isSpecial()) {
|
||||||
return ModdedCustomContentRegistry.spawnMob(level, x, y, z, irisEntity.getSpecialType());
|
return ModdedCustomContentRegistry.spawnMob(level, x, y, z, entity.specialType());
|
||||||
}
|
}
|
||||||
|
|
||||||
EntityType<?> type = resolveType(irisEntity.getType());
|
EntityType<?> type = resolveType(entity.type());
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity entity = type.spawn(level, BlockPos.containing(x, y, z), reasonFor(irisEntity.getReason()));
|
Entity created = type.spawn(level, BlockPos.containing(x, y, z), reasonFor(entity.reason()));
|
||||||
if (entity != null) {
|
if (created != null) {
|
||||||
entity.snapTo(x, y, z, 0F, 0F);
|
created.snapTo(x, y, z, 0F, 0F);
|
||||||
}
|
}
|
||||||
return entity;
|
return created;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void applyConfig(Engine engine, IrisEntity irisEntity, Entity entity, ServerLevel level, int blockX, int blockY, int blockZ, RNG rng, boolean riseEffectActive) {
|
private static void applyConfig(Engine engine, ContentEntity spec, Entity entity, ServerLevel level, int blockX, int blockY, int blockZ, boolean riseEffectActive) {
|
||||||
String customName = irisEntity.getCustomName();
|
ContentEntity.Flags flags = spec.flags();
|
||||||
if (customName != null) {
|
entity.setCustomName(Component.literal(colorize(spec.customName())));
|
||||||
entity.setCustomName(Component.literal(colorize(customName)));
|
entity.setCustomNameVisible(flags.customNameVisible());
|
||||||
}
|
entity.setGlowingTag(flags.glowing());
|
||||||
entity.setCustomNameVisible(irisEntity.isCustomNameVisible());
|
entity.setNoGravity(!flags.gravity());
|
||||||
entity.setGlowingTag(irisEntity.isGlowing());
|
entity.setInvulnerable(flags.invulnerable());
|
||||||
entity.setNoGravity(!irisEntity.isGravity());
|
entity.setSilent(flags.silent());
|
||||||
entity.setInvulnerable(irisEntity.isInvulnerable());
|
|
||||||
entity.setSilent(irisEntity.isSilent());
|
|
||||||
|
|
||||||
boolean persistent = irisEntity.isKeepEntity() || forcePersist();
|
boolean persistent = flags.keepEntity() || forcePersist();
|
||||||
applyPersistence(entity, persistent);
|
applyPersistence(entity, persistent);
|
||||||
|
|
||||||
applyPassengers(engine, irisEntity, entity, level, blockX, blockY, blockZ, rng);
|
applyPassengers(engine, spec, entity, level, blockX, blockY, blockZ);
|
||||||
|
|
||||||
if (entity instanceof LivingEntity living) {
|
if (entity instanceof LivingEntity living) {
|
||||||
applyAttributes(irisEntity, living, level, rng);
|
applyAttributes(spec, living, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!irisEntity.getLoot().getTables().isEmpty()) {
|
if (!spec.lootTables().isEmpty()) {
|
||||||
ModdedDeathLoot.bind(engine, entity, irisEntity.getLoot().getTables(), blockX, blockY, blockZ, rng);
|
ModdedDeathLoot.bind(engine, entity, spec.lootTables(), blockX, blockY, blockZ, spec.lootShuffleSeed());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity instanceof Mob mob) {
|
if (entity instanceof Mob mob) {
|
||||||
mob.setNoAi(shouldDisableAi(irisEntity.isAi()));
|
mob.setNoAi(shouldDisableAi(flags.ai()));
|
||||||
ModdedEntityAwareness.configure(mob, irisEntity.isAware());
|
ModdedEntityAwareness.configure(mob, flags.aware());
|
||||||
mob.setCanPickUpLoot(irisEntity.isPickupItems());
|
mob.setCanPickUpLoot(flags.pickupItems());
|
||||||
if (!irisEntity.isRemovable()) {
|
if (!flags.removable()) {
|
||||||
mob.setPersistenceRequired();
|
mob.setPersistenceRequired();
|
||||||
}
|
}
|
||||||
if (irisEntity.getLeashHolder() != null) {
|
if (spec.leashHolder() != null) {
|
||||||
Entity holder = spawn(engine, irisEntity.getLeashHolder(), level, blockX, blockY, blockZ, rng.nextParallelRNG(LEASH_RNG_SEED));
|
Entity holder = spawn(engine, spec.leashHolder(), level, blockX, blockY, blockZ);
|
||||||
if (holder != null) {
|
if (holder != null) {
|
||||||
mob.setLeashedTo(holder, true);
|
mob.setLeashedTo(holder, true);
|
||||||
}
|
}
|
||||||
@@ -167,56 +162,51 @@ public final class ModdedEntitySpawner {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (entity instanceof LivingEntity equippable) {
|
if (entity instanceof LivingEntity equippable) {
|
||||||
applyEquipment(irisEntity, equippable, level, rng);
|
applyEquipment(spec, equippable, level);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (irisEntity.isBaby()) {
|
if (flags.baby()) {
|
||||||
applyBaby(entity);
|
applyBaby(entity);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity instanceof Panda panda) {
|
if (entity instanceof Panda panda) {
|
||||||
panda.setMainGene(gene(irisEntity.getPandaMainGene()));
|
panda.setMainGene(gene(spec.pandaMainGene()));
|
||||||
panda.setHiddenGene(gene(irisEntity.getPandaHiddenGene()));
|
panda.setHiddenGene(gene(spec.pandaHiddenGene()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (entity instanceof Villager villager) {
|
if (entity instanceof Villager villager) {
|
||||||
ModdedEntityPersistence.configure(villager, true);
|
ModdedEntityPersistence.configure(villager, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
applySpawnEffect(irisEntity.getSpawnEffect(), entity, level);
|
applySpawnEffect(spec.spawnEffect(), entity, level);
|
||||||
ModdedEntityCommandRunner.run(irisEntity.getRawCommands(), level, blockX, blockY, blockZ);
|
ModdedEntityCommandRunner.run(spec.commands(), level, blockX, blockY, blockZ);
|
||||||
if (riseEffectActive && entity instanceof LivingEntity living) {
|
if (riseEffectActive && entity instanceof LivingEntity living) {
|
||||||
startRiseEffect(engine, level, entity, living);
|
startRiseEffect(engine, level, entity, living);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void applyPassengers(Engine engine, IrisEntity irisEntity, Entity entity, ServerLevel level, int blockX, int blockY, int blockZ, RNG rng) {
|
private static void applyPassengers(Engine engine, ContentEntity spec, Entity entity, ServerLevel level, int blockX, int blockY, int blockZ) {
|
||||||
int index = 0;
|
for (ContentEntity passengerSpec : spec.passengers()) {
|
||||||
for (IrisEntity passengerEntity : irisEntity.getPassengers()) {
|
Entity passenger = spawn(engine, passengerSpec, level, blockX, blockY, blockZ);
|
||||||
Entity passenger = spawn(engine, passengerEntity, level, blockX, blockY, blockZ, rng.nextParallelRNG(PASSENGER_RNG_BASE + index++));
|
|
||||||
if (passenger != null) {
|
if (passenger != null) {
|
||||||
passenger.startRiding(entity);
|
passenger.startRiding(entity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void applyAttributes(IrisEntity irisEntity, LivingEntity living, ServerLevel level, RNG rng) {
|
private static void applyAttributes(ContentEntity spec, LivingEntity living, ServerLevel level) {
|
||||||
KList<IrisAttributeModifier> modifiers = irisEntity.getAttributes();
|
if (spec.attributes().isEmpty()) {
|
||||||
if (modifiers.isEmpty()) {
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Registry<Attribute> registry = level.registryAccess().lookupOrThrow(Registries.ATTRIBUTE);
|
Registry<Attribute> registry = level.registryAccess().lookupOrThrow(Registries.ATTRIBUTE);
|
||||||
int index = 0;
|
int index = 0;
|
||||||
for (IrisAttributeModifier modifier : modifiers) {
|
for (ContentItem.Attribute modifier : spec.attributes()) {
|
||||||
index++;
|
index++;
|
||||||
if (rng.nextDouble() >= modifier.getChance()) {
|
Holder<Attribute> holder = ModdedItemTranslator.resolveAttribute(registry, modifier.attribute());
|
||||||
continue;
|
|
||||||
}
|
|
||||||
Holder<Attribute> holder = ModdedItemTranslator.resolveAttribute(registry, modifier.getAttribute());
|
|
||||||
if (holder == null) {
|
if (holder == null) {
|
||||||
if (WARNED_ATTRIBUTES.add(modifier.getAttribute())) {
|
if (WARNED_ATTRIBUTES.add(modifier.attribute())) {
|
||||||
IrisLogging.warn("Iris entity: unknown attribute '" + modifier.getAttribute() + "'");
|
IrisLogging.warn("Iris entity: unknown attribute '" + modifier.attribute() + "'");
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -224,28 +214,29 @@ public final class ModdedEntitySpawner {
|
|||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Identifier id = Identifier.tryParse("iris:" + normalizeName(modifier.getName()) + "_" + index);
|
Identifier id = Identifier.tryParse("iris:" + normalizeName(modifier.name()) + "_" + index);
|
||||||
if (id == null) {
|
if (id == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
instance.addOrReplacePermanentModifier(new AttributeModifier(id, modifier.getAmount(rng), ModdedItemTranslator.operationFor(modifier.getOperation())));
|
instance.addOrReplacePermanentModifier(new AttributeModifier(id, modifier.amount(), ModdedItemTranslator.operationFor(modifier.operation())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void applyEquipment(IrisEntity irisEntity, LivingEntity living, ServerLevel level, RNG rng) {
|
private static void applyEquipment(ContentEntity spec, LivingEntity living, ServerLevel level) {
|
||||||
setSlot(living, EquipmentSlot.HEAD, irisEntity.getHelmet(), level, rng);
|
ContentEntity.Equipment equipment = spec.equipment();
|
||||||
setSlot(living, EquipmentSlot.CHEST, irisEntity.getChestplate(), level, rng);
|
setSlot(living, EquipmentSlot.HEAD, equipment.helmet(), level);
|
||||||
setSlot(living, EquipmentSlot.LEGS, irisEntity.getLeggings(), level, rng);
|
setSlot(living, EquipmentSlot.CHEST, equipment.chestplate(), level);
|
||||||
setSlot(living, EquipmentSlot.FEET, irisEntity.getBoots(), level, rng);
|
setSlot(living, EquipmentSlot.LEGS, equipment.leggings(), level);
|
||||||
setSlot(living, EquipmentSlot.MAINHAND, irisEntity.getMainHand(), level, rng);
|
setSlot(living, EquipmentSlot.FEET, equipment.boots(), level);
|
||||||
setSlot(living, EquipmentSlot.OFFHAND, irisEntity.getOffHand(), level, rng);
|
setSlot(living, EquipmentSlot.MAINHAND, equipment.mainHand(), level);
|
||||||
|
setSlot(living, EquipmentSlot.OFFHAND, equipment.offHand(), level);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void setSlot(LivingEntity living, EquipmentSlot slot, IrisLoot loot, ServerLevel level, RNG rng) {
|
private static void setSlot(LivingEntity living, EquipmentSlot slot, ContentItem item, ServerLevel level) {
|
||||||
if (loot == null || !LootResolver.oneIn(rng, loot.getRarity())) {
|
if (item == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ItemStack stack = ModdedItemTranslator.stack(loot, rng, level);
|
ItemStack stack = ModdedItemTranslator.stack(item, level);
|
||||||
if (stack != null && !stack.isEmpty()) {
|
if (stack != null && !stack.isEmpty()) {
|
||||||
living.setItemSlot(slot, stack);
|
living.setItemSlot(slot, stack);
|
||||||
}
|
}
|
||||||
@@ -257,11 +248,11 @@ public final class ModdedEntitySpawner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static boolean isAreaClearForSpawn(ServerLevel level, IrisEntity irisEntity, int blockX, int blockY, int blockZ) {
|
static boolean isAreaClearForSpawn(ServerLevel level, ContentEntity entity, int blockX, int blockY, int blockZ) {
|
||||||
if (irisEntity.isSpecialType()) {
|
if (entity.isSpecial()) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
EntityType<?> type = resolveType(irisEntity.getType());
|
EntityType<?> type = resolveType(entity.type());
|
||||||
if (type == null) {
|
if (type == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -320,21 +311,21 @@ public final class ModdedEntitySpawner {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void applySpawnEffect(IrisEffect effect, Entity entity, ServerLevel level) {
|
private static void applySpawnEffect(ContentEntity.SpawnEffect effect, Entity entity, ServerLevel level) {
|
||||||
if (effect == null || !effect.shouldApplyNow()) {
|
if (effect == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
SoundEvent sound = resolveSound(effect.getSoundKey());
|
SoundEvent sound = resolveSound(effect.sound());
|
||||||
if (sound != null) {
|
if (sound != null) {
|
||||||
double soundX = entity.getX() + RNG.r.i(-effect.getSoundDistance(), effect.getSoundDistance());
|
double soundX = entity.getX() + RNG.r.i(-effect.soundDistance(), effect.soundDistance());
|
||||||
double soundY = entity.getY() + RNG.r.i(-effect.getSoundDistance(), effect.getSoundDistance());
|
double soundY = entity.getY() + RNG.r.i(-effect.soundDistance(), effect.soundDistance());
|
||||||
double soundZ = entity.getZ() + RNG.r.i(-effect.getSoundDistance(), effect.getSoundDistance());
|
double soundZ = entity.getZ() + RNG.r.i(-effect.soundDistance(), effect.soundDistance());
|
||||||
level.playSound(null, soundX, soundY, soundZ, sound, SoundSource.MASTER,
|
level.playSound(null, soundX, soundY, soundZ, sound, SoundSource.MASTER,
|
||||||
(float) effect.getVolume(), (float) RNG.r.d(effect.getMinPitch(), effect.getMaxPitch()));
|
(float) effect.volume(), (float) RNG.r.d(effect.minPitch(), effect.maxPitch()));
|
||||||
}
|
}
|
||||||
|
|
||||||
ParticleOptions particle = resolveParticle(effect.getParticleEffectKey());
|
ParticleOptions particle = resolveParticle(effect.particle());
|
||||||
if (particle == null) {
|
if (particle == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -342,13 +333,13 @@ public final class ModdedEntitySpawner {
|
|||||||
double addition = RNG.r.d();
|
double addition = RNG.r.d();
|
||||||
double subtraction = RNG.r.d();
|
double subtraction = RNG.r.d();
|
||||||
double particleX = entity.getX() + addition - subtraction + RNG.r.d();
|
double particleX = entity.getX() + addition - subtraction + RNG.r.d();
|
||||||
double particleY = entity.getY() + 0.25 + addition - subtraction + RNG.r.i(effect.getParticleOffset());
|
double particleY = entity.getY() + 0.25 + addition - subtraction + RNG.r.i(effect.particleOffset());
|
||||||
double particleZ = entity.getZ() + addition - subtraction + RNG.r.d();
|
double particleZ = entity.getZ() + addition - subtraction + RNG.r.d();
|
||||||
double altX = effect.isRandomAltX() ? RNG.r.d(-effect.getParticleAltX(), effect.getParticleAltX()) : effect.getParticleAltX();
|
double altX = effect.randomAltX() ? RNG.r.d(-effect.altX(), effect.altX()) : effect.altX();
|
||||||
double altY = effect.isRandomAltY() ? RNG.r.d(-effect.getParticleAltY(), effect.getParticleAltY()) : effect.getParticleAltY();
|
double altY = effect.randomAltY() ? RNG.r.d(-effect.altY(), effect.altY()) : effect.altY();
|
||||||
double altZ = effect.isRandomAltZ() ? RNG.r.d(-effect.getParticleAltZ(), effect.getParticleAltZ()) : effect.getParticleAltZ();
|
double altZ = effect.randomAltZ() ? RNG.r.d(-effect.altZ(), effect.altZ()) : effect.altZ();
|
||||||
level.sendParticles(particle, particleX, particleY, particleZ, effect.getParticleCount(),
|
level.sendParticles(particle, particleX, particleY, particleZ, effect.particleCount(),
|
||||||
altX, altY, altZ, effect.getExtra());
|
altX, altY, altZ, effect.extra());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SoundEvent resolveSound(String key) {
|
private static SoundEvent resolveSound(String key) {
|
||||||
|
|||||||
+55
-105
@@ -18,19 +18,11 @@
|
|||||||
|
|
||||||
package art.arcane.iris.modded;
|
package art.arcane.iris.modded;
|
||||||
|
|
||||||
import art.arcane.iris.engine.framework.LootResolver;
|
import art.arcane.iris.core.content.ContentItem;
|
||||||
import art.arcane.iris.engine.loot.LootTables;
|
|
||||||
import art.arcane.iris.engine.object.loot.InventorySlotType;
|
|
||||||
import art.arcane.iris.engine.object.entity.IrisAttributeModifier;
|
|
||||||
import art.arcane.iris.engine.object.loot.IrisEnchantment;
|
|
||||||
import art.arcane.iris.engine.object.loot.IrisLoot;
|
|
||||||
import art.arcane.iris.engine.object.loot.IrisLootTable;
|
|
||||||
import art.arcane.iris.spi.IrisLogging;
|
import art.arcane.iris.spi.IrisLogging;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import art.arcane.volmlib.util.collection.KMap;
|
|
||||||
import art.arcane.volmlib.util.format.Form;
|
import art.arcane.volmlib.util.format.Form;
|
||||||
import art.arcane.volmlib.util.json.JSONObject;
|
import art.arcane.volmlib.util.json.JSONObject;
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
|
||||||
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
import com.mojang.brigadier.exceptions.CommandSyntaxException;
|
||||||
import net.minecraft.core.Holder;
|
import net.minecraft.core.Holder;
|
||||||
import net.minecraft.core.Registry;
|
import net.minecraft.core.Registry;
|
||||||
@@ -63,6 +55,7 @@ import net.minecraft.world.item.enchantment.ItemEnchantments;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
@@ -74,42 +67,27 @@ public final class ModdedItemTranslator {
|
|||||||
private ModdedItemTranslator() {
|
private ModdedItemTranslator() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static KList<ItemStack> loot(IrisLootTable table, long lootSeed, InventorySlotType slot, ServerLevel level, int x, int y, int z) {
|
/** The stacks of {@code items}, without the ones the platform cannot make. */
|
||||||
KList<ItemStack> out = new KList<>();
|
public static KList<ItemStack> stacks(List<ContentItem> items, ServerLevel level) {
|
||||||
KList<IrisLoot> entries = table.getLoot();
|
KList<ItemStack> stacks = new KList<>();
|
||||||
if (entries.isEmpty() || table.getMaxTries() <= 0) {
|
for (ContentItem item : items) {
|
||||||
return out;
|
ItemStack stack = stack(item, level);
|
||||||
}
|
if (stack != null && !stack.isEmpty()) {
|
||||||
|
stacks.add(stack);
|
||||||
RNG rng = LootTables.rng(lootSeed, table, x, y, z);
|
|
||||||
int m = 0;
|
|
||||||
int c = 0;
|
|
||||||
int mx = Math.max(0, LootResolver.inclusive(rng, table.getMinPicked(), table.getMaxPicked()));
|
|
||||||
|
|
||||||
while (m < mx && c++ < table.getMaxTries()) {
|
|
||||||
int entryIndex = rng.nextInt(entries.size());
|
|
||||||
IrisLoot entry = entries.get(entryIndex);
|
|
||||||
if (entry == null || entry.getSlotTypes() != slot) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ItemStack item = item(entry, table, rng, lootSeed, entryIndex, level, x, y, z);
|
|
||||||
if (item != null && !item.isEmpty()) {
|
|
||||||
out.add(item);
|
|
||||||
m++;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return stacks;
|
||||||
return out;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack stack(IrisLoot loot, RNG rng, ServerLevel level) {
|
/** The stack of {@code item}, or null when the platform has no such item. */
|
||||||
|
public static ItemStack stack(ContentItem item, ServerLevel level) {
|
||||||
try {
|
try {
|
||||||
ItemStack stack = baseStack(loot, rng);
|
ItemStack stack = baseStack(item);
|
||||||
if (stack == null || stack.isEmpty()) {
|
if (stack == null || stack.isEmpty()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
applyComponents(loot, stack, rng, level);
|
applyComponents(item, stack, level);
|
||||||
applyCustomNbt(stack, loot.getCustomNbt());
|
applyCustomNbt(stack, item.customNbt());
|
||||||
return stack;
|
return stack;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
IrisLogging.reportError(e);
|
IrisLogging.reportError(e);
|
||||||
@@ -117,28 +95,8 @@ public final class ModdedItemTranslator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ItemStack item(IrisLoot loot, IrisLootTable table, RNG rng, long lootSeed, int entryIndex, ServerLevel level, int x, int y, int z) {
|
private static ItemStack baseStack(ContentItem item) {
|
||||||
long combinedRarity = LootResolver.combinedRarity(loot.getRarity(), table.getRarity());
|
String raw = item.item();
|
||||||
if (!LootTables.spatialOneIn(lootSeed, table, entryIndex, x, y, z, combinedRarity)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
ItemStack stack = baseStack(loot, rng);
|
|
||||||
if (stack == null || stack.isEmpty()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
applyComponents(loot, stack, rng, level);
|
|
||||||
applyCustomNbt(stack, loot.getCustomNbt());
|
|
||||||
return stack;
|
|
||||||
} catch (Throwable e) {
|
|
||||||
IrisLogging.reportError(e);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static ItemStack baseStack(IrisLoot loot, RNG rng) {
|
|
||||||
String raw = loot.getTypeKey();
|
|
||||||
if (raw == null || raw.isBlank()) {
|
if (raw == null || raw.isBlank()) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -150,55 +108,53 @@ public final class ModdedItemTranslator {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
Item item = BuiltInRegistries.ITEM.getValue(id);
|
return new ItemStack(BuiltInRegistries.ITEM.getValue(id), item.amount());
|
||||||
return new ItemStack(item, Math.max(1, LootResolver.inclusive(rng, loot.getMinAmount(), loot.getMaxAmount())));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void applyComponents(IrisLoot loot, ItemStack stack, RNG rng, ServerLevel level) {
|
private static void applyComponents(ContentItem item, ItemStack stack, ServerLevel level) {
|
||||||
applyEnchantments(loot, stack, rng, level);
|
applyEnchantments(item, stack, level);
|
||||||
applyAttributes(loot, stack, rng, level);
|
applyAttributes(item, stack, level);
|
||||||
|
|
||||||
if (loot.isUnbreakable()) {
|
if (item.unbreakable()) {
|
||||||
stack.set(DataComponents.UNBREAKABLE, Unit.INSTANCE);
|
stack.set(DataComponents.UNBREAKABLE, Unit.INSTANCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loot.getItemFlags().isNotEmpty()) {
|
if (!item.flags().isEmpty()) {
|
||||||
applyItemFlags(loot, stack);
|
applyItemFlags(item, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loot.getCustomModel() != null) {
|
if (item.customModel() != null) {
|
||||||
stack.set(DataComponents.CUSTOM_MODEL_DATA, new CustomModelData(List.of(loot.getCustomModel().floatValue()), List.of(), List.of(), List.of()));
|
stack.set(DataComponents.CUSTOM_MODEL_DATA, new CustomModelData(List.of(item.customModel().floatValue()), List.of(), List.of(), List.of()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stack.getMaxDamage() > 0) {
|
if (stack.getMaxDamage() > 0 && item.damage() != null) {
|
||||||
int max = stack.getMaxDamage();
|
int max = stack.getMaxDamage();
|
||||||
int damage = (int) Math.round(Math.max(0, Math.min(max, (1D - rng.d(loot.getMinDurability(), loot.getMaxDurability())) * max)));
|
int damage = (int) Math.round(Math.max(0, Math.min(max, item.damage() * max)));
|
||||||
stack.set(DataComponents.DAMAGE, damage);
|
stack.set(DataComponents.DAMAGE, damage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loot.getLeatherColor() != null) {
|
if (item.leatherColor() != null) {
|
||||||
try {
|
try {
|
||||||
int rgb = Integer.decode(loot.getLeatherColor()) & 0xFFFFFF;
|
int rgb = Integer.decode(item.leatherColor()) & 0xFFFFFF;
|
||||||
stack.set(DataComponents.DYED_COLOR, new DyedItemColor(rgb));
|
stack.set(DataComponents.DYED_COLOR, new DyedItemColor(rgb));
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
warnOnce("leatherColor:" + loot.getLeatherColor(), "Iris loot: invalid leatherColor '" + loot.getLeatherColor() + "'");
|
warnOnce("leatherColor:" + item.leatherColor(), "Iris loot: invalid leatherColor '" + item.leatherColor() + "'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String dye = loot.getDyeColorKey();
|
if (item.dyeColor() != null) {
|
||||||
if (dye != null) {
|
applyDyeColor(stack, item.dyeColor());
|
||||||
applyDyeColor(stack, dye);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (loot.getDisplayName() != null) {
|
if (item.displayName() != null) {
|
||||||
stack.set(DataComponents.CUSTOM_NAME, Component.literal(colorize(loot.getDisplayName())));
|
stack.set(DataComponents.CUSTOM_NAME, Component.literal(colorize(item.displayName())));
|
||||||
}
|
}
|
||||||
|
|
||||||
applyLore(loot, stack);
|
applyLore(item, stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void applyEnchantments(IrisLoot loot, ItemStack stack, RNG rng, ServerLevel level) {
|
private static void applyEnchantments(ContentItem item, ItemStack stack, ServerLevel level) {
|
||||||
if (loot.getEnchantments().isEmpty()) {
|
if (item.enchantments().isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -207,8 +163,8 @@ public final class ModdedItemTranslator {
|
|||||||
ItemEnchantments.Mutable mutable = new ItemEnchantments.Mutable(stack.getOrDefault(component, ItemEnchantments.EMPTY));
|
ItemEnchantments.Mutable mutable = new ItemEnchantments.Mutable(stack.getOrDefault(component, ItemEnchantments.EMPTY));
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
|
|
||||||
for (IrisEnchantment enchantment : loot.getEnchantments()) {
|
for (ContentItem.Enchantment enchantment : item.enchantments()) {
|
||||||
String name = enchantment.getEnchantment();
|
String name = enchantment.key();
|
||||||
if (name == null || name.isBlank()) {
|
if (name == null || name.isBlank()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -221,10 +177,8 @@ public final class ModdedItemTranslator {
|
|||||||
warnOnce("enchantment:" + key, "Iris loot: unknown enchantment '" + name + "'");
|
warnOnce("enchantment:" + key, "Iris loot: unknown enchantment '" + name + "'");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (rng.nextDouble() < enchantment.getChance()) {
|
mutable.set(holder.get(), enchantment.level());
|
||||||
mutable.set(holder.get(), enchantment.getLevel(rng));
|
changed = true;
|
||||||
changed = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (changed) {
|
if (changed) {
|
||||||
@@ -232,8 +186,8 @@ public final class ModdedItemTranslator {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void applyAttributes(IrisLoot loot, ItemStack stack, RNG rng, ServerLevel level) {
|
private static void applyAttributes(ContentItem item, ItemStack stack, ServerLevel level) {
|
||||||
if (loot.getAttributes().isEmpty()) {
|
if (item.attributes().isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -241,21 +195,17 @@ public final class ModdedItemTranslator {
|
|||||||
ItemAttributeModifiers.Builder builder = ItemAttributeModifiers.builder();
|
ItemAttributeModifiers.Builder builder = ItemAttributeModifiers.builder();
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
|
|
||||||
for (IrisAttributeModifier attribute : loot.getAttributes()) {
|
for (ContentItem.Attribute attribute : item.attributes()) {
|
||||||
if (rng.nextDouble() >= attribute.getChance()) {
|
Holder<Attribute> holder = resolveAttribute(registry, attribute.attribute());
|
||||||
continue;
|
|
||||||
}
|
|
||||||
double amount = attribute.getAmount(rng);
|
|
||||||
Holder<Attribute> holder = resolveAttribute(registry, attribute.getAttribute());
|
|
||||||
if (holder == null) {
|
if (holder == null) {
|
||||||
warnOnce("attribute:" + attribute.getAttribute(), "Iris loot: unknown attribute '" + attribute.getAttribute() + "'");
|
warnOnce("attribute:" + attribute.attribute(), "Iris loot: unknown attribute '" + attribute.attribute() + "'");
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Identifier modifierId = attributeModifierId(attribute.getName());
|
Identifier modifierId = attributeModifierId(attribute.name());
|
||||||
if (modifierId == null) {
|
if (modifierId == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
AttributeModifier modifier = new AttributeModifier(modifierId, amount, operationFor(attribute.getOperation()));
|
AttributeModifier modifier = new AttributeModifier(modifierId, attribute.amount(), operationFor(attribute.operation()));
|
||||||
builder.add(holder, modifier, EquipmentSlotGroup.ANY);
|
builder.add(holder, modifier, EquipmentSlotGroup.ANY);
|
||||||
changed = true;
|
changed = true;
|
||||||
}
|
}
|
||||||
@@ -311,11 +261,11 @@ public final class ModdedItemTranslator {
|
|||||||
return Identifier.tryParse("iris:" + normalized);
|
return Identifier.tryParse("iris:" + normalized);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void applyItemFlags(IrisLoot loot, ItemStack stack) {
|
private static void applyItemFlags(ContentItem item, ItemStack stack) {
|
||||||
TooltipDisplay display = stack.getOrDefault(DataComponents.TOOLTIP_DISPLAY, TooltipDisplay.DEFAULT);
|
TooltipDisplay display = stack.getOrDefault(DataComponents.TOOLTIP_DISPLAY, TooltipDisplay.DEFAULT);
|
||||||
boolean changed = false;
|
boolean changed = false;
|
||||||
|
|
||||||
for (String flag : loot.getItemFlags()) {
|
for (String flag : item.flags()) {
|
||||||
if (flag == null || flag.isBlank()) {
|
if (flag == null || flag.isBlank()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@@ -356,13 +306,13 @@ public final class ModdedItemTranslator {
|
|||||||
stack.set(DataComponents.BASE_COLOR, color);
|
stack.set(DataComponents.BASE_COLOR, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void applyLore(IrisLoot loot, ItemStack stack) {
|
private static void applyLore(ContentItem item, ItemStack stack) {
|
||||||
if (loot.getLore().isEmpty()) {
|
if (item.lore().isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<Component> lines = new ArrayList<>();
|
List<Component> lines = new ArrayList<>();
|
||||||
for (String line : loot.getLore()) {
|
for (String line : item.lore()) {
|
||||||
String colored = colorize(line);
|
String colored = colorize(line);
|
||||||
if (colored.length() > 24) {
|
if (colored.length() > 24) {
|
||||||
for (String wrapped : Form.wrapWords(colored, 24).split("\\Q\n\\E")) {
|
for (String wrapped : Form.wrapWords(colored, 24).split("\\Q\n\\E")) {
|
||||||
@@ -375,7 +325,7 @@ public final class ModdedItemTranslator {
|
|||||||
stack.set(DataComponents.LORE, new ItemLore(lines));
|
stack.set(DataComponents.LORE, new ItemLore(lines));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void applyCustomNbt(ItemStack stack, KMap<String, Object> customNbt) {
|
private static void applyCustomNbt(ItemStack stack, Map<String, Object> customNbt) {
|
||||||
if (customNbt == null || customNbt.isEmpty()) {
|
if (customNbt == null || customNbt.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
+24
-119
@@ -18,19 +18,11 @@
|
|||||||
|
|
||||||
package art.arcane.iris.modded;
|
package art.arcane.iris.modded;
|
||||||
|
|
||||||
import art.arcane.iris.engine.loot.LootResources;
|
import art.arcane.iris.core.content.ContentLoot;
|
||||||
import art.arcane.iris.engine.object.loot.IrisObjectLoot;
|
import art.arcane.iris.core.content.ContentServices;
|
||||||
import art.arcane.iris.engine.object.loot.IrisObjectVanillaLoot;
|
|
||||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
|
||||||
import art.arcane.iris.engine.framework.Engine;
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
import art.arcane.iris.engine.framework.LootResolver;
|
import art.arcane.iris.engine.framework.LootResolver;
|
||||||
import art.arcane.iris.engine.loot.LootTables;
|
|
||||||
import art.arcane.iris.engine.framework.PlacedObject;
|
|
||||||
import art.arcane.iris.engine.object.loot.IObjectLoot;
|
|
||||||
import art.arcane.iris.engine.object.loot.InventorySlotType;
|
|
||||||
import art.arcane.iris.engine.object.loot.IrisLootTable;
|
|
||||||
import art.arcane.iris.spi.IrisLogging;
|
import art.arcane.iris.spi.IrisLogging;
|
||||||
import art.arcane.iris.spi.PlatformBlockState;
|
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
@@ -53,7 +45,6 @@ import net.minecraft.world.level.storage.loot.parameters.LootContextParamSets;
|
|||||||
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
|
||||||
import net.minecraft.world.phys.Vec3;
|
import net.minecraft.world.phys.Vec3;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
|
|
||||||
@@ -65,10 +56,10 @@ public final class ModdedLootApplier {
|
|||||||
if (!isCanonicalContainer(pos, state)) {
|
if (!isCanonicalContainer(pos, state)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
RNG rng = LootResolver.containerRng(engine.getSeedManager().getLoot(), pos.getX(), pos.getY(), pos.getZ());
|
|
||||||
boolean nativeLootDefined = hasNativeLootTable(level, pos, state);
|
boolean nativeLootDefined = hasNativeLootTable(level, pos, state);
|
||||||
List<LootSource> sources = resolveSources(engine, level, rng, pos, state, mc, nativeLootDefined);
|
String containerKey = ModdedBlockResolution.isStorageChest(state) ? ModdedBlockState.serialize(state) : null;
|
||||||
if (sources.isEmpty()) {
|
List<ContentLoot.Part> parts = ContentServices.containerLoot(engine, pos.getX(), pos.getY(), pos.getZ(), containerKey, nativeLootDefined);
|
||||||
|
if (parts.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -80,97 +71,38 @@ public final class ModdedLootApplier {
|
|||||||
|
|
||||||
KList<ItemStack> items = new KList<>();
|
KList<ItemStack> items = new KList<>();
|
||||||
LootParams nativeParams = null;
|
LootParams nativeParams = null;
|
||||||
for (LootSource source : sources) {
|
for (ContentLoot.Part part : parts) {
|
||||||
if (source instanceof IrisLootSource irisSource) {
|
if (part instanceof ContentLoot.Items drawn) {
|
||||||
IrisLootTable table = irisSource.table();
|
items.addAll(ModdedItemTranslator.stacks(drawn.items(), level));
|
||||||
if (table == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
items.addAll(ModdedItemTranslator.loot(table, engine.getSeedManager().getLoot(), InventorySlotType.STORAGE, level, pos.getX(), pos.getY(), pos.getZ()));
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (source instanceof NativeLootSource nativeSource) {
|
if (part instanceof ContentLoot.PlatformTable platform) {
|
||||||
|
LootTable table = nativeTable(level, platform.key());
|
||||||
|
if (table == null) {
|
||||||
|
IrisLogging.warn("Unknown vanilla loot table " + platform.key());
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (nativeParams == null) {
|
if (nativeParams == null) {
|
||||||
nativeParams = new LootParams.Builder(level)
|
nativeParams = new LootParams.Builder(level)
|
||||||
.withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(pos))
|
.withParameter(LootContextParams.ORIGIN, Vec3.atCenterOf(pos))
|
||||||
.create(LootContextParamSets.CHEST);
|
.create(LootContextParamSets.CHEST);
|
||||||
}
|
}
|
||||||
items.addAll(nativeSource.table().getRandomItems(nativeParams, rng.nextLong()));
|
items.addAll(table.getRandomItems(nativeParams, platform.seed()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fillContainer(container, items, rng);
|
fillContainer(container, items, LootResolver.containerRng(engine.getSeedManager().getLoot(), pos.getX(), pos.getY(), pos.getZ()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<LootSource> resolveSources(Engine engine, ServerLevel level, RNG rng, BlockPos pos, BlockState state, MantleChunk<Matter> mc, boolean nativeLootDefined) {
|
private static LootTable nativeTable(ServerLevel level, String name) {
|
||||||
int rx = pos.getX();
|
ResourceKey<LootTable> key = resolveNativeKey(name, candidate -> hasNativeTable(level, candidate));
|
||||||
int rz = pos.getZ();
|
if (key == null) {
|
||||||
int ry = pos.getY() - engine.getWorld().minHeight();
|
return null;
|
||||||
List<LootSource> sources = new ArrayList<>();
|
|
||||||
boolean objectLootDefined = nativeLootDefined;
|
|
||||||
|
|
||||||
PlacedObject po = engine.getObjectPlacement(rx, ry, rz, mc);
|
|
||||||
if (po != null && po.getPlacement() != null && ModdedBlockResolution.isStorageChest(state)) {
|
|
||||||
objectLootDefined = objectLootDefined
|
|
||||||
|| po.getPlacement().getLoot().isNotEmpty()
|
|
||||||
|| po.getPlacement().getVanillaLoot().isNotEmpty();
|
|
||||||
Candidate picked = pickPlacementTable(engine, level, po.getPlacement(), state, rng);
|
|
||||||
if (picked != null) {
|
|
||||||
sources.add(picked.source());
|
|
||||||
if (po.getPlacement().isOverrideGlobalLoot()) {
|
|
||||||
return sources;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
return level.getServer().reloadableRegistries().lookup()
|
||||||
LootTables.resolveEnvironmentSources(
|
.lookupOrThrow(Registries.LOOT_TABLE)
|
||||||
sources,
|
.getOrThrow(key)
|
||||||
engine,
|
.value();
|
||||||
rng,
|
|
||||||
rx,
|
|
||||||
ry,
|
|
||||||
rz,
|
|
||||||
objectLootDefined,
|
|
||||||
IrisLootSource::new
|
|
||||||
);
|
|
||||||
return sources;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static Candidate pickPlacementTable(Engine engine, ServerLevel level, IrisObjectPlacement placement, BlockState state, RNG rng) {
|
|
||||||
List<Candidate> exact = new ArrayList<>();
|
|
||||||
List<Candidate> basic = new ArrayList<>();
|
|
||||||
List<Candidate> global = new ArrayList<>();
|
|
||||||
|
|
||||||
for (IrisObjectLoot loot : placement.getLoot()) {
|
|
||||||
if (loot == null || loot.getWeight() <= 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
IrisLootTable table = LootResources.table(engine.getData(), loot.getName());
|
|
||||||
if (table == null) {
|
|
||||||
IrisLogging.warn("Couldn't find loot table " + loot.getName());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
bucket(engine, loot, new Candidate(new IrisLootSource(table), loot.getWeight()), state, exact, basic, global);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (IrisObjectVanillaLoot loot : placement.getVanillaLoot()) {
|
|
||||||
if (loot == null || loot.getWeight() <= 0) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
ResourceKey<LootTable> key = resolveNativeKey(loot.getName(), candidate -> hasNativeTable(level, candidate));
|
|
||||||
if (key == null) {
|
|
||||||
IrisLogging.warn("Couldn't find vanilla loot table " + loot.getName());
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
LootTable table = level.getServer().reloadableRegistries().lookup()
|
|
||||||
.lookupOrThrow(Registries.LOOT_TABLE)
|
|
||||||
.getOrThrow(key)
|
|
||||||
.value();
|
|
||||||
bucket(engine, loot, new Candidate(new NativeLootSource(table), loot.getWeight()), state, exact, basic, global);
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Candidate> pool = !exact.isEmpty() ? exact : !basic.isEmpty() ? basic : global;
|
|
||||||
return LootResolver.pickWeighted(pool, Candidate::weight, rng);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static ResourceKey<LootTable> resolveNativeKey(String name, Predicate<ResourceKey<LootTable>> registryContains) {
|
static ResourceKey<LootTable> resolveNativeKey(String name, Predicate<ResourceKey<LootTable>> registryContains) {
|
||||||
@@ -197,21 +129,6 @@ public final class ModdedLootApplier {
|
|||||||
.isPresent();
|
.isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void bucket(Engine engine, IObjectLoot loot, Candidate candidate, BlockState state, List<Candidate> exact, List<Candidate> basic, List<Candidate> global) {
|
|
||||||
if (loot.getFilter().isEmpty()) {
|
|
||||||
global.add(candidate);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (PlatformBlockState filterState : loot.getFilter(engine.getData())) {
|
|
||||||
BlockState filter = (BlockState) filterState.nativeHandle();
|
|
||||||
if (loot.isExact() ? filter == state : filter.getBlock() == state.getBlock()) {
|
|
||||||
(loot.isExact() ? exact : basic).add(candidate);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static boolean isCanonicalContainer(BlockPos pos, BlockState state) {
|
static boolean isCanonicalContainer(BlockPos pos, BlockState state) {
|
||||||
if (!(state.getBlock() instanceof ChestBlock) || state.getValue(ChestBlock.TYPE) == ChestType.SINGLE) {
|
if (!(state.getBlock() instanceof ChestBlock) || state.getValue(ChestBlock.TYPE) == ChestType.SINGLE) {
|
||||||
return true;
|
return true;
|
||||||
@@ -324,16 +241,4 @@ public final class ModdedLootApplier {
|
|||||||
container.setItem(i, items[i]);
|
container.setItem(i, items[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private interface LootSource {
|
|
||||||
}
|
|
||||||
|
|
||||||
private record IrisLootSource(IrisLootTable table) implements LootSource {
|
|
||||||
}
|
|
||||||
|
|
||||||
private record NativeLootSource(LootTable table) implements LootSource {
|
|
||||||
}
|
|
||||||
|
|
||||||
private record Candidate(LootSource source, int weight) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
+45
-220
@@ -18,25 +18,15 @@
|
|||||||
|
|
||||||
package art.arcane.iris.modded;
|
package art.arcane.iris.modded;
|
||||||
|
|
||||||
import art.arcane.iris.engine.spawn.SpawnResources;
|
|
||||||
import art.arcane.iris.core.IrisSettings;
|
import art.arcane.iris.core.IrisSettings;
|
||||||
|
import art.arcane.iris.core.content.ContentServices;
|
||||||
|
import art.arcane.iris.core.content.ContentSpawns;
|
||||||
import art.arcane.iris.core.gui.PregeneratorJob;
|
import art.arcane.iris.core.gui.PregeneratorJob;
|
||||||
import art.arcane.iris.engine.IrisComplex;
|
import art.arcane.iris.engine.IrisComplex;
|
||||||
import art.arcane.iris.engine.framework.Engine;
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
import art.arcane.iris.engine.framework.EngineLifecycleTasks;
|
import art.arcane.iris.engine.framework.EngineLifecycleTasks;
|
||||||
import art.arcane.iris.engine.framework.EngineWorldManager;
|
import art.arcane.iris.engine.framework.EngineWorldManager;
|
||||||
import art.arcane.iris.engine.framework.LootResolver;
|
|
||||||
import art.arcane.iris.engine.object.value.IRare;
|
|
||||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
|
||||||
import art.arcane.iris.engine.object.entity.IrisEntity;
|
|
||||||
import art.arcane.iris.engine.object.entity.IrisEntitySpawn;
|
|
||||||
import art.arcane.iris.engine.object.marker.IrisMarker;
|
|
||||||
import art.arcane.iris.engine.object.value.IrisPosition;
|
import art.arcane.iris.engine.object.value.IrisPosition;
|
||||||
import art.arcane.iris.engine.object.value.IrisRange;
|
|
||||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
|
||||||
import art.arcane.iris.engine.object.entity.spawn.IrisSpawnGroup;
|
|
||||||
import art.arcane.iris.engine.object.entity.spawn.IrisSpawner;
|
|
||||||
import art.arcane.iris.engine.object.entity.spawn.IrisSurface;
|
|
||||||
import art.arcane.iris.spi.IrisLogging;
|
import art.arcane.iris.spi.IrisLogging;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
|
import art.arcane.volmlib.util.mantle.flag.MantleFlag;
|
||||||
@@ -45,7 +35,6 @@ import art.arcane.volmlib.util.mantle.runtime.MantleChunk;
|
|||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
import art.arcane.volmlib.util.matter.Matter;
|
import art.arcane.volmlib.util.matter.Matter;
|
||||||
import art.arcane.volmlib.util.matter.MatterMarker;
|
import art.arcane.volmlib.util.matter.MatterMarker;
|
||||||
import art.arcane.volmlib.util.matter.slices.MarkerMatter;
|
|
||||||
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
import it.unimi.dsi.fastutil.objects.Object2IntMap;
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.server.level.ServerLevel;
|
import net.minecraft.server.level.ServerLevel;
|
||||||
@@ -60,6 +49,8 @@ import net.minecraft.world.level.chunk.LevelChunk;
|
|||||||
import net.minecraft.world.phys.AABB;
|
import net.minecraft.world.phys.AABB;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.ArrayBlockingQueue;
|
import java.util.concurrent.ArrayBlockingQueue;
|
||||||
import java.util.concurrent.BlockingQueue;
|
import java.util.concurrent.BlockingQueue;
|
||||||
@@ -397,8 +388,8 @@ public final class ModdedWorldManager implements EngineWorldManager {
|
|||||||
if (tag.equals("cave_floor") || tag.equals("cave_ceiling")) {
|
if (tag.equals("cave_floor") || tag.equals("cave_ceiling")) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IrisMarker resolved = SpawnResources.marker(engine.getData(), tag);
|
Optional<ContentSpawns.MarkerRule> rule = ContentServices.markerRule(engine, tag);
|
||||||
if (resolved == null) {
|
if (rule.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -406,20 +397,17 @@ public final class ModdedWorldManager implements EngineWorldManager {
|
|||||||
int worldZ = (chunkZ << 4) + (z & 15);
|
int worldZ = (chunkZ << 4) + (z & 15);
|
||||||
int worldY = yf + minHeight;
|
int worldY = yf + minHeight;
|
||||||
|
|
||||||
if (resolved.isEmptyAbove() && aboveObstructed(level, worldX, worldY, worldZ)) {
|
if (rule.get().emptyAbove() && aboveObstructed(level, worldX, worldY, worldZ)) {
|
||||||
obstructed.add(new IrisPosition(worldX, yf, worldZ));
|
obstructed.add(new IrisPosition(worldX, yf, worldZ));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
KList<IrisSpawner> spawners = resolveMarkerSpawners(resolved);
|
List<String> spawners = rule.get().spawners();
|
||||||
if (spawners.isEmpty()) {
|
if (spawners.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IrisSpawner chosen = spawners.getRandom();
|
String chosen = spawners.get(RNG.r.nextInt(spawners.size()));
|
||||||
if (chosen == null) {
|
spawnAtMarker(level, new IrisPosition(worldX, worldY, worldZ), tag, chosen, initial);
|
||||||
return;
|
|
||||||
}
|
|
||||||
spawnFromSpawner(level, new IrisPosition(worldX, worldY, worldZ), chosen, initial);
|
|
||||||
});
|
});
|
||||||
Mantle<Matter> mantle = engine.getMantle().getMantle();
|
Mantle<Matter> mantle = engine.getMantle().getMantle();
|
||||||
for (IrisPosition position : obstructed) {
|
for (IrisPosition position : obstructed) {
|
||||||
@@ -427,43 +415,14 @@ public final class ModdedWorldManager implements EngineWorldManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private KList<IrisSpawner> resolveMarkerSpawners(IrisMarker marker) {
|
private void spawnAtMarker(ServerLevel level, IrisPosition position, String marker, String spawner, boolean initial) {
|
||||||
KList<IrisSpawner> spawners = new KList<>();
|
ContentServices.planMarkerSpawn(engine, position.getX(), position.getY(), position.getZ(), marker, spawner, initial)
|
||||||
for (String key : marker.getSpawners()) {
|
.ifPresent(plan -> {
|
||||||
IrisSpawner spawner = SpawnResources.spawner(engine.getData(), key);
|
if (plan.exhaustsMarker()) {
|
||||||
if (spawner == null) {
|
engine.getMantle().getMantle().remove(position.getX(), position.getY() - engine.getWorld().minHeight(), position.getZ(), MatterMarker.class);
|
||||||
IrisLogging.error("Cannot load spawner: " + key + " for marker on " + engine.getName());
|
}
|
||||||
continue;
|
spawn(level, plan);
|
||||||
}
|
});
|
||||||
spawner.setReferenceMarker(marker);
|
|
||||||
spawners.add(spawner);
|
|
||||||
}
|
|
||||||
return spawners;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void spawnFromSpawner(ServerLevel level, IrisPosition position, IrisSpawner spawner, boolean initial) {
|
|
||||||
KList<IrisEntitySpawn> spawns = initial ? spawner.getInitialSpawns() : spawner.getSpawns();
|
|
||||||
if (spawns.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
for (IrisEntitySpawn entry : spawns) {
|
|
||||||
entry.setReferenceSpawner(spawner);
|
|
||||||
entry.setReferenceMarker(spawner.getReferenceMarker());
|
|
||||||
}
|
|
||||||
IrisEntitySpawn chosen = rarityPick(spawns);
|
|
||||||
if (chosen == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
int chunkX = position.getX() >> 4;
|
|
||||||
int chunkZ = position.getZ() >> 4;
|
|
||||||
if (!canSpawn(spawner, chunkX, chunkZ)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int spawned = spawnEntryAt(level, chosen, spawner, position);
|
|
||||||
if (spawned > 0) {
|
|
||||||
spawner.spawn(engine, chunkX, chunkZ);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void spawnAmbient(ServerLevel level, int chunkX, int chunkZ, boolean initial) {
|
private void spawnAmbient(ServerLevel level, int chunkX, int chunkZ, boolean initial) {
|
||||||
@@ -472,184 +431,55 @@ public final class ModdedWorldManager implements EngineWorldManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
int blockX = chunkX << 4;
|
ContentServices.planChunkSpawn(engine, chunkX, chunkZ, countChunkLivingEntities(level, chunkX, chunkZ), initial)
|
||||||
int blockZ = chunkZ << 4;
|
.ifPresent(plan -> spawn(level, plan));
|
||||||
IrisBiome biome = engine.getSurfaceBiome(blockX, blockZ);
|
|
||||||
IrisRegion region = engine.getRegion(blockX, blockZ);
|
|
||||||
int chunkMobs = countChunkLivingEntities(level, chunkX, chunkZ);
|
|
||||||
|
|
||||||
KList<IrisEntitySpawn> pool = new KList<>();
|
|
||||||
collectSpawns(pool, SpawnResources.spawners(engine.getData(), engine.getDimension().getEntitySpawners()), biome, chunkX, chunkZ, chunkMobs, initial);
|
|
||||||
collectSpawns(pool, SpawnResources.spawners(engine.getData(), region.getEntitySpawners()), null, chunkX, chunkZ, chunkMobs, initial);
|
|
||||||
collectSpawns(pool, SpawnResources.spawners(engine.getData(), biome.getEntitySpawners()), null, chunkX, chunkZ, chunkMobs, initial);
|
|
||||||
if (pool.isEmpty()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
IrisEntitySpawn chosen = rarityPick(pool);
|
|
||||||
if (chosen == null || chosen.getReferenceSpawner() == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
IrisSpawner spawner = chosen.getReferenceSpawner();
|
|
||||||
if (!canSpawn(spawner, chunkX, chunkZ)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
int spawned = spawnEntry(level, chosen, spawner, chunkX, chunkZ);
|
|
||||||
if (spawned > 0) {
|
|
||||||
spawner.spawn(engine, chunkX, chunkZ);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void collectSpawns(KList<IrisEntitySpawn> pool, KList<IrisSpawner> spawners, IrisBiome biomeFilter, int chunkX, int chunkZ, int chunkMobs, boolean initial) {
|
/** Spawns the entities of the plan that the light, the surface below and the space around them allow, and tells the plan how many appeared. */
|
||||||
for (IrisSpawner spawner : spawners) {
|
private void spawn(ServerLevel level, ContentSpawns.Plan plan) {
|
||||||
if (spawner == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (spawner.getMaxEntitiesPerChunk() <= chunkMobs) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (biomeFilter != null && !spawner.isValid(biomeFilter)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!canSpawn(spawner, chunkX, chunkZ)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
KList<IrisEntitySpawn> spawns = initial ? spawner.getInitialSpawns() : spawner.getSpawns();
|
|
||||||
for (IrisEntitySpawn entry : spawns) {
|
|
||||||
entry.setReferenceSpawner(spawner);
|
|
||||||
entry.setReferenceMarker(spawner.getReferenceMarker());
|
|
||||||
pool.add(entry);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private int spawnEntry(ServerLevel level, IrisEntitySpawn entry, IrisSpawner spawner, int chunkX, int chunkZ) {
|
|
||||||
IrisEntity irisEntity = entry.getRealEntity(engine);
|
|
||||||
if (irisEntity == null) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int min = entry.getMinSpawns();
|
|
||||||
int max = entry.getMaxSpawns();
|
|
||||||
int count = LootResolver.inclusive(RNG.r, min, max);
|
|
||||||
if (count <= 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
RNG entityRng = entry.getRng().aquire(() -> new RNG(engine.getSeedManager().getEntity()));
|
|
||||||
IrisSpawnGroup group = spawner.getGroup();
|
|
||||||
KList<IrisPosition> caveFloors = group == IrisSpawnGroup.CAVE
|
|
||||||
? engine.getMantle().findMarkers(chunkX, chunkZ, MarkerMatter.CAVE_FLOOR)
|
|
||||||
: new KList<>();
|
|
||||||
int spawned = 0;
|
int spawned = 0;
|
||||||
for (int i = 0; i < count; i++) {
|
for (ContentSpawns.Attempt attempt : plan.attempts()) {
|
||||||
int worldX;
|
if (spawnIfAllowed(level, attempt)) {
|
||||||
int worldY;
|
|
||||||
int worldZ;
|
|
||||||
if (group == IrisSpawnGroup.CAVE) {
|
|
||||||
if (caveFloors.isEmpty()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
IrisPosition caveFloor = caveFloors.getRandom(RNG.r);
|
|
||||||
worldX = caveFloor.getX();
|
|
||||||
worldY = caveFloor.getY() + 1;
|
|
||||||
worldZ = caveFloor.getZ();
|
|
||||||
} else {
|
|
||||||
worldX = (chunkX << 4) + RNG.r.i(16);
|
|
||||||
worldZ = (chunkZ << 4) + RNG.r.i(16);
|
|
||||||
int surfaceY = level.getMinY() + engine.getHeight(worldX, worldZ, false);
|
|
||||||
int solidY = level.getMinY() + engine.getHeight(worldX, worldZ, true);
|
|
||||||
worldY = group == IrisSpawnGroup.NORMAL
|
|
||||||
? surfaceY + 1
|
|
||||||
: RNG.r.i(solidY + 1, surfaceY);
|
|
||||||
}
|
|
||||||
if (worldY <= level.getMinY() || worldY >= level.getMaxY()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
// Rarity is applied exactly once, as pool weighting in rarityPick - never re-rolled per position (Bukkit parity).
|
|
||||||
if (!lightAllowed(spawner, level, worldX, worldY, worldZ)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!surfaceMatches(irisEntity.getSurface(), level, worldX, worldY, worldZ)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!ModdedEntitySpawner.isAreaClearForSpawn(level, irisEntity, worldX, worldY, worldZ)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (ModdedEntitySpawner.spawn(engine, irisEntity, level, worldX, worldY, worldZ, entityRng) != null) {
|
|
||||||
spawned++;
|
spawned++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return spawned;
|
plan.spawned(spawned);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int spawnEntryAt(ServerLevel level, IrisEntitySpawn entry, IrisSpawner spawner, IrisPosition position) {
|
private boolean spawnIfAllowed(ServerLevel level, ContentSpawns.Attempt attempt) {
|
||||||
IrisEntity irisEntity = entry.getRealEntity(engine);
|
if (attempt.worldY() <= level.getMinY() || attempt.worldY() >= level.getMaxY()) {
|
||||||
if (irisEntity == null) {
|
return false;
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
if (attempt.restrictsLight() && !lightAllowed(attempt, level)) {
|
||||||
int min = entry.getMinSpawns();
|
return false;
|
||||||
int max = entry.getMaxSpawns();
|
|
||||||
int count = LootResolver.inclusive(RNG.r, min, max);
|
|
||||||
if (count <= 0) {
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
if (attempt.checkSurface() && !surfaceAllows(attempt, level)) {
|
||||||
exhaustMarker(spawner, position);
|
return false;
|
||||||
|
|
||||||
RNG entityRng = entry.getRng().aquire(() -> new RNG(engine.getSeedManager().getEntity()));
|
|
||||||
int worldX = position.getX();
|
|
||||||
int worldY = position.getY() + 1;
|
|
||||||
int worldZ = position.getZ();
|
|
||||||
int spawned = 0;
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
// Rarity is applied exactly once, as pool weighting in rarityPick - never re-rolled per position (Bukkit parity).
|
|
||||||
if (!lightAllowed(spawner, level, worldX, worldY, worldZ)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (ModdedEntitySpawner.spawn(engine, irisEntity, level, worldX, worldY, worldZ, entityRng) != null) {
|
|
||||||
spawned++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return spawned;
|
return ModdedEntitySpawner.spawn(engine, attempt.entity(), level, attempt.x(), attempt.worldY(), attempt.z()) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void exhaustMarker(IrisSpawner spawner, IrisPosition position) {
|
private static boolean lightAllowed(ContentSpawns.Attempt attempt, ServerLevel level) {
|
||||||
IrisMarker marker = spawner.getReferenceMarker();
|
int light = level.getMaxLocalRawBrightness(new BlockPos(attempt.x(), attempt.worldY(), attempt.z()));
|
||||||
if (marker == null || !marker.shouldExhaust()) {
|
return light >= attempt.minLight() && light <= attempt.maxLight();
|
||||||
return;
|
|
||||||
}
|
|
||||||
engine.getMantle().getMantle().remove(position.getX(), position.getY() - engine.getWorld().minHeight(), position.getZ(), MatterMarker.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean canSpawn(IrisSpawner spawner, int chunkX, int chunkZ) {
|
private static boolean surfaceAllows(ContentSpawns.Attempt attempt, ServerLevel level) {
|
||||||
return spawner.canSpawn(engine, chunkX, chunkZ);
|
BlockState below = level.getBlockState(new BlockPos(attempt.x(), attempt.worldY() - 1, attempt.z()));
|
||||||
|
return matchesSurface(attempt.surface(), below)
|
||||||
|
&& ModdedEntitySpawner.isAreaClearForSpawn(level, attempt.entity(), attempt.x(), attempt.worldY(), attempt.z());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean lightAllowed(IrisSpawner spawner, ServerLevel level, int worldX, int worldY, int worldZ) {
|
private static boolean matchesSurface(ContentSpawns.Surface surface, BlockState below) {
|
||||||
IrisRange range = spawner.getAllowedLightLevels();
|
|
||||||
if (range.getMin() > 0 || range.getMax() < 15) {
|
|
||||||
return range.contains(level.getMaxLocalRawBrightness(new BlockPos(worldX, worldY, worldZ)));
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean surfaceMatches(IrisSurface surface, ServerLevel level, int worldX, int worldY, int worldZ) {
|
|
||||||
BlockState below = level.getBlockState(new BlockPos(worldX, worldY - 1, worldZ));
|
|
||||||
return matchesSurface(surface, below);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static boolean matchesSurface(IrisSurface surface, BlockState below) {
|
|
||||||
if (ModdedBlockResolution.isSolid(below)) {
|
if (ModdedBlockResolution.isSolid(below)) {
|
||||||
return surface == IrisSurface.LAND || surface == IrisSurface.OVERWORLD
|
return surface == ContentSpawns.Surface.LAND || surface == ContentSpawns.Surface.OVERWORLD
|
||||||
|| (surface == IrisSurface.ANIMAL && isAnimalGround(below));
|
|| (surface == ContentSpawns.Surface.ANIMAL && isAnimalGround(below));
|
||||||
}
|
}
|
||||||
if (below.is(Blocks.LAVA)) {
|
if (below.is(Blocks.LAVA)) {
|
||||||
return surface == IrisSurface.LAVA;
|
return surface == ContentSpawns.Surface.LAVA;
|
||||||
}
|
}
|
||||||
if (ModdedBlockResolution.isWater(below) || ModdedBlockResolution.isWaterLogged(below) || isAquaticFoliage(below)) {
|
if (ModdedBlockResolution.isWater(below) || ModdedBlockResolution.isWaterLogged(below) || isAquaticFoliage(below)) {
|
||||||
return surface == IrisSurface.WATER || surface == IrisSurface.OVERWORLD;
|
return surface == ContentSpawns.Surface.WATER || surface == ContentSpawns.Surface.OVERWORLD;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@@ -770,11 +600,6 @@ public final class ModdedWorldManager implements EngineWorldManager {
|
|||||||
return !studio || studioSetting;
|
return !studio || studioSetting;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisEntitySpawn rarityPick(KList<IrisEntitySpawn> entries) {
|
|
||||||
KList<IrisEntitySpawn> weighted = IRare.expandWeighted(entries);
|
|
||||||
return weighted.isEmpty() ? entries.getRandom() : weighted.getRandom();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static long pack(int x, int z) {
|
private static long pack(int x, int z) {
|
||||||
return (((long) x) & 0xFFFFFFFFL) | ((((long) z) & 0xFFFFFFFFL) << 32);
|
return (((long) x) & 0xFFFFFFFFL) | ((((long) z) & 0xFFFFFFFFL) << 32);
|
||||||
}
|
}
|
||||||
|
|||||||
+8
-59
@@ -18,9 +18,6 @@
|
|||||||
|
|
||||||
package art.arcane.iris.modded.command;
|
package art.arcane.iris.modded.command;
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
|
||||||
import art.arcane.iris.engine.spawn.SpawnResources;
|
|
||||||
import art.arcane.iris.engine.loot.LootResources;
|
|
||||||
import art.arcane.iris.modded.ModdedIrisLog;
|
import art.arcane.iris.modded.ModdedIrisLog;
|
||||||
import art.arcane.iris.core.IrisSettings;
|
import art.arcane.iris.core.IrisSettings;
|
||||||
import art.arcane.iris.core.gui.GuiHost;
|
import art.arcane.iris.core.gui.GuiHost;
|
||||||
@@ -37,13 +34,10 @@ import art.arcane.iris.engine.framework.Engine;
|
|||||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||||
import art.arcane.iris.engine.object.world.biome.IrisBiomeGeneratorLink;
|
import art.arcane.iris.engine.object.world.biome.IrisBiomeGeneratorLink;
|
||||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||||
import art.arcane.iris.engine.object.entity.IrisEntitySpawn;
|
|
||||||
import art.arcane.iris.engine.object.terrain.IrisGenerator;
|
import art.arcane.iris.engine.object.terrain.IrisGenerator;
|
||||||
|
import art.arcane.iris.core.pack.ModuleResourceClosure;
|
||||||
import art.arcane.iris.core.pack.PackExportClosure;
|
import art.arcane.iris.core.pack.PackExportClosure;
|
||||||
import art.arcane.iris.engine.object.entity.IrisEntity;
|
|
||||||
import art.arcane.iris.engine.object.marker.IrisMarker;
|
|
||||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||||
import art.arcane.iris.engine.object.entity.spawn.IrisSpawner;
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
||||||
import art.arcane.iris.modded.ModdedDimensionManager;
|
import art.arcane.iris.modded.ModdedDimensionManager;
|
||||||
import art.arcane.iris.modded.ModdedEngineBootstrap;
|
import art.arcane.iris.modded.ModdedEngineBootstrap;
|
||||||
@@ -56,7 +50,6 @@ import art.arcane.volmlib.util.format.Form;
|
|||||||
import art.arcane.volmlib.util.io.IO;
|
import art.arcane.volmlib.util.io.IO;
|
||||||
import art.arcane.volmlib.util.json.JSONObject;
|
import art.arcane.volmlib.util.json.JSONObject;
|
||||||
import art.arcane.volmlib.util.math.M;
|
import art.arcane.volmlib.util.math.M;
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
|
||||||
import art.arcane.volmlib.util.math.Spiraler;
|
import art.arcane.volmlib.util.math.Spiraler;
|
||||||
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
import com.mojang.brigadier.arguments.IntegerArgumentType;
|
||||||
import com.mojang.brigadier.arguments.LongArgumentType;
|
import com.mojang.brigadier.arguments.LongArgumentType;
|
||||||
@@ -887,12 +880,9 @@ public final class ModdedStudioCommands {
|
|||||||
|
|
||||||
LinkedHashSet<String> regionKeys = new LinkedHashSet<>();
|
LinkedHashSet<String> regionKeys = new LinkedHashSet<>();
|
||||||
LinkedHashSet<String> biomeKeys = new LinkedHashSet<>();
|
LinkedHashSet<String> biomeKeys = new LinkedHashSet<>();
|
||||||
LinkedHashSet<String> entityKeys = new LinkedHashSet<>();
|
|
||||||
LinkedHashSet<String> spawnerKeys = new LinkedHashSet<>();
|
|
||||||
LinkedHashSet<String> generatorKeys = new LinkedHashSet<>();
|
LinkedHashSet<String> generatorKeys = new LinkedHashSet<>();
|
||||||
LinkedHashSet<String> lootKeys = new LinkedHashSet<>();
|
ModuleResourceClosure moduleResources = new ModuleResourceClosure(dm);
|
||||||
LinkedHashSet<String> objectKeys = new LinkedHashSet<>();
|
LinkedHashSet<String> objectKeys = new LinkedHashSet<>();
|
||||||
LinkedHashSet<String> markerKeys = new LinkedHashSet<>();
|
|
||||||
LinkedHashSet<String> structureKeys = new LinkedHashSet<>();
|
LinkedHashSet<String> structureKeys = new LinkedHashSet<>();
|
||||||
|
|
||||||
dimension.getAllRegions(() -> dm).forEach((IrisRegion region) -> {
|
dimension.getAllRegions(() -> dm).forEach((IrisRegion region) -> {
|
||||||
@@ -905,8 +895,7 @@ public final class ModdedStudioCommands {
|
|||||||
biomeKeys.add(biome.getLoadKey());
|
biomeKeys.add(biome.getLoadKey());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
lootKeys.addAll(dimension.getLoot().getTables());
|
moduleResources.followSettingsOf(dimension);
|
||||||
spawnerKeys.addAll(dimension.getEntitySpawners());
|
|
||||||
collectStructureKeys(structureKeys, dimension.getStructures());
|
collectStructureKeys(structureKeys, dimension.getStructures());
|
||||||
|
|
||||||
for (String regionKey : regionKeys) {
|
for (String regionKey : regionKeys) {
|
||||||
@@ -919,11 +908,10 @@ public final class ModdedStudioCommands {
|
|||||||
biomeKeys.add(biome.getLoadKey());
|
biomeKeys.add(biome.getLoadKey());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
lootKeys.addAll(region.getLoot().getTables());
|
moduleResources.followSettingsOf(region);
|
||||||
spawnerKeys.addAll(region.getEntitySpawners());
|
moduleResources.follow(region.getObjects());
|
||||||
collectStructureKeys(structureKeys, region.getStructures());
|
collectStructureKeys(structureKeys, region.getStructures());
|
||||||
objectKeys.addAll(PackExportClosure.collectObjectKeys(region.getObjects()));
|
objectKeys.addAll(PackExportClosure.collectObjectKeys(region.getObjects()));
|
||||||
markerKeys.addAll(PackExportClosure.collectMarkerKeys(region.getObjects()));
|
|
||||||
}
|
}
|
||||||
for (String biomeKey : biomeKeys) {
|
for (String biomeKey : biomeKeys) {
|
||||||
IrisBiome biome = dm.getBiomeLoader().load(biomeKey);
|
IrisBiome biome = dm.getBiomeLoader().load(biomeKey);
|
||||||
@@ -931,33 +919,10 @@ public final class ModdedStudioCommands {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
biome.getGenerators().forEach((IrisBiomeGeneratorLink link) -> generatorKeys.add(link.getGenerator()));
|
biome.getGenerators().forEach((IrisBiomeGeneratorLink link) -> generatorKeys.add(link.getGenerator()));
|
||||||
lootKeys.addAll(biome.getLoot().getTables());
|
moduleResources.followSettingsOf(biome);
|
||||||
spawnerKeys.addAll(biome.getEntitySpawners());
|
moduleResources.follow(biome.getObjects());
|
||||||
collectStructureKeys(structureKeys, biome.getStructures());
|
collectStructureKeys(structureKeys, biome.getStructures());
|
||||||
objectKeys.addAll(PackExportClosure.collectObjectKeys(biome.getObjects()));
|
objectKeys.addAll(PackExportClosure.collectObjectKeys(biome.getObjects()));
|
||||||
markerKeys.addAll(PackExportClosure.collectMarkerKeys(biome.getObjects()));
|
|
||||||
}
|
|
||||||
for (String markerKey : markerKeys) {
|
|
||||||
IrisMarker marker = SpawnResources.marker(dm, markerKey);
|
|
||||||
if (marker == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
spawnerKeys.addAll(marker.getSpawners());
|
|
||||||
}
|
|
||||||
for (String spawnerKey : spawnerKeys) {
|
|
||||||
IrisSpawner spawner = SpawnResources.spawner(dm, spawnerKey);
|
|
||||||
if (spawner == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
spawner.getSpawns().forEach((IrisEntitySpawn spawn) -> entityKeys.add(spawn.getEntity()));
|
|
||||||
spawner.getInitialSpawns().forEach((IrisEntitySpawn spawn) -> entityKeys.add(spawn.getEntity()));
|
|
||||||
}
|
|
||||||
for (String entityKey : entityKeys) {
|
|
||||||
IrisEntity entity = SpawnResources.entity(dm, entityKey);
|
|
||||||
if (entity == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
lootKeys.addAll(entity.getLoot().getTables());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
StringBuilder hashes = new StringBuilder();
|
StringBuilder hashes = new StringBuilder();
|
||||||
@@ -990,18 +955,7 @@ public final class ModdedStudioCommands {
|
|||||||
for (String key : biomeKeys) {
|
for (String key : biomeKeys) {
|
||||||
hashes.append(copyJson(folder, "biomes", key, dm.getBiomeLoader().findFile(key)));
|
hashes.append(copyJson(folder, "biomes", key, dm.getBiomeLoader().findFile(key)));
|
||||||
}
|
}
|
||||||
for (String key : entityKeys) {
|
hashes.append(moduleResources.writeTo(folder, true));
|
||||||
hashes.append(copyJson(folder, "entities", key, loadFile(SpawnResources.entity(dm, key))));
|
|
||||||
}
|
|
||||||
for (String key : lootKeys) {
|
|
||||||
hashes.append(copyJson(folder, "loot", key, loadFile(LootResources.table(dm, key))));
|
|
||||||
}
|
|
||||||
for (String key : spawnerKeys) {
|
|
||||||
hashes.append(copyJson(folder, "spawners", key, loadFile(SpawnResources.spawner(dm, key))));
|
|
||||||
}
|
|
||||||
for (String key : markerKeys) {
|
|
||||||
hashes.append(copyJson(folder, "markers", key, loadFile(SpawnResources.marker(dm, key))));
|
|
||||||
}
|
|
||||||
|
|
||||||
JSONObject meta = new JSONObject();
|
JSONObject meta = new JSONObject();
|
||||||
meta.put("hash", IO.hash(hashes.toString()));
|
meta.put("hash", IO.hash(hashes.toString()));
|
||||||
@@ -1091,9 +1045,4 @@ public final class ModdedStudioCommands {
|
|||||||
thread.start();
|
thread.start();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** The file a resource was read from, or null when the pack has no such resource. */
|
|
||||||
private static File loadFile(IrisRegistrant resource) {
|
|
||||||
return resource == null ? null : resource.getLoadFile();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
-41
@@ -1,41 +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.modded;
|
|
||||||
|
|
||||||
import net.minecraft.core.Direction;
|
|
||||||
import net.minecraft.world.level.block.Blocks;
|
|
||||||
import net.minecraft.world.level.block.StairBlock;
|
|
||||||
import net.minecraft.world.level.block.state.BlockState;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertFalse;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
public class ModdedBlockBreakHandlerTest {
|
|
||||||
@Test
|
|
||||||
public void exactMatchingIncludesPropertiesWhileTypeMatchingDoesNot() {
|
|
||||||
BlockState north = Blocks.OAK_STAIRS.defaultBlockState().setValue(StairBlock.FACING, Direction.NORTH);
|
|
||||||
BlockState east = Blocks.OAK_STAIRS.defaultBlockState().setValue(StairBlock.FACING, Direction.EAST);
|
|
||||||
|
|
||||||
assertTrue(ModdedBlockBreakHandler.matchesState(north, north, true));
|
|
||||||
assertFalse(ModdedBlockBreakHandler.matchesState(north, east, true));
|
|
||||||
assertTrue(ModdedBlockBreakHandler.matchesState(north, east, false));
|
|
||||||
assertFalse(ModdedBlockBreakHandler.matchesState(north, Blocks.COBBLESTONE.defaultBlockState(), false));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-11
@@ -1,6 +1,5 @@
|
|||||||
package art.arcane.iris.modded;
|
package art.arcane.iris.modded;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.entity.IrisEffect;
|
|
||||||
import net.minecraft.core.BlockPos;
|
import net.minecraft.core.BlockPos;
|
||||||
import net.minecraft.world.entity.Mob;
|
import net.minecraft.world.entity.Mob;
|
||||||
import net.minecraft.world.entity.EntitySpawnReason;
|
import net.minecraft.world.entity.EntitySpawnReason;
|
||||||
@@ -149,16 +148,6 @@ public class ModdedEntitySpawnerParityTest {
|
|||||||
assertEquals(EntitySpawnReason.NATURAL, ModdedEntitySpawner.reasonFor("not_a_spawn_reason"));
|
assertEquals(EntitySpawnReason.NATURAL, ModdedEntitySpawner.reasonFor("not_a_spawn_reason"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
public void entityEffectExposesNeutralRegistryKeys() {
|
|
||||||
IrisEffect effect = new IrisEffect()
|
|
||||||
.setSound("minecraft:block.amethyst_block.chime")
|
|
||||||
.setParticleEffect("minecraft:flame");
|
|
||||||
|
|
||||||
assertEquals("minecraft:block.amethyst_block.chime", effect.getSoundKey());
|
|
||||||
assertEquals("minecraft:flame", effect.getParticleEffectKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
private static long pack(int x, int z) {
|
private static long pack(int x, int z) {
|
||||||
return (((long) x) & 0xFFFFFFFFL) | ((((long) z) & 0xFFFFFFFFL) << 32);
|
return (((long) x) & 0xFFFFFFFFL) | ((((long) z) & 0xFFFFFFFFL) << 32);
|
||||||
}
|
}
|
||||||
|
|||||||
+6
-6
@@ -2,7 +2,7 @@ package art.arcane.iris.modded;
|
|||||||
|
|
||||||
import art.arcane.iris.engine.framework.LootResolver;
|
import art.arcane.iris.engine.framework.LootResolver;
|
||||||
import art.arcane.iris.engine.loot.LootTables;
|
import art.arcane.iris.engine.loot.LootTables;
|
||||||
import art.arcane.iris.engine.object.loot.IrisLootMode;
|
import art.arcane.iris.builtin.loot.LootMode;
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
import net.minecraft.resources.Identifier;
|
import net.minecraft.resources.Identifier;
|
||||||
import net.minecraft.resources.ResourceKey;
|
import net.minecraft.resources.ResourceKey;
|
||||||
@@ -31,7 +31,7 @@ public class ModdedLootApplierTest {
|
|||||||
public void addAppendsSourcesInOrder() {
|
public void addAppendsSourcesInOrder() {
|
||||||
List<String> sources = new ArrayList<>(List.of("placement-native"));
|
List<String> sources = new ArrayList<>(List.of("placement-native"));
|
||||||
|
|
||||||
LootTables.injectSources(sources, List.of("dimension-iris", "region-iris"), IrisLootMode.ADD, false);
|
LootTables.injectSources(sources, List.of("dimension-iris", "region-iris"), LootMode.ADD, false);
|
||||||
|
|
||||||
assertEquals(List.of("placement-native", "dimension-iris", "region-iris"), sources);
|
assertEquals(List.of("placement-native", "dimension-iris", "region-iris"), sources);
|
||||||
}
|
}
|
||||||
@@ -40,7 +40,7 @@ public class ModdedLootApplierTest {
|
|||||||
public void clearRemovesEverythingAndContributesNothing() {
|
public void clearRemovesEverythingAndContributesNothing() {
|
||||||
List<String> sources = new ArrayList<>(List.of("placement-native", "dimension-iris"));
|
List<String> sources = new ArrayList<>(List.of("placement-native", "dimension-iris"));
|
||||||
|
|
||||||
LootTables.injectSources(sources, List.of("biome-iris"), IrisLootMode.CLEAR, false);
|
LootTables.injectSources(sources, List.of("biome-iris"), LootMode.CLEAR, false);
|
||||||
|
|
||||||
assertEquals(List.of(), sources);
|
assertEquals(List.of(), sources);
|
||||||
}
|
}
|
||||||
@@ -49,7 +49,7 @@ public class ModdedLootApplierTest {
|
|||||||
public void replaceRemovesNativeAndIrisSourcesBeforeAdding() {
|
public void replaceRemovesNativeAndIrisSourcesBeforeAdding() {
|
||||||
List<String> sources = new ArrayList<>(List.of("placement-native", "dimension-iris"));
|
List<String> sources = new ArrayList<>(List.of("placement-native", "dimension-iris"));
|
||||||
|
|
||||||
LootTables.injectSources(sources, List.of("biome-iris"), IrisLootMode.REPLACE, false);
|
LootTables.injectSources(sources, List.of("biome-iris"), LootMode.REPLACE, false);
|
||||||
|
|
||||||
assertEquals(List.of("biome-iris"), sources);
|
assertEquals(List.of("biome-iris"), sources);
|
||||||
}
|
}
|
||||||
@@ -64,7 +64,7 @@ public class ModdedLootApplierTest {
|
|||||||
public void fallbackDoesNotOverrideExistingNativeOrIrisSources() {
|
public void fallbackDoesNotOverrideExistingNativeOrIrisSources() {
|
||||||
List<String> sources = new ArrayList<>(List.of("placement-native", "dimension-iris"));
|
List<String> sources = new ArrayList<>(List.of("placement-native", "dimension-iris"));
|
||||||
|
|
||||||
LootTables.injectSources(sources, List.of("fallback-iris"), IrisLootMode.FALLBACK, false);
|
LootTables.injectSources(sources, List.of("fallback-iris"), LootMode.FALLBACK, false);
|
||||||
|
|
||||||
assertEquals(List.of("placement-native", "dimension-iris"), sources);
|
assertEquals(List.of("placement-native", "dimension-iris"), sources);
|
||||||
}
|
}
|
||||||
@@ -73,7 +73,7 @@ public class ModdedLootApplierTest {
|
|||||||
public void fallbackAddsSourcesWhenPlacementIsEmpty() {
|
public void fallbackAddsSourcesWhenPlacementIsEmpty() {
|
||||||
List<String> sources = new ArrayList<>();
|
List<String> sources = new ArrayList<>();
|
||||||
|
|
||||||
LootTables.injectSources(sources, List.of("fallback-iris"), IrisLootMode.FALLBACK, true);
|
LootTables.injectSources(sources, List.of("fallback-iris"), LootMode.FALLBACK, true);
|
||||||
|
|
||||||
assertEquals(List.of("fallback-iris"), sources);
|
assertEquals(List.of("fallback-iris"), sources);
|
||||||
}
|
}
|
||||||
|
|||||||
-75
@@ -1,75 +0,0 @@
|
|||||||
package art.arcane.iris.modded;
|
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.value.IRare;
|
|
||||||
import art.arcane.iris.engine.object.entity.IrisEntitySpawn;
|
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
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 ModdedSpawnerRarityParityTest {
|
|
||||||
private static IrisEntitySpawn spawn(int rarity) {
|
|
||||||
IrisEntitySpawn spawn = new IrisEntitySpawn();
|
|
||||||
spawn.setRarity(rarity);
|
|
||||||
return spawn;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void rarityIsAppliedOnceAsPoolWeightOnly() {
|
|
||||||
IrisEntitySpawn common = spawn(1);
|
|
||||||
IrisEntitySpawn rare = spawn(4);
|
|
||||||
|
|
||||||
KList<IrisEntitySpawn> expanded = IRare.expandWeighted(List.of(common, rare));
|
|
||||||
|
|
||||||
// totalRarity 5 -> common appears 5/1 = 5 times, rare 5/4 = 1 time.
|
|
||||||
assertEquals(6, expanded.size());
|
|
||||||
assertEquals(5, expanded.stream().filter(entry -> entry == common).count());
|
|
||||||
assertEquals(1, expanded.stream().filter(entry -> entry == rare).count());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void rarityZeroAndNegativeAreClampedToOne() {
|
|
||||||
assertEquals(1, IRare.get(spawn(0)));
|
|
||||||
assertEquals(1, IRare.get(spawn(-5)));
|
|
||||||
assertEquals(3, IRare.get(spawn(3)));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void perPositionSpawnLoopsDoNotRerollEntryRarity() throws Exception {
|
|
||||||
String source = Files.readString(Path.of(System.getProperty("iris.moddedCommonSources"),
|
|
||||||
"art/arcane/iris/modded/ModdedWorldManager.java"));
|
|
||||||
|
|
||||||
for (String method : List.of("private int spawnEntry(", "private int spawnEntryAt(")) {
|
|
||||||
String body = methodBody(source, method);
|
|
||||||
assertFalse(method + " must not re-roll rarity per position; rarityPick already weighted the pool",
|
|
||||||
body.contains("getRarity()"));
|
|
||||||
assertTrue(method + " must keep the min/max spawn-count roll",
|
|
||||||
body.contains("LootResolver.inclusive("));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static String methodBody(String source, String declaration) {
|
|
||||||
int start = source.indexOf(declaration);
|
|
||||||
assertTrue("ModdedWorldManager must declare " + declaration, start >= 0);
|
|
||||||
int open = source.indexOf('{', start);
|
|
||||||
int depth = 0;
|
|
||||||
for (int index = open; index < source.length(); index++) {
|
|
||||||
char character = source.charAt(index);
|
|
||||||
if (character == '{') {
|
|
||||||
depth++;
|
|
||||||
} else if (character == '}') {
|
|
||||||
depth--;
|
|
||||||
if (depth == 0) {
|
|
||||||
return source.substring(open + 1, index);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
throw new AssertionError(declaration + " is not brace balanced");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -104,20 +104,15 @@ art/arcane/iris/engine/object/world/biome/IrisBiome.java
|
|||||||
art/arcane/iris/engine/object/world/biome/custom/IrisBiomeCustomParticle.java
|
art/arcane/iris/engine/object/world/biome/custom/IrisBiomeCustomParticle.java
|
||||||
art/arcane/iris/engine/object/world/biome/IrisBiomeDerivatives.java
|
art/arcane/iris/engine/object/world/biome/IrisBiomeDerivatives.java
|
||||||
art/arcane/iris/engine/object/world/biome/custom/IrisBiomeCustomSpawn.java
|
art/arcane/iris/engine/object/world/biome/custom/IrisBiomeCustomSpawn.java
|
||||||
art/arcane/iris/engine/object/marker/IrisCommandRegistry.java
|
|
||||||
art/arcane/iris/engine/object/compatibility/IrisCompat.java
|
art/arcane/iris/engine/object/compatibility/IrisCompat.java
|
||||||
art/arcane/iris/engine/object/compatibility/IrisCompatabilityBlockFilter.java
|
art/arcane/iris/engine/object/compatibility/IrisCompatabilityBlockFilter.java
|
||||||
art/arcane/iris/engine/object/compatibility/IrisCompatabilityItemFilter.java
|
art/arcane/iris/engine/object/compatibility/IrisCompatabilityItemFilter.java
|
||||||
art/arcane/iris/engine/object/value/IrisDirection.java
|
art/arcane/iris/engine/object/value/IrisDirection.java
|
||||||
art/arcane/iris/engine/object/entity/IrisEffect.java
|
|
||||||
art/arcane/iris/engine/object/prefab/IrisObject.java
|
art/arcane/iris/engine/object/prefab/IrisObject.java
|
||||||
art/arcane/iris/engine/object/placement/IrisObjectPlacement.java
|
art/arcane/iris/engine/object/placement/IrisObjectPlacement.java
|
||||||
art/arcane/iris/engine/object/prefab/IrisObjectRotation.java
|
art/arcane/iris/engine/object/prefab/IrisObjectRotation.java
|
||||||
art/arcane/iris/engine/object/entity/IrisPotionEffect.java
|
|
||||||
art/arcane/iris/engine/object/placement/IrisTree.java
|
art/arcane/iris/engine/object/placement/IrisTree.java
|
||||||
art/arcane/iris/engine/object/loot/IrisVanillaLootTable.java
|
|
||||||
art/arcane/iris/engine/object/prefab/LegacyTileData.java
|
art/arcane/iris/engine/object/prefab/LegacyTileData.java
|
||||||
art/arcane/iris/engine/object/entity/PotionEffectTypes.java
|
|
||||||
art/arcane/iris/engine/object/prefab/TileData.java
|
art/arcane/iris/engine/object/prefab/TileData.java
|
||||||
art/arcane/iris/engine/platform/BukkitChunkGenerator.java
|
art/arcane/iris/engine/platform/BukkitChunkGenerator.java
|
||||||
art/arcane/iris/engine/platform/DummyBiomeProvider.java
|
art/arcane/iris/engine/platform/DummyBiomeProvider.java
|
||||||
@@ -182,3 +177,5 @@ art/arcane/iris/engine/platform/BukkitEntitySpawner.java
|
|||||||
art/arcane/iris/engine/platform/BukkitSurfaces.java
|
art/arcane/iris/engine/platform/BukkitSurfaces.java
|
||||||
art/arcane/iris/platform/bukkit/BukkitAttributes.java
|
art/arcane/iris/platform/bukkit/BukkitAttributes.java
|
||||||
art/arcane/iris/platform/bukkit/BukkitItemStacks.java
|
art/arcane/iris/platform/bukkit/BukkitItemStacks.java
|
||||||
|
art/arcane/iris/platform/bukkit/BukkitAmbientEffects.java
|
||||||
|
art/arcane/iris/platform/bukkit/PotionEffectTypes.java
|
||||||
@@ -0,0 +1,44 @@
|
|||||||
|
/*
|
||||||
|
* 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.content;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An ambient effect that plays now, in host terms: what {@code com.volmit.service.AmbientEffects.Effect} says. The
|
||||||
|
* adapter carries out the parts it has, in the order sound, particles, commands, potion.
|
||||||
|
*/
|
||||||
|
public record ContentEffect(Sound sound, Particles particles, List<Command> commands, Potion potion) {
|
||||||
|
/** A sound, with blocks offset from the player and the volume and pitch decided. */
|
||||||
|
public record Sound(String key, int offsetX, int offsetY, int offsetZ, float volume, float pitch) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Particles {@code forward} blocks ahead of the player and {@code sideways} to the right, on the surface there. */
|
||||||
|
public record Particles(String key, double forward, double sideways, double jitterX, double jitterZ, int lift, int count,
|
||||||
|
double altX, double altY, double altZ, double extra) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Commands run offset from the player. */
|
||||||
|
public record Command(ContentEntity.Command command, double offsetX, double offsetY, double offsetZ) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A potion effect for the player; one with a stronger amplifier already on the player stays. */
|
||||||
|
public record Potion(String key, int strength, int ticks) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* 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.content;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An entity a module decided on, in host terms: what {@code com.volmit.entity.EntitySpec} says, for adapters that cannot
|
||||||
|
* name IrisApi types. Everything random was decided by the module; the adapter creates and configures the entity.
|
||||||
|
*/
|
||||||
|
public record ContentEntity(String type, String specialType, String reason, String customName, Flags flags, Equipment equipment,
|
||||||
|
List<ContentEntity> passengers, List<ContentItem.Attribute> attributes, List<String> lootTables,
|
||||||
|
long lootShuffleSeed, ContentEntity leashHolder, SpawnEffect spawnEffect, boolean riseOutOfGround,
|
||||||
|
String pandaMainGene, String pandaHiddenGene, boolean applySettingsToSpecial,
|
||||||
|
List<Command> commands) {
|
||||||
|
/** Whether the entity is a mob of another plugin. */
|
||||||
|
public boolean isSpecial() {
|
||||||
|
return !specialType.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** What an entity can be set to be, whatever its kind. */
|
||||||
|
public record Flags(boolean customNameVisible, boolean aware, boolean ai, boolean glowing, boolean gravity,
|
||||||
|
boolean invulnerable, boolean silent, boolean pickupItems, boolean removable,
|
||||||
|
boolean keepEntity, boolean baby) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The items an entity wears and holds; null for an empty slot. */
|
||||||
|
public record Equipment(ContentItem helmet, ContentItem chestplate, ContentItem leggings, ContentItem boots,
|
||||||
|
ContentItem mainHand, ContentItem offHand) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Sound and particles shown around an entity that appears; the adapter makes the random choices of the particle motion. */
|
||||||
|
public record SpawnEffect(String sound, int soundDistance, double minPitch, double maxPitch, double volume,
|
||||||
|
String particle, int particleOffset, int particleCount, double altX, double altY,
|
||||||
|
double altZ, boolean randomAltX, boolean randomAltY, boolean randomAltZ, double extra) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Console commands run when an entity appears; {@code {x}}, {@code {y}} and {@code {z}} stand for its block position. */
|
||||||
|
public record Command(List<String> commands, long delay, boolean repeat, long repeatDelay) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* 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.content;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An item a module decided on, in host terms: what {@code com.volmit.item.ItemDrop} says, for adapters that cannot name
|
||||||
|
* IrisApi types. The module made every random choice; the adapter only creates the item on its platform.
|
||||||
|
*
|
||||||
|
* @param damage the fraction of the item's durability already used, or null to leave it undamaged
|
||||||
|
*/
|
||||||
|
public record ContentItem(String item, int amount, String displayName, List<String> lore, List<Enchantment> enchantments,
|
||||||
|
List<Attribute> attributes, boolean unbreakable, List<String> flags, Integer customModel,
|
||||||
|
Double damage, String leatherColor, String dyeColor, Map<String, Object> customNbt) {
|
||||||
|
/** An enchantment at the level the module decided. */
|
||||||
|
public record Enchantment(String key, int level) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** An attribute modifier with the amount the module decided. */
|
||||||
|
public record Attribute(String attribute, String name, String operation, double amount) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* 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.content;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/** Where a container's items come from and what a broken block drops, in host terms. */
|
||||||
|
public final class ContentLoot {
|
||||||
|
private ContentLoot() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** One source of a container's items, in the order their items are added. */
|
||||||
|
public sealed interface Part permits Items, PlatformTable {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Items a module drew from one of the pack's loot tables. */
|
||||||
|
public record Items(List<ContentItem> items) implements Part {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A loot table of the platform, which the adapter draws with {@code seed} so the same container always gets the same items. */
|
||||||
|
public record PlatformTable(String key, long seed) implements Part {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What the modules drop for a broken block.
|
||||||
|
*
|
||||||
|
* @param replacesVanillaDrops whether the platform's own drops of the block are not dropped
|
||||||
|
*/
|
||||||
|
public record BlockDrops(List<ContentItem> drops, boolean replacesVanillaDrops) {
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,192 @@
|
|||||||
|
/*
|
||||||
|
* 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.content;
|
||||||
|
|
||||||
|
import art.arcane.iris.core.modules.ModuleServices;
|
||||||
|
import art.arcane.iris.core.modules.PlatformBlockStates;
|
||||||
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
|
import com.volmit.block.BlockState;
|
||||||
|
import com.volmit.entity.EntitySpec;
|
||||||
|
import com.volmit.item.ItemAttribute;
|
||||||
|
import com.volmit.item.ItemDrop;
|
||||||
|
import com.volmit.item.ItemEnchantment;
|
||||||
|
import com.volmit.service.AmbientEffects;
|
||||||
|
import com.volmit.service.BlockDrops;
|
||||||
|
import com.volmit.service.EntitySpawns;
|
||||||
|
import com.volmit.service.Loot;
|
||||||
|
import com.volmit.world.BlockPosition;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What the pack's modules say about loot, block drops, spawns and ambient effects, for adapters that cannot name IrisApi
|
||||||
|
* types: the questions take plain values and the answers are the host types of this package. The modded adapters, which
|
||||||
|
* fill containers, drop blocks, spawn mobs and play effects themselves, ask here instead of reading the pack's classes.
|
||||||
|
*/
|
||||||
|
public final class ContentServices {
|
||||||
|
private ContentServices() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The sources of the loot of the container at {@code x}, {@code worldY}, {@code z}, in the order their items are added.
|
||||||
|
*
|
||||||
|
* @param containerKey the platform's key for the block when it is a storage chest an object may have given loot, else null
|
||||||
|
*/
|
||||||
|
public static List<ContentLoot.Part> containerLoot(Engine engine, int x, int worldY, int z, String containerKey, boolean nativeLootDefined) {
|
||||||
|
BlockState container = containerKey == null ? null : BlockState.parse(PlatformBlockStates.namespaced(containerKey));
|
||||||
|
Loot.Site site = new Loot.Site(position(engine, x, worldY, z), container, nativeLootDefined, false);
|
||||||
|
List<ContentLoot.Part> parts = new ArrayList<>();
|
||||||
|
for (Loot.Source source : ModuleServices.lootTables(engine, site)) {
|
||||||
|
switch (source) {
|
||||||
|
case Loot.Table table -> parts.add(new ContentLoot.Items(tableItems(engine, x, worldY, z, table.key())));
|
||||||
|
case Loot.PlatformTable table -> parts.add(new ContentLoot.PlatformTable(table.key(), table.seed()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return parts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The items the pack's loot table {@code tableKey} gives at the spot. */
|
||||||
|
public static List<ContentItem> tableItems(Engine engine, int x, int worldY, int z, String tableKey) {
|
||||||
|
Loot.Site site = new Loot.Site(position(engine, x, worldY, z), null, false, false);
|
||||||
|
return ModuleServices.lootItems(engine, site, tableKey).stream().map(ContentServices::itemOf).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** What the modules drop for the block with the platform's key {@code blockKey} broken at the spot. */
|
||||||
|
public static ContentLoot.BlockDrops blockDrops(Engine engine, int x, int worldY, int z, String blockKey) {
|
||||||
|
BlockDrops.Result result = ModuleServices.blockDrops(engine, new BlockDrops.Broken(position(engine, x, worldY, z),
|
||||||
|
BlockState.parse(PlatformBlockStates.namespaced(blockKey))));
|
||||||
|
return new ContentLoot.BlockDrops(result.drops().stream().map(ContentServices::itemOf).toList(), result.replacesVanillaDrops());
|
||||||
|
}
|
||||||
|
|
||||||
|
/** What the first module with something to spawn in the chunk plans. */
|
||||||
|
public static Optional<ContentSpawns.Plan> planChunkSpawn(Engine engine, int chunkX, int chunkZ, int livingEntities, boolean initial) {
|
||||||
|
return planned(engine, new EntitySpawns.Chunk(chunkX, chunkZ, livingEntities, initial));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** What the first module that knows the spawner plans at the marker block. */
|
||||||
|
public static Optional<ContentSpawns.Plan> planMarkerSpawn(Engine engine, int x, int worldY, int z, String marker, String spawner, boolean initial) {
|
||||||
|
return planned(engine, new EntitySpawns.Marker(position(engine, x, worldY, z), marker, spawner, initial));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** What the marker with the tag {@code tag} does; empty for a tag no module knows. */
|
||||||
|
public static Optional<ContentSpawns.MarkerRule> markerRule(Engine engine, String tag) {
|
||||||
|
return ModuleServices.markerRule(engine, tag)
|
||||||
|
.map(rule -> new ContentSpawns.MarkerRule(rule.spawners(), rule.emptyAbove(), rule.removeOnChange()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The entity of the pack named {@code key} as a module would spawn it; empty for an unknown key. */
|
||||||
|
public static Optional<ContentEntity> entity(Engine engine, String key) {
|
||||||
|
return ModuleServices.entity(engine, key).map(ContentServices::entityOf);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The ambient effects due for a player standing at the spot. */
|
||||||
|
public static List<ContentEffect> ambientEffects(Engine engine, int x, int worldY, int z) {
|
||||||
|
return ModuleServices.ambientEffects(engine, position(engine, x, worldY, z)).stream().map(ContentServices::effectOf).toList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Optional<ContentSpawns.Plan> planned(Engine engine, EntitySpawns.Site site) {
|
||||||
|
return ModuleServices.planSpawn(engine, site).map(planned -> new ContentSpawns.Plan(planned, attemptsOf(engine, planned.plan())));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<ContentSpawns.Attempt> attemptsOf(Engine engine, EntitySpawns.Plan plan) {
|
||||||
|
List<ContentSpawns.Attempt> attempts = new ArrayList<>();
|
||||||
|
for (EntitySpawns.Attempt attempt : plan.attempts()) {
|
||||||
|
attempts.add(new ContentSpawns.Attempt(attempt.at().x(), attempt.at().y() + engine.getMinHeight(), attempt.at().z(),
|
||||||
|
entityOf(attempt.entity()), ContentSpawns.surfaceOf(attempt.surface()), attempt.minLight(), attempt.maxLight(),
|
||||||
|
attempt.checkSurface()));
|
||||||
|
}
|
||||||
|
return attempts;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static BlockPosition position(Engine engine, int x, int worldY, int z) {
|
||||||
|
return new BlockPosition(x, worldY - engine.getMinHeight(), z);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ContentItem itemOf(ItemDrop drop) {
|
||||||
|
return new ContentItem(drop.item(), drop.amount(), drop.displayName(), drop.lore(),
|
||||||
|
drop.enchantments().stream().map(ContentServices::enchantmentOf).toList(),
|
||||||
|
drop.attributes().stream().map(ContentServices::attributeOf).toList(), drop.unbreakable(), drop.flags(),
|
||||||
|
drop.customModel(), drop.damage(), drop.leatherColor(), drop.dyeColor(), drop.customNbt());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ContentItem.Enchantment enchantmentOf(ItemEnchantment enchantment) {
|
||||||
|
return new ContentItem.Enchantment(enchantment.key(), enchantment.level());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ContentItem.Attribute attributeOf(ItemAttribute attribute) {
|
||||||
|
return new ContentItem.Attribute(attribute.attribute(), attribute.name(), attribute.operation(), attribute.amount());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ContentEntity entityOf(EntitySpec spec) {
|
||||||
|
return new ContentEntity(spec.type(), spec.specialType(), spec.reason(), spec.customName(), flagsOf(spec.flags()),
|
||||||
|
equipmentOf(spec.equipment()), spec.passengers().stream().map(ContentServices::entityOf).toList(),
|
||||||
|
spec.attributes().stream().map(ContentServices::attributeOf).toList(), spec.lootTables(), spec.lootShuffleSeed(),
|
||||||
|
spec.leashHolder() == null ? null : entityOf(spec.leashHolder()), spawnEffectOf(spec.spawnEffect()),
|
||||||
|
spec.riseOutOfGround(), spec.pandaMainGene(), spec.pandaHiddenGene(), spec.applySettingsToSpecial(),
|
||||||
|
spec.commands().stream().map(ContentServices::commandOf).toList());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ContentEntity.Flags flagsOf(EntitySpec.Flags flags) {
|
||||||
|
return new ContentEntity.Flags(flags.customNameVisible(), flags.aware(), flags.ai(), flags.glowing(), flags.gravity(),
|
||||||
|
flags.invulnerable(), flags.silent(), flags.pickupItems(), flags.removable(), flags.keepEntity(), flags.baby());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ContentEntity.Equipment equipmentOf(EntitySpec.Equipment equipment) {
|
||||||
|
return new ContentEntity.Equipment(optionalItem(equipment.helmet()), optionalItem(equipment.chestplate()),
|
||||||
|
optionalItem(equipment.leggings()), optionalItem(equipment.boots()), optionalItem(equipment.mainHand()),
|
||||||
|
optionalItem(equipment.offHand()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ContentItem optionalItem(ItemDrop drop) {
|
||||||
|
return drop == null ? null : itemOf(drop);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ContentEntity.SpawnEffect spawnEffectOf(EntitySpec.SpawnEffect effect) {
|
||||||
|
if (effect == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
return new ContentEntity.SpawnEffect(effect.sound(), effect.soundDistance(), effect.minPitch(), effect.maxPitch(),
|
||||||
|
effect.volume(), effect.particle(), effect.particleOffset(), effect.particleCount(), effect.altX(), effect.altY(),
|
||||||
|
effect.altZ(), effect.randomAltX(), effect.randomAltY(), effect.randomAltZ(), effect.extra());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ContentEntity.Command commandOf(EntitySpec.Command command) {
|
||||||
|
return new ContentEntity.Command(command.commands(), command.delay(), command.repeat(), command.repeatDelay());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ContentEffect effectOf(AmbientEffects.Effect effect) {
|
||||||
|
return new ContentEffect(soundOf(effect.sound()), particlesOf(effect.particles()),
|
||||||
|
effect.commands().stream().map(command -> new ContentEffect.Command(commandOf(command.command()),
|
||||||
|
command.offsetX(), command.offsetY(), command.offsetZ())).toList(),
|
||||||
|
effect.potion() == null ? null : new ContentEffect.Potion(effect.potion().key(), effect.potion().strength(), effect.potion().ticks()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ContentEffect.Sound soundOf(AmbientEffects.Sound sound) {
|
||||||
|
return sound == null ? null : new ContentEffect.Sound(sound.key(), sound.offsetX(), sound.offsetY(), sound.offsetZ(),
|
||||||
|
sound.volume(), sound.pitch());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ContentEffect.Particles particlesOf(AmbientEffects.Particles particles) {
|
||||||
|
return particles == null ? null : new ContentEffect.Particles(particles.key(), particles.forward(), particles.sideways(),
|
||||||
|
particles.jitterX(), particles.jitterZ(), particles.lift(), particles.count(), particles.altX(), particles.altY(),
|
||||||
|
particles.altZ(), particles.extra());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,85 @@
|
|||||||
|
/*
|
||||||
|
* 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.content;
|
||||||
|
|
||||||
|
import art.arcane.iris.core.modules.ModuleServices;
|
||||||
|
import com.volmit.service.EntitySpawns;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/** What the modules plan to spawn, in host terms. */
|
||||||
|
public final class ContentSpawns {
|
||||||
|
private ContentSpawns() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The ground or fluid an entity spawns on. */
|
||||||
|
public enum Surface {
|
||||||
|
LAND, ANIMAL, WATER, OVERWORLD, LAVA
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* One entity to spawn at a block, if the light there lies in the range (when {@link #restrictsLight()}) and, when
|
||||||
|
* {@code checkSurface}, the block below suits the entity's surface and the space it needs is free.
|
||||||
|
*
|
||||||
|
* @param x world X
|
||||||
|
* @param worldY world Y
|
||||||
|
* @param z world Z
|
||||||
|
* @param checkSurface whether to check the surface and the free space
|
||||||
|
*/
|
||||||
|
public record Attempt(int x, int worldY, int z, ContentEntity entity, Surface surface, int minLight, int maxLight,
|
||||||
|
boolean checkSurface) {
|
||||||
|
/** Whether the light level matters. */
|
||||||
|
public boolean restrictsLight() {
|
||||||
|
return minLight > 0 || maxLight < 15;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** What a marker does: the keys of its spawners, whether it needs free space above it and whether it goes away when its block changes. */
|
||||||
|
public record MarkerRule(List<String> spawners, boolean emptyAbove, boolean removeOnChange) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Entities to spawn, tried one after the other; tell the plan how many appeared, so the spawner's rate limits count them. */
|
||||||
|
public static final class Plan {
|
||||||
|
private final ModuleServices.PlannedSpawn planned;
|
||||||
|
private final List<Attempt> attempts;
|
||||||
|
|
||||||
|
Plan(ModuleServices.PlannedSpawn planned, List<Attempt> attempts) {
|
||||||
|
this.planned = planned;
|
||||||
|
this.attempts = List.copyOf(attempts);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Attempt> attempts() {
|
||||||
|
return attempts;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whether the marker that led here is used up and should be removed. */
|
||||||
|
public boolean exhaustsMarker() {
|
||||||
|
return planned.plan().exhaustsMarker();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Reports how many of the planned entities appeared. */
|
||||||
|
public void spawned(int count) {
|
||||||
|
planned.spawned(count);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static Surface surfaceOf(EntitySpawns.Surface surface) {
|
||||||
|
return Surface.valueOf(surface.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,33 @@
|
|||||||
|
/*
|
||||||
|
* 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.events;
|
||||||
|
|
||||||
|
/** The kind of slot of an inventory that loot fills. World generation only ever fills {@link #STORAGE}. */
|
||||||
|
public enum InventorySlotType {
|
||||||
|
/** Most slots of an inventory. */
|
||||||
|
STORAGE,
|
||||||
|
/** The fuel slot of furnaces, blast furnaces and smokers. */
|
||||||
|
FUEL,
|
||||||
|
/** The cook slot of furnaces. */
|
||||||
|
FURNACE,
|
||||||
|
/** The cook slot of blast furnaces. */
|
||||||
|
BLAST_FURNACE,
|
||||||
|
/** The cook slot of smokers. */
|
||||||
|
SMOKER
|
||||||
|
}
|
||||||
@@ -51,6 +51,7 @@ public class IrisLootEvent extends Event {
|
|||||||
|
|
||||||
private final Engine engine;
|
private final Engine engine;
|
||||||
private final Block block;
|
private final Block block;
|
||||||
|
private final InventorySlotType slot;
|
||||||
private final KList<Loot.Source> tables;
|
private final KList<Loot.Source> tables;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,11 +59,13 @@ public class IrisLootEvent extends Event {
|
|||||||
*
|
*
|
||||||
* @param engine The engine instance.
|
* @param engine The engine instance.
|
||||||
* @param block The block associated with the event.
|
* @param block The block associated with the event.
|
||||||
|
* @param slot The inventory slot type the loot fills.
|
||||||
* @param tables The loot tables the container draws from, as the pack's modules named them. (mutable*)
|
* @param tables The loot tables the container draws from, as the pack's modules named them. (mutable*)
|
||||||
*/
|
*/
|
||||||
public IrisLootEvent(Engine engine, Block block, KList<Loot.Source> tables) {
|
public IrisLootEvent(Engine engine, Block block, InventorySlotType slot, KList<Loot.Source> tables) {
|
||||||
this.engine = engine;
|
this.engine = engine;
|
||||||
this.block = block;
|
this.block = block;
|
||||||
|
this.slot = slot;
|
||||||
this.tables = tables;
|
this.tables = tables;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import art.arcane.iris.engine.framework.Engine;
|
|||||||
import com.volmit.host.FeatureCatalog;
|
import com.volmit.host.FeatureCatalog;
|
||||||
import com.volmit.entity.EntitySpec;
|
import com.volmit.entity.EntitySpec;
|
||||||
import com.volmit.item.ItemDrop;
|
import com.volmit.item.ItemDrop;
|
||||||
|
import com.volmit.service.AmbientEffects;
|
||||||
import com.volmit.service.BlockDrops;
|
import com.volmit.service.BlockDrops;
|
||||||
import com.volmit.service.CaveBiomes;
|
import com.volmit.service.CaveBiomes;
|
||||||
import com.volmit.service.EntitySpawns;
|
import com.volmit.service.EntitySpawns;
|
||||||
@@ -31,6 +32,7 @@ import com.volmit.service.Loot;
|
|||||||
import com.volmit.service.ObjectsAt;
|
import com.volmit.service.ObjectsAt;
|
||||||
import com.volmit.service.SaplingGrowth;
|
import com.volmit.service.SaplingGrowth;
|
||||||
import com.volmit.service.StructureLocator;
|
import com.volmit.service.StructureLocator;
|
||||||
|
import com.volmit.world.BlockPosition;
|
||||||
import com.volmit.world.PackWorld;
|
import com.volmit.world.PackWorld;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
@@ -178,6 +180,16 @@ public final class ModuleServices {
|
|||||||
return Optional.empty();
|
return Optional.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** The ambient effects every module says are due for a player standing at {@code at}, in module order. */
|
||||||
|
public static List<AmbientEffects.Effect> ambientEffects(Engine engine, BlockPosition at) {
|
||||||
|
PackWorld world = engine.getGeneration().world();
|
||||||
|
List<AmbientEffects.Effect> effects = new ArrayList<>();
|
||||||
|
for (AmbientEffects provider : catalog(engine.getData()).services(AmbientEffects.class)) {
|
||||||
|
effects.addAll(provider.due(world, at));
|
||||||
|
}
|
||||||
|
return effects;
|
||||||
|
}
|
||||||
|
|
||||||
/** A plan and the module that made it, which hears how many of its entities appeared. */
|
/** A plan and the module that made it, which hears how many of its entities appeared. */
|
||||||
public record PlannedSpawn(EntitySpawns provider, PackWorld world, EntitySpawns.Plan plan) {
|
public record PlannedSpawn(EntitySpawns provider, PackWorld world, EntitySpawns.Plan plan) {
|
||||||
public void spawned(int count) {
|
public void spawned(int count) {
|
||||||
|
|||||||
@@ -20,8 +20,10 @@ package art.arcane.iris.core.modules;
|
|||||||
|
|
||||||
import art.arcane.volmlib.util.json.JSONArray;
|
import art.arcane.volmlib.util.json.JSONArray;
|
||||||
import art.arcane.volmlib.util.json.JSONObject;
|
import art.arcane.volmlib.util.json.JSONObject;
|
||||||
|
import art.arcane.volmlib.util.json.JSONTokener;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.gson.GsonBuilder;
|
import com.google.gson.GsonBuilder;
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
import com.google.gson.JsonParseException;
|
import com.google.gson.JsonParseException;
|
||||||
import com.google.gson.TypeAdapter;
|
import com.google.gson.TypeAdapter;
|
||||||
import com.google.gson.TypeAdapterFactory;
|
import com.google.gson.TypeAdapterFactory;
|
||||||
@@ -129,6 +131,24 @@ public final class ModuleSettingsDecoder {
|
|||||||
return decoded;
|
return decoded;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The JSON that declares {@code values} at {@code target}: each settings feature under its key, in the shape the
|
||||||
|
* feature is written in (a rooted feature as its root option's value), the inverse of {@link #decode}.
|
||||||
|
*/
|
||||||
|
public JSONObject encode(Target target, ModuleSettings values) {
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
for (FeatureDescriptor<?> feature : settings.get(target)) {
|
||||||
|
values.find(feature.type()).ifPresent(value -> json.put(feature.key(), writtenShape(feature, value)));
|
||||||
|
}
|
||||||
|
return json;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object writtenShape(FeatureDescriptor<?> feature, IrisFeature value) {
|
||||||
|
JsonElement settingsTree = gson.toJsonTree(value, feature.type());
|
||||||
|
JsonElement written = feature.root().map(root -> settingsTree.getAsJsonObject().get(root)).orElse(settingsTree);
|
||||||
|
return new JSONTokener(gson.toJson(written)).nextValue();
|
||||||
|
}
|
||||||
|
|
||||||
private IrisFeature read(FeatureDescriptor<?> feature, Object value, String resource) {
|
private IrisFeature read(FeatureDescriptor<?> feature, Object value, String resource) {
|
||||||
try {
|
try {
|
||||||
requireShape(feature, value);
|
requireShape(feature, value);
|
||||||
|
|||||||
@@ -0,0 +1,211 @@
|
|||||||
|
/*
|
||||||
|
* 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.pack;
|
||||||
|
|
||||||
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
|
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||||
|
import art.arcane.iris.core.modules.IrisPackResources;
|
||||||
|
import art.arcane.iris.engine.object.annotations.RegistryListResource;
|
||||||
|
import art.arcane.volmlib.util.io.IO;
|
||||||
|
import art.arcane.volmlib.util.json.JSONObject;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.volmit.config.ResourceRef;
|
||||||
|
import com.volmit.host.ResourceKindRegistration;
|
||||||
|
import com.volmit.resource.ResourceKind;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.IdentityHashMap;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The resources of the pack's module resource kinds that a pack export has to carry: what the settings of the
|
||||||
|
* exported dimension, regions and biomes (and anything else handed to {@link #follow}) name by {@link ResourceRef} or
|
||||||
|
* {@link RegistryListResource}, and what those resources name in turn. Core does not know the kinds: it follows the
|
||||||
|
* references the modules declare on their classes.
|
||||||
|
*/
|
||||||
|
public final class ModuleResourceClosure {
|
||||||
|
private static final String JAVA_PACKAGE_PREFIX = "java.";
|
||||||
|
private static final String JSON_EXTENSION = ".json";
|
||||||
|
private static final int PRETTY_INDENT = 4;
|
||||||
|
|
||||||
|
private final IrisData data;
|
||||||
|
private final Map<Class<?>, ResourceKind<?>> kindsByType = new HashMap<>();
|
||||||
|
private final Map<ResourceKind<?>, Map<String, Object>> found = new LinkedHashMap<>();
|
||||||
|
private final Set<Object> visited = java.util.Collections.newSetFromMap(new IdentityHashMap<>());
|
||||||
|
|
||||||
|
public ModuleResourceClosure(IrisData data) {
|
||||||
|
this.data = data;
|
||||||
|
for (ResourceKindRegistration registration : data.getModules().pack().catalog().resourceKinds()) {
|
||||||
|
kindsByType.put(registration.kind().type(), registration.kind());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Adds the resources that the module settings of {@code owner} reference, and those they reference. */
|
||||||
|
public void followSettingsOf(IrisRegistrant owner) {
|
||||||
|
owner.getModuleSettings().values().forEach(this::follow);
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Adds the resources that {@code holder} references, and those they reference. */
|
||||||
|
public void follow(Object holder) {
|
||||||
|
if (holder == null || !visited.add(holder)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (holder instanceof Collection<?> collection) {
|
||||||
|
collection.forEach(this::follow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (holder instanceof Map<?, ?> map) {
|
||||||
|
map.values().forEach(this::follow);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (holder instanceof Object[] array) {
|
||||||
|
for (Object element : array) {
|
||||||
|
follow(element);
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (isLeaf(holder.getClass())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (Class<?> type = holder.getClass(); type != null && type != Object.class; type = type.getSuperclass()) {
|
||||||
|
for (Field field : type.getDeclaredFields()) {
|
||||||
|
followField(holder, field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** Whether nothing was found. */
|
||||||
|
public boolean isEmpty() {
|
||||||
|
return found.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The keys of the resources found of the kind that reads into {@code type}, in key order. */
|
||||||
|
public List<String> keysOf(Class<?> type) {
|
||||||
|
ResourceKind<?> kind = kindsByType.get(type);
|
||||||
|
return kind == null || !found.containsKey(kind) ? List.of() : new ArrayList<>(new TreeMap<>(found.get(kind)).keySet());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes every resource found as {@code <folder of its kind>/<key>.json} below {@code targetRoot}, kinds in folder
|
||||||
|
* order and keys in key order.
|
||||||
|
*
|
||||||
|
* @return the hashes of the files written, to put into the package's hash
|
||||||
|
*/
|
||||||
|
public String writeTo(File targetRoot, boolean minify) throws IOException {
|
||||||
|
StringBuilder hashes = new StringBuilder();
|
||||||
|
List<Map.Entry<ResourceKind<?>, Map<String, Object>>> kinds = new ArrayList<>(found.entrySet());
|
||||||
|
kinds.sort(Comparator.comparing(entry -> entry.getKey().folder()));
|
||||||
|
for (Map.Entry<ResourceKind<?>, Map<String, Object>> kind : kinds) {
|
||||||
|
for (Map.Entry<String, Object> resource : new TreeMap<>(kind.getValue()).entrySet()) {
|
||||||
|
String json = new JSONObject(new Gson().toJson(resource.getValue())).toString(minify ? 0 : PRETTY_INDENT);
|
||||||
|
IO.writeAll(new File(targetRoot, kind.getKey().folder() + "/" + resource.getKey() + JSON_EXTENSION), json);
|
||||||
|
hashes.append(IO.hash(json));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hashes.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void followField(Object holder, Field field) {
|
||||||
|
if (Modifier.isStatic(field.getModifiers()) || Modifier.isTransient(field.getModifiers()) || field.getType().isPrimitive()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Object value = valueOf(holder, field);
|
||||||
|
if (value == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Class<?> referenced = referencedType(field);
|
||||||
|
if (referenced == null) {
|
||||||
|
follow(value);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (String key : keysIn(value)) {
|
||||||
|
add(referenced, key);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The class of the resources the field names by key, or null when it names none. */
|
||||||
|
private static Class<?> referencedType(Field field) {
|
||||||
|
ResourceRef reference = field.getAnnotation(ResourceRef.class);
|
||||||
|
if (reference != null) {
|
||||||
|
return reference.value();
|
||||||
|
}
|
||||||
|
RegistryListResource registry = field.getAnnotation(RegistryListResource.class);
|
||||||
|
return registry == null ? null : registry.value();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<String> keysIn(Object value) {
|
||||||
|
List<String> keys = new ArrayList<>();
|
||||||
|
if (value instanceof String key) {
|
||||||
|
keys.add(key);
|
||||||
|
} else if (value instanceof Collection<?> collection) {
|
||||||
|
collection.stream().filter(String.class::isInstance).map(String.class::cast).forEach(keys::add);
|
||||||
|
}
|
||||||
|
return keys;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void add(Class<?> type, String key) {
|
||||||
|
ResourceKind<?> kind = kindsByType.get(type);
|
||||||
|
if (kind == null || key == null || key.isBlank()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Map<String, Object> ofKind = found.computeIfAbsent(kind, ignored -> new LinkedHashMap<>());
|
||||||
|
if (ofKind.containsKey(key)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Object resource = lookup(kind, key);
|
||||||
|
if (resource == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ofKind.put(key, resource);
|
||||||
|
follow(resource);
|
||||||
|
}
|
||||||
|
|
||||||
|
private Object lookup(ResourceKind<?> kind, String key) {
|
||||||
|
IrisPackResources resources = data.getPackResources();
|
||||||
|
try {
|
||||||
|
return resources.find(kind.key(resources.idOf(key))).orElse(null);
|
||||||
|
} catch (IllegalStateException failedToLoad) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean isLeaf(Class<?> type) {
|
||||||
|
return type.isEnum() || type.getName().startsWith(JAVA_PACKAGE_PREFIX);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Object valueOf(Object holder, Field field) {
|
||||||
|
try {
|
||||||
|
field.setAccessible(true);
|
||||||
|
return field.get(holder);
|
||||||
|
} catch (ReflectiveOperationException | RuntimeException inaccessible) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -18,7 +18,6 @@
|
|||||||
|
|
||||||
package art.arcane.iris.core.pack;
|
package art.arcane.iris.core.pack;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.marker.IrisObjectMarker;
|
|
||||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||||
import art.arcane.volmlib.util.collection.KSet;
|
import art.arcane.volmlib.util.collection.KSet;
|
||||||
|
|
||||||
@@ -32,25 +31,6 @@ public final class PackExportClosure {
|
|||||||
private PackExportClosure() {
|
private PackExportClosure() {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static KSet<String> collectMarkerKeys(Iterable<IrisObjectPlacement> placements) {
|
|
||||||
KSet<String> markerKeys = new KSet<>();
|
|
||||||
if (placements == null) {
|
|
||||||
return markerKeys;
|
|
||||||
}
|
|
||||||
for (IrisObjectPlacement placement : placements) {
|
|
||||||
if (placement == null || placement.getMarkers() == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
for (IrisObjectMarker marker : placement.getMarkers()) {
|
|
||||||
if (marker == null || marker.getMarker() == null || marker.getMarker().isBlank()) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
markerKeys.add(marker.getMarker());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return markerKeys;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static KSet<String> collectObjectKeys(Iterable<IrisObjectPlacement> placements) {
|
public static KSet<String> collectObjectKeys(Iterable<IrisObjectPlacement> placements) {
|
||||||
KSet<String> objectKeys = new KSet<>();
|
KSet<String> objectKeys = new KSet<>();
|
||||||
if (placements == null) {
|
if (placements == null) {
|
||||||
|
|||||||
@@ -18,27 +18,22 @@
|
|||||||
|
|
||||||
package art.arcane.iris.core.project;
|
package art.arcane.iris.core.project;
|
||||||
|
|
||||||
import art.arcane.iris.engine.spawn.SpawnResources;
|
|
||||||
import art.arcane.iris.engine.loot.LootResources;
|
|
||||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
|
import art.arcane.iris.core.loader.IrisRegistrant;
|
||||||
import art.arcane.iris.core.localization.BukkitRuntimeMessages;
|
import art.arcane.iris.core.localization.BukkitRuntimeMessages;
|
||||||
import art.arcane.iris.core.localization.IrisLanguage;
|
import art.arcane.iris.core.localization.IrisLanguage;
|
||||||
import art.arcane.iris.core.pack.ImageMapPackageClosure;
|
import art.arcane.iris.core.pack.ImageMapPackageClosure;
|
||||||
|
import art.arcane.iris.core.pack.ModuleResourceClosure;
|
||||||
import art.arcane.iris.core.pack.PackValidationResult;
|
import art.arcane.iris.core.pack.PackValidationResult;
|
||||||
import art.arcane.iris.core.pack.PackValidator;
|
import art.arcane.iris.core.pack.PackValidator;
|
||||||
import art.arcane.iris.core.pack.StructurePackageClosure;
|
import art.arcane.iris.core.pack.StructurePackageClosure;
|
||||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||||
import art.arcane.iris.engine.object.material.IrisBlockData;
|
import art.arcane.iris.engine.object.material.IrisBlockData;
|
||||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||||
import art.arcane.iris.engine.object.entity.IrisEntity;
|
|
||||||
import art.arcane.iris.engine.object.terrain.IrisGenerator;
|
import art.arcane.iris.engine.object.terrain.IrisGenerator;
|
||||||
import art.arcane.iris.engine.object.loot.IrisLootTable;
|
|
||||||
import art.arcane.iris.core.pack.PackExportClosure;
|
|
||||||
import art.arcane.iris.engine.object.marker.IrisMarker;
|
|
||||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||||
import art.arcane.iris.engine.object.entity.spawn.IrisSpawner;
|
|
||||||
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
import art.arcane.iris.engine.object.structure.IrisStructurePlacement;
|
||||||
import art.arcane.iris.spi.IrisLogging;
|
import art.arcane.iris.spi.IrisLogging;
|
||||||
import art.arcane.iris.spi.IrisPlatforms;
|
import art.arcane.iris.spi.IrisPlatforms;
|
||||||
@@ -52,11 +47,11 @@ import art.arcane.volmlib.util.localization.MessageArgument;
|
|||||||
import art.arcane.volmlib.util.math.M;
|
import art.arcane.volmlib.util.math.M;
|
||||||
import art.arcane.volmlib.util.scheduling.ChronoLatch;
|
import art.arcane.volmlib.util.scheduling.ChronoLatch;
|
||||||
import art.arcane.volmlib.util.scheduling.O;
|
import art.arcane.volmlib.util.scheduling.O;
|
||||||
|
import com.volmit.FeatureAttachment.Target;
|
||||||
import org.zeroturnaround.zip.ZipUtil;
|
import org.zeroturnaround.zip.ZipUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Comparator;
|
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@@ -109,10 +104,8 @@ public class IrisPackageCompiler {
|
|||||||
IrisLogging.info("Packaging Dimension " + dimension.getName() + " " + (obfuscate ? "(Obfuscated)" : ""));
|
IrisLogging.info("Packaging Dimension " + dimension.getName() + " " + (obfuscate ? "(Obfuscated)" : ""));
|
||||||
KSet<IrisRegion> regions = new KSet<>();
|
KSet<IrisRegion> regions = new KSet<>();
|
||||||
KSet<IrisBiome> biomes = new KSet<>();
|
KSet<IrisBiome> biomes = new KSet<>();
|
||||||
KSet<IrisEntity> entities = new KSet<>();
|
|
||||||
KSet<IrisSpawner> spawners = new KSet<>();
|
|
||||||
KSet<IrisGenerator> generators = new KSet<>();
|
KSet<IrisGenerator> generators = new KSet<>();
|
||||||
KSet<IrisLootTable> loot = new KSet<>();
|
ModuleResourceClosure moduleResources = new ModuleResourceClosure(dm);
|
||||||
KSet<IrisBlockData> blocks = new KSet<>();
|
KSet<IrisBlockData> blocks = new KSet<>();
|
||||||
|
|
||||||
// KSet is ConcurrentHashMap-backed: both add(null) and remove(null) throw NPE, so a
|
// KSet is ConcurrentHashMap-backed: both add(null) and remove(null) throw NPE, so a
|
||||||
@@ -122,29 +115,16 @@ public class IrisPackageCompiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
dimension.getAllRegions(() -> dm).forEach((region) -> addIfPresent(regions, region));
|
dimension.getAllRegions(() -> dm).forEach((region) -> addIfPresent(regions, region));
|
||||||
dimension.getLoot().getTables().forEach((i) -> addIfPresent(loot, LootResources.table(dm, i)));
|
moduleResources.followSettingsOf(dimension);
|
||||||
regions.forEach((i) -> biomes.addAll(i.getAllBiomes(() -> dm)));
|
regions.forEach((i) -> biomes.addAll(i.getAllBiomes(() -> dm)));
|
||||||
dimension.getReachableBiomes(() -> dm).forEach((biome) -> addIfPresent(biomes, biome));
|
dimension.getReachableBiomes(() -> dm).forEach((biome) -> addIfPresent(biomes, biome));
|
||||||
regions.forEach((r) -> r.getLoot().getTables().forEach((i) -> addIfPresent(loot, LootResources.table(dm, i))));
|
regions.forEach(moduleResources::followSettingsOf);
|
||||||
regions.forEach((r) -> r.getEntitySpawners().forEach((sp) -> addIfPresent(spawners, SpawnResources.spawner(dm, sp))));
|
|
||||||
dimension.getEntitySpawners().forEach((sp) -> addIfPresent(spawners, SpawnResources.spawner(dm, sp)));
|
|
||||||
biomes.forEach((i) -> i.getGenerators().forEach((j) -> addIfPresent(generators, j.getCachedGenerator(() -> dm))));
|
biomes.forEach((i) -> i.getGenerators().forEach((j) -> addIfPresent(generators, j.getCachedGenerator(() -> dm))));
|
||||||
biomes.forEach((r) -> r.getLoot().getTables().forEach((i) -> addIfPresent(loot, LootResources.table(dm, i))));
|
biomes.forEach(moduleResources::followSettingsOf);
|
||||||
biomes.forEach((r) -> r.getEntitySpawners().forEach((sp) -> addIfPresent(spawners, SpawnResources.spawner(dm, sp))));
|
|
||||||
KList<IrisObjectPlacement> allPlacements = new KList<>();
|
KList<IrisObjectPlacement> allPlacements = new KList<>();
|
||||||
regions.forEach((r) -> allPlacements.addAll(r.getObjects()));
|
regions.forEach((r) -> allPlacements.addAll(r.getObjects()));
|
||||||
biomes.forEach((i) -> allPlacements.addAll(i.getObjects()));
|
biomes.forEach((i) -> allPlacements.addAll(i.getObjects()));
|
||||||
KSet<IrisMarker> markers = new KSet<>();
|
moduleResources.follow(allPlacements);
|
||||||
for (String markerKey : PackExportClosure.collectMarkerKeys(allPlacements)) {
|
|
||||||
IrisMarker marker = SpawnResources.marker(dm, markerKey);
|
|
||||||
if (marker == null) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
markers.add(marker);
|
|
||||||
marker.getSpawners().forEach((sp) -> addIfPresent(spawners, SpawnResources.spawner(dm, sp)));
|
|
||||||
}
|
|
||||||
collectSpawnerEntityKeys(spawners).forEach((i) -> addIfPresent(entities, SpawnResources.entity(dm, i)));
|
|
||||||
entities.forEach((e) -> e.getLoot().getTables().forEach((i) -> addIfPresent(loot, LootResources.table(dm, i))));
|
|
||||||
Set<String> structureKeys = new LinkedHashSet<>();
|
Set<String> structureKeys = new LinkedHashSet<>();
|
||||||
collectStructureKeys(structureKeys, dimension.getStructures());
|
collectStructureKeys(structureKeys, dimension.getStructures());
|
||||||
regions.forEach((region) -> collectStructureKeys(structureKeys, region.getStructures()));
|
regions.forEach((region) -> collectStructureKeys(structureKeys, region.getStructures()));
|
||||||
@@ -224,7 +204,7 @@ public class IrisPackageCompiler {
|
|||||||
}
|
}
|
||||||
b.append(structureClosure.writeTo(folder, minify));
|
b.append(structureClosure.writeTo(folder, minify));
|
||||||
b.append(ImageMapPackageClosure.writeAll(dm, folder, minify));
|
b.append(ImageMapPackageClosure.writeAll(dm, folder, minify));
|
||||||
a = new JSONObject(new Gson().toJson(dimension)).toString(minify ? 0 : 4);
|
a = withModuleSettings(dimension, Target.DIMENSION, dm).toString(minify ? 0 : 4);
|
||||||
IO.writeAll(new File(folder, "dimensions/" + dimension.getLoadKey() + ".json"), a);
|
IO.writeAll(new File(folder, "dimensions/" + dimension.getLoadKey() + ".json"), a);
|
||||||
b.append(IO.hash(a));
|
b.append(IO.hash(a));
|
||||||
|
|
||||||
@@ -238,7 +218,7 @@ public class IrisPackageCompiler {
|
|||||||
b = new StringBuilder();
|
b = new StringBuilder();
|
||||||
|
|
||||||
for (IrisRegion i : regions) {
|
for (IrisRegion i : regions) {
|
||||||
a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4);
|
a = withModuleSettings(i, Target.REGION, dm).toString(minify ? 0 : 4);
|
||||||
IO.writeAll(new File(folder, "regions/" + i.getLoadKey() + ".json"), a);
|
IO.writeAll(new File(folder, "regions/" + i.getLoadKey() + ".json"), a);
|
||||||
b.append(IO.hash(a));
|
b.append(IO.hash(a));
|
||||||
}
|
}
|
||||||
@@ -250,35 +230,12 @@ public class IrisPackageCompiler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (IrisBiome i : biomes) {
|
for (IrisBiome i : biomes) {
|
||||||
a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4);
|
a = withModuleSettings(i, Target.BIOME, dm).toString(minify ? 0 : 4);
|
||||||
IO.writeAll(new File(folder, "biomes/" + i.getLoadKey() + ".json"), a);
|
IO.writeAll(new File(folder, "biomes/" + i.getLoadKey() + ".json"), a);
|
||||||
b.append(IO.hash(a));
|
b.append(IO.hash(a));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (IrisEntity i : entities) {
|
b.append(moduleResources.writeTo(folder, minify));
|
||||||
a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4);
|
|
||||||
IO.writeAll(new File(folder, "entities/" + i.getLoadKey() + ".json"), a);
|
|
||||||
b.append(IO.hash(a));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (IrisLootTable i : loot) {
|
|
||||||
a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4);
|
|
||||||
IO.writeAll(new File(folder, "loot/" + i.getLoadKey() + ".json"), a);
|
|
||||||
b.append(IO.hash(a));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Sorted so package.json.hash stays stable across runs.
|
|
||||||
for (IrisSpawner i : spawners.stream().sorted(Comparator.comparing(IrisSpawner::getLoadKey)).toList()) {
|
|
||||||
a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4);
|
|
||||||
IO.writeAll(new File(folder, "spawners/" + i.getLoadKey() + ".json"), a);
|
|
||||||
b.append(IO.hash(a));
|
|
||||||
}
|
|
||||||
|
|
||||||
for (IrisMarker i : markers.stream().sorted(Comparator.comparing(IrisMarker::getLoadKey)).toList()) {
|
|
||||||
a = new JSONObject(new Gson().toJson(i)).toString(minify ? 0 : 4);
|
|
||||||
IO.writeAll(new File(folder, "markers/" + i.getLoadKey() + ".json"), a);
|
|
||||||
b.append(IO.hash(a));
|
|
||||||
}
|
|
||||||
|
|
||||||
c.append(IO.hash(b.toString()));
|
c.append(IO.hash(b.toString()));
|
||||||
String finalHash = IO.hash(c.toString());
|
String finalHash = IO.hash(c.toString());
|
||||||
@@ -301,13 +258,12 @@ public class IrisPackageCompiler {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
static KSet<String> collectSpawnerEntityKeys(KSet<IrisSpawner> spawners) {
|
/** The JSON of a dimension, region or biome with the settings its modules declare, which the resource itself does not hold. */
|
||||||
KSet<String> entityKeys = new KSet<>();
|
private static JSONObject withModuleSettings(IrisRegistrant resource, Target target, IrisData data) {
|
||||||
for (IrisSpawner spawner : spawners) {
|
JSONObject json = new JSONObject(new Gson().toJson(resource));
|
||||||
spawner.getSpawns().forEach((spawn) -> entityKeys.add(spawn.getEntity()));
|
JSONObject settings = data.getModules().settings().encode(target, resource.getModuleSettings());
|
||||||
spawner.getInitialSpawns().forEach((spawn) -> entityKeys.add(spawn.getEntity()));
|
settings.keySet().forEach(key -> json.put(key, settings.get(key)));
|
||||||
}
|
return json;
|
||||||
return entityKeys;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void collectStructureKeys(Set<String> keys, KList<IrisStructurePlacement> placements) {
|
private static void collectStructureKeys(Set<String> keys, KList<IrisStructurePlacement> placements) {
|
||||||
|
|||||||
@@ -19,14 +19,13 @@
|
|||||||
package art.arcane.iris.engine.framework;
|
package art.arcane.iris.engine.framework;
|
||||||
|
|
||||||
import art.arcane.iris.core.IrisSettings;
|
import art.arcane.iris.core.IrisSettings;
|
||||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
import art.arcane.iris.core.modules.ModuleServices;
|
||||||
import art.arcane.iris.engine.object.entity.IrisEffect;
|
import art.arcane.iris.platform.bukkit.BukkitAmbientEffects;
|
||||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
|
||||||
import art.arcane.iris.engine.platform.EngineBukkitOps;
|
|
||||||
import art.arcane.iris.platform.bukkit.BukkitWorldBinding;
|
import art.arcane.iris.platform.bukkit.BukkitWorldBinding;
|
||||||
import art.arcane.iris.spi.IrisLogging;
|
import art.arcane.iris.spi.IrisLogging;
|
||||||
import art.arcane.iris.util.common.scheduling.J;
|
import art.arcane.iris.util.common.scheduling.J;
|
||||||
import art.arcane.volmlib.util.math.M;
|
import art.arcane.volmlib.util.math.M;
|
||||||
|
import com.volmit.world.BlockPosition;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@@ -35,8 +34,7 @@ import org.bukkit.entity.Player;
|
|||||||
public class EnginePlayer {
|
public class EnginePlayer {
|
||||||
private final Engine engine;
|
private final Engine engine;
|
||||||
private final Player player;
|
private final Player player;
|
||||||
private IrisBiome biome;
|
private BlockPosition sampledPosition;
|
||||||
private IrisRegion region;
|
|
||||||
private Location lastLocation;
|
private Location lastLocation;
|
||||||
private long lastSample;
|
private long lastSample;
|
||||||
|
|
||||||
@@ -56,26 +54,14 @@ public class EnginePlayer {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (region != null) {
|
if (sampledPosition == null) {
|
||||||
for (IrisEffect effect : region.getEffects()) {
|
return;
|
||||||
try {
|
|
||||||
effect.apply(player, getEngine());
|
|
||||||
} catch (Throwable e) {
|
|
||||||
IrisLogging.reportError(e);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (biome != null) {
|
try {
|
||||||
for (IrisEffect effect : biome.getEffects()) {
|
BukkitAmbientEffects.play(player, engine, ModuleServices.ambientEffects(engine, sampledPosition));
|
||||||
try {
|
} catch (Throwable e) {
|
||||||
effect.apply(player, getEngine());
|
IrisLogging.reportError(e);
|
||||||
} catch (Throwable e) {
|
|
||||||
IrisLogging.reportError(e);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -94,8 +80,7 @@ public class EnginePlayer {
|
|||||||
if (needsSample(sampled, ticksSinceLastSample(), distanceSquared)) {
|
if (needsSample(sampled, ticksSinceLastSample(), distanceSquared)) {
|
||||||
lastLocation = current;
|
lastLocation = current;
|
||||||
lastSample = M.ms();
|
lastSample = M.ms();
|
||||||
biome = EngineBukkitOps.getBiome(engine, current);
|
sampledPosition = new BlockPosition(current.getBlockX(), current.getBlockY() - engine.getWorld().minHeight(), current.getBlockZ());
|
||||||
region = EngineBukkitOps.getRegion(engine, current);
|
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} catch (Throwable e) {
|
} catch (Throwable e) {
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import art.arcane.iris.platform.bukkit.BukkitBlockResolution;
|
|||||||
import art.arcane.iris.core.loader.IrisData;
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
import art.arcane.iris.core.tools.IrisToolbelt;
|
import art.arcane.iris.core.tools.IrisToolbelt;
|
||||||
import art.arcane.iris.engine.framework.Engine;
|
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.core.events.IrisLootEvent;
|
||||||
import art.arcane.iris.engine.mantle.EngineMantle;
|
import art.arcane.iris.engine.mantle.EngineMantle;
|
||||||
import art.arcane.iris.engine.platform.EngineBukkitOps;
|
import art.arcane.iris.engine.platform.EngineBukkitOps;
|
||||||
@@ -86,7 +87,7 @@ public class WorldObjectPlacer implements IObjectPlacer {
|
|||||||
KList<Loot.Source> tables = EngineBukkitOps.getLootTables(engine, block);
|
KList<Loot.Source> tables = EngineBukkitOps.getLootTables(engine, block);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Bukkit.getPluginManager().callEvent(new IrisLootEvent(engine, block, tables));
|
Bukkit.getPluginManager().callEvent(new IrisLootEvent(engine, block, InventorySlotType.STORAGE, tables));
|
||||||
if (tables.isEmpty()) {
|
if (tables.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,6 +19,7 @@
|
|||||||
package art.arcane.iris.engine.platform;
|
package art.arcane.iris.engine.platform;
|
||||||
|
|
||||||
import art.arcane.iris.platform.bukkit.BukkitWorldBinding;
|
import art.arcane.iris.platform.bukkit.BukkitWorldBinding;
|
||||||
|
import art.arcane.iris.core.events.InventorySlotType;
|
||||||
import art.arcane.iris.core.events.IrisLootEvent;
|
import art.arcane.iris.core.events.IrisLootEvent;
|
||||||
import art.arcane.iris.core.link.Identifier;
|
import art.arcane.iris.core.link.Identifier;
|
||||||
import art.arcane.iris.core.service.ExternalDataSVC;
|
import art.arcane.iris.core.service.ExternalDataSVC;
|
||||||
@@ -304,7 +305,7 @@ public final class EngineBukkitOps {
|
|||||||
KList<Loot.Source> tables = new KList<>(getLootTables(engine, block, hasNativeLootTable(block)));
|
KList<Loot.Source> tables = new KList<>(getLootTables(engine, block, hasNativeLootTable(block)));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Bukkit.getPluginManager().callEvent(new IrisLootEvent(engine, block, tables));
|
Bukkit.getPluginManager().callEvent(new IrisLootEvent(engine, block, InventorySlotType.STORAGE, tables));
|
||||||
if (tables.isEmpty()) return;
|
if (tables.isEmpty()) return;
|
||||||
InventoryHolder m = (InventoryHolder) block.getState();
|
InventoryHolder m = (InventoryHolder) block.getState();
|
||||||
addItems(engine, false, m.getInventory(), tables, c.getWorld(), block.getX(), y, block.getZ());
|
addItems(engine, false, m.getInventory(), tables, c.getWorld(), block.getX(), y, block.getZ());
|
||||||
|
|||||||
@@ -0,0 +1,144 @@
|
|||||||
|
/*
|
||||||
|
* 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.platform.bukkit;
|
||||||
|
|
||||||
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
|
import art.arcane.iris.spi.IrisLogging;
|
||||||
|
import art.arcane.iris.util.common.data.registry.RegistryUtil;
|
||||||
|
import art.arcane.iris.util.common.scheduling.ConsoleCommands;
|
||||||
|
import art.arcane.iris.util.common.scheduling.J;
|
||||||
|
import com.volmit.entity.EntitySpec;
|
||||||
|
import com.volmit.service.AmbientEffects;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.Particle;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Plays the ambient effects a module decided on to a Bukkit player: the sound, the particles, the commands and the
|
||||||
|
* potion effect of each, in that order. Everything random was decided by the module; what the platform lacks is skipped.
|
||||||
|
*/
|
||||||
|
public final class BukkitAmbientEffects {
|
||||||
|
private static final double QUARTER_TURN_RADIANS = Math.toRadians(90);
|
||||||
|
private static final int ABOVE_SURFACE_BLOCKS = 1;
|
||||||
|
|
||||||
|
private BukkitAmbientEffects() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void play(Player player, Engine engine, List<AmbientEffects.Effect> effects) {
|
||||||
|
for (AmbientEffects.Effect effect : effects) {
|
||||||
|
J.runEntity(player, () -> playOnEntityThread(player, engine, effect));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void playOnEntityThread(Player player, Engine engine, AmbientEffects.Effect effect) {
|
||||||
|
if (effect.sound() != null) {
|
||||||
|
playSound(player, effect.sound());
|
||||||
|
}
|
||||||
|
if (effect.particles() != null) {
|
||||||
|
showParticles(player, engine, effect.particles());
|
||||||
|
}
|
||||||
|
effect.commands().forEach(command -> runCommand(player, command));
|
||||||
|
if (effect.potion() != null) {
|
||||||
|
givePotion(player, effect.potion());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void playSound(Player player, AmbientEffects.Sound sound) {
|
||||||
|
Sound type = lookup(Sound.class, sound.key());
|
||||||
|
if (type == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Location at = player.getLocation().clone().add(sound.offsetX(), sound.offsetY(), sound.offsetZ());
|
||||||
|
player.playSound(at, type, sound.volume(), sound.pitch());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void showParticles(Player player, Engine engine, AmbientEffects.Particles particles) {
|
||||||
|
Particle type = lookup(Particle.class, particles.key());
|
||||||
|
if (type == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Location location = player.getLocation();
|
||||||
|
Vector direction = location.getDirection();
|
||||||
|
Location spot = location.clone()
|
||||||
|
.add(direction.clone().multiply(particles.forward()))
|
||||||
|
.add(direction.clone().rotateAroundY(QUARTER_TURN_RADIANS).multiply(particles.sideways()));
|
||||||
|
spot.setY(Math.round(engine.getHeight(spot.getBlockX(), spot.getBlockZ())) + ABOVE_SURFACE_BLOCKS);
|
||||||
|
spot.add(particles.jitterX(), 0, particles.jitterZ());
|
||||||
|
double x = spot.getX();
|
||||||
|
double y = spot.getY() + player.getWorld().getMinHeight() + particles.lift();
|
||||||
|
double z = spot.getZ();
|
||||||
|
if (particles.extra() != 0) {
|
||||||
|
player.spawnParticle(type, x, y, z, particles.count(), particles.altX(), particles.altY(), particles.altZ(), particles.extra());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.spawnParticle(type, x, y, z, particles.count(), particles.altX(), particles.altY(), particles.altZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void runCommand(Player player, AmbientEffects.Command command) {
|
||||||
|
Location at = player.getLocation().clone().add(command.offsetX(), command.offsetY(), command.offsetZ());
|
||||||
|
EntitySpec.Command run = command.command();
|
||||||
|
ConsoleCommands.run(run.commands(), run.delay(), run.repeat(), run.repeatDelay(), at.getBlockX(), at.getBlockY(), at.getBlockZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void givePotion(Player player, AmbientEffects.Potion potion) {
|
||||||
|
PotionEffectType type = potionType(potion.key());
|
||||||
|
PotionEffect current = player.getPotionEffect(type);
|
||||||
|
if (current != null) {
|
||||||
|
if (current.getAmplifier() > potion.strength()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.removePotionEffect(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
player.addPotionEffect(new PotionEffect(type, potion.ticks(), potion.strength(), true, false, false));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** The potion effect type a pack names, or luck for a name the platform does not know, with a warning once. */
|
||||||
|
private static PotionEffectType potionType(String name) {
|
||||||
|
if (name == null || name.isEmpty()) {
|
||||||
|
return PotionEffectType.LUCK;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
PotionEffectType resolved = PotionEffectTypes.resolve(name);
|
||||||
|
if (resolved != null) {
|
||||||
|
return resolved;
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
IrisLogging.reportError(e);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (PotionEffectTypes.shouldWarn(name)) {
|
||||||
|
IrisLogging.warn("Unknown Potion Effect Type: \"" + name + "\". Valid types: " + PotionEffectTypes.knownTypesList());
|
||||||
|
}
|
||||||
|
return PotionEffectType.LUCK;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static <T> T lookup(Class<T> type, String key) {
|
||||||
|
NamespacedKey namespacedKey = NamespacedKey.fromString(key);
|
||||||
|
return namespacedKey == null ? null : RegistryUtil.lookup(type).get(namespacedKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
/*
|
||||||
|
* 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.platform.bukkit;
|
||||||
|
|
||||||
|
import art.arcane.iris.util.common.reflect.KeyedType;
|
||||||
|
import org.bukkit.NamespacedKey;
|
||||||
|
import org.bukkit.Registry;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.TreeSet;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
public final class PotionEffectTypes {
|
||||||
|
private static final Map<String, String> LEGACY_ALIASES;
|
||||||
|
private static final Set<String> MISSING_WARNED = ConcurrentHashMap.newKeySet();
|
||||||
|
|
||||||
|
static {
|
||||||
|
Map<String, String> m = new HashMap<>();
|
||||||
|
m.put("SLOW", "SLOWNESS");
|
||||||
|
m.put("FAST_DIGGING", "HASTE");
|
||||||
|
m.put("SLOW_DIGGING", "MINING_FATIGUE");
|
||||||
|
m.put("INCREASE_DAMAGE", "STRENGTH");
|
||||||
|
m.put("HEAL", "INSTANT_HEALTH");
|
||||||
|
m.put("HARM", "INSTANT_DAMAGE");
|
||||||
|
m.put("JUMP", "JUMP_BOOST");
|
||||||
|
m.put("CONFUSION", "NAUSEA");
|
||||||
|
m.put("DAMAGE_RESISTANCE", "RESISTANCE");
|
||||||
|
LEGACY_ALIASES = Collections.unmodifiableMap(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
private PotionEffectTypes() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String normalize(String input) {
|
||||||
|
if (input == null) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
String upper = input.trim().toUpperCase(Locale.ROOT).replace(' ', '_');
|
||||||
|
if (upper.contains(":")) {
|
||||||
|
upper = upper.substring(upper.indexOf(':') + 1);
|
||||||
|
}
|
||||||
|
return LEGACY_ALIASES.getOrDefault(upper, upper);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PotionEffectType resolve(String rawName) {
|
||||||
|
if (rawName == null || rawName.trim().isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
String wanted = normalize(rawName);
|
||||||
|
for (PotionEffectType i : Registry.EFFECT) {
|
||||||
|
NamespacedKey key = KeyedType.getKey(i);
|
||||||
|
if (key == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
String candidate = key.getKey().toUpperCase(Locale.ROOT).replace(' ', '_');
|
||||||
|
if (candidate.equals(wanted)) {
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String knownTypesList() {
|
||||||
|
TreeSet<String> names = new TreeSet<>();
|
||||||
|
for (PotionEffectType i : Registry.EFFECT) {
|
||||||
|
NamespacedKey key = KeyedType.getKey(i);
|
||||||
|
if (key != null) {
|
||||||
|
names.add(key.getKey().toUpperCase(Locale.ROOT).replace(' ', '_'));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return String.join(", ", names);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean shouldWarn(String rawName) {
|
||||||
|
return MISSING_WARNED.add(normalize(rawName));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -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.util.common.director.handlers;
|
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.engine.object.entity.IrisEntity;
|
|
||||||
import art.arcane.iris.engine.spawn.SpawnResources;
|
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
|
||||||
import art.arcane.iris.util.common.director.specialhandlers.RegistrantHandler;
|
|
||||||
|
|
||||||
public class EntityHandler extends RegistrantHandler<IrisEntity> {
|
|
||||||
|
|
||||||
public EntityHandler() {
|
|
||||||
super(IrisEntity.class, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected KList<IrisEntity> loadAll(IrisData data) {
|
|
||||||
KList<IrisEntity> entities = new KList<>();
|
|
||||||
for (String key : SpawnResources.entityKeys(data)) {
|
|
||||||
IrisEntity entity = SpawnResources.entity(data, key);
|
|
||||||
if (entity != null) {
|
|
||||||
entities.add(entity);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return entities;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getRandomDefault() {
|
|
||||||
return "entity";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+77
@@ -0,0 +1,77 @@
|
|||||||
|
/*
|
||||||
|
* 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.util.common.director.specialhandlers;
|
||||||
|
|
||||||
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
|
import art.arcane.iris.core.modules.PackModulesException;
|
||||||
|
import art.arcane.iris.core.pack.PackDirectoryResolver;
|
||||||
|
import art.arcane.iris.engine.spawn.SpawnResources;
|
||||||
|
import art.arcane.iris.spi.IrisPlatforms;
|
||||||
|
import art.arcane.iris.util.common.director.DirectorParameterHandler;
|
||||||
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
|
import art.arcane.volmlib.util.director.exceptions.DirectorParsingException;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.LinkedHashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
/** The key of an entity of a pack: the open pack's, then those of the packs in the packs folder. */
|
||||||
|
public final class EntityKeyHandler implements DirectorParameterHandler<String> {
|
||||||
|
@Override
|
||||||
|
public KList<String> getPossibilities() {
|
||||||
|
Set<String> keys = new LinkedHashSet<>();
|
||||||
|
IrisData activeData = data();
|
||||||
|
if (activeData != null) {
|
||||||
|
addEntityKeys(keys, activeData);
|
||||||
|
}
|
||||||
|
for (File pack : PackDirectoryResolver.listVisiblePackDirectories(
|
||||||
|
IrisPlatforms.get().packsFolder())) {
|
||||||
|
addEntityKeys(keys, IrisData.get(pack));
|
||||||
|
}
|
||||||
|
return new KList<>(keys);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString(String value) {
|
||||||
|
return value == null ? "" : value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String parse(String input, boolean force) throws DirectorParsingException {
|
||||||
|
for (String option : getPossibilities(input)) {
|
||||||
|
if (option.equalsIgnoreCase(input)) {
|
||||||
|
return option;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new DirectorParsingException("Unable to find Entity \"" + input + "\"");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean supports(Class<?> type) {
|
||||||
|
return type == String.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** A pack whose modules fail to load has no entities to offer; its failure was reported when it loaded. */
|
||||||
|
private static void addEntityKeys(Set<String> keys, IrisData data) {
|
||||||
|
try {
|
||||||
|
keys.addAll(SpawnResources.entityKeys(data));
|
||||||
|
} catch (PackModulesException ignored) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,7 +26,6 @@ import art.arcane.iris.util.project.matter.slices.IdentifierMatter;
|
|||||||
import art.arcane.iris.util.project.matter.slices.ModuleLayerMatter;
|
import art.arcane.iris.util.project.matter.slices.ModuleLayerMatter;
|
||||||
import art.arcane.iris.util.project.matter.slices.NativeStructureOwnershipMatter;
|
import art.arcane.iris.util.project.matter.slices.NativeStructureOwnershipMatter;
|
||||||
import art.arcane.iris.util.project.matter.slices.PlatformBlockMatter;
|
import art.arcane.iris.util.project.matter.slices.PlatformBlockMatter;
|
||||||
import art.arcane.iris.util.project.matter.slices.SpawnerMatter;
|
|
||||||
import art.arcane.iris.util.project.matter.slices.TileMatter;
|
import art.arcane.iris.util.project.matter.slices.TileMatter;
|
||||||
import art.arcane.iris.util.project.matter.slices.TreeBlockMaterialMatter;
|
import art.arcane.iris.util.project.matter.slices.TreeBlockMaterialMatter;
|
||||||
import art.arcane.volmlib.util.matter.IrisMatter;
|
import art.arcane.volmlib.util.matter.IrisMatter;
|
||||||
@@ -52,7 +51,6 @@ public final class IrisMatterSupport {
|
|||||||
IrisMatter.registerSliceType(new ModuleLayerMatter());
|
IrisMatter.registerSliceType(new ModuleLayerMatter());
|
||||||
IrisMatter.registerSliceType(new NativeStructureOwnershipMatter());
|
IrisMatter.registerSliceType(new NativeStructureOwnershipMatter());
|
||||||
IrisMatter.registerSliceType(new PlatformBlockMatter());
|
IrisMatter.registerSliceType(new PlatformBlockMatter());
|
||||||
IrisMatter.registerSliceType(new SpawnerMatter());
|
|
||||||
IrisMatter.registerSliceType(new TileMatter());
|
IrisMatter.registerSliceType(new TileMatter());
|
||||||
IrisMatter.registerSliceType(new TreeBlockMaterialMatter());
|
IrisMatter.registerSliceType(new TreeBlockMaterialMatter());
|
||||||
registered = true;
|
registered = true;
|
||||||
|
|||||||
@@ -1,53 +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.util.project.matter.slices;
|
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.core.loader.IrisRegistrant;
|
|
||||||
import art.arcane.iris.util.project.matter.IrisMatterContext;
|
|
||||||
import art.arcane.volmlib.util.data.palette.Palette;
|
|
||||||
import art.arcane.volmlib.util.matter.slices.RawMatter;
|
|
||||||
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
|
|
||||||
public abstract class RegistryMatter<T extends IrisRegistrant> extends RawMatter<T> {
|
|
||||||
public RegistryMatter(int width, int height, int depth, Class<T> c, T e) {
|
|
||||||
super(width, height, depth, c);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Palette<T> getGlobalPalette() {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void writeNode(T b, DataOutputStream dos) throws IOException {
|
|
||||||
dos.writeUTF(b.getLoadKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public T readNode(DataInputStream din) throws IOException {
|
|
||||||
return load(IrisMatterContext.require(), din.readUTF());
|
|
||||||
}
|
|
||||||
|
|
||||||
/** The resource of the pack {@code data} named by {@code key}, or null when the pack has none. */
|
|
||||||
protected abstract T load(IrisData data, String key);
|
|
||||||
}
|
|
||||||
@@ -1,40 +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.util.project.matter.slices;
|
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.engine.object.entity.spawn.IrisSpawner;
|
|
||||||
import art.arcane.iris.engine.spawn.SpawnResources;
|
|
||||||
import art.arcane.volmlib.util.matter.Sliced;
|
|
||||||
|
|
||||||
@Sliced
|
|
||||||
public class SpawnerMatter extends RegistryMatter<IrisSpawner> {
|
|
||||||
public SpawnerMatter() {
|
|
||||||
this(1, 1, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
public SpawnerMatter(int width, int height, int depth) {
|
|
||||||
super(width, height, depth, IrisSpawner.class, new IrisSpawner());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected IrisSpawner load(IrisData data, String key) {
|
|
||||||
return SpawnResources.spawner(data, key);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,133 @@
|
|||||||
|
/*
|
||||||
|
* 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.content;
|
||||||
|
|
||||||
|
import art.arcane.iris.builtin.loot.LootTable;
|
||||||
|
import art.arcane.iris.builtin.spawn.EntityDefinition;
|
||||||
|
import art.arcane.iris.builtin.spawn.SpawnMarker;
|
||||||
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
|
import art.arcane.iris.core.modules.ModuleResourceFixture;
|
||||||
|
import art.arcane.iris.engine.UsableBlockPlatform;
|
||||||
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
|
import art.arcane.iris.engine.framework.EngineGeneration;
|
||||||
|
import art.arcane.iris.engine.framework.SeedManager;
|
||||||
|
import art.arcane.iris.engine.loot.LootModule;
|
||||||
|
import art.arcane.iris.engine.loot.LootResources;
|
||||||
|
import art.arcane.iris.engine.object.TestSettings;
|
||||||
|
import art.arcane.iris.engine.object.world.IrisWorld;
|
||||||
|
import art.arcane.iris.engine.spawn.SpawnModule;
|
||||||
|
import art.arcane.iris.engine.spawn.SpawnResources;
|
||||||
|
import art.arcane.iris.spi.PlatformWorld;
|
||||||
|
import com.volmit.item.ItemRegistry;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
/** The answers of the loot and spawn modules reach adapters that cannot name IrisApi as host-typed values. */
|
||||||
|
public class ContentServicesTest {
|
||||||
|
private Engine engine;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void bindPlatform() {
|
||||||
|
UsableBlockPlatform.bind();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void unbindPlatform() {
|
||||||
|
UsableBlockPlatform.unbind();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void buildEngine() {
|
||||||
|
engine = mock(Engine.class);
|
||||||
|
IrisData data = mock(IrisData.class);
|
||||||
|
ModuleResourceFixture fixture = ModuleResourceFixture.serve(data);
|
||||||
|
ModuleResourceFixture.serveModules(data, new SpawnModule(), new LootModule());
|
||||||
|
ItemRegistry items = mock(ItemRegistry.class);
|
||||||
|
when(items.maxDurability(anyString())).thenReturn(OptionalInt.of(0));
|
||||||
|
when(data.getPackResources().items()).thenReturn(items);
|
||||||
|
when(engine.getData()).thenReturn(data);
|
||||||
|
IrisWorld engineWorld = mock(IrisWorld.class);
|
||||||
|
when(engineWorld.platformWorld()).thenReturn(mock(PlatformWorld.class));
|
||||||
|
when(engine.getWorld()).thenReturn(engineWorld);
|
||||||
|
SeedManager seeds = mock(SeedManager.class);
|
||||||
|
when(seeds.getEntity()).thenReturn(11L);
|
||||||
|
when(seeds.getLoot()).thenReturn(5L);
|
||||||
|
when(engine.getSeedManager()).thenReturn(seeds);
|
||||||
|
when(engine.getMinHeight()).thenReturn(-64);
|
||||||
|
when(engine.getGeneration()).thenReturn(new EngineGeneration(engine));
|
||||||
|
fixture.resource(SpawnResources.ENTITIES, "guard", TestSettings.of(EntityDefinition.class, """
|
||||||
|
{"type": "minecraft:zombie", "customName": "Guard", "baby": true, "glowing": true,
|
||||||
|
"helmet": {"type": "iron_helmet", "enchantments": [{"enchantment": "protection", "minLevel": 3, "maxLevel": 3}]},
|
||||||
|
"loot": {"tables": ["guard/drops"]},
|
||||||
|
"rawCommands": [{"commands": ["say hi {x}"], "delay": 4, "repeat": true, "repeatDelay": 20}]}"""));
|
||||||
|
fixture.resource(SpawnResources.MARKERS, "camp", TestSettings.of(SpawnMarker.class,
|
||||||
|
"{\"spawners\": [], \"emptyAbove\": false, \"removeOnChange\": false}"));
|
||||||
|
fixture.resource(LootResources.TABLES, "guard/drops", TestSettings.of(LootTable.class,
|
||||||
|
"{\"name\": \"Drops\", \"minPicked\": 1, \"maxPicked\": 1, \"loot\": [{\"type\": \"bread\", \"minAmount\": 3, \"maxAmount\": 3}]}"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void anEntityKeepsEveryDecisionTheModuleMade() {
|
||||||
|
ContentEntity guard = ContentServices.entity(engine, "guard").orElseThrow();
|
||||||
|
|
||||||
|
assertEquals("minecraft:zombie", guard.type());
|
||||||
|
assertEquals("Guard", guard.customName());
|
||||||
|
assertTrue(guard.flags().baby());
|
||||||
|
assertTrue(guard.flags().glowing());
|
||||||
|
assertFalse(guard.isSpecial());
|
||||||
|
assertEquals("iron_helmet", guard.equipment().helmet().item());
|
||||||
|
assertEquals(List.of(new ContentItem.Enchantment("protection", 3)), guard.equipment().helmet().enchantments());
|
||||||
|
assertEquals(List.of("guard/drops"), guard.lootTables());
|
||||||
|
assertEquals(List.of(new ContentEntity.Command(List.of("say hi {x}"), 4, true, 20)), guard.commands());
|
||||||
|
assertTrue(ContentServices.entity(engine, "nobody").isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void aMarkerRuleIsTheModulesAnswer() {
|
||||||
|
ContentSpawns.MarkerRule rule = ContentServices.markerRule(engine, "camp").orElseThrow();
|
||||||
|
|
||||||
|
assertEquals(List.of(), rule.spawners());
|
||||||
|
assertFalse(rule.emptyAbove());
|
||||||
|
assertFalse(rule.removeOnChange());
|
||||||
|
assertTrue(ContentServices.markerRule(engine, "unknown").isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void aTablesItemsAreDrawnByTheModuleAtTheSpot() {
|
||||||
|
List<ContentItem> items = ContentServices.tableItems(engine, 10, 64, -3, "guard/drops");
|
||||||
|
|
||||||
|
assertEquals(1, items.size());
|
||||||
|
assertEquals("bread", items.getFirst().item());
|
||||||
|
assertEquals(3, items.getFirst().amount());
|
||||||
|
assertEquals(items, ContentServices.tableItems(engine, 10, 64, -3, "guard/drops"));
|
||||||
|
assertTrue(ContentServices.tableItems(engine, 10, 64, -3, "missing").isEmpty());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,276 @@
|
|||||||
|
/*
|
||||||
|
* 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.loot.BlockDrop;
|
||||||
|
import art.arcane.iris.builtin.loot.BlockDropSettings;
|
||||||
|
import art.arcane.iris.builtin.loot.LootMode;
|
||||||
|
import art.arcane.iris.builtin.loot.LootSettings;
|
||||||
|
import art.arcane.iris.builtin.loot.LootSlot;
|
||||||
|
import art.arcane.iris.builtin.loot.LootTable;
|
||||||
|
import art.arcane.iris.builtin.spawn.AmbientEffect;
|
||||||
|
import art.arcane.iris.builtin.spawn.EffectSettings;
|
||||||
|
import art.arcane.iris.builtin.spawn.EntityDefinition;
|
||||||
|
import art.arcane.iris.builtin.spawn.SpawnGroup;
|
||||||
|
import art.arcane.iris.builtin.spawn.SpawnWeather;
|
||||||
|
import art.arcane.iris.builtin.spawn.Spawner;
|
||||||
|
import art.arcane.iris.builtin.spawn.SpawnerSettings;
|
||||||
|
import art.arcane.volmlib.util.json.JSONObject;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.volmit.FeatureAttachment.Target;
|
||||||
|
import com.volmit.block.BlockSpec;
|
||||||
|
import com.volmit.host.LoadedPack;
|
||||||
|
import com.volmit.host.ModuleHost;
|
||||||
|
import org.junit.After;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Rule;
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.rules.TemporaryFolder;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertSame;
|
||||||
|
import static org.junit.Assert.assertThrows;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Files of the overworld pack exactly as they were before the loot and spawn fields became module settings (copied from
|
||||||
|
* the pack backup), decoded by the built-in modules: {@code loot} is an object, {@code blockDrops}, {@code entitySpawners}
|
||||||
|
* and {@code effects} are lists, the loot tables, spawners and entities are the pack's own files.
|
||||||
|
*/
|
||||||
|
public class LootAndSpawnPackDecodingTest {
|
||||||
|
private static final String PACK = "/art/arcane/iris/core/modules/pack-before-loot-and-spawn";
|
||||||
|
|
||||||
|
@Rule
|
||||||
|
public TemporaryFolder folder = new TemporaryFolder();
|
||||||
|
|
||||||
|
private Path packFolder;
|
||||||
|
private LoadedPack pack;
|
||||||
|
private ModuleSettingsDecoder decoder;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void loadBuiltIns() throws IOException, URISyntaxException {
|
||||||
|
packFolder = Path.of(LootAndSpawnPackDecodingTest.class.getResource(PACK).toURI());
|
||||||
|
pack = LoadedPack.load(packFolder, ModuleHost.of(IrisModuleHost.builtInModules())
|
||||||
|
.reservingFields(ModuleTargets.reservedFields())
|
||||||
|
.describingHostTypesIn(IrisModuleHost.HOST_TYPE_PACKAGE).copyingJarsTo(folder.newFolder("copies").toPath()));
|
||||||
|
decoder = new ModuleSettingsDecoder(pack.catalog(), packFolder, Gson::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
@After
|
||||||
|
public void closePack() {
|
||||||
|
pack.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void theDimensionReadsItsLootReference() throws IOException {
|
||||||
|
ModuleSettings settings = decoder.decode(Target.DIMENSION, file("dimensions/overworld.json"), "dimension overworld");
|
||||||
|
|
||||||
|
LootSettings loot = settings.find(LootSettings.class).orElseThrow();
|
||||||
|
assertEquals(LootMode.FALLBACK, loot.mode());
|
||||||
|
assertEquals(List.of("global-clutter"), loot.tables());
|
||||||
|
assertEquals(1D, loot.multiplier(), 0);
|
||||||
|
assertTrue(settings.find(BlockDropSettings.class).isEmpty());
|
||||||
|
assertTrue(settings.find(SpawnerSettings.class).isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void aRegionReadsItsLootAndItsSpawners() throws IOException {
|
||||||
|
ModuleSettings settings = decoder.decode(Target.REGION, file("regions/terralost.json"), "region terralost");
|
||||||
|
|
||||||
|
LootSettings loot = settings.find(LootSettings.class).orElseThrow();
|
||||||
|
assertEquals(LootMode.FALLBACK, loot.mode());
|
||||||
|
assertEquals(0.5, loot.multiplier(), 0);
|
||||||
|
assertEquals(List.of("tropical/food", "cave/clutter"), loot.tables());
|
||||||
|
assertEquals(List.of("temperate/cave", "temperate/hostile", "temperate/passive", "temperate/water"),
|
||||||
|
settings.find(SpawnerSettings.class).orElseThrow().spawners());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void aRegionReadsItsBlockDrops() throws IOException {
|
||||||
|
ModuleSettings settings = decoder.decode(Target.REGION, file("regions/swamp.json"), "region swamp");
|
||||||
|
|
||||||
|
List<BlockDrop> drops = settings.find(BlockDropSettings.class).orElseThrow().drops();
|
||||||
|
assertEquals(1, drops.size());
|
||||||
|
assertEquals(List.of(BlockSpec.of("minecraft:grass_block"), BlockSpec.of("minecraft:dark_oak_leaves"),
|
||||||
|
BlockSpec.of("minecraft:short_grass"), BlockSpec.of("minecraft:tall_grass")), drops.getFirst().blocks());
|
||||||
|
assertEquals("slime_ball", drops.getFirst().drops().getFirst().type());
|
||||||
|
assertEquals(24, drops.getFirst().drops().getFirst().rarity());
|
||||||
|
assertFalse(drops.getFirst().exactBlocks());
|
||||||
|
assertFalse(drops.getFirst().skipParents());
|
||||||
|
assertFalse(drops.getFirst().replaceVanillaDrops());
|
||||||
|
assertEquals(LootSlot.STORAGE, drops.getFirst().drops().getFirst().slotTypes());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void aRegionReadsItsEffectsLootAndBlockDropsTogether() throws IOException {
|
||||||
|
JSONObject region = file("regions/mushroom.json");
|
||||||
|
|
||||||
|
ModuleSettings settings = decoder.decode(Target.REGION, region, "region mushroom");
|
||||||
|
|
||||||
|
List<AmbientEffect> effects = settings.find(EffectSettings.class).orElseThrow().effects();
|
||||||
|
assertEquals(region.getJSONArray("effects").length(), effects.size());
|
||||||
|
assertEquals("CRIMSON_SPORE", effects.getFirst().particleEffect());
|
||||||
|
assertEquals(1e-05, effects.getFirst().particleAltX(), 0);
|
||||||
|
assertEquals(1, effects.getFirst().particleAway());
|
||||||
|
assertEquals(5, effects.getFirst().particleDistance());
|
||||||
|
assertEquals(2, effects.getFirst().particleOffset());
|
||||||
|
assertEquals(50, effects.getFirst().interval());
|
||||||
|
assertEquals(3, effects.getFirst().chance());
|
||||||
|
assertNull(effects.getFirst().sound());
|
||||||
|
AmbientEffect sound = effects.get(1);
|
||||||
|
assertEquals("AMBIENT.WARPED_FOREST.ADDITIONS", sound.sound());
|
||||||
|
assertEquals(6.2, sound.volume(), 0);
|
||||||
|
assertEquals(0.2, sound.minPitch(), 0);
|
||||||
|
assertEquals(0.3, sound.maxPitch(), 0);
|
||||||
|
assertEquals(3, sound.soundDistance());
|
||||||
|
assertEquals(60000, sound.interval());
|
||||||
|
assertEquals(8, sound.chance());
|
||||||
|
assertEquals(2, settings.find(BlockDropSettings.class).orElseThrow().drops().getFirst().drops().size());
|
||||||
|
assertEquals(List.of("mushroom/clutter", "mushroom/food"), settings.find(LootSettings.class).orElseThrow().tables());
|
||||||
|
assertEquals(4, settings.find(SpawnerSettings.class).orElseThrow().spawners().size());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void aRegionsPotionEffectKeepsItsStrengthAndTicks() throws IOException {
|
||||||
|
ModuleSettings settings = decoder.decode(Target.REGION, file("regions/hot.json"), "region hot");
|
||||||
|
|
||||||
|
AmbientEffect potion = settings.find(EffectSettings.class).orElseThrow().effects().getFirst();
|
||||||
|
assertEquals("CONFUSION", potion.potionEffect());
|
||||||
|
assertEquals(0, potion.potionStrength());
|
||||||
|
assertEquals(87, potion.potionTicksMin());
|
||||||
|
assertEquals(67, potion.potionTicksMax());
|
||||||
|
assertEquals(1200, potion.chance());
|
||||||
|
assertEquals(500, potion.interval());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void aBiomeReadsItsEffects() throws IOException {
|
||||||
|
ModuleSettings settings = decoder.decode(Target.BIOME, file("biomes/tropical/volcanoes.json"), "biome tropical/volcanoes");
|
||||||
|
|
||||||
|
AmbientEffect smoke = settings.find(EffectSettings.class).orElseThrow().effects().getFirst();
|
||||||
|
assertEquals("CAMPFIRE_SIGNAL_SMOKE", smoke.particleEffect());
|
||||||
|
assertEquals(0.13885, smoke.particleAltY(), 0);
|
||||||
|
assertEquals(300, smoke.interval());
|
||||||
|
assertEquals(1, smoke.chance());
|
||||||
|
assertEquals(0, smoke.particleCount());
|
||||||
|
assertTrue(smoke.randomAltX());
|
||||||
|
assertFalse(smoke.randomAltY());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void aDimensionHasNoEffects() throws IOException {
|
||||||
|
JSONObject dimension = new JSONObject("{\"effects\": [{\"chance\": 1}], \"loot\": {}}");
|
||||||
|
|
||||||
|
ModuleSettings settings = decoder.decode(Target.DIMENSION, dimension, "dimension overworld");
|
||||||
|
|
||||||
|
assertTrue(settings.find(EffectSettings.class).isEmpty());
|
||||||
|
assertFalse(decoder.keys(Target.DIMENSION).contains("effects"));
|
||||||
|
assertTrue(decoder.keys(Target.REGION).contains("effects"));
|
||||||
|
assertTrue(decoder.keys(Target.BIOME).containsAll(Set.of("loot", "blockDrops", "entitySpawners", "effects")));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void thePacksSpawnersLootTablesAndEntitiesReadTheirOwnFiles() throws IOException {
|
||||||
|
Spawner spawner = decoder.decodeResource(Spawner.class, Files.readString(packFolder.resolve("spawners/mushroom/passive.json")));
|
||||||
|
|
||||||
|
assertEquals(SpawnGroup.NORMAL, spawner.group());
|
||||||
|
assertEquals(2, spawner.maxEntitiesPerChunk());
|
||||||
|
assertEquals(SpawnWeather.NONE, spawner.weather());
|
||||||
|
assertEquals(2_000L, spawner.maximumRate().interval());
|
||||||
|
assertFalse(spawner.maximumRate().isInfinite());
|
||||||
|
assertTrue(spawner.maximumRatePerChunk().isInfinite());
|
||||||
|
assertTrue(spawner.timeBlock().contains(12));
|
||||||
|
assertFalse(spawner.timeBlock().contains(2));
|
||||||
|
assertEquals(0, spawner.allowedLightLevels().min(), 0);
|
||||||
|
assertEquals(15, spawner.allowedLightLevels().max(), 0);
|
||||||
|
assertEquals(3, spawner.spawns().size());
|
||||||
|
assertEquals("standard/passive/mooshroom", spawner.spawns().getFirst().entity());
|
||||||
|
assertEquals(3, spawner.spawns().getFirst().maxSpawns());
|
||||||
|
assertEquals(3, spawner.spawns().get(1).rarity());
|
||||||
|
assertEquals(1, spawner.spawns().get(1).minSpawns());
|
||||||
|
assertTrue(spawner.initialSpawns().isEmpty());
|
||||||
|
|
||||||
|
LootTable table = decoder.decodeResource(LootTable.class, Files.readString(packFolder.resolve("loot/global-clutter.json")));
|
||||||
|
assertEquals("Global Clutter", table.name());
|
||||||
|
assertEquals(20, table.maxTries());
|
||||||
|
assertEquals(2, table.maxPicked());
|
||||||
|
assertEquals("stone", table.loot().getFirst().type());
|
||||||
|
assertEquals(8, table.loot().getFirst().maxAmount());
|
||||||
|
assertEquals(LootSlot.STORAGE, table.loot().getFirst().slotTypes());
|
||||||
|
|
||||||
|
EntityDefinition entity = decoder.decodeResource(EntityDefinition.class, Files.readString(packFolder.resolve("entities/standard/passive/mooshroom.json")));
|
||||||
|
assertEquals("MOOSHROOM", entity.type());
|
||||||
|
assertTrue(entity.aware());
|
||||||
|
assertTrue(entity.ai());
|
||||||
|
assertTrue(entity.gravity());
|
||||||
|
assertTrue(entity.loot().tables().isEmpty());
|
||||||
|
assertEquals(LootMode.ADD, entity.loot().mode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void theFeatureIdsAreNotKeys() {
|
||||||
|
JSONObject byId = new JSONObject("{\"iris:loot\": {\"tables\": [\"a\"]}, \"iris:spawn\": [\"a\"]}");
|
||||||
|
|
||||||
|
assertSame(ModuleSettings.NONE, decoder.decode(Target.REGION, byId, "region forests"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void aWrongShapeNamesTheKeyAndTheFile() {
|
||||||
|
IllegalArgumentException list = assertThrows(IllegalArgumentException.class,
|
||||||
|
() -> decoder.decode(Target.REGION, new JSONObject("{\"entitySpawners\": {\"spawners\": [\"a\"]}}"), "region forests"));
|
||||||
|
IllegalArgumentException object = assertThrows(IllegalArgumentException.class,
|
||||||
|
() -> decoder.decode(Target.REGION, new JSONObject("{\"loot\": [\"a\"]}"), "region forests"));
|
||||||
|
|
||||||
|
assertTrue(list.getMessage(), list.getMessage().contains("under \"entitySpawners\" in region forests"));
|
||||||
|
assertTrue(object.getMessage(), object.getMessage().contains("under \"loot\" in region forests"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void settingsEncodeBackToTheJsonThePackWrote() throws IOException {
|
||||||
|
for (String file : List.of("regions/terralost.json", "regions/swamp.json", "regions/mushroom.json", "regions/hot.json")) {
|
||||||
|
JSONObject region = this.file(file);
|
||||||
|
ModuleSettings settings = decoder.decode(Target.REGION, region, "region " + file);
|
||||||
|
|
||||||
|
JSONObject written = decoder.encode(Target.REGION, settings);
|
||||||
|
|
||||||
|
for (String key : List.of("loot", "blockDrops", "entitySpawners", "effects")) {
|
||||||
|
assertEquals(file + " " + key, region.has(key), written.has(key));
|
||||||
|
}
|
||||||
|
if (region.has("entitySpawners")) {
|
||||||
|
assertEquals(region.getJSONArray("entitySpawners").toString(), written.getJSONArray("entitySpawners").toString());
|
||||||
|
}
|
||||||
|
if (region.has("effects")) {
|
||||||
|
assertEquals(region.getJSONArray("effects").length(), written.getJSONArray("effects").length());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private JSONObject file(String relative) throws IOException {
|
||||||
|
return new JSONObject(Files.readString(packFolder.resolve(relative)));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,134 @@
|
|||||||
|
/*
|
||||||
|
* 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.pack;
|
||||||
|
|
||||||
|
import art.arcane.iris.builtin.loot.LootTable;
|
||||||
|
import art.arcane.iris.builtin.spawn.EntityDefinition;
|
||||||
|
import art.arcane.iris.builtin.spawn.SpawnMarker;
|
||||||
|
import art.arcane.iris.builtin.spawn.Spawner;
|
||||||
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
|
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||||
|
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||||
|
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||||
|
import art.arcane.volmlib.util.json.JSONObject;
|
||||||
|
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;
|
||||||
|
|
||||||
|
/** An export carries the loot tables, spawners, entities and markers that the pack's settings and placements reference, and what those reference. */
|
||||||
|
public class ModuleResourceClosureTest {
|
||||||
|
@Rule
|
||||||
|
public TemporaryFolder temporaryFolder = new TemporaryFolder();
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void followsEveryLevelsSettingsAndThePlacementsThroughSpawnersEntitiesAndMarkers() throws Exception {
|
||||||
|
IrisData data = IrisData.openValidation(pack().toFile());
|
||||||
|
try {
|
||||||
|
ModuleResourceClosure closure = new ModuleResourceClosure(data);
|
||||||
|
IrisDimension dimension = data.getDimensionLoader().load("main");
|
||||||
|
IrisRegion region = data.getRegionLoader().load("region");
|
||||||
|
IrisBiome biome = data.getBiomeLoader().load("biome");
|
||||||
|
|
||||||
|
closure.followSettingsOf(dimension);
|
||||||
|
closure.followSettingsOf(region);
|
||||||
|
closure.followSettingsOf(biome);
|
||||||
|
closure.follow(biome.getObjects());
|
||||||
|
|
||||||
|
assertEquals(List.of("drops", "global", "regional"), closure.keysOf(LootTable.class));
|
||||||
|
assertEquals(List.of("camp/zombies", "cave", "marker/spawner"), closure.keysOf(Spawner.class));
|
||||||
|
assertEquals(List.of("beta/sentinel", "cow", "zombie"), closure.keysOf(EntityDefinition.class));
|
||||||
|
assertEquals(List.of("camp"), closure.keysOf(SpawnMarker.class));
|
||||||
|
} finally {
|
||||||
|
data.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whatIsNotReferencedIsNotExportedAndMissingKeysAreSkipped() throws Exception {
|
||||||
|
IrisData data = IrisData.openValidation(pack().toFile());
|
||||||
|
try {
|
||||||
|
ModuleResourceClosure closure = new ModuleResourceClosure(data);
|
||||||
|
|
||||||
|
closure.followSettingsOf(data.getRegionLoader().load("region"));
|
||||||
|
|
||||||
|
assertEquals(List.of("regional"), closure.keysOf(LootTable.class));
|
||||||
|
assertEquals(List.of(), closure.keysOf(Spawner.class));
|
||||||
|
assertFalse(closure.keysOf(LootTable.class).contains("unused"));
|
||||||
|
assertTrue(new ModuleResourceClosure(data).isEmpty());
|
||||||
|
} finally {
|
||||||
|
data.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void writesEachResourceUnderTheFolderOfItsKind() throws Exception {
|
||||||
|
IrisData data = IrisData.openValidation(pack().toFile());
|
||||||
|
try {
|
||||||
|
ModuleResourceClosure closure = new ModuleResourceClosure(data);
|
||||||
|
closure.followSettingsOf(data.getDimensionLoader().load("main"));
|
||||||
|
File target = temporaryFolder.newFolder("export");
|
||||||
|
|
||||||
|
String hashes = closure.writeTo(target, true);
|
||||||
|
|
||||||
|
assertFalse(hashes.isEmpty());
|
||||||
|
assertEquals("Global", new JSONObject(Files.readString(target.toPath().resolve("loot/global.json"))).getString("name"));
|
||||||
|
assertTrue(Files.isRegularFile(target.toPath().resolve("spawners/camp/zombies.json")));
|
||||||
|
assertTrue(Files.isRegularFile(target.toPath().resolve("entities/zombie.json")));
|
||||||
|
assertFalse(Files.exists(target.toPath().resolve("loot/unused.json")));
|
||||||
|
} finally {
|
||||||
|
data.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Path pack() throws Exception {
|
||||||
|
File pack = temporaryFolder.newFolder("pack");
|
||||||
|
write(pack, "dimensions/main.json", "{\"regions\":[\"region\"],\"loot\":{\"tables\":[\"global\"]},\"entitySpawners\":[\"camp/zombies\"]}");
|
||||||
|
write(pack, "regions/region.json", "{\"landBiomes\":[\"biome\"],\"loot\":{\"tables\":[\"regional\"]}}");
|
||||||
|
write(pack, "biomes/biome.json", "{\"name\":\"Biome\",\"entitySpawners\":[\"cave\"],\"blockDrops\":[{\"blocks\":[{\"block\":\"stone\"}],\"drops\":[{\"type\":\"gravel\"}]}],"
|
||||||
|
+ "\"objects\":[{\"place\":[\"hut\"],\"loot\":[{\"name\":\"drops\"}],\"markers\":[{\"marker\":\"camp\",\"mark\":[{\"block\":\"stone\"}]}]}]}");
|
||||||
|
write(pack, "loot/global.json", "{\"name\":\"Global\",\"loot\":[{\"type\":\"stick\"}]}");
|
||||||
|
write(pack, "loot/regional.json", "{\"name\":\"Regional\",\"loot\":[{\"type\":\"stick\"}]}");
|
||||||
|
write(pack, "loot/drops.json", "{\"name\":\"Drops\",\"loot\":[{\"type\":\"stick\"}]}");
|
||||||
|
write(pack, "loot/unused.json", "{\"name\":\"Unused\",\"loot\":[{\"type\":\"stick\"}]}");
|
||||||
|
write(pack, "spawners/camp/zombies.json", "{\"spawns\":[{\"entity\":\"zombie\"}],\"initialSpawns\":[{\"entity\":\"beta/sentinel\"}]}");
|
||||||
|
write(pack, "spawners/cave.json", "{\"spawns\":[{\"entity\":\"cow\"}]}");
|
||||||
|
write(pack, "spawners/marker/spawner.json", "{\"spawns\":[{\"entity\":\"cow\"}]}");
|
||||||
|
write(pack, "entities/zombie.json", "{\"type\":\"minecraft:zombie\",\"loot\":{\"tables\":[\"drops\"]}}");
|
||||||
|
write(pack, "entities/beta/sentinel.json", "{\"type\":\"minecraft:skeleton\"}");
|
||||||
|
write(pack, "entities/cow.json", "{\"type\":\"minecraft:cow\"}");
|
||||||
|
write(pack, "markers/camp.json", "{\"spawners\":[\"marker/spawner\"]}");
|
||||||
|
return pack.toPath();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static 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,6 +1,5 @@
|
|||||||
package art.arcane.iris.core.pack;
|
package art.arcane.iris.core.pack;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.marker.IrisObjectMarker;
|
|
||||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -13,28 +12,19 @@ import static org.junit.Assert.assertEquals;
|
|||||||
import static org.junit.Assert.assertTrue;
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
public class PackExportClosureTest {
|
public class PackExportClosureTest {
|
||||||
private static IrisObjectPlacement placement(String objectKey, String... markerKeys) {
|
private static IrisObjectPlacement placement(String objectKey) {
|
||||||
IrisObjectPlacement placement = new IrisObjectPlacement();
|
IrisObjectPlacement placement = new IrisObjectPlacement();
|
||||||
placement.setPlace(new KList<>(objectKey));
|
placement.setPlace(new KList<>(objectKey));
|
||||||
KList<IrisObjectMarker> markers = new KList<>();
|
|
||||||
for (String markerKey : markerKeys) {
|
|
||||||
IrisObjectMarker marker = new IrisObjectMarker();
|
|
||||||
marker.setMarker(markerKey);
|
|
||||||
markers.add(marker);
|
|
||||||
}
|
|
||||||
placement.setMarkers(markers);
|
|
||||||
return placement;
|
return placement;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void collectsMarkerAndObjectKeysFromPlacements() {
|
public void collectsObjectKeysFromPlacements() {
|
||||||
List<IrisObjectPlacement> placements = List.of(
|
List<IrisObjectPlacement> placements = List.of(
|
||||||
placement("houses/hut", "spawn-point", "loot-marker"),
|
placement("houses/hut"),
|
||||||
placement("trees/oak"),
|
placement("trees/oak"),
|
||||||
placement("houses/hut", "spawn-point"));
|
placement("houses/hut"));
|
||||||
|
|
||||||
assertEquals(List.of("loot-marker", "spawn-point"),
|
|
||||||
PackExportClosure.collectMarkerKeys(placements).stream().sorted().toList());
|
|
||||||
assertEquals(List.of("houses/hut", "trees/oak"),
|
assertEquals(List.of("houses/hut", "trees/oak"),
|
||||||
PackExportClosure.collectObjectKeys(placements).stream().sorted().toList());
|
PackExportClosure.collectObjectKeys(placements).stream().sorted().toList());
|
||||||
}
|
}
|
||||||
@@ -42,10 +32,9 @@ public class PackExportClosureTest {
|
|||||||
@Test
|
@Test
|
||||||
public void toleratesNullPlacementsAndBlankKeys() {
|
public void toleratesNullPlacementsAndBlankKeys() {
|
||||||
KList<IrisObjectPlacement> placements = new KList<>();
|
KList<IrisObjectPlacement> placements = new KList<>();
|
||||||
placements.add(placement("", ""));
|
placements.add(placement(""));
|
||||||
placements.add((IrisObjectPlacement) null);
|
placements.add((IrisObjectPlacement) null);
|
||||||
|
|
||||||
assertTrue(PackExportClosure.collectMarkerKeys(placements).isEmpty());
|
|
||||||
assertTrue(PackExportClosure.collectObjectKeys(placements).isEmpty());
|
assertTrue(PackExportClosure.collectObjectKeys(placements).isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,11 +46,11 @@ public class PackExportClosureTest {
|
|||||||
public void bothPackagersExportSpawnersMarkersAndTheFullEntityGraph() throws Exception {
|
public void bothPackagersExportSpawnersMarkersAndTheFullEntityGraph() throws Exception {
|
||||||
String bukkit = Files.readString(Path.of(
|
String bukkit = Files.readString(Path.of(
|
||||||
"src/main/java/art/arcane/iris/core/project/IrisPackageCompiler.java")).replace("\r\n", "\n");
|
"src/main/java/art/arcane/iris/core/project/IrisPackageCompiler.java")).replace("\r\n", "\n");
|
||||||
assertTrue("Bukkit packager must write spawners/", bukkit.contains("\"spawners/\""));
|
|
||||||
assertTrue("Bukkit packager must write markers/", bukkit.contains("\"markers/\""));
|
|
||||||
assertTrue("Bukkit packager must export region objects alongside biome objects",
|
assertTrue("Bukkit packager must export region objects alongside biome objects",
|
||||||
bukkit.contains("regions.forEach((r) -> allPlacements.addAll(r.getObjects()))"));
|
bukkit.contains("regions.forEach((r) -> allPlacements.addAll(r.getObjects()))"));
|
||||||
assertTrue("Bukkit packager must export entity loot tables", bukkit.contains("getLoot().getTables()"));
|
assertTrue("Bukkit packager must export the spawn and loot resources the settings reference",
|
||||||
|
bukkit.contains("moduleResources.writeTo(folder, minify)"));
|
||||||
|
assertTrue("Bukkit packager must export the placements' references", bukkit.contains("moduleResources.follow(allPlacements)"));
|
||||||
int bukkitValidation = bukkit.indexOf("PackValidator.validateForPackaging(project.getPath())");
|
int bukkitValidation = bukkit.indexOf("PackValidator.validateForPackaging(project.getPath())");
|
||||||
assertTrue("Bukkit packager must validate before opening or mutating package state",
|
assertTrue("Bukkit packager must validate before opening or mutating package state",
|
||||||
bukkitValidation >= 0
|
bukkitValidation >= 0
|
||||||
@@ -70,9 +59,9 @@ public class PackExportClosureTest {
|
|||||||
|
|
||||||
String modded = Files.readString(Path.of(
|
String modded = Files.readString(Path.of(
|
||||||
"../adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedStudioCommands.java")).replace("\r\n", "\n");
|
"../adapters/modded-common/src/main/java/art/arcane/iris/modded/command/ModdedStudioCommands.java")).replace("\r\n", "\n");
|
||||||
assertTrue("modded packager must write spawners/", modded.contains("\"spawners\""));
|
assertTrue("modded packager must write the spawn and loot resources the settings reference",
|
||||||
assertTrue("modded packager must write markers/", modded.contains("\"markers\""));
|
modded.contains("moduleResources.writeTo(folder, true)"));
|
||||||
assertTrue("modded packager must include initial spawns", modded.contains("getInitialSpawns"));
|
assertTrue("modded packager must export the placements' references", modded.contains("moduleResources.follow(region.getObjects())"));
|
||||||
assertTrue("modded packager must export region objects", modded.contains("region.getObjects()"));
|
assertTrue("modded packager must export region objects", modded.contains("region.getObjects()"));
|
||||||
int moddedValidation = modded.indexOf("PackValidator.validateForPackaging(packFolder)");
|
int moddedValidation = modded.indexOf("PackValidator.validateForPackaging(packFolder)");
|
||||||
assertTrue("modded packager must validate before mutating package state",
|
assertTrue("modded packager must validate before mutating package state",
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
package art.arcane.iris.core.project;
|
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.entity.IrisEntitySpawn;
|
|
||||||
import art.arcane.iris.engine.object.entity.spawn.IrisSpawner;
|
|
||||||
import art.arcane.volmlib.util.collection.KSet;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertTrue;
|
|
||||||
|
|
||||||
public class IrisProjectEntityDependencyTest {
|
|
||||||
@Test
|
|
||||||
public void collectsInitialOnlyEntityAlongsideNormalSpawnEntityForExport() {
|
|
||||||
IrisSpawner spawner = new IrisSpawner();
|
|
||||||
spawner.getSpawns().add(new IrisEntitySpawn().setEntity("standard/passive/cow"));
|
|
||||||
spawner.getInitialSpawns().add(new IrisEntitySpawn().setEntity("beta/sentinel"));
|
|
||||||
KSet<IrisSpawner> spawners = new KSet<>();
|
|
||||||
spawners.add(spawner);
|
|
||||||
|
|
||||||
KSet<String> entityKeys = IrisPackageCompiler.collectSpawnerEntityKeys(spawners);
|
|
||||||
|
|
||||||
assertEquals(2, entityKeys.size());
|
|
||||||
assertTrue(entityKeys.contains("standard/passive/cow"));
|
|
||||||
assertTrue(entityKeys.contains("beta/sentinel"));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void returnsNoEntityDependenciesForEmptySpawnerSet() {
|
|
||||||
KSet<String> entityKeys = IrisPackageCompiler.collectSpawnerEntityKeys(new KSet<>());
|
|
||||||
|
|
||||||
assertTrue(entityKeys.isEmpty());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* 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.engine.loot;
|
||||||
|
|
||||||
|
import art.arcane.iris.builtin.loot.LootTable;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.volmit.item.ItemDrop;
|
||||||
|
import com.volmit.item.ItemRegistry;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What a loot table gives at fixed spots of a fixed world, as the whole drawn items, hashed. The numbers were taken
|
||||||
|
* before the loot classes became settings of the loot module; a change in them changes the loot of existing worlds.
|
||||||
|
*/
|
||||||
|
public class LootDrawPinTest {
|
||||||
|
private static final long LOOT_SEED = 8123456789L;
|
||||||
|
private static final String TABLE = """
|
||||||
|
{"name": "Pin table", "rarity": 1, "minPicked": 2, "maxPicked": 6, "maxTries": 20, "loot": [
|
||||||
|
{"type": "diamond_sword", "rarity": 2, "minAmount": 1, "maxAmount": 3, "minDurability": 0.25, "maxDurability": 0.75,
|
||||||
|
"displayName": "Pin blade", "lore": ["one", "two"], "unbreakable": true, "itemFlags": ["HIDE_ENCHANTS"],
|
||||||
|
"enchantments": [{"enchantment": "sharpness", "minLevel": 1, "maxLevel": 5, "chance": 0.6},
|
||||||
|
{"enchantment": "unbreaking", "minLevel": 2, "maxLevel": 3}],
|
||||||
|
"attributes": [{"attribute": "max_health", "name": "bonus", "minAmount": 2, "maxAmount": 6, "chance": 0.7}]},
|
||||||
|
{"type": "diamond", "minAmount": 1, "maxAmount": 5},
|
||||||
|
{"type": "bread", "rarity": 2, "minAmount": 2, "maxAmount": 8, "customModel": 4, "dyeColor": "red", "leatherColor": "#ff0000"},
|
||||||
|
{"type": "stick", "slotTypes": "FUEL"},
|
||||||
|
{"type": "unknown_item"}
|
||||||
|
]}
|
||||||
|
""";
|
||||||
|
private static final int[][] SPOTS = {{0, 64, 0}, {10, 64, -30}, {-512, 12, 777}, {4096, 200, -4096}, {7, -50, 7}};
|
||||||
|
|
||||||
|
private ItemRegistry registry;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void knowTheItems() {
|
||||||
|
registry = mock(ItemRegistry.class);
|
||||||
|
when(registry.maxDurability(anyString())).thenReturn(OptionalInt.empty());
|
||||||
|
when(registry.maxDurability("diamond_sword")).thenReturn(OptionalInt.of(1561));
|
||||||
|
when(registry.maxDurability("diamond")).thenReturn(OptionalInt.of(0));
|
||||||
|
when(registry.maxDurability("bread")).thenReturn(OptionalInt.of(0));
|
||||||
|
when(registry.maxDurability("stick")).thenReturn(OptionalInt.of(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void aTableGivesThePinnedItemsAtEachSpot() {
|
||||||
|
LootTable table = new Gson().fromJson(TABLE, LootTable.class);
|
||||||
|
LootItems items = new LootItems(registry, false);
|
||||||
|
|
||||||
|
List<Integer> hashes = new ArrayList<>();
|
||||||
|
for (int[] spot : SPOTS) {
|
||||||
|
List<ItemDrop> drops = items.draw("Pin table", table, LOOT_SEED, spot[0], spot[1], spot[2]);
|
||||||
|
hashes.add(drops.toString().hashCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals(List.of(-492887340, -92432338, -1096436977, -1436497629, -1714085578), hashes);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,139 @@
|
|||||||
|
/*
|
||||||
|
* 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.engine.loot;
|
||||||
|
|
||||||
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
|
import art.arcane.iris.core.modules.BuiltInPack;
|
||||||
|
import art.arcane.iris.core.modules.ModuleResourceFixture;
|
||||||
|
import art.arcane.iris.engine.IrisComplex;
|
||||||
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
|
import art.arcane.iris.builtin.loot.LootSettings;
|
||||||
|
import art.arcane.iris.builtin.loot.LootTable;
|
||||||
|
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||||
|
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||||
|
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||||
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Which loot tables a spot draws from, in which order and how often, for the loot references of its dimension, region and
|
||||||
|
* biomes, as written in pack JSON. Taken before the references became settings of the loot module.
|
||||||
|
*/
|
||||||
|
public class LootEnvironmentPinTest {
|
||||||
|
private static final int X = 10;
|
||||||
|
private static final int Z = 20;
|
||||||
|
private static final int SURFACE_Y = 70;
|
||||||
|
private static final int CAVE_Y = 40;
|
||||||
|
|
||||||
|
private Engine engine;
|
||||||
|
private IrisDimension dimension;
|
||||||
|
private IrisRegion region;
|
||||||
|
private IrisBiome surface;
|
||||||
|
private IrisBiome cave;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void buildTheWorld() {
|
||||||
|
engine = mock(Engine.class, RETURNS_DEEP_STUBS);
|
||||||
|
IrisData data = mock(IrisData.class);
|
||||||
|
ModuleResourceFixture fixture = ModuleResourceFixture.serve(data);
|
||||||
|
for (String key : List.of("a", "b", "c", "d", "e")) {
|
||||||
|
fixture.resource(LootResources.TABLES, key, table(key));
|
||||||
|
}
|
||||||
|
IrisComplex complex = engine.getComplex();
|
||||||
|
when(engine.getData()).thenReturn(data);
|
||||||
|
dimension = mock(IrisDimension.class);
|
||||||
|
region = mock(IrisRegion.class);
|
||||||
|
surface = biome("surface");
|
||||||
|
cave = biome("cave");
|
||||||
|
when(engine.getDimension()).thenReturn(dimension);
|
||||||
|
when(complex.getRegionStream().get(X, Z)).thenReturn(region);
|
||||||
|
when(complex.getTrueBiomeStream().get(X, Z)).thenReturn(surface);
|
||||||
|
when(complex.getHeightStream().get(X, Z)).thenReturn(64D);
|
||||||
|
when(engine.getCaveBiome(X, CAVE_Y, Z)).thenReturn(cave);
|
||||||
|
when(engine.getCaveBiome(X, SURFACE_Y, Z)).thenReturn(surface);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void everyLevelAddsItsTablesInOrderAndTheMultipliersScaleTheCount() {
|
||||||
|
references("{\"tables\": [\"a\"]}", "{\"tables\": [\"b\", \"c\"], \"multiplier\": 2}", "{\"tables\": [\"d\"], \"multiplier\": 1.5}", "{}");
|
||||||
|
|
||||||
|
assertEquals(List.of("a", "b", "c", "d", "c", "d", "a", "b", "d", "c", "a", "b"), identities(false, SURFACE_Y));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void fallbackReferencesStepAsideForTablesThatAnObjectDefined() {
|
||||||
|
references("{\"mode\": \"FALLBACK\", \"tables\": [\"a\"]}", "{\"tables\": [\"b\"]}", "{\"mode\": \"FALLBACK\", \"tables\": [\"c\"]}", "{}");
|
||||||
|
|
||||||
|
assertEquals(List.of("b"), identities(true, SURFACE_Y));
|
||||||
|
assertEquals(List.of("a", "b", "c"), identities(false, SURFACE_Y));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void replaceAndClearDropWhatCameBefore() {
|
||||||
|
references("{\"tables\": [\"a\"]}", "{\"mode\": \"REPLACE\", \"tables\": [\"b\"]}", "{\"tables\": [\"d\"]}", "{}");
|
||||||
|
assertEquals(List.of("b", "d"), identities(false, SURFACE_Y));
|
||||||
|
|
||||||
|
references("{\"tables\": [\"a\"]}", "{\"tables\": [\"b\"]}", "{\"mode\": \"CLEAR\", \"tables\": [\"d\"]}", "{}");
|
||||||
|
assertEquals(List.of(), identities(false, SURFACE_Y));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void belowTheSurfaceTheCaveBiomeAddsItsTablesToo() {
|
||||||
|
references("{\"tables\": [\"a\"]}", "{}", "{\"tables\": [\"b\"]}", "{\"tables\": [\"e\"], \"multiplier\": 3}");
|
||||||
|
|
||||||
|
assertEquals(List.of("a", "b", "e", "e", "b", "a", "e", "a", "b"), identities(false, CAVE_Y));
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> identities(boolean objectLootDefined, int y) {
|
||||||
|
List<String> sources = new ArrayList<>();
|
||||||
|
LootTables.resolveEnvironmentSources(sources, engine, new RNG(19L), X, y, Z, objectLootDefined, key -> key);
|
||||||
|
return sources;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void references(String dimensionJson, String regionJson, String surfaceJson, String caveJson) {
|
||||||
|
when(dimension.getModuleSettings()).thenReturn(BuiltInPack.settings(loot(dimensionJson)));
|
||||||
|
when(region.getModuleSettings()).thenReturn(BuiltInPack.settings(loot(regionJson)));
|
||||||
|
when(surface.getModuleSettings()).thenReturn(BuiltInPack.settings(loot(surfaceJson)));
|
||||||
|
when(cave.getModuleSettings()).thenReturn(BuiltInPack.settings(loot(caveJson)));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static LootSettings loot(String json) {
|
||||||
|
return new Gson().fromJson(json, LootSettings.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IrisBiome biome(String key) {
|
||||||
|
IrisBiome biome = mock(IrisBiome.class);
|
||||||
|
when(biome.getLoadKey()).thenReturn(key);
|
||||||
|
return biome;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static LootTable table(String key) {
|
||||||
|
return new Gson().fromJson("{\"name\": \"" + key + "\"}", LootTable.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,10 +1,8 @@
|
|||||||
package art.arcane.iris.engine.loot;
|
package art.arcane.iris.engine.loot;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.entity.IrisAttributeModifier;
|
import art.arcane.iris.builtin.loot.LootEntry;
|
||||||
import art.arcane.iris.engine.object.loot.IrisEnchantment;
|
import art.arcane.iris.builtin.loot.LootTable;
|
||||||
import art.arcane.iris.engine.object.loot.IrisLoot;
|
import art.arcane.iris.engine.object.TestSettings;
|
||||||
import art.arcane.iris.engine.object.loot.IrisLootTable;
|
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
import com.volmit.item.ItemDrop;
|
import com.volmit.item.ItemDrop;
|
||||||
import com.volmit.item.ItemRegistry;
|
import com.volmit.item.ItemRegistry;
|
||||||
@@ -37,10 +35,10 @@ public class LootItemsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void anEntryDrawsAmountEnchantmentsAttributesAndDamageFromOneStreamInThatOrder() {
|
public void anEntryDrawsAmountEnchantmentsAttributesAndDamageFromOneStreamInThatOrder() {
|
||||||
IrisLoot entry = new IrisLoot().setType("diamond_sword").setMinAmount(1).setMaxAmount(3)
|
LootEntry entry = entry("""
|
||||||
.setMinDurability(0.25).setMaxDurability(0.75)
|
{"type": "diamond_sword", "minAmount": 1, "maxAmount": 3, "minDurability": 0.25, "maxDurability": 0.75,
|
||||||
.setEnchantments(new KList<>(new IrisEnchantment("sharpness", 1, 5, 1D)))
|
"enchantments": [{"enchantment": "sharpness", "minLevel": 1, "maxLevel": 5, "chance": 1}],
|
||||||
.setAttributes(new KList<>(new IrisAttributeModifier("max_health", "bonus", "ADD_NUMBER", 2, 6, 1D)));
|
"attributes": [{"attribute": "max_health", "name": "bonus", "operation": "ADD_NUMBER", "minAmount": 2, "maxAmount": 6, "chance": 1}]}""");
|
||||||
RNG expected = new RNG(5L);
|
RNG expected = new RNG(5L);
|
||||||
int amount = (int) (1 + expected.nextLong(3));
|
int amount = (int) (1 + expected.nextLong(3));
|
||||||
expected.nextDouble();
|
expected.nextDouble();
|
||||||
@@ -59,7 +57,7 @@ public class LootItemsTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void anItemThatCannotBeDamagedDrawsNoDamageAndKeepsTheStreamAligned() {
|
public void anItemThatCannotBeDamagedDrawsNoDamageAndKeepsTheStreamAligned() {
|
||||||
IrisLoot entry = new IrisLoot().setType("diamond").setMinAmount(2).setMaxAmount(2);
|
LootEntry entry = entry("{\"type\": \"diamond\", \"minAmount\": 2, \"maxAmount\": 2}");
|
||||||
RNG rng = new RNG(9L);
|
RNG rng = new RNG(9L);
|
||||||
RNG untouched = new RNG(9L);
|
RNG untouched = new RNG(9L);
|
||||||
|
|
||||||
@@ -75,32 +73,37 @@ public class LootItemsTest {
|
|||||||
RNG rng = new RNG(9L);
|
RNG rng = new RNG(9L);
|
||||||
RNG untouched = new RNG(9L);
|
RNG untouched = new RNG(9L);
|
||||||
|
|
||||||
assertNull(new LootItems(registry, false).give(new IrisLoot().setType("not_an_item"), rng));
|
assertNull(new LootItems(registry, false).give(entry("{\"type\": \"not_an_item\"}"), rng));
|
||||||
assertNull(new LootItems(registry, false).give(new IrisLoot().setType("air"), rng));
|
assertNull(new LootItems(registry, false).give(entry("{\"type\": \"air\"}"), rng));
|
||||||
assertEquals(untouched.nextLong(), rng.nextLong());
|
assertEquals(untouched.nextLong(), rng.nextLong());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void debugItemsSayWhereTheyCameFrom() {
|
public void debugItemsSayWhereTheyCameFrom() {
|
||||||
IrisLootTable table = new IrisLootTable().setName("dungeon").setRarity(4);
|
LootTable table = table("{\"name\": \"dungeon\", \"rarity\": 4, \"minPicked\": 1, \"maxPicked\": 1, \"loot\": [{\"type\": \"diamond\", \"rarity\": 3}]}");
|
||||||
table.setLoot(new KList<>(new IrisLoot().setType("diamond").setRarity(3)));
|
|
||||||
table.setMinPicked(1).setMaxPicked(1);
|
|
||||||
|
|
||||||
List<ItemDrop> drops = new LootItems(registry, true).draw(table, LOOT_SEED, 0, 64, 0);
|
List<ItemDrop> drops = new LootItems(registry, true).draw("dungeon", table, LOOT_SEED, 0, 64, 0);
|
||||||
|
|
||||||
for (ItemDrop drop : drops) {
|
for (ItemDrop drop : drops) {
|
||||||
assertEquals(new ItemDrop.Source("dungeon", 4, 3), drop.source());
|
assertEquals(new ItemDrop.Source("dungeon", 4, 3), drop.source());
|
||||||
}
|
}
|
||||||
assertTrue(new LootItems(registry, false).draw(table, LOOT_SEED, 0, 64, 0).stream().allMatch(drop -> drop.source() == null));
|
assertTrue(new LootItems(registry, false).draw("dungeon", table, LOOT_SEED, 0, 64, 0).stream().allMatch(drop -> drop.source() == null));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void aTableGivesTheSameItemsAtTheSameSpotAndSeed() {
|
public void aTableGivesTheSameItemsAtTheSameSpotAndSeed() {
|
||||||
IrisLootTable table = new IrisLootTable().setName("tools").setMinPicked(2).setMaxPicked(4);
|
LootTable table = table("{\"name\": \"tools\", \"minPicked\": 2, \"maxPicked\": 4, \"loot\": [{\"type\": \"diamond\", \"maxAmount\": 5}, {\"type\": \"diamond_sword\"}]}");
|
||||||
table.setLoot(new KList<>(new IrisLoot().setType("diamond").setMaxAmount(5), new IrisLoot().setType("diamond_sword")));
|
|
||||||
|
|
||||||
LootItems items = new LootItems(registry, false);
|
LootItems items = new LootItems(registry, false);
|
||||||
|
|
||||||
assertEquals(items.draw(table, LOOT_SEED, 10, 64, -30), items.draw(table, LOOT_SEED, 10, 64, -30));
|
assertEquals(items.draw("tools", table, LOOT_SEED, 10, 64, -30), items.draw("tools", table, LOOT_SEED, 10, 64, -30));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static LootEntry entry(String json) {
|
||||||
|
return TestSettings.of(LootEntry.class, json);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static LootTable table(String json) {
|
||||||
|
return TestSettings.of(LootTable.class, json);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,13 +6,16 @@ import art.arcane.iris.engine.framework.LootResolver;
|
|||||||
import art.arcane.iris.engine.IrisComplex;
|
import art.arcane.iris.engine.IrisComplex;
|
||||||
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||||
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
import art.arcane.iris.engine.object.world.dimension.IrisDimension;
|
||||||
import art.arcane.iris.engine.object.loot.IrisLootMode;
|
import art.arcane.iris.builtin.loot.LootSettings;
|
||||||
import art.arcane.iris.engine.object.loot.IrisLootReference;
|
import art.arcane.iris.builtin.loot.LootTable;
|
||||||
import art.arcane.iris.engine.object.loot.IrisLootTable;
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
|
import art.arcane.iris.core.modules.BuiltInPack;
|
||||||
|
import art.arcane.iris.core.modules.ModuleResourceFixture;
|
||||||
|
import art.arcane.iris.core.modules.ModuleSettings;
|
||||||
|
import art.arcane.iris.engine.object.TestSettings;
|
||||||
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||||
import art.arcane.iris.engine.object.annotations.Desc;
|
import com.volmit.config.Desc;
|
||||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
import com.volmit.config.MaxNumber;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
|
||||||
import art.arcane.volmlib.util.math.RNG;
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
import com.volmit.item.ItemRegistry;
|
import com.volmit.item.ItemRegistry;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@@ -70,20 +73,17 @@ public class LootResolverTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void spatialSeedsIncludeWorldTableAndAbsolutePosition() {
|
public void spatialSeedsIncludeWorldTableAndAbsolutePosition() {
|
||||||
IrisLootTable first = new IrisLootTable().setName("first");
|
long baseline = LootTables.seed(41L, "first", 0, 64, 0);
|
||||||
IrisLootTable second = new IrisLootTable().setName("second");
|
|
||||||
|
|
||||||
long baseline = LootTables.seed(41L, first, 0, 64, 0);
|
assertEquals(baseline, LootTables.seed(41L, "first", 0, 64, 0));
|
||||||
|
assertNotEquals(baseline, LootTables.seed(42L, "first", 0, 64, 0));
|
||||||
assertEquals(baseline, LootTables.seed(41L, first, 0, 64, 0));
|
assertNotEquals(baseline, LootTables.seed(41L, "second", 0, 64, 0));
|
||||||
assertNotEquals(baseline, LootTables.seed(42L, first, 0, 64, 0));
|
assertNotEquals(baseline, LootTables.seed(41L, "first", 16, 64, 0));
|
||||||
assertNotEquals(baseline, LootTables.seed(41L, second, 0, 64, 0));
|
|
||||||
assertNotEquals(baseline, LootTables.seed(41L, first, 16, 64, 0));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void spatialRarityIsStableAndDistributed() {
|
public void spatialRarityIsStableAndDistributed() {
|
||||||
IrisLootTable table = new IrisLootTable().setName("distribution");
|
String table = "distribution";
|
||||||
int successes = 0;
|
int successes = 0;
|
||||||
|
|
||||||
for (int x = 0; x < 65_536; x++) {
|
for (int x = 0; x < 65_536; x++) {
|
||||||
@@ -103,7 +103,7 @@ public class LootResolverTest {
|
|||||||
@Test
|
@Test
|
||||||
public void nativeOrObjectLootSuppressesFallbackReferences() {
|
public void nativeOrObjectLootSuppressesFallbackReferences() {
|
||||||
ResolutionFixture fixture = new ResolutionFixture();
|
ResolutionFixture fixture = new ResolutionFixture();
|
||||||
List<IrisLootTable> sources = new ArrayList<>();
|
List<String> sources = new ArrayList<>();
|
||||||
|
|
||||||
LootTables.resolveEnvironmentSources(
|
LootTables.resolveEnvironmentSources(
|
||||||
sources,
|
sources,
|
||||||
@@ -113,7 +113,7 @@ public class LootResolverTest {
|
|||||||
70,
|
70,
|
||||||
20,
|
20,
|
||||||
true,
|
true,
|
||||||
table -> table
|
key -> key
|
||||||
);
|
);
|
||||||
|
|
||||||
assertTrue(sources.isEmpty());
|
assertTrue(sources.isEmpty());
|
||||||
@@ -122,7 +122,7 @@ public class LootResolverTest {
|
|||||||
@Test
|
@Test
|
||||||
public void emptyPlacementUsesEachFallbackScopeOnce() {
|
public void emptyPlacementUsesEachFallbackScopeOnce() {
|
||||||
ResolutionFixture fixture = new ResolutionFixture();
|
ResolutionFixture fixture = new ResolutionFixture();
|
||||||
List<IrisLootTable> sources = new ArrayList<>();
|
List<String> sources = new ArrayList<>();
|
||||||
|
|
||||||
LootTables.resolveEnvironmentSources(
|
LootTables.resolveEnvironmentSources(
|
||||||
sources,
|
sources,
|
||||||
@@ -132,10 +132,10 @@ public class LootResolverTest {
|
|||||||
70,
|
70,
|
||||||
20,
|
20,
|
||||||
false,
|
false,
|
||||||
table -> table
|
key -> key
|
||||||
);
|
);
|
||||||
|
|
||||||
assertEquals(List.of(fixture.dimensionTable, fixture.regionTable, fixture.surfaceTable), sources);
|
assertEquals(List.of("dimension", "region", "surface"), sources);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -170,7 +170,7 @@ public class LootResolverTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IllegalArgumentException failure = assertThrows(IllegalArgumentException.class,
|
IllegalArgumentException failure = assertThrows(IllegalArgumentException.class,
|
||||||
() -> LootResolver.scaleSources(sources, IrisLootReference.MAX_MULTIPLIER, new RNG(17L)));
|
() -> LootResolver.scaleSources(sources, LootSettings.MAX_MULTIPLIER, new RNG(17L)));
|
||||||
|
|
||||||
assertTrue(failure.getMessage().contains("maximum of 256 sources"));
|
assertTrue(failure.getMessage().contains("maximum of 256 sources"));
|
||||||
assertEquals(17, sources.size());
|
assertEquals(17, sources.size());
|
||||||
@@ -183,7 +183,7 @@ public class LootResolverTest {
|
|||||||
sources.add("table-" + index);
|
sources.add("table-" + index);
|
||||||
}
|
}
|
||||||
|
|
||||||
LootResolver.scaleSources(sources, IrisLootReference.MAX_MULTIPLIER, new RNG(17L));
|
LootResolver.scaleSources(sources, LootSettings.MAX_MULTIPLIER, new RNG(17L));
|
||||||
|
|
||||||
assertEquals(256, sources.size());
|
assertEquals(256, sources.size());
|
||||||
}
|
}
|
||||||
@@ -231,26 +231,26 @@ public class LootResolverTest {
|
|||||||
public void combinedMultiplierAboveReferenceCapRemainsUsableUnderResolvedSourceCap() {
|
public void combinedMultiplierAboveReferenceCapRemainsUsableUnderResolvedSourceCap() {
|
||||||
List<String> sources = new ArrayList<>(List.of("table"));
|
List<String> sources = new ArrayList<>(List.of("table"));
|
||||||
|
|
||||||
LootResolver.scaleSources(sources, IrisLootReference.MAX_MULTIPLIER * 2D, new RNG(17L));
|
LootResolver.scaleSources(sources, LootSettings.MAX_MULTIPLIER * 2D, new RNG(17L));
|
||||||
|
|
||||||
assertEquals(32, sources.size());
|
assertEquals(32, sources.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void lootMultiplierCapIsPublishedInSchemaMetadata() throws Exception {
|
public void lootMultiplierCapIsPublishedInSchemaMetadata() throws Exception {
|
||||||
Field multiplier = IrisLootReference.class.getDeclaredField("multiplier");
|
Field multiplier = LootSettings.class.getDeclaredField("multiplier");
|
||||||
MaxNumber maximum = multiplier.getAnnotation(MaxNumber.class);
|
MaxNumber maximum = multiplier.getAnnotation(MaxNumber.class);
|
||||||
Desc description = multiplier.getAnnotation(Desc.class);
|
Desc description = multiplier.getAnnotation(Desc.class);
|
||||||
|
|
||||||
assertEquals(IrisLootReference.MAX_MULTIPLIER, maximum.value(), 0D);
|
assertEquals(LootSettings.MAX_MULTIPLIER, maximum.value(), 0D);
|
||||||
assertTrue(description.value().contains("0 to 16"));
|
assertTrue(description.value().contains("0 to 16"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void emptyLootTableReturnsNoItems() {
|
public void emptyLootTableReturnsNoItems() {
|
||||||
IrisLootTable table = new IrisLootTable().setName("empty");
|
LootTable table = TestSettings.of(LootTable.class, "{\"name\": \"empty\"}");
|
||||||
|
|
||||||
assertTrue(new LootItems(mock(ItemRegistry.class), false).draw(table, 7L, 0, 64, 0).isEmpty());
|
assertTrue(new LootItems(mock(ItemRegistry.class), false).draw("empty", table, 7L, 0, 64, 0).isEmpty());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -264,23 +264,23 @@ public class LootResolverTest {
|
|||||||
|
|
||||||
private static final class ResolutionFixture {
|
private static final class ResolutionFixture {
|
||||||
private final Engine engine = mock(Engine.class, RETURNS_DEEP_STUBS);
|
private final Engine engine = mock(Engine.class, RETURNS_DEEP_STUBS);
|
||||||
private final IrisLootTable dimensionTable = new IrisLootTable().setName("dimension");
|
|
||||||
private final IrisLootTable regionTable = new IrisLootTable().setName("region");
|
|
||||||
private final IrisLootTable surfaceTable = new IrisLootTable().setName("surface");
|
|
||||||
|
|
||||||
private ResolutionFixture() {
|
private ResolutionFixture() {
|
||||||
IrisDimension dimension = mock(IrisDimension.class);
|
IrisDimension dimension = mock(IrisDimension.class);
|
||||||
IrisRegion region = mock(IrisRegion.class);
|
IrisRegion region = mock(IrisRegion.class);
|
||||||
IrisBiome surface = mock(IrisBiome.class);
|
IrisBiome surface = mock(IrisBiome.class);
|
||||||
IrisComplex complex = engine.getComplex();
|
IrisComplex complex = engine.getComplex();
|
||||||
IrisLootReference dimensionReference = reference(dimensionTable);
|
IrisData data = mock(IrisData.class);
|
||||||
IrisLootReference regionReference = reference(regionTable);
|
ModuleResourceFixture tables = ModuleResourceFixture.serve(data);
|
||||||
IrisLootReference surfaceReference = reference(surfaceTable);
|
for (String key : List.of("dimension", "region", "surface")) {
|
||||||
|
tables.resource(LootResources.TABLES, key, TestSettings.of(LootTable.class, "{\"name\": \"" + key + "\"}"));
|
||||||
|
}
|
||||||
|
|
||||||
|
when(engine.getData()).thenReturn(data);
|
||||||
when(engine.getDimension()).thenReturn(dimension);
|
when(engine.getDimension()).thenReturn(dimension);
|
||||||
when(dimension.getLoot()).thenReturn(dimensionReference);
|
when(dimension.getModuleSettings()).thenReturn(fallbackTo("dimension"));
|
||||||
when(region.getLoot()).thenReturn(regionReference);
|
when(region.getModuleSettings()).thenReturn(fallbackTo("region"));
|
||||||
when(surface.getLoot()).thenReturn(surfaceReference);
|
when(surface.getModuleSettings()).thenReturn(fallbackTo("surface"));
|
||||||
when(surface.getLoadKey()).thenReturn("surface");
|
when(surface.getLoadKey()).thenReturn("surface");
|
||||||
when(complex.getRegionStream().get(10, 20)).thenReturn(region);
|
when(complex.getRegionStream().get(10, 20)).thenReturn(region);
|
||||||
when(complex.getTrueBiomeStream().get(10, 20)).thenReturn(surface);
|
when(complex.getTrueBiomeStream().get(10, 20)).thenReturn(surface);
|
||||||
@@ -288,12 +288,8 @@ public class LootResolverTest {
|
|||||||
when(engine.getCaveBiome(10, 70, 20)).thenReturn(surface);
|
when(engine.getCaveBiome(10, 70, 20)).thenReturn(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
private IrisLootReference reference(IrisLootTable table) {
|
private static ModuleSettings fallbackTo(String table) {
|
||||||
IrisLootReference reference = mock(IrisLootReference.class);
|
return BuiltInPack.settings(TestSettings.of(LootSettings.class, "{\"mode\": \"FALLBACK\", \"tables\": [\"" + table + "\"]}"));
|
||||||
when(reference.getMode()).thenReturn(IrisLootMode.FALLBACK);
|
|
||||||
when(reference.getMultiplier()).thenReturn(1D);
|
|
||||||
when(reference.getLootTables(any())).thenReturn(new KList<>(table));
|
|
||||||
return reference;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ package art.arcane.iris.engine.loot;
|
|||||||
import art.arcane.iris.core.loader.IrisData;
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
import art.arcane.iris.core.project.ModuleResourceSchemas;
|
import art.arcane.iris.core.project.ModuleResourceSchemas;
|
||||||
import art.arcane.iris.core.project.SchemaTestPlatform;
|
import art.arcane.iris.core.project.SchemaTestPlatform;
|
||||||
import art.arcane.iris.engine.object.loot.IrisLootTable;
|
import art.arcane.iris.builtin.loot.LootTable;
|
||||||
import art.arcane.volmlib.util.json.JSONObject;
|
import art.arcane.volmlib.util.json.JSONObject;
|
||||||
import com.volmit.host.ValidatorRegistration;
|
import com.volmit.host.ValidatorRegistration;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
@@ -53,7 +53,7 @@ public class LootResourcesTest {
|
|||||||
assertEquals(List.of("iris:loot/table"), catalog.resourceKinds().stream().map(registration -> registration.kind().id().toString())
|
assertEquals(List.of("iris:loot/table"), catalog.resourceKinds().stream().map(registration -> registration.kind().id().toString())
|
||||||
.filter(id -> id.startsWith("iris:loot/")).toList());
|
.filter(id -> id.startsWith("iris:loot/")).toList());
|
||||||
assertTrue(catalog.validators().stream().map(ValidatorRegistration::validator).anyMatch(LootValidator.class::isInstance));
|
assertTrue(catalog.validators().stream().map(ValidatorRegistration::validator).anyMatch(LootValidator.class::isInstance));
|
||||||
assertFalse(data.getLoaders().containsKey(IrisLootTable.class));
|
assertFalse(data.getLoaders().containsKey(LootTable.class));
|
||||||
} finally {
|
} finally {
|
||||||
data.close();
|
data.close();
|
||||||
}
|
}
|
||||||
@@ -64,19 +64,18 @@ public class LootResourcesTest {
|
|||||||
Path pack = lootPack("tables");
|
Path pack = lootPack("tables");
|
||||||
IrisData data = IrisData.openValidation(pack.toFile());
|
IrisData data = IrisData.openValidation(pack.toFile());
|
||||||
try {
|
try {
|
||||||
IrisLootTable table = LootResources.table(data, "dungeon/chest");
|
LootTable table = LootResources.table(data, "dungeon/chest");
|
||||||
|
|
||||||
assertEquals("Chest", table.getName());
|
assertEquals("Chest", table.name());
|
||||||
assertEquals("dungeon/chest", table.getLoadKey());
|
assertEquals(1, table.loot().size());
|
||||||
assertEquals(pack.resolve("loot/dungeon/chest.json").toFile(), table.getLoadFile());
|
assertEquals("stick", table.loot().getFirst().type());
|
||||||
assertEquals(List.of("dungeon/chest"), LootResources.tableKeys(data));
|
assertEquals(List.of("dungeon/chest"), LootResources.tableKeys(data));
|
||||||
assertEquals(List.of(table), LootResources.tables(data, List.of("dungeon/chest", "missing")));
|
|
||||||
assertNull(LootResources.table(data, "missing"));
|
assertNull(LootResources.table(data, "missing"));
|
||||||
assertNull(LootResources.table(data, " "));
|
assertNull(LootResources.table(data, " "));
|
||||||
|
|
||||||
write(pack, "loot/dungeon/chest.json", "{\"name\":\"Renamed\"}");
|
write(pack, "loot/dungeon/chest.json", "{\"name\":\"Renamed\"}");
|
||||||
data.dump();
|
data.dump();
|
||||||
assertEquals("Renamed", LootResources.table(data, "dungeon/chest").getName());
|
assertEquals("Renamed", LootResources.table(data, "dungeon/chest").name());
|
||||||
} finally {
|
} finally {
|
||||||
data.close();
|
data.close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package art.arcane.iris.engine.loot;
|
package art.arcane.iris.engine.loot;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.loot.IrisLootMode;
|
import art.arcane.iris.builtin.loot.LootMode;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -13,18 +13,18 @@ public class LootTablesClearModeTest {
|
|||||||
@Test
|
@Test
|
||||||
public void clearSuppressesItsOwnTablesAndReplaceDoesNot() {
|
public void clearSuppressesItsOwnTablesAndReplaceDoesNot() {
|
||||||
List<String> cleared = new ArrayList<>(List.of("placement", "dimension"));
|
List<String> cleared = new ArrayList<>(List.of("placement", "dimension"));
|
||||||
LootTables.injectSources(cleared, List.of("biome"), IrisLootMode.CLEAR, false);
|
LootTables.injectSources(cleared, List.of("biome"), LootMode.CLEAR, false);
|
||||||
assertTrue("CLEAR must clear parents and contribute nothing", cleared.isEmpty());
|
assertTrue("CLEAR must clear parents and contribute nothing", cleared.isEmpty());
|
||||||
|
|
||||||
List<String> replaced = new ArrayList<>(List.of("placement", "dimension"));
|
List<String> replaced = new ArrayList<>(List.of("placement", "dimension"));
|
||||||
LootTables.injectSources(replaced, List.of("biome"), IrisLootMode.REPLACE, false);
|
LootTables.injectSources(replaced, List.of("biome"), LootMode.REPLACE, false);
|
||||||
assertEquals(List.of("biome"), replaced);
|
assertEquals(List.of("biome"), replaced);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void clearIgnoresTheFallbackFlag() {
|
public void clearIgnoresTheFallbackFlag() {
|
||||||
List<String> sources = new ArrayList<>(List.of("placement"));
|
List<String> sources = new ArrayList<>(List.of("placement"));
|
||||||
LootTables.injectSources(sources, List.of("biome"), IrisLootMode.CLEAR, true);
|
LootTables.injectSources(sources, List.of("biome"), LootMode.CLEAR, true);
|
||||||
assertTrue(sources.isEmpty());
|
assertTrue(sources.isEmpty());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,8 @@
|
|||||||
package art.arcane.iris.engine.loot;
|
package art.arcane.iris.engine.loot;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.loot.IrisLoot;
|
import art.arcane.iris.builtin.loot.LootEntry;
|
||||||
import art.arcane.iris.engine.object.loot.IrisLootTable;
|
import art.arcane.iris.builtin.loot.LootTable;
|
||||||
import art.arcane.iris.engine.object.annotations.MaxNumber;
|
import com.volmit.config.MaxNumber;
|
||||||
import com.volmit.validation.Problem;
|
import com.volmit.validation.Problem;
|
||||||
import com.volmit.validation.Severity;
|
import com.volmit.validation.Severity;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
@@ -110,11 +110,11 @@ public class LootValidatorTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void lootWorkCapsArePublishedInSchemaMetadata() throws Exception {
|
public void lootWorkCapsArePublishedInSchemaMetadata() throws Exception {
|
||||||
assertSchemaMaximum(IrisLootTable.class, "minPicked", IrisLootTable.MAX_PICKED);
|
assertSchemaMaximum(LootTable.class, "minPicked", LootTable.MAX_PICKED);
|
||||||
assertSchemaMaximum(IrisLootTable.class, "maxPicked", IrisLootTable.MAX_PICKED);
|
assertSchemaMaximum(LootTable.class, "maxPicked", LootTable.MAX_PICKED);
|
||||||
assertSchemaMaximum(IrisLootTable.class, "maxTries", IrisLootTable.MAX_TRIES);
|
assertSchemaMaximum(LootTable.class, "maxTries", LootTable.MAX_TRIES);
|
||||||
assertSchemaMaximum(IrisLoot.class, "minAmount", IrisLoot.MAX_AMOUNT);
|
assertSchemaMaximum(LootEntry.class, "minAmount", LootEntry.MAX_AMOUNT);
|
||||||
assertSchemaMaximum(IrisLoot.class, "maxAmount", IrisLoot.MAX_AMOUNT);
|
assertSchemaMaximum(LootEntry.class, "maxAmount", LootEntry.MAX_AMOUNT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void assertSchemaMaximum(Class<?> type, String fieldName, int expected) throws Exception {
|
private void assertSchemaMaximum(Class<?> type, String fieldName, int expected) throws Exception {
|
||||||
|
|||||||
@@ -0,0 +1,150 @@
|
|||||||
|
/*
|
||||||
|
* 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.engine.loot;
|
||||||
|
|
||||||
|
import art.arcane.iris.builtin.loot.LootTable;
|
||||||
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
|
import art.arcane.iris.core.modules.ModuleResourceFixture;
|
||||||
|
import art.arcane.iris.engine.UsableBlockPlatform;
|
||||||
|
import art.arcane.iris.engine.object.TestSettings;
|
||||||
|
import art.arcane.iris.engine.object.loot.IObjectLoot;
|
||||||
|
import art.arcane.iris.spi.PlatformBlockState;
|
||||||
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
|
import com.volmit.service.Loot;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The loot table an object placement gives a chest: a table naming the chest's exact state beats one naming its kind of
|
||||||
|
* block, which beats one naming no block; the weights pick among equals; platform tables count when the platform has them.
|
||||||
|
*/
|
||||||
|
public class PlacementLootTest {
|
||||||
|
private static final String CHEST = "minecraft:chest[facing=north]";
|
||||||
|
private static final String EAST_CHEST = "minecraft:chest[facing=east]";
|
||||||
|
private static final long LOOT_SEED = 99L;
|
||||||
|
|
||||||
|
private PlacementLoot placement;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void bindPlatform() {
|
||||||
|
UsableBlockPlatform.bind();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void unbindPlatform() {
|
||||||
|
UsableBlockPlatform.unbind();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void servePackTables() {
|
||||||
|
IrisData data = mock(IrisData.class);
|
||||||
|
ModuleResourceFixture fixture = ModuleResourceFixture.serve(data);
|
||||||
|
for (String key : List.of("everywhere", "chests", "this-chest", "other")) {
|
||||||
|
fixture.resource(LootResources.TABLES, key, TestSettings.of(LootTable.class, "{\"name\": \"" + key + "\"}"));
|
||||||
|
}
|
||||||
|
placement = new PlacementLoot(data, () -> Set.of("minecraft:chests/simple_dungeon"), LOOT_SEED);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void aTableThatNamesTheExactStateBeatsOneThatNamesTheKindOfBlock() {
|
||||||
|
List<IObjectLoot> pack = List.of(entry("everywhere", 1, false), entry("chests", 1, false, CHEST), entry("this-chest", 1, true, CHEST));
|
||||||
|
|
||||||
|
assertEquals(new Loot.Table("this-chest"), pick(List.of(), pack, CHEST));
|
||||||
|
assertEquals(new Loot.Table("chests"), pick(List.of(), pack, EAST_CHEST));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void aTableThatNamesNoBlockServesChestsNothingElseNames() {
|
||||||
|
List<IObjectLoot> pack = List.of(entry("everywhere", 1, false), entry("other", 1, false, "minecraft:barrel"));
|
||||||
|
|
||||||
|
assertEquals(new Loot.Table("everywhere"), pick(List.of(), pack, CHEST));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void exactEntriesDoNotApplyToOtherStatesAndNothingMatchingGivesNothing() {
|
||||||
|
List<IObjectLoot> pack = List.of(entry("this-chest", 1, true, CHEST), entry("other", 1, false, "minecraft:barrel"));
|
||||||
|
|
||||||
|
assertNull(pick(List.of(), pack, EAST_CHEST));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void weightsPickAmongEqualsAndZeroWeightsAreIgnored() {
|
||||||
|
List<IObjectLoot> pack = List.of(entry("everywhere", 3, false), entry("chests", 1, false), entry("other", 0, false));
|
||||||
|
int everywhere = 0;
|
||||||
|
RNG rng = new RNG(5L);
|
||||||
|
|
||||||
|
for (int i = 0; i < 4000; i++) {
|
||||||
|
Loot.Source picked = placement.pick(List.of(), pack, block(CHEST), rng, 0, 64, 0);
|
||||||
|
if (picked.equals(new Loot.Table("everywhere"))) {
|
||||||
|
everywhere++;
|
||||||
|
} else {
|
||||||
|
assertEquals(new Loot.Table("chests"), picked);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
assertEquals(3000, everywhere, 150);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void aPlatformTableWithAnythingThePlatformHasIsASourceWithTheSeedOfItsIdentity() {
|
||||||
|
List<IObjectLoot> platform = List.of(entry("chests/simple_dungeon", 1, false), entry("chests/missing", 1, false));
|
||||||
|
|
||||||
|
Loot.Source picked = pick(platform, List.of(), CHEST);
|
||||||
|
|
||||||
|
assertEquals(new Loot.PlatformTable("minecraft:chests/simple_dungeon",
|
||||||
|
LootTables.seed(LOOT_SEED, "Vanilla minecraft:chests/simple_dungeon", 0, 64, 0)), picked);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void tablesTheWorldLacksAreSkipped() {
|
||||||
|
assertNull(pick(List.of(entry("chests/missing", 1, false)), List.of(entry("not-a-table", 1, false)), CHEST));
|
||||||
|
}
|
||||||
|
|
||||||
|
private Loot.Source pick(List<IObjectLoot> platform, List<IObjectLoot> pack, String container) {
|
||||||
|
return placement.pick(platform, pack, block(container), new RNG(1L), 0, 64, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static PlatformBlockState block(String key) {
|
||||||
|
return UsableBlockPlatform.block(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IObjectLoot entry(String name, int weight, boolean exact, String... filter) {
|
||||||
|
IObjectLoot loot = mock(IObjectLoot.class);
|
||||||
|
when(loot.getName()).thenReturn(name);
|
||||||
|
when(loot.getWeight()).thenReturn(weight);
|
||||||
|
when(loot.isExact()).thenReturn(exact);
|
||||||
|
KList<PlatformBlockState> filterStates = new KList<>();
|
||||||
|
for (String key : filter) {
|
||||||
|
filterStates.add(block(key));
|
||||||
|
}
|
||||||
|
when(loot.getFilter(org.mockito.ArgumentMatchers.any())).thenReturn(filterStates);
|
||||||
|
return loot;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,72 @@
|
|||||||
|
/*
|
||||||
|
* 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.engine.loot;
|
||||||
|
|
||||||
|
import art.arcane.iris.builtin.loot.BlockDrop;
|
||||||
|
import art.arcane.iris.engine.UsableBlockPlatform;
|
||||||
|
import art.arcane.iris.engine.object.TestSettings;
|
||||||
|
import com.volmit.block.BlockRegistry;
|
||||||
|
import com.volmit.block.BlockSpec;
|
||||||
|
import com.volmit.block.BlockState;
|
||||||
|
import org.junit.AfterClass;
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
/** Which broken blocks a block drop applies to: the exact state it names, or any state of that block. */
|
||||||
|
public class ResolvedBlockDropTest {
|
||||||
|
private static final String NORTH_STAIRS = "minecraft:oak_stairs[facing=north]";
|
||||||
|
private static final String EAST_STAIRS = "minecraft:oak_stairs[facing=east]";
|
||||||
|
private static final String COBBLESTONE = "minecraft:cobblestone";
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void bindPlatform() {
|
||||||
|
UsableBlockPlatform.bind();
|
||||||
|
}
|
||||||
|
|
||||||
|
@AfterClass
|
||||||
|
public static void unbindPlatform() {
|
||||||
|
UsableBlockPlatform.unbind();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void exactMatchingIncludesPropertiesWhileTypeMatchingDoesNot() {
|
||||||
|
ResolvedBlockDrop exact = resolved(true);
|
||||||
|
ResolvedBlockDrop byType = resolved(false);
|
||||||
|
|
||||||
|
assertTrue(exact.dropsFor(NORTH_STAIRS));
|
||||||
|
assertFalse(exact.dropsFor(EAST_STAIRS));
|
||||||
|
assertTrue(byType.dropsFor(NORTH_STAIRS));
|
||||||
|
assertTrue(byType.dropsFor(EAST_STAIRS));
|
||||||
|
assertFalse(byType.dropsFor(COBBLESTONE));
|
||||||
|
assertFalse(exact.dropsFor(COBBLESTONE));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ResolvedBlockDrop resolved(boolean exactBlocks) {
|
||||||
|
BlockDrop drop = TestSettings.of(BlockDrop.class, "{\"exactBlocks\": " + exactBlocks + ", \"blocks\": [{\"block\": \"oak_stairs\"}]}");
|
||||||
|
BlockRegistry blocks = mock(BlockRegistry.class);
|
||||||
|
when(blocks.resolve(any(BlockSpec.class))).thenReturn(BlockState.parse(NORTH_STAIRS));
|
||||||
|
return ResolvedBlockDrop.of(drop, blocks);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
/*
|
|
||||||
* 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.engine.object.loot;
|
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.loot.IrisLoot;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
import static org.junit.Assert.assertNull;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* The modded item translator reads loot keys through these accessors instead of reflecting on IrisLoot fields, so
|
|
||||||
* they are part of the platform-neutral contract.
|
|
||||||
*/
|
|
||||||
public class IrisLootKeyAccessorTest {
|
|
||||||
@Test
|
|
||||||
public void typeKeyReturnsAuthoredKeyVerbatim() {
|
|
||||||
IrisLoot loot = new IrisLoot();
|
|
||||||
loot.setType("mymod:ruby_sword");
|
|
||||||
assertEquals("mymod:ruby_sword", loot.getTypeKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void typeKeyDefaultsToEmptyString() {
|
|
||||||
assertEquals("", new IrisLoot().getTypeKey());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void dyeColorKeyReturnsAuthoredValueAndNullWhenUnset() {
|
|
||||||
IrisLoot loot = new IrisLoot();
|
|
||||||
assertNull(loot.getDyeColorKey());
|
|
||||||
loot.setDyeColor("LIGHT_BLUE");
|
|
||||||
assertEquals("LIGHT_BLUE", loot.getDyeColorKey());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/*
|
||||||
|
* 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.engine.object.value;
|
||||||
|
|
||||||
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
|
/** Rarity weights a pool exactly once: the entity spawners of both platforms pick a spawn from the expanded pool. */
|
||||||
|
public class IRareWeightingTest {
|
||||||
|
private record Spawn(int rarity) implements IRare {
|
||||||
|
@Override
|
||||||
|
public int getRarity() {
|
||||||
|
return rarity;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void rarityIsAppliedOnceAsPoolWeightOnly() {
|
||||||
|
Spawn common = new Spawn(1);
|
||||||
|
Spawn rare = new Spawn(4);
|
||||||
|
|
||||||
|
KList<Spawn> expanded = IRare.expandWeighted(List.of(common, rare));
|
||||||
|
|
||||||
|
// totalRarity 5 -> common appears 5/1 = 5 times, rare 5/4 = 1 time.
|
||||||
|
assertEquals(6, expanded.size());
|
||||||
|
assertEquals(5, expanded.stream().filter(entry -> entry == common).count());
|
||||||
|
assertEquals(1, expanded.stream().filter(entry -> entry == rare).count());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void rarityZeroAndNegativeAreClampedToOne() {
|
||||||
|
assertEquals(1, IRare.get(new Spawn(0)));
|
||||||
|
assertEquals(1, IRare.get(new Spawn(-5)));
|
||||||
|
assertEquals(3, IRare.get(new Spawn(3)));
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
package art.arcane.iris.engine.object.value;
|
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.value.IrisDuration;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertEquals;
|
|
||||||
|
|
||||||
public class IrisDurationTest {
|
|
||||||
@Test
|
|
||||||
public void convertsRealAndMinecraftUnitsToMilliseconds() {
|
|
||||||
IrisDuration duration = new IrisDuration();
|
|
||||||
duration.setMilliseconds(1);
|
|
||||||
duration.setMinecraftTicks(1);
|
|
||||||
duration.setSeconds(1);
|
|
||||||
duration.setMinutes(1);
|
|
||||||
duration.setMinecraftHours(1);
|
|
||||||
duration.setHours(1);
|
|
||||||
duration.setMinecraftDays(1);
|
|
||||||
duration.setMinecraftWeeks(1);
|
|
||||||
duration.setMinecraftLunarCycles(1);
|
|
||||||
duration.setDays(1);
|
|
||||||
|
|
||||||
assertEquals(109_311_051L, duration.toMilliseconds());
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void convertsMinecraftCalendarUnitsUsingTwentyMinuteDays() {
|
|
||||||
IrisDuration day = new IrisDuration();
|
|
||||||
IrisDuration week = new IrisDuration();
|
|
||||||
IrisDuration lunarCycle = new IrisDuration();
|
|
||||||
day.setMinecraftDays(1);
|
|
||||||
week.setMinecraftWeeks(1);
|
|
||||||
lunarCycle.setMinecraftLunarCycles(1);
|
|
||||||
|
|
||||||
assertEquals(1_200_000L, day.toMilliseconds());
|
|
||||||
assertEquals(8_400_000L, week.toMilliseconds());
|
|
||||||
assertEquals(9_600_000L, lunarCycle.toMilliseconds());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,141 @@
|
|||||||
|
/*
|
||||||
|
* 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.engine.spawn;
|
||||||
|
|
||||||
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
|
import art.arcane.iris.core.modules.BuiltInPack;
|
||||||
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
|
import art.arcane.iris.engine.framework.EngineGeneration;
|
||||||
|
import art.arcane.iris.engine.object.TestSettings;
|
||||||
|
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||||
|
import art.arcane.iris.engine.object.world.region.IrisRegion;
|
||||||
|
import art.arcane.iris.engine.object.world.IrisWorld;
|
||||||
|
import art.arcane.iris.builtin.spawn.EffectSettings;
|
||||||
|
import art.arcane.iris.spi.PlatformWorld;
|
||||||
|
import com.volmit.service.AmbientEffects;
|
||||||
|
import com.volmit.world.BlockPosition;
|
||||||
|
import com.volmit.world.PackWorld;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
/** The ambient effects due around a player: the region's, then the biome's, each when its interval and chance allow, fully decided. */
|
||||||
|
public class AmbientEffectingTest {
|
||||||
|
private static final BlockPosition AT = new BlockPosition(10, 70, -20);
|
||||||
|
private static final String SOUND_AND_POTION = """
|
||||||
|
{"effects": [{"sound": "ambient.cave", "soundDistance": 4, "minPitch": 0.5, "maxPitch": 0.5, "volume": 2,
|
||||||
|
"potionEffect": "luck", "potionStrength": 1, "potionTicksMin": 100, "potionTicksMax": 100,
|
||||||
|
"interval": 1, "chance": 1}]}""";
|
||||||
|
private static final String PARTICLES_AND_COMMANDS = """
|
||||||
|
{"effects": [{"particleEffect": "flame", "particleDistance": 1, "particleAway": 5, "particleDistanceWidth": 0,
|
||||||
|
"particleCount": 2, "particleAltX": 0.5, "randomAltX": false, "randomAltZ": false, "extra": 0.25,
|
||||||
|
"commandRegistry": {"rawCommands": [{"commands": ["say hi {x}"], "delay": 3},
|
||||||
|
{"commands": ["say never"], "weather": "DOWNFALL"}],
|
||||||
|
"commandOffsetX": 2, "commandRandomAltX": false, "commandAllRandomLocations": false},
|
||||||
|
"interval": 1, "chance": 1}]}""";
|
||||||
|
|
||||||
|
private Engine engine;
|
||||||
|
private IrisRegion region;
|
||||||
|
private IrisBiome biome;
|
||||||
|
private PackWorld world;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void buildWorld() {
|
||||||
|
engine = mock(Engine.class);
|
||||||
|
when(engine.getData()).thenReturn(mock(IrisData.class));
|
||||||
|
IrisWorld engineWorld = mock(IrisWorld.class);
|
||||||
|
PlatformWorld platformWorld = mock(PlatformWorld.class);
|
||||||
|
when(engineWorld.platformWorld()).thenReturn(platformWorld);
|
||||||
|
when(engine.getWorld()).thenReturn(engineWorld);
|
||||||
|
region = mock(IrisRegion.class);
|
||||||
|
biome = mock(IrisBiome.class);
|
||||||
|
when(region.getModuleSettings()).thenReturn(ModuleSettingsOf.none());
|
||||||
|
when(biome.getModuleSettings()).thenReturn(ModuleSettingsOf.none());
|
||||||
|
when(engine.getRegion(10, -20)).thenReturn(region);
|
||||||
|
when(engine.getBiome(10, 70, -20)).thenReturn(biome);
|
||||||
|
world = new EngineGeneration(engine).world();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void anAreaWithoutEffectsHasNothingDue() {
|
||||||
|
assertEquals(List.of(), new AmbientEffecting().due(world, AT));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void aSoundAndAPotionComeWithTheirDecidedValues() throws Exception {
|
||||||
|
when(biome.getModuleSettings()).thenReturn(BuiltInPack.settings(TestSettings.of(EffectSettings.class, SOUND_AND_POTION)));
|
||||||
|
Thread.sleep(5);
|
||||||
|
|
||||||
|
List<AmbientEffects.Effect> due = new AmbientEffecting().due(world, AT);
|
||||||
|
|
||||||
|
assertEquals(1, due.size());
|
||||||
|
AmbientEffects.Sound sound = due.getFirst().sound();
|
||||||
|
assertEquals("ambient.cave", sound.key());
|
||||||
|
assertTrue(Math.abs(sound.offsetX()) <= 4 && Math.abs(sound.offsetY()) <= 4 && Math.abs(sound.offsetZ()) <= 4);
|
||||||
|
assertEquals(2F, sound.volume(), 0);
|
||||||
|
assertEquals(0.5F, sound.pitch(), 0);
|
||||||
|
assertEquals(new AmbientEffects.Potion("luck", 1, 100), due.getFirst().potion());
|
||||||
|
assertNull(due.getFirst().particles());
|
||||||
|
assertTrue(due.getFirst().commands().isEmpty());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void particlesAndOnlyTheCommandsThatMayRunNowComeWithTheirOffsets() throws Exception {
|
||||||
|
when(region.getModuleSettings()).thenReturn(BuiltInPack.settings(TestSettings.of(EffectSettings.class, PARTICLES_AND_COMMANDS)));
|
||||||
|
Thread.sleep(5);
|
||||||
|
|
||||||
|
AmbientEffects.Effect effect = new AmbientEffecting().due(world, AT).getFirst();
|
||||||
|
|
||||||
|
assertEquals("flame", effect.particles().key());
|
||||||
|
assertEquals(5, effect.particles().forward(), 0);
|
||||||
|
assertEquals(0, effect.particles().sideways(), 0);
|
||||||
|
assertEquals(0.5, effect.particles().altX(), 0);
|
||||||
|
assertEquals(0.25, effect.particles().extra(), 0);
|
||||||
|
assertEquals(2, effect.particles().count());
|
||||||
|
assertEquals(1, effect.commands().size());
|
||||||
|
assertEquals(List.of("say hi {x}"), effect.commands().getFirst().command().commands());
|
||||||
|
assertEquals(3, effect.commands().getFirst().command().delay());
|
||||||
|
assertEquals(2, effect.commands().getFirst().offsetX(), 0);
|
||||||
|
assertNull(effect.sound());
|
||||||
|
assertNull(effect.potion());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void anEffectPlaysOnlyOncePerInterval() {
|
||||||
|
when(biome.getModuleSettings()).thenReturn(BuiltInPack.settings(TestSettings.of(EffectSettings.class,
|
||||||
|
SOUND_AND_POTION.replace("\"interval\": 1", "\"interval\": 600000"))));
|
||||||
|
AmbientEffecting effecting = new AmbientEffecting();
|
||||||
|
|
||||||
|
assertEquals(1, effecting.due(world, AT).size());
|
||||||
|
assertEquals(0, effecting.due(world, AT).size());
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final class ModuleSettingsOf {
|
||||||
|
private static art.arcane.iris.core.modules.ModuleSettings none() {
|
||||||
|
return art.arcane.iris.core.modules.ModuleSettings.NONE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
/*
|
||||||
|
* 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.engine.spawn;
|
||||||
|
|
||||||
|
import art.arcane.iris.engine.loot.LootItems;
|
||||||
|
import art.arcane.iris.builtin.spawn.EntityDefinition;
|
||||||
|
import art.arcane.iris.spi.PlatformWorld;
|
||||||
|
import art.arcane.volmlib.util.math.RNG;
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.volmit.entity.EntitySpec;
|
||||||
|
import com.volmit.item.ItemRegistry;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.OptionalInt;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* What an entity of the pack becomes when it is made from a fixed stream, hashed. The number was taken before the entity
|
||||||
|
* classes became settings of the spawn module; a change in it changes the equipment, attributes and passengers worlds spawn.
|
||||||
|
*/
|
||||||
|
public class EntityResolutionPinTest {
|
||||||
|
private static final long STREAM_SEED = 4321L;
|
||||||
|
private static final String ENTITY = """
|
||||||
|
{"type": "minecraft:zombie", "customName": "&cPin", "aware": false, "glowing": true, "baby": true, "removable": true,
|
||||||
|
"helmet": {"type": "iron_helmet", "rarity": 2, "minDurability": 0.2, "maxDurability": 0.9,
|
||||||
|
"enchantments": [{"enchantment": "protection", "minLevel": 1, "maxLevel": 4}]},
|
||||||
|
"mainHand": {"type": "diamond_sword", "minAmount": 1, "maxAmount": 1,
|
||||||
|
"attributes": [{"attribute": "attack_damage", "name": "pin", "minAmount": 1, "maxAmount": 9}]},
|
||||||
|
"offHand": {"type": "bread", "minAmount": 1, "maxAmount": 6},
|
||||||
|
"attributes": [{"attribute": "max_health", "name": "tough", "minAmount": 10, "maxAmount": 40, "chance": 0.8},
|
||||||
|
{"attribute": "movement_speed", "name": "quick", "operation": "ADD_SCALAR", "minAmount": 0.1, "maxAmount": 0.3}],
|
||||||
|
"loot": {"tables": ["zombie/drops", "zombie/rare"]},
|
||||||
|
"passengers": [{"type": "minecraft:chicken", "baby": true, "helmet": {"type": "bread"}}],
|
||||||
|
"leashHolder": {"type": "minecraft:bat", "attributes": [{"attribute": "max_health", "name": "tiny", "minAmount": 1, "maxAmount": 3}]},
|
||||||
|
"spawnEffect": {"sound": "entity.zombie.ambient", "particleEffect": "SMOKE", "particleCount": 3, "interval": 1, "chance": 1},
|
||||||
|
"spawnEffectRiseOutOfGround": true,
|
||||||
|
"rawCommands": [{"commands": ["say hello {x}"], "delay": 5, "repeat": true, "repeatDelay": 40}]}
|
||||||
|
""";
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void anEntityResolvesToThePinnedSpec() {
|
||||||
|
ItemRegistry registry = mock(ItemRegistry.class);
|
||||||
|
when(registry.maxDurability(anyString())).thenReturn(OptionalInt.of(0));
|
||||||
|
when(registry.maxDurability("iron_helmet")).thenReturn(OptionalInt.of(165));
|
||||||
|
when(registry.maxDurability("diamond_sword")).thenReturn(OptionalInt.of(1561));
|
||||||
|
PlatformWorld world = mock(PlatformWorld.class);
|
||||||
|
EntityDefinition entity = new Gson().fromJson(ENTITY, EntityDefinition.class);
|
||||||
|
|
||||||
|
EntitySpec spec = new EntityResolution(new LootItems(registry, false), world, new EffectTimers()).resolve(entity, new RNG(STREAM_SEED));
|
||||||
|
|
||||||
|
assertEquals(-819231818, spec.toString().hashCode());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -25,10 +25,10 @@ import art.arcane.iris.engine.framework.Engine;
|
|||||||
import art.arcane.iris.engine.framework.EngineGeneration;
|
import art.arcane.iris.engine.framework.EngineGeneration;
|
||||||
import art.arcane.iris.engine.framework.SeedManager;
|
import art.arcane.iris.engine.framework.SeedManager;
|
||||||
import art.arcane.iris.engine.mantle.EngineMantle;
|
import art.arcane.iris.engine.mantle.EngineMantle;
|
||||||
import art.arcane.iris.engine.object.entity.IrisEntity;
|
import art.arcane.iris.builtin.spawn.EntityDefinition;
|
||||||
import art.arcane.iris.engine.object.entity.IrisEntitySpawn;
|
import art.arcane.iris.builtin.spawn.SpawnMarker;
|
||||||
import art.arcane.iris.engine.object.entity.spawn.IrisSpawner;
|
import art.arcane.iris.builtin.spawn.Spawner;
|
||||||
import art.arcane.iris.engine.object.marker.IrisMarker;
|
import art.arcane.iris.engine.object.TestSettings;
|
||||||
import art.arcane.iris.engine.object.world.IrisWorld;
|
import art.arcane.iris.engine.object.world.IrisWorld;
|
||||||
import art.arcane.iris.spi.PlatformWorld;
|
import art.arcane.iris.spi.PlatformWorld;
|
||||||
import art.arcane.volmlib.util.collection.KList;
|
import art.arcane.volmlib.util.collection.KList;
|
||||||
@@ -97,10 +97,9 @@ public class EntitySpawningTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void aMarkerMeansItsSpawnersAndWhetherItGoesAwayWhenItsBlockChanges() {
|
public void aMarkerMeansItsSpawnersAndWhetherItGoesAwayWhenItsBlockChanges() {
|
||||||
IrisMarker marker = new IrisMarker();
|
SpawnMarker marker = TestSettings.of(SpawnMarker.class, "{\"spawners\": [\"zombies\", \"missing\"], \"emptyAbove\": true, \"removeOnChange\": false}");
|
||||||
marker.setSpawners(new KList<>("zombies", "missing")).setEmptyAbove(true).setRemoveOnChange(false);
|
|
||||||
fixture.resource(SpawnResources.MARKERS, "camp", marker);
|
fixture.resource(SpawnResources.MARKERS, "camp", marker);
|
||||||
fixture.resource(SpawnResources.SPAWNERS, "zombies", new IrisSpawner());
|
fixture.resource(SpawnResources.SPAWNERS, "zombies", new Spawner());
|
||||||
|
|
||||||
EntitySpawns.MarkerRule rule = new EntitySpawning().marker(world, "camp").orElseThrow();
|
EntitySpawns.MarkerRule rule = new EntitySpawning().marker(world, "camp").orElseThrow();
|
||||||
|
|
||||||
@@ -117,16 +116,10 @@ public class EntitySpawningTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void aMarkerSpawnPlansEntitiesOneBlockAboveTheMarkerWithoutSurfaceChecks() {
|
public void aMarkerSpawnPlansEntitiesOneBlockAboveTheMarkerWithoutSurfaceChecks() {
|
||||||
IrisSpawner spawner = new IrisSpawner();
|
Spawner spawner = TestSettings.of(Spawner.class, "{\"spawns\": [{\"entity\": \"zombie\", \"minSpawns\": 2, \"maxSpawns\": 2}]}");
|
||||||
spawner.setLoadKey("camp/zombies");
|
|
||||||
spawner.getSpawns().add(new IrisEntitySpawn().setEntity("zombie").setMinSpawns(2).setMaxSpawns(2));
|
|
||||||
fixture.resource(SpawnResources.SPAWNERS, "camp/zombies", spawner);
|
fixture.resource(SpawnResources.SPAWNERS, "camp/zombies", spawner);
|
||||||
IrisMarker marker = new IrisMarker();
|
fixture.resource(SpawnResources.MARKERS, "camp", TestSettings.of(SpawnMarker.class, "{\"exhaustionChance\": 2}"));
|
||||||
marker.setExhaustionChance(2);
|
fixture.resource(SpawnResources.ENTITIES, "zombie", TestSettings.of(EntityDefinition.class, "{\"type\": \"minecraft:zombie\"}"));
|
||||||
fixture.resource(SpawnResources.MARKERS, "camp", marker);
|
|
||||||
IrisEntity zombie = new IrisEntity();
|
|
||||||
zombie.setType("minecraft:zombie");
|
|
||||||
fixture.resource(SpawnResources.ENTITIES, "zombie", zombie);
|
|
||||||
when(engine.getMinHeight()).thenReturn(-64);
|
when(engine.getMinHeight()).thenReturn(-64);
|
||||||
|
|
||||||
EntitySpawns.Plan plan = new EntitySpawning()
|
EntitySpawns.Plan plan = new EntitySpawning()
|
||||||
@@ -145,8 +138,7 @@ public class EntitySpawningTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void aSpawnerThatCannotFireOrHasNoEntitiesPlansNothing() {
|
public void aSpawnerThatCannotFireOrHasNoEntitiesPlansNothing() {
|
||||||
IrisSpawner empty = new IrisSpawner();
|
fixture.resource(SpawnResources.SPAWNERS, "empty", new Spawner());
|
||||||
fixture.resource(SpawnResources.SPAWNERS, "empty", empty);
|
|
||||||
|
|
||||||
Optional<EntitySpawns.Plan> plan = new EntitySpawning().plan(world, new EntitySpawns.Marker(MARKER_BLOCK, "camp", "empty", false));
|
Optional<EntitySpawns.Plan> plan = new EntitySpawning().plan(world, new EntitySpawns.Marker(MARKER_BLOCK, "camp", "empty", false));
|
||||||
|
|
||||||
@@ -155,9 +147,8 @@ public class EntitySpawningTest {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void anEntityOfThePackResolvesToTheSpecTheHostSpawns() {
|
public void anEntityOfThePackResolvesToTheSpecTheHostSpawns() {
|
||||||
IrisEntity entity = new IrisEntity();
|
fixture.resource(SpawnResources.ENTITIES, "cow", TestSettings.of(EntityDefinition.class,
|
||||||
entity.setType("minecraft:cow").setCustomName("&6Bessie").setBaby(true);
|
"{\"type\": \"minecraft:cow\", \"customName\": \"&6Bessie\", \"baby\": true}"));
|
||||||
fixture.resource(SpawnResources.ENTITIES, "cow", entity);
|
|
||||||
|
|
||||||
EntitySpec spec = new EntitySpawning().entity(world, "cow").orElseThrow();
|
EntitySpec spec = new EntitySpawning().entity(world, "cow").orElseThrow();
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
package art.arcane.iris.engine.spawn;
|
||||||
|
|
||||||
|
import art.arcane.iris.engine.object.TestSettings;
|
||||||
|
import art.arcane.iris.builtin.spawn.SpawnDuration;
|
||||||
|
import art.arcane.iris.builtin.spawn.SpawnRate;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
public class SpawnDurationTest {
|
||||||
|
@Test
|
||||||
|
public void convertsRealAndMinecraftUnitsToMilliseconds() {
|
||||||
|
SpawnDuration duration = TestSettings.of(SpawnDuration.class, """
|
||||||
|
{"milliseconds": 1, "minecraftTicks": 1, "seconds": 1, "minutes": 1, "minecraftHours": 1, "hours": 1,
|
||||||
|
"minecraftDays": 1, "minecraftWeeks": 1, "minecraftLunarCycles": 1, "days": 1}""");
|
||||||
|
|
||||||
|
assertEquals(109_311_051L, duration.toMilliseconds());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void convertsMinecraftCalendarUnitsUsingTwentyMinuteDays() {
|
||||||
|
assertEquals(1_200_000L, TestSettings.of(SpawnDuration.class, "{\"minecraftDays\": 1}").toMilliseconds());
|
||||||
|
assertEquals(8_400_000L, TestSettings.of(SpawnDuration.class, "{\"minecraftWeeks\": 1}").toMilliseconds());
|
||||||
|
assertEquals(9_600_000L, TestSettings.of(SpawnDuration.class, "{\"minecraftLunarCycles\": 1}").toMilliseconds());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void aRateSpreadsItsAmountOverItsDurationAndHasNoLimitWithoutOne() {
|
||||||
|
SpawnRate rate = TestSettings.of(SpawnRate.class, "{\"amount\": 4, \"per\": {\"seconds\": 2}}");
|
||||||
|
|
||||||
|
assertEquals(500L, rate.interval());
|
||||||
|
assertFalse(rate.isInfinite());
|
||||||
|
assertTrue(TestSettings.of(SpawnRate.class, "{\"amount\": 4}").isInfinite());
|
||||||
|
assertEquals(1L, new SpawnRate().interval());
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,9 +19,12 @@
|
|||||||
package art.arcane.iris.engine.spawn;
|
package art.arcane.iris.engine.spawn;
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
import art.arcane.iris.core.loader.IrisData;
|
||||||
import art.arcane.iris.engine.object.entity.IrisEntity;
|
import art.arcane.iris.core.project.ModuleResourceSchemas;
|
||||||
import art.arcane.iris.engine.object.entity.spawn.IrisSpawner;
|
import art.arcane.iris.core.project.SchemaTestPlatform;
|
||||||
import art.arcane.iris.engine.object.marker.IrisMarker;
|
import art.arcane.volmlib.util.json.JSONObject;
|
||||||
|
import art.arcane.iris.builtin.spawn.EntityDefinition;
|
||||||
|
import art.arcane.iris.builtin.spawn.SpawnMarker;
|
||||||
|
import art.arcane.iris.builtin.spawn.Spawner;
|
||||||
import org.junit.Rule;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.rules.TemporaryFolder;
|
import org.junit.rules.TemporaryFolder;
|
||||||
@@ -35,6 +38,7 @@ import java.util.List;
|
|||||||
import static org.junit.Assert.assertEquals;
|
import static org.junit.Assert.assertEquals;
|
||||||
import static org.junit.Assert.assertFalse;
|
import static org.junit.Assert.assertFalse;
|
||||||
import static org.junit.Assert.assertNull;
|
import static org.junit.Assert.assertNull;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
/** Spawners, entities and markers are resource kinds of module {@code iris:spawn}, read from the folders packs have always had. */
|
/** Spawners, entities and markers are resource kinds of module {@code iris:spawn}, read from the folders packs have always had. */
|
||||||
public class SpawnResourcesTest {
|
public class SpawnResourcesTest {
|
||||||
@@ -51,9 +55,9 @@ public class SpawnResourcesTest {
|
|||||||
.filter(kind -> kind.id().toString().startsWith("iris:spawn/")).toList();
|
.filter(kind -> kind.id().toString().startsWith("iris:spawn/")).toList();
|
||||||
assertEquals(List.of("iris:spawn/entity", "iris:spawn/marker", "iris:spawn/spawner"), kinds.stream().map(kind -> kind.id().toString()).toList());
|
assertEquals(List.of("iris:spawn/entity", "iris:spawn/marker", "iris:spawn/spawner"), kinds.stream().map(kind -> kind.id().toString()).toList());
|
||||||
assertEquals(List.of("entities", "markers", "spawners"), kinds.stream().map(kind -> kind.folder()).toList());
|
assertEquals(List.of("entities", "markers", "spawners"), kinds.stream().map(kind -> kind.folder()).toList());
|
||||||
assertFalse(data.getLoaders().containsKey(IrisSpawner.class));
|
assertFalse(data.getLoaders().containsKey(Spawner.class));
|
||||||
assertFalse(data.getLoaders().containsKey(IrisEntity.class));
|
assertFalse(data.getLoaders().containsKey(EntityDefinition.class));
|
||||||
assertFalse(data.getLoaders().containsKey(IrisMarker.class));
|
assertFalse(data.getLoaders().containsKey(SpawnMarker.class));
|
||||||
} finally {
|
} finally {
|
||||||
data.close();
|
data.close();
|
||||||
}
|
}
|
||||||
@@ -64,13 +68,12 @@ public class SpawnResourcesTest {
|
|||||||
Path pack = spawnPack("spawns");
|
Path pack = spawnPack("spawns");
|
||||||
IrisData data = IrisData.openValidation(pack.toFile());
|
IrisData data = IrisData.openValidation(pack.toFile());
|
||||||
try {
|
try {
|
||||||
IrisSpawner spawner = SpawnResources.spawner(data, "camp/zombies");
|
Spawner spawner = SpawnResources.spawner(data, "camp/zombies");
|
||||||
|
|
||||||
assertEquals("camp/zombies", spawner.getLoadKey());
|
assertEquals("zombie", spawner.spawns().getFirst().entity());
|
||||||
assertEquals(pack.resolve("spawners/camp/zombies.json").toFile(), spawner.getLoadFile());
|
assertEquals("minecraft:zombie", SpawnResources.entity(data, "zombie").type());
|
||||||
assertEquals("minecraft:zombie", SpawnResources.entity(data, "zombie").getType());
|
assertEquals(List.of("camp/zombies"), SpawnResources.marker(data, "camp").spawners());
|
||||||
assertEquals(List.of("camp/zombies"), SpawnResources.marker(data, "camp").getSpawners());
|
assertEquals(List.of(new SpawnResources.KeyedSpawner("camp/zombies", spawner)), SpawnResources.spawners(data, List.of("camp/zombies", "missing")));
|
||||||
assertEquals(List.of(spawner), SpawnResources.spawners(data, List.of("camp/zombies", "missing")));
|
|
||||||
assertEquals(List.of("zombie"), SpawnResources.entityKeys(data));
|
assertEquals(List.of("zombie"), SpawnResources.entityKeys(data));
|
||||||
assertEquals(List.of("camp"), SpawnResources.markerKeys(data));
|
assertEquals(List.of("camp"), SpawnResources.markerKeys(data));
|
||||||
assertEquals(List.of("camp/zombies"), SpawnResources.spawnerKeys(data));
|
assertEquals(List.of("camp/zombies"), SpawnResources.spawnerKeys(data));
|
||||||
@@ -79,7 +82,26 @@ public class SpawnResourcesTest {
|
|||||||
|
|
||||||
write(pack, "entities/zombie.json", "{\"type\":\"minecraft:husk\"}");
|
write(pack, "entities/zombie.json", "{\"type\":\"minecraft:husk\"}");
|
||||||
data.dump();
|
data.dump();
|
||||||
assertEquals("minecraft:husk", SpawnResources.entity(data, "zombie").getType());
|
assertEquals("minecraft:husk", SpawnResources.entity(data, "zombie").type());
|
||||||
|
} finally {
|
||||||
|
data.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void studioDescribesSpawnersEntitiesAndMarkers() throws Exception {
|
||||||
|
Path pack = spawnPack("studio");
|
||||||
|
IrisData data = IrisData.openValidation(pack.toFile());
|
||||||
|
try (SchemaTestPlatform ignored = SchemaTestPlatform.bind(temporaryFolder.getRoot())) {
|
||||||
|
List<JSONObject> entries = ModuleResourceSchemas.entries(data, true);
|
||||||
|
|
||||||
|
for (String schema : List.of("spawners", "entities", "markers")) {
|
||||||
|
assertTrue(schema, entries.stream().anyMatch(entry -> entry.getString("url").equals("./.iris/schema/" + schema + "-schema.json")));
|
||||||
|
assertTrue(schema, Files.exists(pack.resolve(".iris/schema/" + schema + "-schema.json")));
|
||||||
|
}
|
||||||
|
JSONObject entity = new JSONObject(Files.readString(pack.resolve(".iris/schema/entities-schema.json")));
|
||||||
|
assertTrue(entity.toString().contains("passengers"));
|
||||||
|
assertTrue(entity.toString().contains("tables"));
|
||||||
} finally {
|
} finally {
|
||||||
data.close();
|
data.close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,113 @@
|
|||||||
|
/*
|
||||||
|
* 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.engine.spawn;
|
||||||
|
|
||||||
|
import art.arcane.iris.builtin.spawn.Spawner;
|
||||||
|
import art.arcane.iris.engine.framework.Engine;
|
||||||
|
import art.arcane.iris.engine.object.TestSettings;
|
||||||
|
import art.arcane.iris.engine.object.runtime.IrisEngineData;
|
||||||
|
import art.arcane.iris.engine.object.world.IrisWorld;
|
||||||
|
import art.arcane.iris.engine.object.world.biome.InferredType;
|
||||||
|
import art.arcane.iris.engine.object.world.biome.IrisBiome;
|
||||||
|
import art.arcane.iris.spi.PlatformWorld;
|
||||||
|
import org.junit.Before;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertFalse;
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
/** Whether a spawner may fire: the biome kind its group wants, the world's time and weather, and its rates in the engine's data. */
|
||||||
|
public class SpawnerGateTest {
|
||||||
|
private Engine engine;
|
||||||
|
private PlatformWorld world;
|
||||||
|
|
||||||
|
@Before
|
||||||
|
public void buildEngine() {
|
||||||
|
engine = mock(Engine.class);
|
||||||
|
IrisWorld engineWorld = mock(IrisWorld.class);
|
||||||
|
world = mock(PlatformWorld.class);
|
||||||
|
when(engineWorld.platformWorld()).thenReturn(world);
|
||||||
|
when(engine.getWorld()).thenReturn(engineWorld);
|
||||||
|
when(engine.getEngineData()).thenReturn(new IrisEngineData());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void theGroupDecidesWhichBiomesSuit() {
|
||||||
|
Spawner normal = spawner("{\"group\": \"NORMAL\"}");
|
||||||
|
Spawner underwater = spawner("{\"group\": \"UNDERWATER\"}");
|
||||||
|
Spawner beach = spawner("{\"group\": \"BEACH\"}");
|
||||||
|
Spawner cave = spawner("{\"group\": \"CAVE\"}");
|
||||||
|
|
||||||
|
assertTrue(SpawnerGate.suits(normal, biome(InferredType.LAND)));
|
||||||
|
assertFalse(SpawnerGate.suits(normal, biome(InferredType.SEA)));
|
||||||
|
assertTrue(SpawnerGate.suits(underwater, biome(InferredType.SEA)));
|
||||||
|
assertFalse(SpawnerGate.suits(underwater, biome(InferredType.LAND)));
|
||||||
|
assertTrue(SpawnerGate.suits(beach, biome(InferredType.SHORE)));
|
||||||
|
assertFalse(SpawnerGate.suits(beach, biome(InferredType.CAVE)));
|
||||||
|
assertTrue(SpawnerGate.suits(cave, biome(InferredType.SEA)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void timeAndWeatherMustMatch() {
|
||||||
|
Spawner daytimeRain = spawner("{\"timeBlock\": {\"startHour\": 8, \"endHour\": 18}, \"weather\": \"DOWNFALL\"}");
|
||||||
|
when(world.getTime()).thenReturn(6000L);
|
||||||
|
when(world.isStorming()).thenReturn(true);
|
||||||
|
assertTrue(SpawnerGate.suits(daytimeRain, world));
|
||||||
|
|
||||||
|
when(world.isStorming()).thenReturn(false);
|
||||||
|
assertFalse(SpawnerGate.suits(daytimeRain, world));
|
||||||
|
|
||||||
|
when(world.isStorming()).thenReturn(true);
|
||||||
|
when(world.getTime()).thenReturn(20000L);
|
||||||
|
assertFalse(SpawnerGate.suits(daytimeRain, world));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void aSpawnerWithoutRatesAlwaysMayFire() {
|
||||||
|
Spawner free = spawner("{}");
|
||||||
|
|
||||||
|
SpawnerGate.spawned("free", free, engine, 3, 4);
|
||||||
|
|
||||||
|
assertTrue(SpawnerGate.canSpawn("free", free, engine, 3, 4));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void aRateHoldsTheSpawnerBackForItsIntervalPerWorldAndPerChunk() {
|
||||||
|
Spawner limited = spawner("{\"maximumRate\": {\"amount\": 1, \"per\": {\"minutes\": 10}}, \"maximumRatePerChunk\": {\"amount\": 1, \"per\": {\"minutes\": 10}}}");
|
||||||
|
|
||||||
|
assertTrue(SpawnerGate.canSpawn("limited", limited, engine, 3, 4));
|
||||||
|
SpawnerGate.spawned("limited", limited, engine, 3, 4);
|
||||||
|
|
||||||
|
assertFalse(SpawnerGate.canSpawn("limited", limited, engine, 3, 4));
|
||||||
|
assertFalse(SpawnerGate.canSpawn("limited", limited, engine, 9, 9));
|
||||||
|
assertTrue(SpawnerGate.canSpawn("other", limited, engine, 9, 9));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Spawner spawner(String json) {
|
||||||
|
return TestSettings.of(Spawner.class, json);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static IrisBiome biome(InferredType type) {
|
||||||
|
IrisBiome biome = mock(IrisBiome.class);
|
||||||
|
when(biome.getInferredType()).thenReturn(type);
|
||||||
|
return biome;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,14 +1,7 @@
|
|||||||
package art.arcane.iris.purity;
|
package art.arcane.iris.purity;
|
||||||
|
|
||||||
import art.arcane.iris.engine.object.entity.IrisEffect;
|
|
||||||
import art.arcane.iris.engine.object.entity.IrisEntity;
|
|
||||||
import art.arcane.iris.engine.object.entity.spawn.IrisSpawner;
|
|
||||||
import art.arcane.iris.engine.object.image.IrisImage;
|
import art.arcane.iris.engine.object.image.IrisImage;
|
||||||
import art.arcane.iris.engine.object.image.IrisImageMap;
|
import art.arcane.iris.engine.object.image.IrisImageMap;
|
||||||
import art.arcane.iris.engine.object.loot.IrisLoot;
|
|
||||||
import art.arcane.iris.engine.object.loot.IrisLootTable;
|
|
||||||
import art.arcane.iris.engine.object.loot.IrisVanillaLootTable;
|
|
||||||
import art.arcane.iris.engine.object.marker.IrisMarker;
|
|
||||||
import art.arcane.iris.engine.object.material.IrisBlockData;
|
import art.arcane.iris.engine.object.material.IrisBlockData;
|
||||||
import art.arcane.iris.engine.object.mod.IrisMod;
|
import art.arcane.iris.engine.object.mod.IrisMod;
|
||||||
import art.arcane.iris.engine.object.noise.expression.IrisExpression;
|
import art.arcane.iris.engine.object.noise.expression.IrisExpression;
|
||||||
@@ -128,11 +121,7 @@ public class PackTypeBukkitPurityGateTest {
|
|||||||
private static final List<String> MODULE_RESOURCE_ROOTS = List.of(
|
private static final List<String> MODULE_RESOURCE_ROOTS = List.of(
|
||||||
"art.arcane.iris.engine.object.structure.IrisStructure",
|
"art.arcane.iris.engine.object.structure.IrisStructure",
|
||||||
"art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool",
|
"art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPool",
|
||||||
"art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece",
|
"art.arcane.iris.engine.object.structure.jigsaw.IrisJigsawPiece");
|
||||||
"art.arcane.iris.engine.object.loot.IrisLootTable",
|
|
||||||
"art.arcane.iris.engine.object.entity.spawn.IrisSpawner",
|
|
||||||
"art.arcane.iris.engine.object.entity.IrisEntity",
|
|
||||||
"art.arcane.iris.engine.object.marker.IrisMarker");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Types reachable from a pack that are not roots and carry no {@code @Snippet}, but are
|
* Types reachable from a pack that are not roots and carry no {@code @Snippet}, but are
|
||||||
@@ -140,8 +129,7 @@ public class PackTypeBukkitPurityGateTest {
|
|||||||
*/
|
*/
|
||||||
private static final List<String> ADDITIONAL_PACK_TYPES = List.of(
|
private static final List<String> ADDITIONAL_PACK_TYPES = List.of(
|
||||||
"art.arcane.iris.engine.object.prefab.TileData",
|
"art.arcane.iris.engine.object.prefab.TileData",
|
||||||
"art.arcane.iris.engine.object.prefab.LegacyTileData",
|
"art.arcane.iris.engine.object.prefab.LegacyTileData");
|
||||||
"art.arcane.iris.engine.object.loot.IrisVanillaLootTable");
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Bukkit-registry constant holders that a core pack type may reference, so their class initializer
|
* Bukkit-registry constant holders that a core pack type may reference, so their class initializer
|
||||||
@@ -211,7 +199,7 @@ public class PackTypeBukkitPurityGateTest {
|
|||||||
BukkitHidingClassLoader hiding = new BukkitHidingClassLoader(getClass().getClassLoader());
|
BukkitHidingClassLoader hiding = new BukkitHidingClassLoader(getClass().getClassLoader());
|
||||||
List<String> gateTypes = gateTypes();
|
List<String> gateTypes = gateTypes();
|
||||||
assertTrue("expected the @Snippet scan to find the pack snippet types, found only "
|
assertTrue("expected the @Snippet scan to find the pack snippet types, found only "
|
||||||
+ gateTypes.size(), gateTypes.size() > 60);
|
+ gateTypes.size(), gateTypes.size() > 40);
|
||||||
|
|
||||||
List<String> failures = new ArrayList<>();
|
List<String> failures = new ArrayList<>();
|
||||||
List<String> skipped = new ArrayList<>();
|
List<String> skipped = new ArrayList<>();
|
||||||
|
|||||||
@@ -1,55 +0,0 @@
|
|||||||
package art.arcane.iris.util.project.matter;
|
|
||||||
|
|
||||||
import art.arcane.iris.core.loader.IrisData;
|
|
||||||
import art.arcane.iris.core.modules.ModuleResourceFixture;
|
|
||||||
import art.arcane.iris.engine.spawn.SpawnResources;
|
|
||||||
import art.arcane.iris.engine.object.entity.spawn.IrisSpawner;
|
|
||||||
import art.arcane.iris.util.project.matter.slices.SpawnerMatter;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
import java.io.ByteArrayInputStream;
|
|
||||||
import java.io.ByteArrayOutputStream;
|
|
||||||
import java.io.DataInputStream;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.util.concurrent.ExecutorService;
|
|
||||||
import java.util.concurrent.Executors;
|
|
||||||
import java.util.concurrent.Future;
|
|
||||||
|
|
||||||
import static org.junit.Assert.assertSame;
|
|
||||||
import static org.mockito.Mockito.mock;
|
|
||||||
|
|
||||||
public class RegistryMatterContextTest {
|
|
||||||
@Test
|
|
||||||
public void registrySliceResolvesThroughExplicitDataOnIoWorker() throws Exception {
|
|
||||||
IrisSpawner firstResolved = new IrisSpawner();
|
|
||||||
IrisSpawner secondResolved = new IrisSpawner();
|
|
||||||
IrisData firstData = dataReturning(firstResolved);
|
|
||||||
IrisData secondData = dataReturning(secondResolved);
|
|
||||||
ExecutorService executor = Executors.newSingleThreadExecutor();
|
|
||||||
try {
|
|
||||||
Future<IrisSpawner> firstRead = executor.submit(() -> readSpawner(firstData));
|
|
||||||
Future<IrisSpawner> secondRead = executor.submit(() -> readSpawner(secondData));
|
|
||||||
assertSame(firstResolved, firstRead.get());
|
|
||||||
assertSame(secondResolved, secondRead.get());
|
|
||||||
} finally {
|
|
||||||
executor.shutdownNow();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private IrisSpawner readSpawner(IrisData data) throws Exception {
|
|
||||||
ByteArrayOutputStream bytes = new ByteArrayOutputStream();
|
|
||||||
try (DataOutputStream output = new DataOutputStream(bytes)) {
|
|
||||||
output.writeUTF("test-spawner");
|
|
||||||
}
|
|
||||||
try (IrisMatterContext.Scope scope = IrisMatterContext.open(data);
|
|
||||||
DataInputStream input = new DataInputStream(new ByteArrayInputStream(bytes.toByteArray()))) {
|
|
||||||
return new SpawnerMatter().readNode(input);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private IrisData dataReturning(IrisSpawner resolved) {
|
|
||||||
IrisData data = mock(IrisData.class);
|
|
||||||
ModuleResourceFixture.serve(data).resource(SpawnResources.SPAWNERS, "test-spawner", resolved);
|
|
||||||
return data;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+72
@@ -0,0 +1,72 @@
|
|||||||
|
{
|
||||||
|
"name": "Tropical Volcanoes",
|
||||||
|
"color": "#8C1E1E",
|
||||||
|
"rarity": 1,
|
||||||
|
"derivative": "minecraft:the_void",
|
||||||
|
"vanillaDerivative": "minecraft:the_void",
|
||||||
|
"customDerivitives": [{
|
||||||
|
"category": "jungle",
|
||||||
|
"id": "tropical_volcano",
|
||||||
|
"grassColor": "#BDBF0B",
|
||||||
|
"foliageColor": "#BDBF0B",
|
||||||
|
"fogColor": "#DD793C",
|
||||||
|
"downfallType": "none"
|
||||||
|
}],
|
||||||
|
"children": ["tropical/volcanoes-lava"],
|
||||||
|
"generators": [{
|
||||||
|
"generator": "mountain",
|
||||||
|
"max": 180,
|
||||||
|
"min": 30
|
||||||
|
}],
|
||||||
|
"layers": [
|
||||||
|
{
|
||||||
|
"minHeight": 1,
|
||||||
|
"maxHeight": 1,
|
||||||
|
"palette": [{"block": "minecraft:basalt"}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": 2,
|
||||||
|
"maxHeight": 2,
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:basalt",
|
||||||
|
"data": {"axis": "x"}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"block": "minecraft:basalt",
|
||||||
|
"data": {"axis": "y"}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"block": "minecraft:basalt",
|
||||||
|
"data": {"axis": "z"}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": 3,
|
||||||
|
"maxHeight": 10,
|
||||||
|
"palette": [{"block": "minecraft:blackstone"}]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": 1,
|
||||||
|
"maxHeight": 2,
|
||||||
|
"palette": [{"block": "minecraft:tuff"}]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"effects": [{
|
||||||
|
"particleAltX": 0.001,
|
||||||
|
"particleAltY": 0.13885,
|
||||||
|
"particleAltZ": 0.001,
|
||||||
|
"chance": 1,
|
||||||
|
"particleEffect": "CAMPFIRE_SIGNAL_SMOKE",
|
||||||
|
"particleOffset": 0,
|
||||||
|
"interval": 300,
|
||||||
|
"particleCount": 0
|
||||||
|
}],
|
||||||
|
"childStyle": {
|
||||||
|
"style": "GLOB",
|
||||||
|
"zoom": 0.2,
|
||||||
|
"exponent": 4
|
||||||
|
},
|
||||||
|
"childShrinkFactor": 1
|
||||||
|
}
|
||||||
+946
@@ -0,0 +1,946 @@
|
|||||||
|
{
|
||||||
|
"version": 4002,
|
||||||
|
"name": "Overworld",
|
||||||
|
"importedStructures": {
|
||||||
|
"datapackOverrides": true,
|
||||||
|
"adjustments": [
|
||||||
|
{
|
||||||
|
"match": [
|
||||||
|
"minecraft:stronghold"
|
||||||
|
],
|
||||||
|
"yBand": {
|
||||||
|
"min": -120,
|
||||||
|
"max": -20
|
||||||
|
},
|
||||||
|
"terrain": {
|
||||||
|
"mode": "ENCASE",
|
||||||
|
"horizontalPadding": 4,
|
||||||
|
"ceilingPadding": 4,
|
||||||
|
"floorPadding": 4,
|
||||||
|
"encasePalette": {
|
||||||
|
"zoom": 1,
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:stone_bricks",
|
||||||
|
"weight": 6
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"block": "minecraft:mossy_stone_bricks",
|
||||||
|
"weight": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"block": "minecraft:cracked_stone_bricks",
|
||||||
|
"weight": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"block": "minecraft:cobblestone",
|
||||||
|
"weight": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"match": [
|
||||||
|
"minecraft:trial_chambers"
|
||||||
|
],
|
||||||
|
"yShift": -64
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"match": [
|
||||||
|
"minecraft:mineshaft"
|
||||||
|
],
|
||||||
|
"preserveSourceY": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"match": [
|
||||||
|
"minecraft:village"
|
||||||
|
],
|
||||||
|
"stilt": {
|
||||||
|
"maxDepth": 2,
|
||||||
|
"palette": {
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:dirt"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"structures": [
|
||||||
|
{
|
||||||
|
"nativeStructures": [
|
||||||
|
{
|
||||||
|
"structure": "minecraft:ancient_city"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"placementId": "ancient-city-native",
|
||||||
|
"nativeSuppression": "REPLACE_SOURCE",
|
||||||
|
"underground": true,
|
||||||
|
"terrain": {
|
||||||
|
"mode": "FORCE_CARVE",
|
||||||
|
"horizontalPadding": 14,
|
||||||
|
"ceilingPadding": 12,
|
||||||
|
"floorPadding": 0,
|
||||||
|
"shape": "ERODED",
|
||||||
|
"erosionStrength": 1.0,
|
||||||
|
"erosionFrequency": 0.05
|
||||||
|
},
|
||||||
|
"stilt": {
|
||||||
|
"maxDepth": 768,
|
||||||
|
"spacing": 1,
|
||||||
|
"palette": {
|
||||||
|
"style": {
|
||||||
|
"style": "STATIC"
|
||||||
|
},
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:deepslate_bricks",
|
||||||
|
"weight": 6
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"block": "minecraft:cracked_deepslate_bricks",
|
||||||
|
"weight": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"block": "minecraft:deepslate_tiles",
|
||||||
|
"weight": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"block": "minecraft:cracked_deepslate_tiles",
|
||||||
|
"weight": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"minHeight": -220,
|
||||||
|
"maxHeight": -220,
|
||||||
|
"distribution": "RANDOM_SPREAD",
|
||||||
|
"spacing": 64,
|
||||||
|
"separation": 5,
|
||||||
|
"salt": 42069
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"fullbright": false,
|
||||||
|
"upperDimension": "",
|
||||||
|
"upperDimensionGap": 32,
|
||||||
|
"upperDimensionCarving": false,
|
||||||
|
"upperDimensionObjects": false,
|
||||||
|
"environment": "NORMAL",
|
||||||
|
"dimensionAngleDeg": 69,
|
||||||
|
"fluidHeight": 50,
|
||||||
|
"continentZoom": 1,
|
||||||
|
"continentalStyle": {
|
||||||
|
"style": "NOWHERE_CELLULAR",
|
||||||
|
"fracture": {
|
||||||
|
"style": "FRACTAL_SMOKE",
|
||||||
|
"axialFracturing": true,
|
||||||
|
"multiplier": 1,
|
||||||
|
"fracture": {
|
||||||
|
"style": "STATIC",
|
||||||
|
"multiplier": 1,
|
||||||
|
"axialFracturing": true
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"axialFracturing": true,
|
||||||
|
"zoom": 6
|
||||||
|
},
|
||||||
|
"logicalHeight": 512,
|
||||||
|
"dimensionHeight": {
|
||||||
|
"max": 512,
|
||||||
|
"min": -256
|
||||||
|
},
|
||||||
|
"landChance": 0.69,
|
||||||
|
"regionStyle": {
|
||||||
|
"style": "CELLULAR_IRIS_DOUBLE",
|
||||||
|
"axialFracturing": true,
|
||||||
|
"fracture": {
|
||||||
|
"axialFracturing": true,
|
||||||
|
"multiplier": 9,
|
||||||
|
"style": "FRACTAL_WATER",
|
||||||
|
"zoom": 0.15,
|
||||||
|
"fracture": {
|
||||||
|
"style": "STATIC",
|
||||||
|
"multiplier": 1,
|
||||||
|
"axialFracturing": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"regionZoom": 16.15,
|
||||||
|
"regions": [
|
||||||
|
"frozen",
|
||||||
|
"hot",
|
||||||
|
"terralost",
|
||||||
|
"mushroom",
|
||||||
|
"forests",
|
||||||
|
"tundra",
|
||||||
|
"magnetics",
|
||||||
|
"temperate",
|
||||||
|
"estranged",
|
||||||
|
"tropical",
|
||||||
|
"swamp",
|
||||||
|
"prismatics"
|
||||||
|
],
|
||||||
|
"seaBiomeStyle": {
|
||||||
|
"style": "SIMPLEX",
|
||||||
|
"axialFracturing": true
|
||||||
|
},
|
||||||
|
"landBiomeStyle": {
|
||||||
|
"style": "NOWHERE_CELLULAR",
|
||||||
|
"axialFracturing": true,
|
||||||
|
"fracture": {
|
||||||
|
"multiplier": 55,
|
||||||
|
"axialFracturing": true,
|
||||||
|
"style": "NOWHERE",
|
||||||
|
"zoom": 0.15,
|
||||||
|
"fracture": {
|
||||||
|
"axialFracturing": true,
|
||||||
|
"style": "STATIC",
|
||||||
|
"multiplier": 4
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ores": [
|
||||||
|
{
|
||||||
|
"threshold": 1,
|
||||||
|
"range": {
|
||||||
|
"min": 0,
|
||||||
|
"max": 0
|
||||||
|
},
|
||||||
|
"palette": {
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:bedrock"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"chanceStyle": {
|
||||||
|
"style": "FLAT"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"threshold": 0.625,
|
||||||
|
"range": {
|
||||||
|
"min": 1,
|
||||||
|
"max": 1
|
||||||
|
},
|
||||||
|
"palette": {
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:bedrock"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"chanceStyle": "snippet/style/bedrock"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"threshold": 0.35,
|
||||||
|
"range": {
|
||||||
|
"min": 2,
|
||||||
|
"max": 4
|
||||||
|
},
|
||||||
|
"palette": {
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:bedrock"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"chanceStyle": "snippet/style/bedrock"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"threshold": 1,
|
||||||
|
"range": {
|
||||||
|
"min": 1,
|
||||||
|
"max": 57
|
||||||
|
},
|
||||||
|
"palette": {
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:deepslate"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"chanceStyle": {
|
||||||
|
"style": "FLAT"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"threshold": 0.874,
|
||||||
|
"range": {
|
||||||
|
"min": 58,
|
||||||
|
"max": 58
|
||||||
|
},
|
||||||
|
"palette": {
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:deepslate"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"chanceStyle": "snippet/style/deepslate"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"threshold": 0.75,
|
||||||
|
"range": {
|
||||||
|
"min": 59,
|
||||||
|
"max": 59
|
||||||
|
},
|
||||||
|
"palette": {
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:deepslate"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"chanceStyle": "snippet/style/deepslate"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"threshold": 0.625,
|
||||||
|
"range": {
|
||||||
|
"min": 60,
|
||||||
|
"max": 60
|
||||||
|
},
|
||||||
|
"palette": {
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:deepslate"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"chanceStyle": "snippet/style/deepslate"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"threshold": 0.5,
|
||||||
|
"range": {
|
||||||
|
"min": 61,
|
||||||
|
"max": 61
|
||||||
|
},
|
||||||
|
"palette": {
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:deepslate"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"chanceStyle": "snippet/style/deepslate"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"threshold": 0.375,
|
||||||
|
"range": {
|
||||||
|
"min": 62,
|
||||||
|
"max": 62
|
||||||
|
},
|
||||||
|
"palette": {
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:deepslate"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"chanceStyle": "snippet/style/deepslate"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"threshold": 0.25,
|
||||||
|
"range": {
|
||||||
|
"min": 63,
|
||||||
|
"max": 63
|
||||||
|
},
|
||||||
|
"palette": {
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:deepslate"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"chanceStyle": "snippet/style/deepslate"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"threshold": 0.125,
|
||||||
|
"range": {
|
||||||
|
"min": 64,
|
||||||
|
"max": 64
|
||||||
|
},
|
||||||
|
"palette": {
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:deepslate"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"chanceStyle": "snippet/style/deepslate"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"shoreBiomeStyle": {
|
||||||
|
"style": "NOWHERE_CELLULAR"
|
||||||
|
},
|
||||||
|
"deposits": [
|
||||||
|
{
|
||||||
|
"minHeight": 19,
|
||||||
|
"maxPerChunk": 8,
|
||||||
|
"maxHeight": 390,
|
||||||
|
"minPerChunk": 1,
|
||||||
|
"minSize": 25,
|
||||||
|
"maxSize": 25,
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:granite"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"varience": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": 19,
|
||||||
|
"maxPerChunk": 8,
|
||||||
|
"maxHeight": 310,
|
||||||
|
"minPerChunk": 1,
|
||||||
|
"minSize": 25,
|
||||||
|
"maxSize": 25,
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:andesite"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"varience": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": 19,
|
||||||
|
"maxPerChunk": 8,
|
||||||
|
"maxHeight": 309,
|
||||||
|
"minPerChunk": 1,
|
||||||
|
"minSize": 25,
|
||||||
|
"maxSize": 25,
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:diorite"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"varience": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": 19,
|
||||||
|
"maxPerChunk": 8,
|
||||||
|
"maxHeight": 389,
|
||||||
|
"minPerChunk": 1,
|
||||||
|
"minSize": 25,
|
||||||
|
"maxSize": 25,
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:gravel"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"varience": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": 400,
|
||||||
|
"maxHeight": 767,
|
||||||
|
"heightDistribution": "UNIFORM",
|
||||||
|
"surfaceClearance": 0,
|
||||||
|
"minPerChunk": 60,
|
||||||
|
"maxPerChunk": 60,
|
||||||
|
"minSize": 17,
|
||||||
|
"maxSize": 17,
|
||||||
|
"shape": "VANILLA_ELLIPSOID",
|
||||||
|
"discardChanceOnAirExposure": 0.3,
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:coal_ore"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"replaceableBlocks": [
|
||||||
|
"minecraft:stone",
|
||||||
|
"minecraft:granite",
|
||||||
|
"minecraft:diorite",
|
||||||
|
"minecraft:andesite",
|
||||||
|
"minecraft:deepslate",
|
||||||
|
"minecraft:tuff"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": 128,
|
||||||
|
"maxHeight": 512,
|
||||||
|
"heightDistribution": "TRIANGLE",
|
||||||
|
"surfaceClearance": 1,
|
||||||
|
"minPerChunk": 80,
|
||||||
|
"maxPerChunk": 80,
|
||||||
|
"minSize": 17,
|
||||||
|
"maxSize": 17,
|
||||||
|
"shape": "VANILLA_ELLIPSOID",
|
||||||
|
"discardChanceOnAirExposure": 0.65,
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:coal_ore"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": 288,
|
||||||
|
"maxHeight": 896,
|
||||||
|
"heightDistribution": "TRIANGLE",
|
||||||
|
"surfaceClearance": 0,
|
||||||
|
"minPerChunk": 180,
|
||||||
|
"maxPerChunk": 180,
|
||||||
|
"minSize": 9,
|
||||||
|
"maxSize": 9,
|
||||||
|
"shape": "VANILLA_ELLIPSOID",
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:iron_ore"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"replaceableBlocks": [
|
||||||
|
"minecraft:stone",
|
||||||
|
"minecraft:granite",
|
||||||
|
"minecraft:diorite",
|
||||||
|
"minecraft:andesite",
|
||||||
|
"minecraft:deepslate",
|
||||||
|
"minecraft:tuff"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": 80,
|
||||||
|
"maxHeight": 240,
|
||||||
|
"heightDistribution": "TRIANGLE",
|
||||||
|
"surfaceClearance": 0,
|
||||||
|
"minPerChunk": 40,
|
||||||
|
"maxPerChunk": 40,
|
||||||
|
"minSize": 9,
|
||||||
|
"maxSize": 9,
|
||||||
|
"shape": "VANILLA_ELLIPSOID",
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:iron_ore"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": 0,
|
||||||
|
"maxHeight": 272,
|
||||||
|
"heightDistribution": "UNIFORM",
|
||||||
|
"surfaceClearance": 0,
|
||||||
|
"minPerChunk": 40,
|
||||||
|
"maxPerChunk": 40,
|
||||||
|
"minSize": 4,
|
||||||
|
"maxSize": 4,
|
||||||
|
"shape": "VANILLA_ELLIPSOID",
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:iron_ore"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": 96,
|
||||||
|
"maxHeight": 352,
|
||||||
|
"heightDistribution": "TRIANGLE",
|
||||||
|
"surfaceClearance": 0,
|
||||||
|
"minPerChunk": 64,
|
||||||
|
"maxPerChunk": 64,
|
||||||
|
"minSize": 10,
|
||||||
|
"maxSize": 10,
|
||||||
|
"shape": "VANILLA_ELLIPSOID",
|
||||||
|
"biomeScope": "CAVE",
|
||||||
|
"excludedBiomes": [
|
||||||
|
"carving/drip",
|
||||||
|
"carving/drip-child",
|
||||||
|
"carving/drip-lite",
|
||||||
|
"carving/drip-lite-child"
|
||||||
|
],
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:copper_ore"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": 96,
|
||||||
|
"maxHeight": 352,
|
||||||
|
"heightDistribution": "TRIANGLE",
|
||||||
|
"surfaceClearance": 0,
|
||||||
|
"minPerChunk": 64,
|
||||||
|
"maxPerChunk": 64,
|
||||||
|
"minSize": 20,
|
||||||
|
"maxSize": 20,
|
||||||
|
"shape": "VANILLA_ELLIPSOID",
|
||||||
|
"biomeScope": "CAVE",
|
||||||
|
"includedBiomes": [
|
||||||
|
"carving/drip",
|
||||||
|
"carving/drip-child",
|
||||||
|
"carving/drip-lite",
|
||||||
|
"carving/drip-lite-child"
|
||||||
|
],
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:copper_ore"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": 0,
|
||||||
|
"maxHeight": 192,
|
||||||
|
"heightDistribution": "TRIANGLE",
|
||||||
|
"surfaceClearance": 0,
|
||||||
|
"minPerChunk": 16,
|
||||||
|
"maxPerChunk": 16,
|
||||||
|
"minSize": 9,
|
||||||
|
"maxSize": 9,
|
||||||
|
"shape": "VANILLA_ELLIPSOID",
|
||||||
|
"discardChanceOnAirExposure": 0.5,
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:gold_ore"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": 0,
|
||||||
|
"maxHeight": 32,
|
||||||
|
"heightDistribution": "UNIFORM",
|
||||||
|
"surfaceClearance": 0,
|
||||||
|
"minPerChunk": 0,
|
||||||
|
"maxPerChunk": 2,
|
||||||
|
"minSize": 9,
|
||||||
|
"maxSize": 9,
|
||||||
|
"shape": "VANILLA_ELLIPSOID",
|
||||||
|
"discardChanceOnAirExposure": 0.5,
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:gold_ore"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"replaceableBlocks": [
|
||||||
|
"minecraft:stone",
|
||||||
|
"minecraft:granite",
|
||||||
|
"minecraft:diorite",
|
||||||
|
"minecraft:andesite",
|
||||||
|
"minecraft:deepslate",
|
||||||
|
"minecraft:tuff"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": 192,
|
||||||
|
"maxHeight": 640,
|
||||||
|
"heightDistribution": "UNIFORM",
|
||||||
|
"surfaceClearance": 0,
|
||||||
|
"minPerChunk": 100,
|
||||||
|
"maxPerChunk": 100,
|
||||||
|
"minSize": 9,
|
||||||
|
"maxSize": 9,
|
||||||
|
"shape": "VANILLA_ELLIPSOID",
|
||||||
|
"biomeScope": "SURFACE",
|
||||||
|
"includedBiomes": [
|
||||||
|
"minecraft:badlands",
|
||||||
|
"minecraft:eroded_badlands",
|
||||||
|
"minecraft:wooded_badlands"
|
||||||
|
],
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:gold_ore"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"replaceableBlocks": [
|
||||||
|
"minecraft:stone",
|
||||||
|
"minecraft:granite",
|
||||||
|
"minecraft:diorite",
|
||||||
|
"minecraft:andesite",
|
||||||
|
"minecraft:deepslate",
|
||||||
|
"minecraft:tuff"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": 0,
|
||||||
|
"maxHeight": 158,
|
||||||
|
"heightDistribution": "UNIFORM",
|
||||||
|
"surfaceClearance": 0,
|
||||||
|
"minPerChunk": 16,
|
||||||
|
"maxPerChunk": 16,
|
||||||
|
"minSize": 8,
|
||||||
|
"maxSize": 8,
|
||||||
|
"shape": "VANILLA_ELLIPSOID",
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"lit": false
|
||||||
|
},
|
||||||
|
"block": "minecraft:redstone_ore"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": -64,
|
||||||
|
"maxHeight": 64,
|
||||||
|
"heightDistribution": "TRIANGLE",
|
||||||
|
"surfaceClearance": 0,
|
||||||
|
"minPerChunk": 16,
|
||||||
|
"maxPerChunk": 16,
|
||||||
|
"minSize": 8,
|
||||||
|
"maxSize": 8,
|
||||||
|
"shape": "VANILLA_ELLIPSOID",
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"lit": false
|
||||||
|
},
|
||||||
|
"block": "minecraft:redstone_ore"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"replaceableBlocks": [
|
||||||
|
"minecraft:stone",
|
||||||
|
"minecraft:granite",
|
||||||
|
"minecraft:diorite",
|
||||||
|
"minecraft:andesite",
|
||||||
|
"minecraft:deepslate",
|
||||||
|
"minecraft:tuff"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": -160,
|
||||||
|
"maxHeight": 160,
|
||||||
|
"heightDistribution": "TRIANGLE",
|
||||||
|
"surfaceClearance": 0,
|
||||||
|
"minPerChunk": 28,
|
||||||
|
"maxPerChunk": 28,
|
||||||
|
"minSize": 4,
|
||||||
|
"maxSize": 4,
|
||||||
|
"shape": "VANILLA_ELLIPSOID",
|
||||||
|
"discardChanceOnAirExposure": 0.5,
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:diamond_ore"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": 0,
|
||||||
|
"maxHeight": 120,
|
||||||
|
"heightDistribution": "UNIFORM",
|
||||||
|
"surfaceClearance": 0,
|
||||||
|
"minPerChunk": 8,
|
||||||
|
"maxPerChunk": 8,
|
||||||
|
"minSize": 8,
|
||||||
|
"maxSize": 8,
|
||||||
|
"shape": "VANILLA_ELLIPSOID",
|
||||||
|
"discardChanceOnAirExposure": 0.5,
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:diamond_ore"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": -160,
|
||||||
|
"maxHeight": 160,
|
||||||
|
"heightDistribution": "TRIANGLE",
|
||||||
|
"surfaceClearance": 0,
|
||||||
|
"minPerChunk": 4,
|
||||||
|
"maxPerChunk": 4,
|
||||||
|
"spawnChance": 0.1111111111111111,
|
||||||
|
"minSize": 12,
|
||||||
|
"maxSize": 12,
|
||||||
|
"shape": "VANILLA_ELLIPSOID",
|
||||||
|
"discardChanceOnAirExposure": 0.7,
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:diamond_ore"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": -160,
|
||||||
|
"maxHeight": 160,
|
||||||
|
"heightDistribution": "TRIANGLE",
|
||||||
|
"surfaceClearance": 0,
|
||||||
|
"minPerChunk": 16,
|
||||||
|
"maxPerChunk": 16,
|
||||||
|
"minSize": 8,
|
||||||
|
"maxSize": 8,
|
||||||
|
"shape": "VANILLA_ELLIPSOID",
|
||||||
|
"discardChanceOnAirExposure": 1.0,
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:diamond_ore"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": 64,
|
||||||
|
"maxHeight": 192,
|
||||||
|
"heightDistribution": "TRIANGLE",
|
||||||
|
"surfaceClearance": 0,
|
||||||
|
"minPerChunk": 8,
|
||||||
|
"maxPerChunk": 8,
|
||||||
|
"minSize": 7,
|
||||||
|
"maxSize": 7,
|
||||||
|
"shape": "VANILLA_ELLIPSOID",
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:lapis_ore"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": 0,
|
||||||
|
"maxHeight": 256,
|
||||||
|
"heightDistribution": "UNIFORM",
|
||||||
|
"surfaceClearance": 0,
|
||||||
|
"minPerChunk": 16,
|
||||||
|
"maxPerChunk": 16,
|
||||||
|
"minSize": 7,
|
||||||
|
"maxSize": 7,
|
||||||
|
"shape": "VANILLA_ELLIPSOID",
|
||||||
|
"discardChanceOnAirExposure": 1.0,
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:lapis_ore"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"minHeight": 96,
|
||||||
|
"maxHeight": 1088,
|
||||||
|
"heightDistribution": "TRIANGLE",
|
||||||
|
"surfaceClearance": 0,
|
||||||
|
"minPerChunk": 200,
|
||||||
|
"maxPerChunk": 200,
|
||||||
|
"minSize": 3,
|
||||||
|
"maxSize": 3,
|
||||||
|
"shape": "VANILLA_ELLIPSOID",
|
||||||
|
"biomeScope": "SURFACE",
|
||||||
|
"includedBiomes": [
|
||||||
|
"minecraft:cherry_grove",
|
||||||
|
"minecraft:frozen_peaks",
|
||||||
|
"minecraft:grove",
|
||||||
|
"minecraft:jagged_peaks",
|
||||||
|
"minecraft:meadow",
|
||||||
|
"minecraft:snowy_slopes",
|
||||||
|
"minecraft:stony_peaks",
|
||||||
|
"minecraft:windswept_forest",
|
||||||
|
"minecraft:windswept_gravelly_hills",
|
||||||
|
"minecraft:windswept_hills"
|
||||||
|
],
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:emerald_ore"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"replaceableBlocks": [
|
||||||
|
"minecraft:stone",
|
||||||
|
"minecraft:granite",
|
||||||
|
"minecraft:diorite",
|
||||||
|
"minecraft:andesite",
|
||||||
|
"minecraft:deepslate",
|
||||||
|
"minecraft:tuff"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"caveBiomeStyle": {
|
||||||
|
"style": "SIMPLEX",
|
||||||
|
"zoom": 2.6
|
||||||
|
},
|
||||||
|
"coordFractureZoom": 0.15,
|
||||||
|
"preventLeafDecay": true,
|
||||||
|
"useMantle": true,
|
||||||
|
"carvingEnabled": true,
|
||||||
|
"decorate": true,
|
||||||
|
"loot": {
|
||||||
|
"mode": "FALLBACK",
|
||||||
|
"tables": [
|
||||||
|
"global-clutter"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"caveProfile": {
|
||||||
|
"enabled": true,
|
||||||
|
"verticalRange": {
|
||||||
|
"min": 6,
|
||||||
|
"max": 700
|
||||||
|
},
|
||||||
|
"baseDensityStyle": {
|
||||||
|
"style": "PERLIN_IRIS",
|
||||||
|
"zoom": 0.72
|
||||||
|
},
|
||||||
|
"detailDensityStyle": {
|
||||||
|
"style": "SIMPLEX",
|
||||||
|
"zoom": 0.54
|
||||||
|
},
|
||||||
|
"warpStyle": {
|
||||||
|
"style": "FRACTAL_WATER",
|
||||||
|
"zoom": 0.5
|
||||||
|
},
|
||||||
|
"baseWeight": 0.9,
|
||||||
|
"detailWeight": 0.11,
|
||||||
|
"warpStrength": 0.24,
|
||||||
|
"densityThreshold": {
|
||||||
|
"min": -0.14,
|
||||||
|
"max": -0.06,
|
||||||
|
"style": {
|
||||||
|
"style": "SIMPLEX",
|
||||||
|
"zoom": 0.74
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"thresholdBias": 0.14,
|
||||||
|
"sampleStep": 3,
|
||||||
|
"surfaceClearance": 5,
|
||||||
|
"allowSurfaceBreak": true,
|
||||||
|
"surfaceBreakStyle": {
|
||||||
|
"style": "SIMPLEX",
|
||||||
|
"zoom": 0.88
|
||||||
|
},
|
||||||
|
"surfaceBreakNoiseThreshold": 0.6,
|
||||||
|
"surfaceBreakDepth": 16,
|
||||||
|
"surfaceBreakThresholdBoost": 0.1,
|
||||||
|
"objectMinDepthBelowSurface": 14,
|
||||||
|
"defaultObjectAnchor": "FLOOR",
|
||||||
|
"defaultObjectPlaceMode": "ORGANIC_STILT",
|
||||||
|
"anchorScanStep": 1,
|
||||||
|
"anchorSearchAttempts": 12,
|
||||||
|
"allowFluid": true,
|
||||||
|
"fluidMinDepthBelowSurface": 20,
|
||||||
|
"fluidRequiresFloor": true,
|
||||||
|
"allowLava": true,
|
||||||
|
"modules": [
|
||||||
|
{
|
||||||
|
"style": {
|
||||||
|
"style": "SIMPLEX_VASCULAR",
|
||||||
|
"zoom": 1.08
|
||||||
|
},
|
||||||
|
"weight": 0.08,
|
||||||
|
"threshold": 0.03,
|
||||||
|
"verticalRange": {
|
||||||
|
"min": 24,
|
||||||
|
"max": 660
|
||||||
|
},
|
||||||
|
"invert": false
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"style": {
|
||||||
|
"style": "FRACTAL_FBM_SIMPLEX",
|
||||||
|
"zoom": 0.24
|
||||||
|
},
|
||||||
|
"weight": 0.04,
|
||||||
|
"threshold": 0.08,
|
||||||
|
"verticalRange": {
|
||||||
|
"min": 6,
|
||||||
|
"max": 240
|
||||||
|
},
|
||||||
|
"invert": true
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"verticalEdgeFade": 24,
|
||||||
|
"verticalEdgeFadeStrength": 0.18,
|
||||||
|
"minCarveCells": 24,
|
||||||
|
"recoveryThresholdBoost": 0.07
|
||||||
|
},
|
||||||
|
"carving": [
|
||||||
|
{
|
||||||
|
"id": "global-deepdark-band",
|
||||||
|
"enabled": true,
|
||||||
|
"biome": "carving/standard-deepdark",
|
||||||
|
"worldYRange": {
|
||||||
|
"min": -250,
|
||||||
|
"max": -175
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"type": "ZOMBIE"}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
{"type": "MOOSHROOM"}
|
||||||
+115
@@ -0,0 +1,115 @@
|
|||||||
|
{
|
||||||
|
"name": "Global Clutter",
|
||||||
|
"rarity": 1,
|
||||||
|
"maxPicked": 2,
|
||||||
|
"minPicked": 1,
|
||||||
|
"maxTries": 20,
|
||||||
|
"loot": [
|
||||||
|
{
|
||||||
|
"type": "stone",
|
||||||
|
"minAmount": 1,
|
||||||
|
"maxAmount": 8,
|
||||||
|
"rarity": 1,
|
||||||
|
"slotTypes": "STORAGE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "stick",
|
||||||
|
"minAmount": 1,
|
||||||
|
"maxAmount": 6,
|
||||||
|
"rarity": 1,
|
||||||
|
"slotTypes": "STORAGE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "flint",
|
||||||
|
"minAmount": 1,
|
||||||
|
"maxAmount": 4,
|
||||||
|
"rarity": 2,
|
||||||
|
"slotTypes": "STORAGE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "string",
|
||||||
|
"minAmount": 1,
|
||||||
|
"maxAmount": 4,
|
||||||
|
"rarity": 2,
|
||||||
|
"slotTypes": "STORAGE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "leather",
|
||||||
|
"minAmount": 1,
|
||||||
|
"maxAmount": 3,
|
||||||
|
"rarity": 3,
|
||||||
|
"slotTypes": "STORAGE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "paper",
|
||||||
|
"minAmount": 1,
|
||||||
|
"maxAmount": 5,
|
||||||
|
"rarity": 3,
|
||||||
|
"slotTypes": "STORAGE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "torch",
|
||||||
|
"minAmount": 2,
|
||||||
|
"maxAmount": 8,
|
||||||
|
"rarity": 2,
|
||||||
|
"slotTypes": "STORAGE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "ladder",
|
||||||
|
"minAmount": 1,
|
||||||
|
"maxAmount": 6,
|
||||||
|
"rarity": 4,
|
||||||
|
"slotTypes": "STORAGE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "bucket",
|
||||||
|
"minAmount": 1,
|
||||||
|
"maxAmount": 1,
|
||||||
|
"rarity": 9,
|
||||||
|
"slotTypes": "STORAGE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "arrow",
|
||||||
|
"minAmount": 2,
|
||||||
|
"maxAmount": 10,
|
||||||
|
"rarity": 4,
|
||||||
|
"slotTypes": "STORAGE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "glass_bottle",
|
||||||
|
"minAmount": 1,
|
||||||
|
"maxAmount": 4,
|
||||||
|
"rarity": 4,
|
||||||
|
"slotTypes": "STORAGE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "copper_ingot",
|
||||||
|
"minAmount": 1,
|
||||||
|
"maxAmount": 5,
|
||||||
|
"rarity": 6,
|
||||||
|
"slotTypes": "STORAGE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "amethyst_shard",
|
||||||
|
"minAmount": 1,
|
||||||
|
"maxAmount": 4,
|
||||||
|
"rarity": 7,
|
||||||
|
"slotTypes": "STORAGE"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "enchanted_book",
|
||||||
|
"minAmount": 1,
|
||||||
|
"maxAmount": 1,
|
||||||
|
"rarity": 28,
|
||||||
|
"slotTypes": "STORAGE",
|
||||||
|
"enchantments": [
|
||||||
|
{
|
||||||
|
"enchantment": "unbreaking",
|
||||||
|
"minLevel": 2,
|
||||||
|
"maxLevel": 3,
|
||||||
|
"chance": 1.0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
+138
@@ -0,0 +1,138 @@
|
|||||||
|
{
|
||||||
|
"name": "Hot",
|
||||||
|
"color": "#D1CD44",
|
||||||
|
"rarity": 3,
|
||||||
|
"seaBiomeZoom": 3.5,
|
||||||
|
"landBiomes": [
|
||||||
|
"hot/desert-dunes",
|
||||||
|
"hot/small-valley",
|
||||||
|
"hot/desert-dunes-red",
|
||||||
|
"savanna/savanna",
|
||||||
|
"mesa/dark",
|
||||||
|
"savanna/plateau",
|
||||||
|
"savanna/forest",
|
||||||
|
"savanna/acacia-denmyre",
|
||||||
|
"mesa/plateau",
|
||||||
|
"mesa/valleys",
|
||||||
|
"mesa/plateau-high",
|
||||||
|
"mesa/valleys",
|
||||||
|
"mesa/mesa",
|
||||||
|
"hot/mountain-middle",
|
||||||
|
"hot/mountain-plains",
|
||||||
|
"hot/oasis",
|
||||||
|
"vanilla/savanna_plateau",
|
||||||
|
"vanilla/windswept_savanna",
|
||||||
|
"vanilla/wooded_badlands"
|
||||||
|
],
|
||||||
|
"caveBiomes": [
|
||||||
|
"carving/sandstone",
|
||||||
|
"carving/sand-hollows",
|
||||||
|
"carving/red-sandstone",
|
||||||
|
"carving/mixed-sandstone",
|
||||||
|
"carving/volcanic",
|
||||||
|
"carving/ember-rifts"
|
||||||
|
],
|
||||||
|
"shoreBiomes": [
|
||||||
|
"hot/shore/beach",
|
||||||
|
"hot/shore/beach-grass",
|
||||||
|
"mesa/shore/beach",
|
||||||
|
"savanna/shore/beach"
|
||||||
|
],
|
||||||
|
"seaBiomes": [
|
||||||
|
"hot/sea/ocean",
|
||||||
|
"ocean/rich-oceans",
|
||||||
|
"hot/sea/river",
|
||||||
|
"mesa/sea/river"
|
||||||
|
],
|
||||||
|
"landBiomeZoom": 7,
|
||||||
|
"effects": [
|
||||||
|
{
|
||||||
|
"potionTicksMin": 87,
|
||||||
|
"potionEffect": "CONFUSION",
|
||||||
|
"chance": 1200,
|
||||||
|
"potionStrength": 0,
|
||||||
|
"potionTicksMax": 67,
|
||||||
|
"interval": 500
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"particleAltX": 0.001,
|
||||||
|
"particleAltY": 0.00885,
|
||||||
|
"particleAltZ": 0.001,
|
||||||
|
"chance": 2,
|
||||||
|
"particleEffect": "CAMPFIRE_SIGNAL_SMOKE",
|
||||||
|
"particleOffset": 0,
|
||||||
|
"interval": 1350,
|
||||||
|
"particleCount": 0
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"shoreHeightMin": 3.2,
|
||||||
|
"shoreHeightMax": 6.2,
|
||||||
|
"shoreHeightZoom": 1.14,
|
||||||
|
"loot": {
|
||||||
|
"mode": "FALLBACK",
|
||||||
|
"multiplier": 0.5,
|
||||||
|
"tables": [
|
||||||
|
"hot/food",
|
||||||
|
"cactus/clutter",
|
||||||
|
"beach/clutter"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"caveProfile": {
|
||||||
|
"enabled": true,
|
||||||
|
"verticalRange": {
|
||||||
|
"min": 6,
|
||||||
|
"max": 90
|
||||||
|
},
|
||||||
|
"baseDensityStyle": {
|
||||||
|
"style": "IRIS_DOUBLE",
|
||||||
|
"zoom": 0.8
|
||||||
|
},
|
||||||
|
"detailDensityStyle": {
|
||||||
|
"style": "SIMPLEX",
|
||||||
|
"zoom": 0.5
|
||||||
|
},
|
||||||
|
"warpStyle": {
|
||||||
|
"style": "SIMPLEX",
|
||||||
|
"zoom": 0.5
|
||||||
|
},
|
||||||
|
"baseWeight": 1,
|
||||||
|
"detailWeight": 0,
|
||||||
|
"warpStrength": 0,
|
||||||
|
"densityThreshold": {
|
||||||
|
"min": -0.1,
|
||||||
|
"max": -0.04,
|
||||||
|
"style": {
|
||||||
|
"style": "SIMPLEX",
|
||||||
|
"zoom": 0.5
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"thresholdBias": 0.14,
|
||||||
|
"sampleStep": 3,
|
||||||
|
"surfaceClearance": 12,
|
||||||
|
"allowSurfaceBreak": false,
|
||||||
|
"surfaceBreakStyle": {
|
||||||
|
"style": "SIMPLEX",
|
||||||
|
"zoom": 0.88
|
||||||
|
},
|
||||||
|
"surfaceBreakNoiseThreshold": 0.99,
|
||||||
|
"surfaceBreakDepth": 4,
|
||||||
|
"surfaceBreakThresholdBoost": 0.02,
|
||||||
|
"objectMinDepthBelowSurface": 14,
|
||||||
|
"defaultObjectAnchor": "FLOOR",
|
||||||
|
"defaultObjectPlaceMode": "ORGANIC_STILT",
|
||||||
|
"anchorScanStep": 1,
|
||||||
|
"anchorSearchAttempts": 12,
|
||||||
|
"allowFluid": true,
|
||||||
|
"fluidMinDepthBelowSurface": 20,
|
||||||
|
"fluidRequiresFloor": true,
|
||||||
|
"allowLava": true,
|
||||||
|
"modules": []
|
||||||
|
},
|
||||||
|
"caveBiomeZoom": 3.6,
|
||||||
|
"entitySpawners": [
|
||||||
|
"hot/cave",
|
||||||
|
"hot/hostile",
|
||||||
|
"hot/passive",
|
||||||
|
"hot/water"
|
||||||
|
]
|
||||||
|
}
|
||||||
+266
@@ -0,0 +1,266 @@
|
|||||||
|
{
|
||||||
|
"name": "Mushroom",
|
||||||
|
"color": "#F1C3EF",
|
||||||
|
"rarity": 15,
|
||||||
|
"proceduralObjects": {
|
||||||
|
"fungi": [
|
||||||
|
{
|
||||||
|
"name": "red-cap",
|
||||||
|
"chance": 0.05,
|
||||||
|
"density": 2,
|
||||||
|
"variants": 6,
|
||||||
|
"seed": 9301,
|
||||||
|
"stem": "minecraft:mushroom_stem",
|
||||||
|
"cap": "minecraft:red_mushroom_block",
|
||||||
|
"capShape": "DOME",
|
||||||
|
"stemHeightMin": 4,
|
||||||
|
"stemHeightMax": 9,
|
||||||
|
"stemWidth": 2,
|
||||||
|
"stemCurve": 6,
|
||||||
|
"stemWaveAmplitude": 0.4,
|
||||||
|
"stemWavePeriods": 1.5,
|
||||||
|
"capRadiusMin": 3,
|
||||||
|
"capRadiusMax": 5,
|
||||||
|
"capThickness": 2,
|
||||||
|
"capSquish": 0.7,
|
||||||
|
"capDroop": 18,
|
||||||
|
"capOverhang": 2,
|
||||||
|
"gillBlock": "minecraft:mushroom_stem",
|
||||||
|
"gillChance": 0.7,
|
||||||
|
"rotation": {
|
||||||
|
"enabled": true,
|
||||||
|
"yAxis": {
|
||||||
|
"enabled": true,
|
||||||
|
"min": 0,
|
||||||
|
"max": 360,
|
||||||
|
"interval": 90
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "brown-table",
|
||||||
|
"chance": 0.05,
|
||||||
|
"density": 2,
|
||||||
|
"variants": 6,
|
||||||
|
"seed": 9302,
|
||||||
|
"stem": "minecraft:mushroom_stem",
|
||||||
|
"cap": "minecraft:brown_mushroom_block",
|
||||||
|
"capShape": "FLAT_WIDE",
|
||||||
|
"stemHeightMin": 5,
|
||||||
|
"stemHeightMax": 11,
|
||||||
|
"stemWidth": 2,
|
||||||
|
"stemCurve": 4,
|
||||||
|
"capRadiusMin": 4,
|
||||||
|
"capRadiusMax": 7,
|
||||||
|
"capThickness": 1,
|
||||||
|
"capSquish": 0.35,
|
||||||
|
"capDroop": 8,
|
||||||
|
"capOverhang": 3,
|
||||||
|
"gillBlock": "minecraft:shroomlight",
|
||||||
|
"gillChance": 0.5,
|
||||||
|
"rotation": {
|
||||||
|
"enabled": true,
|
||||||
|
"yAxis": {
|
||||||
|
"enabled": true,
|
||||||
|
"min": 0,
|
||||||
|
"max": 360,
|
||||||
|
"interval": 90
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "spindle-toadstool",
|
||||||
|
"chance": 0.35,
|
||||||
|
"density": 3,
|
||||||
|
"variants": 6,
|
||||||
|
"seed": 9303,
|
||||||
|
"stem": "minecraft:mushroom_stem",
|
||||||
|
"stemPalette": {
|
||||||
|
"style": {
|
||||||
|
"style": "SIMPLEX",
|
||||||
|
"zoom": 0.6
|
||||||
|
},
|
||||||
|
"palette": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:mushroom_stem",
|
||||||
|
"weight": 5
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"block": "minecraft:pale_oak_wood",
|
||||||
|
"weight": 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"cap": "minecraft:red_mushroom_block",
|
||||||
|
"capShape": "CONICAL",
|
||||||
|
"stemHeightMin": 6,
|
||||||
|
"stemHeightMax": 12,
|
||||||
|
"stemWidth": 1,
|
||||||
|
"stemCurve": 10,
|
||||||
|
"stemWaveAmplitude": 0.6,
|
||||||
|
"stemWavePeriods": 2,
|
||||||
|
"capRadiusMin": 2,
|
||||||
|
"capRadiusMax": 4,
|
||||||
|
"capThickness": 2,
|
||||||
|
"capSquish": 0.9,
|
||||||
|
"capDroop": 22,
|
||||||
|
"capOverhang": 1,
|
||||||
|
"spotBlock": "minecraft:brown_mushroom_block",
|
||||||
|
"spotChance": 0.25,
|
||||||
|
"gillBlock": "minecraft:shroomlight",
|
||||||
|
"gillChance": 0.6,
|
||||||
|
"rotation": {
|
||||||
|
"enabled": true,
|
||||||
|
"yAxis": {
|
||||||
|
"enabled": true,
|
||||||
|
"min": 0,
|
||||||
|
"max": 360,
|
||||||
|
"interval": 90
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"landBiomes": [
|
||||||
|
"mushroom/forest",
|
||||||
|
"mushroom/crimson-forest",
|
||||||
|
"mushroom/forest-extended",
|
||||||
|
"mushroom/plains",
|
||||||
|
"mushroom/warped-forest"
|
||||||
|
],
|
||||||
|
"caveBiomes": [
|
||||||
|
"carving/mushroom",
|
||||||
|
"carving/rocky-cavebiome",
|
||||||
|
"carving/drip-lite",
|
||||||
|
"carving/moss-pillars",
|
||||||
|
"carving/crystalized-overgrown"
|
||||||
|
],
|
||||||
|
"shoreBiomes": [
|
||||||
|
"mushroom/shore/beach"
|
||||||
|
],
|
||||||
|
"seaBiomes": [
|
||||||
|
"mushroom/sea/ocean",
|
||||||
|
"mushroom/sea/lake"
|
||||||
|
],
|
||||||
|
"blockDrops": [
|
||||||
|
{
|
||||||
|
"drops": [
|
||||||
|
{
|
||||||
|
"type": "red_mushroom",
|
||||||
|
"rarity": 8
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "brown_mushroom",
|
||||||
|
"rarity": 8
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"blocks": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:mycelium"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"block": "minecraft:mushroom_stem"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"block": "minecraft:red_mushroom_block"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"block": "minecraft:brown_mushroom_block"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"landBiomeZoom": 1.8,
|
||||||
|
"effects": [
|
||||||
|
{
|
||||||
|
"particleAltX": 1e-05,
|
||||||
|
"particleAway": 1,
|
||||||
|
"particleAltY": 0.01885,
|
||||||
|
"particleAltZ": 1e-05,
|
||||||
|
"chance": 3,
|
||||||
|
"particleEffect": "CRIMSON_SPORE",
|
||||||
|
"particleDistance": 5,
|
||||||
|
"particleOffset": 2,
|
||||||
|
"interval": 50,
|
||||||
|
"particleCount": 0
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"volume": 6.2,
|
||||||
|
"minPitch": 0.2,
|
||||||
|
"chance": 8,
|
||||||
|
"maxPitch": 0.3,
|
||||||
|
"sound": "AMBIENT.WARPED_FOREST.ADDITIONS",
|
||||||
|
"interval": 60000,
|
||||||
|
"soundDistance": 3
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"shoreHeightMin": 3.2,
|
||||||
|
"shoreHeightMax": 6.2,
|
||||||
|
"shoreHeightZoom": 1.14,
|
||||||
|
"loot": {
|
||||||
|
"mode": "FALLBACK",
|
||||||
|
"multiplier": 0.5,
|
||||||
|
"tables": [
|
||||||
|
"mushroom/clutter",
|
||||||
|
"mushroom/food"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"caveProfile": {
|
||||||
|
"enabled": true,
|
||||||
|
"verticalRange": {
|
||||||
|
"min": 6,
|
||||||
|
"max": 100
|
||||||
|
},
|
||||||
|
"baseDensityStyle": {
|
||||||
|
"style": "CELLULAR",
|
||||||
|
"zoom": 0.9
|
||||||
|
},
|
||||||
|
"detailDensityStyle": {
|
||||||
|
"style": "SIMPLEX",
|
||||||
|
"zoom": 0.5
|
||||||
|
},
|
||||||
|
"warpStyle": {
|
||||||
|
"style": "SIMPLEX",
|
||||||
|
"zoom": 0.5
|
||||||
|
},
|
||||||
|
"baseWeight": 1.0,
|
||||||
|
"detailWeight": 0.0,
|
||||||
|
"warpStrength": 0.0,
|
||||||
|
"densityThreshold": {
|
||||||
|
"min": -0.12,
|
||||||
|
"max": -0.06,
|
||||||
|
"style": {
|
||||||
|
"style": "SIMPLEX",
|
||||||
|
"zoom": 0.5
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"thresholdBias": 0.1,
|
||||||
|
"sampleStep": 3,
|
||||||
|
"surfaceClearance": 12,
|
||||||
|
"allowSurfaceBreak": false,
|
||||||
|
"surfaceBreakStyle": {
|
||||||
|
"style": "SIMPLEX",
|
||||||
|
"zoom": 0.88
|
||||||
|
},
|
||||||
|
"surfaceBreakNoiseThreshold": 0.99,
|
||||||
|
"surfaceBreakDepth": 4,
|
||||||
|
"surfaceBreakThresholdBoost": 0.02,
|
||||||
|
"objectMinDepthBelowSurface": 14,
|
||||||
|
"defaultObjectAnchor": "FLOOR",
|
||||||
|
"defaultObjectPlaceMode": "ORGANIC_STILT",
|
||||||
|
"anchorScanStep": 1,
|
||||||
|
"anchorSearchAttempts": 12,
|
||||||
|
"allowFluid": true,
|
||||||
|
"fluidMinDepthBelowSurface": 20,
|
||||||
|
"fluidRequiresFloor": true,
|
||||||
|
"allowLava": true,
|
||||||
|
"modules": []
|
||||||
|
},
|
||||||
|
"caveBiomeZoom": 3.2,
|
||||||
|
"entitySpawners": [
|
||||||
|
"mushroom/cave",
|
||||||
|
"mushroom/hostile",
|
||||||
|
"mushroom/passive",
|
||||||
|
"mushroom/water"
|
||||||
|
]
|
||||||
|
}
|
||||||
+126
@@ -0,0 +1,126 @@
|
|||||||
|
{
|
||||||
|
"name": "Swamp",
|
||||||
|
"color": "#69943C",
|
||||||
|
"rarity": 2,
|
||||||
|
"landBiomes": [
|
||||||
|
"swamp/roofed-forest",
|
||||||
|
"swamp/sea/lake",
|
||||||
|
"swamp/roofed-wayward",
|
||||||
|
"swamp/marsh",
|
||||||
|
"swamp/handy-willow-forest",
|
||||||
|
"swamp/cambian-drift",
|
||||||
|
"swamp/swamp-forest",
|
||||||
|
"swamp/willow-forest",
|
||||||
|
"swamp/creaks",
|
||||||
|
"vanilla/mangrove_swamp"
|
||||||
|
],
|
||||||
|
"caveBiomes": [
|
||||||
|
"carving/swamp",
|
||||||
|
"carving/lush",
|
||||||
|
"carving/drip-lite",
|
||||||
|
"carving/drip",
|
||||||
|
"carving/moss-pillars"
|
||||||
|
],
|
||||||
|
"shoreBiomes": [
|
||||||
|
"swamp/shore/beach"
|
||||||
|
],
|
||||||
|
"seaBiomes": [
|
||||||
|
"swamp/sea/ocean",
|
||||||
|
"swamp/swamp-mangrove-lake",
|
||||||
|
"swamp/sea/ocean-tree"
|
||||||
|
],
|
||||||
|
"landBiomeZoom": 2,
|
||||||
|
"shoreHeightMin": 1.2,
|
||||||
|
"shoreHeightMax": 3,
|
||||||
|
"shoreHeightZoom": 3.14,
|
||||||
|
"blockDrops": [
|
||||||
|
{
|
||||||
|
"drops": [
|
||||||
|
{
|
||||||
|
"type": "slime_ball",
|
||||||
|
"rarity": 24
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"blocks": [
|
||||||
|
{
|
||||||
|
"block": "minecraft:grass_block"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"block": "minecraft:dark_oak_leaves"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"block": "minecraft:short_grass"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"block": "minecraft:tall_grass"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"loot": {
|
||||||
|
"mode": "FALLBACK",
|
||||||
|
"multiplier": 0.5,
|
||||||
|
"tables": [
|
||||||
|
"swamp/clutter",
|
||||||
|
"swamp/food"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"caveProfile": {
|
||||||
|
"enabled": true,
|
||||||
|
"verticalRange": {
|
||||||
|
"min": 6,
|
||||||
|
"max": 80
|
||||||
|
},
|
||||||
|
"baseDensityStyle": {
|
||||||
|
"style": "FRACTAL_SMOKE",
|
||||||
|
"zoom": 0.45
|
||||||
|
},
|
||||||
|
"detailDensityStyle": {
|
||||||
|
"style": "SIMPLEX",
|
||||||
|
"zoom": 0.5
|
||||||
|
},
|
||||||
|
"warpStyle": {
|
||||||
|
"style": "SIMPLEX",
|
||||||
|
"zoom": 0.5
|
||||||
|
},
|
||||||
|
"baseWeight": 1,
|
||||||
|
"detailWeight": 0,
|
||||||
|
"warpStrength": 0,
|
||||||
|
"densityThreshold": {
|
||||||
|
"min": -0.14,
|
||||||
|
"max": -0.06,
|
||||||
|
"style": {
|
||||||
|
"style": "SIMPLEX",
|
||||||
|
"zoom": 0.5
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"thresholdBias": 0.06,
|
||||||
|
"sampleStep": 3,
|
||||||
|
"surfaceClearance": 12,
|
||||||
|
"allowSurfaceBreak": false,
|
||||||
|
"surfaceBreakStyle": {
|
||||||
|
"style": "SIMPLEX",
|
||||||
|
"zoom": 0.88
|
||||||
|
},
|
||||||
|
"surfaceBreakNoiseThreshold": 0.99,
|
||||||
|
"surfaceBreakDepth": 4,
|
||||||
|
"surfaceBreakThresholdBoost": 0.02,
|
||||||
|
"objectMinDepthBelowSurface": 14,
|
||||||
|
"defaultObjectAnchor": "FLOOR",
|
||||||
|
"defaultObjectPlaceMode": "ORGANIC_STILT",
|
||||||
|
"anchorScanStep": 1,
|
||||||
|
"anchorSearchAttempts": 12,
|
||||||
|
"allowFluid": true,
|
||||||
|
"fluidMinDepthBelowSurface": 20,
|
||||||
|
"fluidRequiresFloor": true,
|
||||||
|
"allowLava": true,
|
||||||
|
"modules": []
|
||||||
|
},
|
||||||
|
"caveBiomeZoom": 3.2,
|
||||||
|
"entitySpawners": [
|
||||||
|
"swamp/cave",
|
||||||
|
"swamp/hostile",
|
||||||
|
"swamp/passive",
|
||||||
|
"swamp/water"
|
||||||
|
]
|
||||||
|
}
|
||||||
+96
@@ -0,0 +1,96 @@
|
|||||||
|
{
|
||||||
|
"name": "Terralost",
|
||||||
|
"color": "#446600",
|
||||||
|
"rarity": 5,
|
||||||
|
"landBiomes": [
|
||||||
|
"terralost/amethyst-rainforest",
|
||||||
|
"terralost/ancient-sands",
|
||||||
|
"terralost/amethyst-canyon",
|
||||||
|
"terralost/alpine-grove",
|
||||||
|
"terralost/alpine-highlands",
|
||||||
|
"dev"
|
||||||
|
],
|
||||||
|
"landBiomeZoom": 3,
|
||||||
|
"shoreBiomes": [
|
||||||
|
"tundra/shore/beach"
|
||||||
|
],
|
||||||
|
"seaBiomes": [
|
||||||
|
"mountain/sea/river"
|
||||||
|
],
|
||||||
|
"shoreHeightMin": 2.2,
|
||||||
|
"shoreHeightMax": 5.2,
|
||||||
|
"shoreHeightZoom": 1.14,
|
||||||
|
"loot": {
|
||||||
|
"mode": "FALLBACK",
|
||||||
|
"multiplier": 0.5,
|
||||||
|
"tables": [
|
||||||
|
"tropical/food",
|
||||||
|
"cave/clutter"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"caveBiomes": [
|
||||||
|
"carving/amethyst",
|
||||||
|
"carving/calcite",
|
||||||
|
"carving/deepslate",
|
||||||
|
"carving/deepravine",
|
||||||
|
"carving/chalk-gardens"
|
||||||
|
],
|
||||||
|
"caveProfile": {
|
||||||
|
"enabled": true,
|
||||||
|
"verticalRange": {
|
||||||
|
"min": 6,
|
||||||
|
"max": 60
|
||||||
|
},
|
||||||
|
"baseDensityStyle": {
|
||||||
|
"style": "SIMPLEX",
|
||||||
|
"zoom": 0.4
|
||||||
|
},
|
||||||
|
"detailDensityStyle": {
|
||||||
|
"style": "SIMPLEX",
|
||||||
|
"zoom": 0.5
|
||||||
|
},
|
||||||
|
"warpStyle": {
|
||||||
|
"style": "SIMPLEX",
|
||||||
|
"zoom": 0.5
|
||||||
|
},
|
||||||
|
"baseWeight": 1.0,
|
||||||
|
"detailWeight": 0.0,
|
||||||
|
"warpStrength": 0.0,
|
||||||
|
"densityThreshold": {
|
||||||
|
"min": -0.16,
|
||||||
|
"max": -0.08,
|
||||||
|
"style": {
|
||||||
|
"style": "SIMPLEX",
|
||||||
|
"zoom": 0.5
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"thresholdBias": 0.12,
|
||||||
|
"sampleStep": 3,
|
||||||
|
"surfaceClearance": 12,
|
||||||
|
"allowSurfaceBreak": false,
|
||||||
|
"surfaceBreakStyle": {
|
||||||
|
"style": "SIMPLEX",
|
||||||
|
"zoom": 0.88
|
||||||
|
},
|
||||||
|
"surfaceBreakNoiseThreshold": 0.99,
|
||||||
|
"surfaceBreakDepth": 4,
|
||||||
|
"surfaceBreakThresholdBoost": 0.02,
|
||||||
|
"objectMinDepthBelowSurface": 14,
|
||||||
|
"defaultObjectAnchor": "FLOOR",
|
||||||
|
"defaultObjectPlaceMode": "ORGANIC_STILT",
|
||||||
|
"anchorScanStep": 1,
|
||||||
|
"anchorSearchAttempts": 12,
|
||||||
|
"allowFluid": true,
|
||||||
|
"fluidMinDepthBelowSurface": 20,
|
||||||
|
"fluidRequiresFloor": true,
|
||||||
|
"allowLava": true,
|
||||||
|
"modules": []
|
||||||
|
},
|
||||||
|
"caveBiomeZoom": 3.1,
|
||||||
|
"entitySpawners": [
|
||||||
|
"temperate/cave",
|
||||||
|
"temperate/hostile",
|
||||||
|
"temperate/passive",
|
||||||
|
"temperate/water"
|
||||||
|
]
|
||||||
|
}
|
||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
{
|
||||||
|
"group": "NORMAL",
|
||||||
|
"maximumRate": {
|
||||||
|
"amount": 15,
|
||||||
|
"per": {"seconds": 30}
|
||||||
|
},
|
||||||
|
"timeBlock": {
|
||||||
|
"startHour": 6,
|
||||||
|
"endHour": 18
|
||||||
|
},
|
||||||
|
"maxEntitiesPerChunk": 2,
|
||||||
|
"weather": "NONE",
|
||||||
|
"spawns": [
|
||||||
|
{
|
||||||
|
"entity": "standard/passive/mooshroom",
|
||||||
|
"maxSpawns": 3,
|
||||||
|
"minSpawns": 1,
|
||||||
|
"rarity": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"entity": "standard/passive/cow",
|
||||||
|
"maxSpawns": 2,
|
||||||
|
"rarity": 3
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"entity": "standard/passive/pig",
|
||||||
|
"maxSpawns": 2,
|
||||||
|
"minSpawns": 1,
|
||||||
|
"rarity": 2
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
+33
@@ -0,0 +1,33 @@
|
|||||||
|
{
|
||||||
|
"group": "NORMAL",
|
||||||
|
"maximumRate": {
|
||||||
|
"amount": 8,
|
||||||
|
"per": { "seconds": 30 }
|
||||||
|
},
|
||||||
|
"maxEntitiesPerChunk": 5,
|
||||||
|
"spawns": [
|
||||||
|
{
|
||||||
|
"entity": "standard/passive/frog",
|
||||||
|
"maxSpawns": 3,
|
||||||
|
"minSpawns": 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"entity": "standard/passive/tadpole",
|
||||||
|
"maxSpawns": 3,
|
||||||
|
"minSpawns": 1,
|
||||||
|
"rarity": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"entity": "standard/passive/tropicalfish",
|
||||||
|
"maxSpawns": 3,
|
||||||
|
"minSpawns": 1,
|
||||||
|
"rarity": 2
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"entity": "standard/passive/turtle",
|
||||||
|
"maxSpawns": 3,
|
||||||
|
"minSpawns": 1,
|
||||||
|
"rarity": 2
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Reference in new issue
Block a user