From 864ba23f94a1fb70a485f8fb8174c2f5e29f233c Mon Sep 17 00:00:00 2001 From: MehVahdJukaar Date: Sun, 17 Nov 2024 00:10:45 +0100 Subject: [PATCH] fire block fix --- changelog.md | 3 ++- .../core/mixins/forge/FireBlockMixin.java | 17 ++++++++++------- gradle.properties | 2 +- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/changelog.md b/changelog.md index 06a636dfc..141aeaaac 100644 --- a/changelog.md +++ b/changelog.md @@ -1 +1,2 @@ -- improved fake level api by adding an experimental fake server level \ No newline at end of file +- fixed fire block consumed event not working on forge +- fixed fake server level not firing forge level unload event \ No newline at end of file diff --git a/forge/src/main/java/net/mehvahdjukaar/moonlight/core/mixins/forge/FireBlockMixin.java b/forge/src/main/java/net/mehvahdjukaar/moonlight/core/mixins/forge/FireBlockMixin.java index 5140cdc42..4daf2244c 100644 --- a/forge/src/main/java/net/mehvahdjukaar/moonlight/core/mixins/forge/FireBlockMixin.java +++ b/forge/src/main/java/net/mehvahdjukaar/moonlight/core/mixins/forge/FireBlockMixin.java @@ -1,5 +1,7 @@ package net.mehvahdjukaar.moonlight.core.mixins.forge; +import com.llamalad7.mixinextras.injector.wrapoperation.Operation; +import com.llamalad7.mixinextras.injector.wrapoperation.WrapOperation; import com.llamalad7.mixinextras.sugar.Local; import com.llamalad7.mixinextras.sugar.Share; import com.llamalad7.mixinextras.sugar.ref.LocalRef; @@ -25,15 +27,16 @@ protected FireBlockMixin(Properties settings, float damage) { super(settings, damage); } - @Inject(method = "tryCatchFire", + @WrapOperation(method = "tryCatchFire", at = @At(value = "INVOKE", - target = "net/minecraft/world/level/Level.removeBlock (Lnet/minecraft/core/BlockPos;Z)Z", - shift = At.Shift.AFTER)) - private void afterRemoveBlock(Level level, BlockPos pos, int chance, RandomSource pRandom, int age, - Direction face, CallbackInfo ci, @Local BlockState before) { - var event = IFireConsumeBlockEvent.create(pos, level, before, chance, age, face); + target = "net/minecraft/world/level/Level.removeBlock (Lnet/minecraft/core/BlockPos;Z)Z")) + private boolean afterRemoveBlock(Level level, BlockPos pos, boolean isMoving, Operation original, + @Local BlockState oldState, @Local(ordinal = 0, argsOnly = true) int chance, + @Local(ordinal = 1, argsOnly = true) int age, @Local(argsOnly = true) Direction face) { + var event = IFireConsumeBlockEvent.create(pos, level, oldState, chance, age, face); MoonlightEventsHelper.postEvent(event, IFireConsumeBlockEvent.class); BlockState newState = event.getFinalState(); - if (newState != null) level.setBlockAndUpdate(pos, newState); + if (newState != null) return level.setBlockAndUpdate(pos, newState); + else return original.call(level, pos, isMoving); } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 74e324ce5..d7101b6bc 100644 --- a/gradle.properties +++ b/gradle.properties @@ -4,7 +4,7 @@ minecraft_version = 1.20.1 enabled_platforms = fabric,forge mod_id = moonlight -mod_version = 1.20-2.13.25 +mod_version = 1.20-2.13.26 maven_group = net.mehvahdjukaar project_id = 499980