Skip to content

Commit 308d526

Browse files
Fix explosion mixin that caused crash
1 parent 34cf02f commit 308d526

File tree

2 files changed

+7
-23
lines changed

2 files changed

+7
-23
lines changed

fabric/src/main/java/me/moros/bending/fabric/mixin/ExplosionMixin.java

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,41 +19,25 @@
1919

2020
package me.moros.bending.fabric.mixin;
2121

22-
import java.util.Collections;
2322
import java.util.List;
2423

24+
import com.llamalad7.mixinextras.injector.WrapWithCondition;
2525
import me.moros.bending.fabric.event.ServerItemEvents;
2626
import net.minecraft.core.BlockPos;
2727
import net.minecraft.server.level.ServerLevel;
2828
import net.minecraft.world.InteractionResult;
2929
import net.minecraft.world.item.ItemStack;
3030
import net.minecraft.world.level.Explosion;
3131
import net.minecraft.world.level.Level;
32-
import net.minecraft.world.level.block.state.BlockState;
33-
import net.minecraft.world.level.storage.loot.LootParams;
34-
import net.minecraft.world.level.storage.loot.parameters.LootContextParams;
35-
import org.spongepowered.asm.mixin.Final;
3632
import org.spongepowered.asm.mixin.Mixin;
37-
import org.spongepowered.asm.mixin.Shadow;
3833
import org.spongepowered.asm.mixin.injection.At;
39-
import org.spongepowered.asm.mixin.injection.Redirect;
4034

4135
@Mixin(Explosion.class)
4236
public abstract class ExplosionMixin {
43-
@Shadow
44-
@Final
45-
private Level level;
46-
47-
@Redirect(method = "finalizeExplosion", at = @At(value = "INVOKE",
48-
target = "Lnet/minecraft/world/level/block/state/BlockState;getDrops(Lnet/minecraft/world/level/storage/loot/LootParams$Builder;)Ljava/util/List;")
49-
)
50-
private List<ItemStack> bending$blockDrops(BlockState state, LootParams.Builder builder) {
51-
var stacks = state.getDrops(builder);
52-
var pos = BlockPos.containing(builder.getParameter(LootContextParams.ORIGIN));
53-
var result = ServerItemEvents.BLOCK_DROP_LOOT.invoker().onDropLoot((ServerLevel) level, pos, stacks);
54-
if (result.getResult() != InteractionResult.FAIL) {
55-
return result.getObject();
56-
}
57-
return Collections.emptyList();
37+
@WrapWithCondition(method = "finalizeExplosion", at = @At(value = "INVOKE",
38+
target = "Lnet/minecraft/world/level/block/Block;popResource(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/item/ItemStack;)V"))
39+
private boolean bending$blockDrops(Level level, BlockPos pos, ItemStack itemStack) {
40+
var result = ServerItemEvents.BLOCK_DROP_LOOT.invoker().onDropLoot((ServerLevel) level, pos, List.of(itemStack));
41+
return result.getResult() != InteractionResult.FAIL;
5842
}
5943
}

fabric/src/main/resources/fabric.mod.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
],
2626
"depends": {
2727
"fabric": "*",
28-
"fabricloader": ">=0.14.12",
28+
"fabricloader": ">=0.15.0",
2929
"minecraft": ">=1.20.4",
3030
"cloud": "*",
3131
"adventure-platform-fabric": "*"

0 commit comments

Comments
 (0)