Majrusz Library

Majrusz Library

19M Downloads

Not compatible with `Vitalize`

SiverDX opened this issue ยท 3 comments

commented

Mod: https://www.curseforge.com/minecraft/mc-mods/vitalize

See terrarium-earth/Vitalize#9
Would it be possible to not throw an Exception by adding a check there?

this.lastDamagePlayer = this.getParameter( LootContextParams.LAST_DAMAGE_PLAYER );

Error with 4.0.0:

java.util.NoSuchElementException: minecraft:last_damage_player
	at earth.terrarium.vitalize.api.ModifiedLootContext.m_165124_(ModifiedLootContext.java:44) ~[vitalize-forge-1.19.2-1.1.1.jar%23753!/:?] {re:classloading}
	at com.mlib.gamemodifiers.contexts.OnLoot$Data.getParameter(OnLoot.java:131) ~[majrusz-library-1.19.2-4.0.0.jar%23633!/:4.0.0] {re:classloading}
	at com.mlib.gamemodifiers.contexts.OnLoot$Data.<init>(OnLoot.java:103) ~[majrusz-library-1.19.2-4.0.0.jar%23633!/:4.0.0] {re:classloading}
	at com.mlib.gamemodifiers.contexts.OnLoot.dispatch(OnLoot.java:36) ~[majrusz-library-1.19.2-4.0.0.jar%23633!/:4.0.0] {re:classloading}
	at com.mlib.features.AnyModification.doApply(AnyModification.java:28) ~[majrusz-library-1.19.2-4.0.0.jar%23633!/:4.0.0] {re:classloading}
	at net.minecraftforge.common.loot.LootModifier.apply(LootModifier.java:58) ~[forge-1.19.2-43.2.11-universal.jar%23774!/:?] {re:classloading}
	at net.minecraftforge.common.ForgeHooks.modifyLoot(ForgeHooks.java:1320) ~[forge-1.19.2-43.2.11-universal.jar%23774!/:?] {re:mixin,re:classloading,pl:mixin:APP:enigmaticlegacy.mixins.json:MixinForgeHooks,pl:mixin:A}
	at net.minecraft.world.level.storage.loot.LootTable.m_230922_(LootTable.java:90) ~[client-1.19.2-20220805.130853-srg.jar%23769!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:balm.mixins.json:LootTableMixin,pl:mixin:APP:quark.mixins.json:accessor.AccessorLootTable,pl:mixin:A}
	at earth.terrarium.vitalize.api.LootTableUtils.getLootTable(LootTableUtils.java:22) ~[vitalize-forge-1.19.2-1.1.1.jar%23753!/:?] {re:classloading}
	at earth.terrarium.vitalize.blocks.SoulRevitalizerBlockEntity.tick(SoulRevitalizerBlockEntity.java:157) ~[vitalize-forge-1.19.2-1.1.1.jar%23753!/:?] {re:classloading}
	at net.minecraft.world.level.chunk.LevelChunk$BoundTickingBlockEntity.m_142224_(LevelChunk.java:687) ~[client-1.19.2-20220805.130853-srg.jar%23769!/:?] {re:classloading}
	at net.minecraft.world.level.chunk.LevelChunk$RebindableTickingBlockEntityWrapper.m_142224_(LevelChunk.java:780) ~[client-1.19.2-20220805.130853-srg.jar%23769!/:?] {re:mixin,re:classloading,pl:mixin:APP:canary.mixins.json:world.block_entity_ticking.sleeping.RebindableTickingBlockEntityWrapperAccessor,pl:mixin:A}
	at net.minecraft.world.level.Level.redirect$fjb000$redirectTick(Level.java:6538) ~[client-1.19.2-20220805.130853-srg.jar%23769!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:dynamiclightsreforged.mixins.json:WorldMixin,pl:mixin:APP:sliceanddice.mixins.json:LevelMixin,pl:mixin:APP:starlight.mixins.json:common.world.LevelMixin,pl:mixin:APP:canary.mixins.json:alloc.chunk_random.LevelMixin,pl:mixin:APP:canary.mixins.json:block.hopper.LevelMixin,pl:mixin:APP:canary.mixins.json:util.block_entity_retrieval.LevelMixin,pl:mixin:APP:canary.mixins.json:world.block_entity_ticking.sleeping.LevelMixin,pl:mixin:APP:canary.mixins.json:world.chunk_access.LevelMixin,pl:mixin:APP:canary.mixins.json:world.inline_block_access.LevelMixin,pl:mixin:APP:canary.mixins.json:world.inline_height.LevelMixin,pl:mixin:APP:citadel.mixins.json:LevelMixin,pl:mixin:APP:observable.common.json:LevelMixin,pl:mixin:APP:fabrication.mixins.json:d_minor_mechanics.water_fills_on_break.MixinWorld,pl:mixin:A}
	at net.minecraft.world.level.Level.m_46463_(Level.java:446) ~[client-1.19.2-20220805.130853-srg.jar%23769!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:dynamiclightsreforged.mixins.json:WorldMixin,pl:mixin:APP:sliceanddice.mixins.json:LevelMixin,pl:mixin:APP:starlight.mixins.json:common.world.LevelMixin,pl:mixin:APP:canary.mixins.json:alloc.chunk_random.LevelMixin,pl:mixin:APP:canary.mixins.json:block.hopper.LevelMixin,pl:mixin:APP:canary.mixins.json:util.block_entity_retrieval.LevelMixin,pl:mixin:APP:canary.mixins.json:world.block_entity_ticking.sleeping.LevelMixin,pl:mixin:APP:canary.mixins.json:world.chunk_access.LevelMixin,pl:mixin:APP:canary.mixins.json:world.inline_block_access.LevelMixin,pl:mixin:APP:canary.mixins.json:world.inline_height.LevelMixin,pl:mixin:APP:citadel.mixins.json:LevelMixin,pl:mixin:APP:observable.common.json:LevelMixin,pl:mixin:APP:fabrication.mixins.json:d_minor_mechanics.water_fills_on_break.MixinWorld,pl:mixin:A}
	at net.minecraft.server.level.ServerLevel.m_8793_(ServerLevel.java:331) ~[client-1.19.2-20220805.130853-srg.jar%23769!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:APP:modernfix-common.mixins.json:perf.cache_strongholds.ServerLevelMixin,pl:mixin:APP:supplementaries-common.mixins.json:ServerLevelMixin,pl:mixin:APP:pluto.mixins.json:fast_entity_access.ServerLevelMixin,pl:mixin:APP:starlight.mixins.json:common.world.ServerWorldMixin,pl:mixin:APP:crafttweaker.mixins.json:common.transform.world.level.MixinServerLevel,pl:mixin:APP:canary.mixins.json:alloc.chunk_random.ServerLevelMixin,pl:mixin:APP:canary.mixins.json:chunk.entity_class_groups.ServerLevelAccessor,pl:mixin:APP:canary.mixins.json:entity.inactive_navigations.ServerLevelMixin,pl:mixin:APP:canary.mixins.json:profiler.ServerLevelMixin,pl:mixin:APP:canary.mixins.json:util.entity_movement_tracking.ServerLevelAccessor,pl:mixin:APP:citadel.mixins.json:ServerLevelMixin,pl:mixin:APP:observable.common.json:ServerLevelMixin,pl:mixin:APP:betterdeserttemples.mixins.json:ServerLevelMixin,pl:mixin:APP:blueprint.mixins.json:ServerLevelMixin,pl:mixin:APP:rottencreatures-common.mixins.json:common.ServerLevelMixin,pl:mixin:APP:create.mixins.json:accessor.ServerLevelAccessor,pl:mixin:APP:fabrication.mixins.json:c_tweaks.alt_absorption_sound.MixinServerWorld,pl:mixin:APP:fabrication.mixins.json:b_utility.item_despawn.MixinServerWorld,pl:mixin:APP:fabrication.mixins.json:i_woina.no_experience.MixinServerWorld,pl:mixin:A}
	at net.minecraft.server.MinecraftServer.m_5703_(MinecraftServer.java:866) ~[client-1.19.2-20220805.130853-srg.jar%23769!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:A}
	at net.minecraft.server.MinecraftServer.m_5705_(MinecraftServer.java:806) ~[client-1.19.2-20220805.130853-srg.jar%23769!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:A}
	at net.minecraft.client.server.IntegratedServer.m_5705_(IntegratedServer.java:84) ~[client-1.19.2-20220805.130853-srg.jar%23769!/:?] {re:mixin,pl:runtimedistcleaner:A,re:classloading,pl:mixin:A,pl:runtimedistcleaner:A}
	at net.minecraft.server.MinecraftServer.m_130011_(MinecraftServer.java:654) ~[client-1.19.2-20220805.130853-srg.jar%23769!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:A}
	at net.minecraft.server.MinecraftServer.m_206580_(MinecraftServer.java:244) ~[client-1.19.2-20220805.130853-srg.jar%23769!/:?] {re:mixin,pl:accesstransformer:B,re:classloading,pl:accesstransformer:B,pl:mixin:A}
	at java.lang.Thread.run(Unknown Source) ~[?:?] {re:mixin}
