lightning rod fix

This commit is contained in:
2025-12-26 03:07:31 +01:00
parent 51ce8ba5dc
commit a560e64029
2 changed files with 7 additions and 3 deletions

View File

@@ -1,5 +1,6 @@
package com.kasetoatz.superenchants.mixin;
import net.minecraft.entity.Entity;
import net.minecraft.entity.projectile.TridentEntity;
import net.minecraft.loot.condition.WeatherCheckLootCondition;
import net.minecraft.loot.context.LootContext;
@@ -9,14 +10,17 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable;
import java.util.Objects;
@Mixin(WeatherCheckLootCondition.class)
public class WeatherCheckLootConditionMixin
{
@Inject(method="test(Lnet/minecraft/loot/context/LootContext;)Z", at=@At("RETURN"), cancellable=true)
public void test(LootContext lootContext, CallbackInfoReturnable<Boolean> cir)
{
Integer level = lootContext.get(LootContextParameters.ENCHANTMENT_LEVEL);
if (lootContext.get(LootContextParameters.DIRECT_ATTACKING_ENTITY) instanceof TridentEntity && level != null && level > 1)
Entity entity = Objects.requireNonNullElse(lootContext.get(LootContextParameters.DIRECT_ATTACKING_ENTITY), lootContext.get(LootContextParameters.THIS_ENTITY));
Integer level = Objects.requireNonNullElse(lootContext.get(LootContextParameters.ENCHANTMENT_LEVEL), 0);
if (entity instanceof TridentEntity && level > 1)
{
cir.setReturnValue(true);
}