mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-30 01:34:04 +00:00
Iris has no loaders for loot tables, spawners, entities and markers any more
Callers read them through LootResources and SpawnResources; the pack's loot check moved to iris:loot. RegistryMatter asks its subclass how to load a key, the entity command handler lists entities through the module kind.
This commit is contained in:
1 parent
406d3e47d3
commit
e120991ad3
24 files changed
+423
-394
No files matched your search
+2
-1
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.modded;
|
||||
|
||||
import art.arcane.iris.engine.spawn.SpawnResources;
|
||||
import art.arcane.iris.core.loader.IrisData;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.framework.LootResolver;
|
||||
@@ -235,7 +236,7 @@ public final class ModdedBlockBreakHandler {
|
||||
if ("cave_floor".equals(tag) || "cave_ceiling".equals(tag)) {
|
||||
return;
|
||||
}
|
||||
IrisMarker configured = engine.getData().getMarkerLoader().load(tag);
|
||||
IrisMarker configured = SpawnResources.marker(engine.getData(), tag);
|
||||
if (configured == null || configured.isRemoveOnChange()) {
|
||||
engine.getMantle().getMantle().remove(position.getX(), mantleY, position.getZ(), MatterMarker.class);
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.modded;
|
||||
|
||||
import art.arcane.iris.engine.loot.LootResources;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
import art.arcane.iris.engine.object.loot.InventorySlotType;
|
||||
import art.arcane.iris.engine.object.loot.IrisLootTable;
|
||||
@@ -104,7 +105,7 @@ public final class ModdedDeathLoot {
|
||||
private static KList<ItemStack> resolve(Engine engine, ServerLevel level, LootBinding binding) {
|
||||
KList<ItemStack> drops = new KList<>();
|
||||
for (String key : binding.tableKeys()) {
|
||||
IrisLootTable table = engine.getData().getLootLoader().load(key);
|
||||
IrisLootTable table = LootResources.table(engine.getData(), key);
|
||||
if (table == null) {
|
||||
if (WARNED_TABLES.add(key)) {
|
||||
IrisLogging.warn("Iris death loot: unknown loot table '" + key + "'");
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.modded;
|
||||
|
||||
import art.arcane.iris.engine.loot.LootResources;
|
||||
import art.arcane.iris.engine.object.loot.IrisObjectLoot;
|
||||
import art.arcane.iris.engine.object.loot.IrisObjectVanillaLoot;
|
||||
import art.arcane.iris.engine.object.placement.IrisObjectPlacement;
|
||||
@@ -144,7 +145,7 @@ public final class ModdedLootApplier {
|
||||
if (loot == null || loot.getWeight() <= 0) {
|
||||
continue;
|
||||
}
|
||||
IrisLootTable table = engine.getData().getLootLoader().load(loot.getName());
|
||||
IrisLootTable table = LootResources.table(engine.getData(), loot.getName());
|
||||
if (table == null) {
|
||||
IrisLogging.warn("Couldn't find loot table " + loot.getName());
|
||||
continue;
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
|
||||
package art.arcane.iris.modded;
|
||||
|
||||
import art.arcane.iris.engine.spawn.SpawnResources;
|
||||
import art.arcane.iris.core.IrisSettings;
|
||||
import art.arcane.iris.core.gui.PregeneratorJob;
|
||||
import art.arcane.iris.engine.IrisComplex;
|
||||
@@ -396,7 +397,7 @@ public final class ModdedWorldManager implements EngineWorldManager {
|
||||
if (tag.equals("cave_floor") || tag.equals("cave_ceiling")) {
|
||||
return;
|
||||
}
|
||||
IrisMarker resolved = engine.getData().getMarkerLoader().load(tag);
|
||||
IrisMarker resolved = SpawnResources.marker(engine.getData(), tag);
|
||||
if (resolved == null) {
|
||||
return;
|
||||
}
|
||||
@@ -429,7 +430,7 @@ public final class ModdedWorldManager implements EngineWorldManager {
|
||||
private KList<IrisSpawner> resolveMarkerSpawners(IrisMarker marker) {
|
||||
KList<IrisSpawner> spawners = new KList<>();
|
||||
for (String key : marker.getSpawners()) {
|
||||
IrisSpawner spawner = engine.getData().getSpawnerLoader().load(key);
|
||||
IrisSpawner spawner = SpawnResources.spawner(engine.getData(), key);
|
||||
if (spawner == null) {
|
||||
IrisLogging.error("Cannot load spawner: " + key + " for marker on " + engine.getName());
|
||||
continue;
|
||||
@@ -478,9 +479,9 @@ public final class ModdedWorldManager implements EngineWorldManager {
|
||||
int chunkMobs = countChunkLivingEntities(level, chunkX, chunkZ);
|
||||
|
||||
KList<IrisEntitySpawn> pool = new KList<>();
|
||||
collectSpawns(pool, engine.getData().getSpawnerLoader().loadAll(engine.getDimension().getEntitySpawners()), biome, chunkX, chunkZ, chunkMobs, initial);
|
||||
collectSpawns(pool, engine.getData().getSpawnerLoader().loadAll(region.getEntitySpawners()), null, chunkX, chunkZ, chunkMobs, initial);
|
||||
collectSpawns(pool, engine.getData().getSpawnerLoader().loadAll(biome.getEntitySpawners()), null, chunkX, chunkZ, chunkMobs, initial);
|
||||
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;
|
||||
}
|
||||
|
||||
+15
-7
@@ -18,6 +18,9 @@
|
||||
|
||||
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.core.IrisSettings;
|
||||
import art.arcane.iris.core.gui.GuiHost;
|
||||
@@ -935,14 +938,14 @@ public final class ModdedStudioCommands {
|
||||
markerKeys.addAll(PackExportClosure.collectMarkerKeys(biome.getObjects()));
|
||||
}
|
||||
for (String markerKey : markerKeys) {
|
||||
IrisMarker marker = dm.getMarkerLoader().load(markerKey);
|
||||
IrisMarker marker = SpawnResources.marker(dm, markerKey);
|
||||
if (marker == null) {
|
||||
continue;
|
||||
}
|
||||
spawnerKeys.addAll(marker.getSpawners());
|
||||
}
|
||||
for (String spawnerKey : spawnerKeys) {
|
||||
IrisSpawner spawner = dm.getSpawnerLoader().load(spawnerKey);
|
||||
IrisSpawner spawner = SpawnResources.spawner(dm, spawnerKey);
|
||||
if (spawner == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -950,7 +953,7 @@ public final class ModdedStudioCommands {
|
||||
spawner.getInitialSpawns().forEach((IrisEntitySpawn spawn) -> entityKeys.add(spawn.getEntity()));
|
||||
}
|
||||
for (String entityKey : entityKeys) {
|
||||
IrisEntity entity = dm.getEntityLoader().load(entityKey);
|
||||
IrisEntity entity = SpawnResources.entity(dm, entityKey);
|
||||
if (entity == null) {
|
||||
continue;
|
||||
}
|
||||
@@ -988,16 +991,16 @@ public final class ModdedStudioCommands {
|
||||
hashes.append(copyJson(folder, "biomes", key, dm.getBiomeLoader().findFile(key)));
|
||||
}
|
||||
for (String key : entityKeys) {
|
||||
hashes.append(copyJson(folder, "entities", key, dm.getEntityLoader().findFile(key)));
|
||||
hashes.append(copyJson(folder, "entities", key, loadFile(SpawnResources.entity(dm, key))));
|
||||
}
|
||||
for (String key : lootKeys) {
|
||||
hashes.append(copyJson(folder, "loot", key, dm.getLootLoader().findFile(key)));
|
||||
hashes.append(copyJson(folder, "loot", key, loadFile(LootResources.table(dm, key))));
|
||||
}
|
||||
for (String key : spawnerKeys) {
|
||||
hashes.append(copyJson(folder, "spawners", key, dm.getSpawnerLoader().findFile(key)));
|
||||
hashes.append(copyJson(folder, "spawners", key, loadFile(SpawnResources.spawner(dm, key))));
|
||||
}
|
||||
for (String key : markerKeys) {
|
||||
hashes.append(copyJson(folder, "markers", key, dm.getMarkerLoader().findFile(key)));
|
||||
hashes.append(copyJson(folder, "markers", key, loadFile(SpawnResources.marker(dm, key))));
|
||||
}
|
||||
|
||||
JSONObject meta = new JSONObject();
|
||||
@@ -1088,4 +1091,9 @@ public final class ModdedStudioCommands {
|
||||
thread.start();
|
||||
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();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user