Apotheosis

Apotheosis

70M Downloads

Allow the specification of loot tables in `Affix Convert Rarities`

SiverDX opened this issue ยท 5 comments

commented

Currently you can only clamp the rarity based on the entire dimension (items and gems)

But if you want a couple of loot tables to have the chance to have higher rarities you'd have to allow ALL loot tables of that dimension to have those chances

Currently I'm doing this as a workaround but it would be cool to specify it in the config (through regex preferably)

String id = context.getQueriedLootTableId().toString();
String modifiedDimension = "mt:chests_";
Clamped rarities;
if (id.startsWith("mt:")) {
	if (id.contains("common")) {
		modifiedDimension += "common";
	} else if (id.contains("rare")) {
		modifiedDimension += "rare";
	} else if (id.contains("epic")) {
		modifiedDimension += "epic";
	} else if (id.contains("legendary")) {
		modifiedDimension += "legendary";
	} else {
		modifiedDimension += context.getLevel().dimension().location();
	}
	rarities = AdventureConfig.AFFIX_CONVERT_RARITIES.get(new ResourceLocation(modifiedDimension));
} else {
	rarities = AdventureConfig.AFFIX_CONVERT_RARITIES.get(context.getLevel().dimension().location());
}

Config

S:"Affix Convert Rarities" <
    mt:chests_common|common|uncommon
    mt:chests_rare|common|rare
    mt:chests_epic|uncommon|epic
    mt:chests_legendary|rare|mythic
    overworld|common|rare
    the_nether|uncommon|epic
    the_end|rare|mythic
    twilightforest:twilight_forest|uncommon|epic
 >

What it could look like:

S:"Affix Convert Rarities" <
    overworld|mt:chests.*?common.*|common|uncommon
    overworld|mt:chests.*?rare.*|common|rare
    overworld|mt:chests.*?epic.*|uncommon|epic
    overworld|mt:chests.*?legendary.*|rare|mythic
    overworld|.*|common|rare
    the_nether|.*|uncommon|epic
    the_end|.*|rare|mythic
    twilightforest:twilight_forest|.*|uncommon|epic
 >
commented

Probably better to discuss this further on discord, the generation of affix loot entries is fairly complicated and this medium is ill-suited for explaining it (the back and forth would be extensive)

commented

And If I add this to a loot table it will overwrite the default one that gets added to every loot table?

commented

As a loot pool entry:

{
  "type": "apotheosis:random_affix_item",
  "rarity": "epic",
  "entries": [
    "overworld/bow",
    "overworld/stone_axe"
  ]
}

Both the rarity and entries are optional. Not specifying a rarity will pull a random one, and not specifying any entries will use the entire set of affix loot entries for the dimension the loot is generated in.

This example above will generate an epic item that is either a bow or a stone axe.

I don't think I use this natively in any of the loot pools, but this shows the structure of where a loot pool entry would appear https://github.com/Shadows-of-Fire/Apotheosis/blob/1.19/src/main/resources/data/apotheosis/loot_tables/chests/chest_valuable.json#L12

commented

The convert rarities are used in a way that would make this data structure unviable (they are used for more than just loot tables)

If you are making custom loot tables, I suggest using the affix loot pool entry to achieve the desired result https://github.com/Shadows-of-Fire/Apotheosis/blob/1.19/src/main/java/shadows/apotheosis/adventure/loot/AffixLootPoolEntry.java

commented

I'm not sure on how to do that

Neither the constructor AffixLootPoolEntry nor the method createItemStack seem to be called when loot is generated
(I thought maybe I had to write a mixin to change the rarity based on the loot context)

I saw this part:
Registry.register(Registry.LOOT_POOL_ENTRY_TYPE, new ResourceLocation(Apotheosis.MODID, "random_affix_item"), AffixLootPoolEntry.TYPE);

but I'm unsure on how that is actually used and where (do I need to create my own entry like that? But how would I tell the mod to generate from that pool instead)