commented

Hi, thanks for the report but I am afraid that there is no reason to fix it in my mod. All parameters are checked before I access them over here:

return this.context.hasParam( parameter ) ? this.context.getParam( parameter ) : null;
and for some reason Vitalize mod always returns true for minecraft:last_damage_player even if it is undefined over here:
https://github.com/terrarium-earth/Vitalize/blob/1.19/common/src/main/java/earth/terrarium/vitalize/api/ModifiedLootContext.java#L60

commented

Might be to make certain loot drop, not sure

Apotheosis is doing this, had no issues with it so far:
https://github.com/Shadows-of-Fire/Apotheosis/blob/0ad17e2c2b47eb94967e29019c987ddc0d9d240d/src/main/java/shadows/apotheosis/adventure/loot/GemLootPoolEntry.java#L92

See:

public <T> T getParam(LootContextParam<T> lootContextParam) {
    T object = this.params.get(lootContextParam);
    if (object == null) {
        throw new NoSuchElementException(lootContextParam.getName().toString());
    } else {
        return object;
    }
}
@Nullable
public <T> T getParamOrNull(LootContextParam<T> lootContextParam) {
    return this.params.get(lootContextParam);
}
commented

You are right, I replaced that code as it has the exact same meaning but it becomes compatible with Vitalize mod 6d588d2 (it still should be fixed in Vitalize mod to avoid compatibility issues with other mods). Anyway thanks for the report, I will release 4.1.0 version within few days and once it is released I will close this report