diff --git a/changelog.md b/changelog.md index 1cb2560e..baecf738 100644 --- a/changelog.md +++ b/changelog.md @@ -1,3 +1 @@ -- added extra debug logs disabled by default that can be enabled via configuration file -- made configuration files continue loading after encountering invalid data -- fixed game crash when items had unsupported NBT format (reported by @bons66) \ No newline at end of file +- fixed compatibility crash with Chrysalis (reported by @Paxx3, @ZacGames) \ No newline at end of file diff --git a/fabric/src/main/java/com/majruszlibrary/mixin/fabric/MixinEnderMan.java b/fabric/src/main/java/com/majruszlibrary/mixin/fabric/MixinEnderMan.java index b3465873..25304d8f 100644 --- a/fabric/src/main/java/com/majruszlibrary/mixin/fabric/MixinEnderMan.java +++ b/fabric/src/main/java/com/majruszlibrary/mixin/fabric/MixinEnderMan.java @@ -4,37 +4,21 @@ import com.majruszlibrary.events.base.Events; import net.minecraft.world.entity.monster.EnderMan; import net.minecraft.world.entity.player.Player; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.At; import org.spongepowered.asm.mixin.injection.Inject; -import org.spongepowered.asm.mixin.injection.Redirect; import org.spongepowered.asm.mixin.injection.callback.CallbackInfoReturnable; @Mixin( EnderMan.class ) public abstract class MixinEnderMan { - private Player majruszlibrary$lastPlayer = null; - @Inject( - at = @At( "HEAD" ), + at = @At( "RETURN" ), + cancellable = true, method = "isLookingAtMe (Lnet/minecraft/world/entity/player/Player;)Z" ) private void isLookingAtMe( Player player, CallbackInfoReturnable< Boolean > callback ) { - this.majruszlibrary$lastPlayer = player; - } - - @Redirect( - at = @At( - target = "Lnet/minecraft/world/item/ItemStack;is (Lnet/minecraft/world/item/Item;)Z", - value = "INVOKE" - ), - method = "isLookingAtMe (Lnet/minecraft/world/entity/player/Player;)Z" - ) - private boolean is( ItemStack itemStack, Item item ) { - EnderMan enderMan = ( EnderMan )( Object )this; - - return itemStack.is( item ) - || Events.dispatch( new OnEnderManAngered( enderMan, this.majruszlibrary$lastPlayer ) ).isAngerCancelled(); + if( callback.getReturnValue() && Events.dispatch( new OnEnderManAngered( ( EnderMan )( Object )this, player ) ).isAngerCancelled() ) { + callback.setReturnValue( false ); + } } } diff --git a/gradle.properties b/gradle.properties index c2b6e333..a21f891d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -7,7 +7,7 @@ minecraft_version=1.20.1 # Mod mod_id=majruszlibrary mod_archives_name=majrusz-library -mod_version=7.0.3 +mod_version=7.0.4 mod_display_name=Majrusz Library mod_description=Library with common code for my other modifications. mod_authors=Majrusz