Skip to content

Commit

Permalink
Fix MixinServerPlayerGameMode
Browse files Browse the repository at this point in the history
  • Loading branch information
wdog5734 committed Oct 16, 2024
1 parent b420a0a commit 5d171c4
Showing 1 changed file with 9 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.mohistmc.banner.mixin.server.level;

import com.llamalad7.mixinextras.sugar.Local;
import com.llamalad7.mixinextras.sugar.ref.LocalRef;
import com.mohistmc.banner.injection.server.level.InjectionServerPlayerGameMode;
import java.util.ArrayList;
import java.util.Objects;
Expand Down Expand Up @@ -269,6 +271,11 @@ public void handleBlockBreakAction(BlockPos blockposition, ServerboundPlayerActi
@Unique
private final AtomicReference<BlockBreakEvent> banner$event = new AtomicReference<>();

@Inject(method = "destroyBlock", at = @At("RETURN"))
private void banner$clearDrops(BlockPos blockPos, CallbackInfoReturnable<Boolean> cir) {
this.level.banner$setCaptureDrops(null);
}

@Inject(method = "destroyBlock", at = @At("HEAD"), cancellable = true)
private void banner$fireBreakEvent(BlockPos blockposition, CallbackInfoReturnable<Boolean> cir) {
BlockState iblockdata = this.level.getBlockState(blockposition);
Expand Down Expand Up @@ -358,9 +365,8 @@ public void handleBlockBreakAction(BlockPos blockposition, ServerboundPlayerActi
at = @At(value = "INVOKE",
target = "Lnet/minecraft/server/level/ServerLevel;getBlockEntity(Lnet/minecraft/core/BlockPos;)Lnet/minecraft/world/level/block/entity/BlockEntity;",
shift = At.Shift.BEFORE), locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true)
private void banner$resetState(BlockPos pos, CallbackInfoReturnable<Boolean> cir, BlockState blockState) {
blockState = this.level.getBlockState(pos); // CraftBukkit - update state from plugins
if (blockState.isAir()) cir.setReturnValue(false); // CraftBukkit - A plugin set block to air without cancelling
private void banner$resetState(BlockPos pos, CallbackInfoReturnable<Boolean> cir, @Local LocalRef<BlockState> blockState) { blockState.set(this.level.getBlockState(pos)); // CraftBukkit - update state from plugins
if (blockState.get().isAir()) cir.setReturnValue(false); // CraftBukkit - A plugin set block to air without cancelling
}

// CraftBukkit start - whole method
Expand Down

0 comments on commit 5d171c4

Please sign in to comment.