Skip to content

Commit

Permalink
Remove block entity parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinthegreat1 committed Oct 25, 2023
1 parent f4a2ee1 commit 92f136b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@

package net.fabricmc.fabric.api.event.client.player;

import org.jetbrains.annotations.Nullable;

import net.minecraft.block.BlockState;
import net.minecraft.block.entity.BlockEntity;
import net.minecraft.entity.player.PlayerEntity;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
Expand All @@ -39,9 +36,9 @@ public class ClientPlayerBlockBreakEvents {
* <p>Only called client side.
*/
public static final Event<After> AFTER = EventFactory.createArrayBacked(After.class,
(listeners) -> (world, player, pos, state, entity) -> {
(listeners) -> (world, player, pos, state) -> {
for (After event : listeners) {
event.afterBlockBreak(world, player, pos, state, entity);
event.afterBlockBreak(world, player, pos, state);
}
}
);
Expand All @@ -51,12 +48,11 @@ public interface After {
/**
* Called after a block is successfully broken.
*
* @param world the world where the block was broken
* @param world the world where the block was broken
* @param player the player who broke the block
* @param pos the position where the block was broken
* @param state the block state <strong>before</strong> the block was broken
* @param blockEntity the block entity of the broken block, can be {@code null}
* @param pos the position where the block was broken
* @param state the block state <strong>before</strong> the block was broken
*/
void afterBlockBreak(World world, PlayerEntity player, BlockPos pos, BlockState state, @Nullable BlockEntity blockEntity);
void afterBlockBreak(World world, PlayerEntity player, BlockPos pos, BlockState state);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ private void fabric_fireAttackBlockCallback(BlockPos pos, Direction direction, C

@Inject(method = "breakBlock", at = @At(value = "INVOKE", target = "Lnet/minecraft/block/Block;onBroken(Lnet/minecraft/world/WorldAccess;Lnet/minecraft/util/math/BlockPos;Lnet/minecraft/block/BlockState;)V"), locals = LocalCapture.CAPTURE_FAILHARD)
private void fabric$onBlockBroken(BlockPos pos, CallbackInfoReturnable<Boolean> cir, World world, BlockState blockState) {
ClientPlayerBlockBreakEvents.AFTER.invoker().afterBlockBreak(world, this.client.player, pos, blockState, world.getBlockEntity(pos));
ClientPlayerBlockBreakEvents.AFTER.invoker().afterBlockBreak(world, this.client.player, pos, blockState);
}

@Inject(at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayerInteractionManager;sendSequencedPacket(Lnet/minecraft/client/world/ClientWorld;Lnet/minecraft/client/network/SequencedPacketCreator;)V"), method = "interactBlock", cancellable = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ public class ClientPlayerBlockBreakTests implements ClientModInitializer {

@Override
public void onInitializeClient() {
ClientPlayerBlockBreakEvents.AFTER.register(((world, player, pos, state, entity) -> LOGGER.info("Block broken at {}, {}, {} (client-side = {})", pos.getX(), pos.getY(), pos.getZ(), world.isClient())));
ClientPlayerBlockBreakEvents.AFTER.register(((world, player, pos, state) -> LOGGER.info("Block broken at {}, {}, {} (client-side = {})", pos.getX(), pos.getY(), pos.getZ(), world.isClient())));
}
}

0 comments on commit 92f136b

Please sign in to comment.