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

@@ -7,7 +7,7 @@ yarn_mappings=1.21.11+build.2
loader_version=0.18.2 loader_version=0.18.2
loom_version=1.14-SNAPSHOT loom_version=1.14-SNAPSHOT
# Mod Properties # Mod Properties
mod_version=1.8 mod_version=1.9
maven_group=com.kasetoatz maven_group=com.kasetoatz
archives_base_name=SuperEnchants archives_base_name=SuperEnchants
# Dependencies # Dependencies

View File

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