mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2026-11-29 09:15:27 +00:00
Merge branch 'wave2/d' into feat/irisapi-host
This commit is contained in:
commit
0b303eb937
63 files changed
+2321
-1187
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 + "'");
|
||||
|
||||
@@ -20,6 +20,7 @@ package art.arcane.iris.modded;
|
||||
|
||||
import art.arcane.iris.spi.PlatformItem;
|
||||
import net.minecraft.world.item.Item;
|
||||
import net.minecraft.world.item.ItemStack;
|
||||
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@@ -55,4 +56,9 @@ public final class ModdedItem implements PlatformItem {
|
||||
public Object nativeHandle() {
|
||||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int maxDurability() {
|
||||
return new ItemStack(item).getMaxDamage();
|
||||
}
|
||||
}
|
||||
+3
-2
@@ -19,6 +19,7 @@
|
||||
package art.arcane.iris.modded;
|
||||
|
||||
import art.arcane.iris.engine.framework.LootResolver;
|
||||
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;
|
||||
@@ -80,7 +81,7 @@ public final class ModdedItemTranslator {
|
||||
return out;
|
||||
}
|
||||
|
||||
RNG rng = LootResolver.tableRng(lootSeed, table, x, y, z);
|
||||
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()));
|
||||
@@ -118,7 +119,7 @@ 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) {
|
||||
long combinedRarity = LootResolver.combinedRarity(loot.getRarity(), table.getRarity());
|
||||
if (!LootResolver.spatialOneIn(lootSeed, table, entryIndex, x, y, z, combinedRarity)) {
|
||||
if (!LootTables.spatialOneIn(lootSeed, table, entryIndex, x, y, z, combinedRarity)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,11 +18,13 @@
|
||||
|
||||
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;
|
||||
import art.arcane.iris.engine.framework.Engine;
|
||||
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;
|
||||
@@ -121,7 +123,7 @@ public final class ModdedLootApplier {
|
||||
}
|
||||
}
|
||||
|
||||
LootResolver.resolveEnvironmentSources(
|
||||
LootTables.resolveEnvironmentSources(
|
||||
sources,
|
||||
engine,
|
||||
rng,
|
||||
@@ -143,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();
|
||||
}
|
||||
}
|
||||
+6
-5
@@ -1,6 +1,7 @@
|
||||
package art.arcane.iris.modded;
|
||||
|
||||
import art.arcane.iris.engine.framework.LootResolver;
|
||||
import art.arcane.iris.engine.loot.LootTables;
|
||||
import art.arcane.iris.engine.object.loot.IrisLootMode;
|
||||
import art.arcane.volmlib.util.math.RNG;
|
||||
import net.minecraft.resources.Identifier;
|
||||
@@ -30,7 +31,7 @@ public class ModdedLootApplierTest {
|
||||
public void addAppendsSourcesInOrder() {
|
||||
List<String> sources = new ArrayList<>(List.of("placement-native"));
|
||||
|
||||
LootResolver.injectSources(sources, List.of("dimension-iris", "region-iris"), IrisLootMode.ADD, false);
|
||||
LootTables.injectSources(sources, List.of("dimension-iris", "region-iris"), IrisLootMode.ADD, false);
|
||||
|
||||
assertEquals(List.of("placement-native", "dimension-iris", "region-iris"), sources);
|
||||
}
|
||||
@@ -39,7 +40,7 @@ public class ModdedLootApplierTest {
|
||||
public void clearRemovesEverythingAndContributesNothing() {
|
||||
List<String> sources = new ArrayList<>(List.of("placement-native", "dimension-iris"));
|
||||
|
||||
LootResolver.injectSources(sources, List.of("biome-iris"), IrisLootMode.CLEAR, false);
|
||||
LootTables.injectSources(sources, List.of("biome-iris"), IrisLootMode.CLEAR, false);
|
||||
|
||||
assertEquals(List.of(), sources);
|
||||
}
|
||||
@@ -48,7 +49,7 @@ public class ModdedLootApplierTest {
|
||||
public void replaceRemovesNativeAndIrisSourcesBeforeAdding() {
|
||||
List<String> sources = new ArrayList<>(List.of("placement-native", "dimension-iris"));
|
||||
|
||||
LootResolver.injectSources(sources, List.of("biome-iris"), IrisLootMode.REPLACE, false);
|
||||
LootTables.injectSources(sources, List.of("biome-iris"), IrisLootMode.REPLACE, false);
|
||||
|
||||
assertEquals(List.of("biome-iris"), sources);
|
||||
}
|
||||
@@ -63,7 +64,7 @@ public class ModdedLootApplierTest {
|
||||
public void fallbackDoesNotOverrideExistingNativeOrIrisSources() {
|
||||
List<String> sources = new ArrayList<>(List.of("placement-native", "dimension-iris"));
|
||||
|
||||
LootResolver.injectSources(sources, List.of("fallback-iris"), IrisLootMode.FALLBACK, false);
|
||||
LootTables.injectSources(sources, List.of("fallback-iris"), IrisLootMode.FALLBACK, false);
|
||||
|
||||
assertEquals(List.of("placement-native", "dimension-iris"), sources);
|
||||
}
|
||||
@@ -72,7 +73,7 @@ public class ModdedLootApplierTest {
|
||||
public void fallbackAddsSourcesWhenPlacementIsEmpty() {
|
||||
List<String> sources = new ArrayList<>();
|
||||
|
||||
LootResolver.injectSources(sources, List.of("fallback-iris"), IrisLootMode.FALLBACK, true);
|
||||
LootTables.injectSources(sources, List.of("fallback-iris"), IrisLootMode.FALLBACK, true);
|
||||
|
||||
assertEquals(List.of("fallback-iris"), sources);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user