Skip to content

Commit

Permalink
fire block fix
Browse files Browse the repository at this point in the history
  • Loading branch information
MehVahdJukaar committed Nov 16, 2024
1 parent 1f3bd7f commit 864ba23
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion changelog.md
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- improved fake level api by adding an experimental fake server level
- fixed fire block consumed event not working on forge
- fixed fake server level not firing forge level unload event
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<Boolean> 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);
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 864ba23

Please sign in to comment.