[Scarpet] Added ability to cancel events (#1497)
* Added ability to cancel events * Made more events cancellable * Added event_priority to __config * Check for string values for performance * Made player_finishes_using_item cancellable * Made player_chooses_recipe cancellable * Made player_swaps_hands cancellable * Made player_message cancellable * Added __on_player_placing_block (#1498) * Added event to docs, keywords, event_test * Added docs for event cancellation
This commit is contained in:
1 parent
4bb4b557e5
commit
24b9c386ec
14 files changed
+243
-99
No files matched your search
@@ -38,14 +38,18 @@ public class ServerPlayerGameMode_scarpetEventsMixin implements ServerPlayerInte
|
||||
|
||||
@Shadow public ServerLevel level;
|
||||
|
||||
@Inject(method = "destroyBlock", locals = LocalCapture.CAPTURE_FAILHARD, at = @At(
|
||||
@Inject(method = "destroyBlock", locals = LocalCapture.CAPTURE_FAILHARD, cancellable = true, at = @At(
|
||||
value = "INVOKE",
|
||||
target = "Lnet/minecraft/world/level/block/Block;playerWillDestroy(Lnet/minecraft/world/level/Level;Lnet/minecraft/core/BlockPos;Lnet/minecraft/world/level/block/state/BlockState;Lnet/minecraft/world/entity/player/Player;)V",
|
||||
shift = At.Shift.BEFORE
|
||||
))
|
||||
private void onBlockBroken(BlockPos blockPos_1, CallbackInfoReturnable<Boolean> cir, BlockState blockState_1, BlockEntity be, Block b)
|
||||
{
|
||||
PLAYER_BREAK_BLOCK.onBlockBroken(player, blockPos_1, blockState_1);
|
||||
if(PLAYER_BREAK_BLOCK.onBlockBroken(player, blockPos_1, blockState_1)) {
|
||||
this.level.sendBlockUpdated(blockPos_1, blockState_1, blockState_1, 3);
|
||||
cir.setReturnValue(false);
|
||||
cir.cancel();
|
||||
}
|
||||
}
|
||||
|
||||
@Inject(method = "useItemOn", at = @At(
|
||||
|
||||
Reference in new issue
Block a user