add fallback loot mode

This commit is contained in:
Julian Krings 2025-01-02 13:28:20 +01:00
parent fb59c7370d
commit cb6e4570f4
No known key found for this signature in database
GPG Key ID: 208C6E08C3B718D2
3 changed files with 13 additions and 7 deletions

View File

@ -468,7 +468,10 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
} }
@Override @Override
default void injectTables(KList<IrisLootTable> list, IrisLootReference r) { default void injectTables(KList<IrisLootTable> list, IrisLootReference r, boolean fallback) {
if (r.getMode().equals(IrisLootMode.FALLBACK) && !fallback)
return;
if (r.getMode().equals(IrisLootMode.CLEAR) || r.getMode().equals(IrisLootMode.REPLACE)) { if (r.getMode().equals(IrisLootMode.CLEAR) || r.getMode().equals(IrisLootMode.REPLACE)) {
list.clear(); list.clear();
} }
@ -503,10 +506,11 @@ public interface Engine extends DataProvider, Fallible, LootProvider, BlockUpdat
IrisBiome biomeUnder = ry < he ? getComplex().getCaveBiomeStream().get(rx, rz) : biomeSurface; IrisBiome biomeUnder = ry < he ? getComplex().getCaveBiomeStream().get(rx, rz) : biomeSurface;
double multiplier = 1D * getDimension().getLoot().getMultiplier() * region.getLoot().getMultiplier() * biomeSurface.getLoot().getMultiplier() * biomeUnder.getLoot().getMultiplier(); double multiplier = 1D * getDimension().getLoot().getMultiplier() * region.getLoot().getMultiplier() * biomeSurface.getLoot().getMultiplier() * biomeUnder.getLoot().getMultiplier();
injectTables(tables, getDimension().getLoot()); boolean fallback = tables.isEmpty();
injectTables(tables, region.getLoot()); injectTables(tables, getDimension().getLoot(), fallback);
injectTables(tables, biomeSurface.getLoot()); injectTables(tables, region.getLoot(), fallback);
injectTables(tables, biomeUnder.getLoot()); injectTables(tables, biomeSurface.getLoot(), fallback);
injectTables(tables, biomeUnder.getLoot(), fallback);
if (tables.isNotEmpty()) { if (tables.isNotEmpty()) {
int target = (int) Math.round(tables.size() * multiplier); int target = (int) Math.round(tables.size() * multiplier);

View File

@ -30,7 +30,7 @@ import org.bukkit.inventory.Inventory;
public interface LootProvider { public interface LootProvider {
void scramble(Inventory inventory, RNG rng); void scramble(Inventory inventory, RNG rng);
void injectTables(KList<IrisLootTable> list, IrisLootReference r); void injectTables(KList<IrisLootTable> list, IrisLootReference r, boolean fallback);
KList<IrisLootTable> getLootTables(RNG rng, Block b); KList<IrisLootTable> getLootTables(RNG rng, Block b);

View File

@ -27,5 +27,7 @@ public enum IrisLootMode {
@Desc("Clear all loot tables then add this table") @Desc("Clear all loot tables then add this table")
CLEAR, CLEAR,
@Desc("Replace all loot tables with this table (same as clear)") @Desc("Replace all loot tables with this table (same as clear)")
REPLACE REPLACE,
@Desc("Only use when there was no loot table defined by an object")
FALLBACK
} }