Skip to content

Commit

Permalink
Revert "Fix #104"
Browse files Browse the repository at this point in the history
This reverts commit b01c455.
  • Loading branch information
IThundxr committed Nov 2, 2024
1 parent e8810f4 commit 54e8f8d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,4 +90,20 @@ public static void onPlayerJoin(ServerPlayer player) {
}
}
}

@MultiLoaderEvent
public static InteractionResult onUseBlock(Player player, Level level, InteractionHand hand, BlockHitResult hitResult) {
BlockPos pos = hitResult.getBlockPos();
BlockState state = level.getBlockState(pos);

boolean offhandFix = !level.isClientSide()
&& !player.getOffhandItem().isEmpty()
&& !(player.getOffhandItem().getItem() instanceof BlockItem) &&
hand.equals(InteractionHand.MAIN_HAND);
if ((offhandFix || player.isShiftKeyDown()) && state.getBlock() instanceof VendorBlock vb) {
return vb.use(state, level, pos, player, hand, hitResult);
}

return InteractionResult.PASS;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@
public class NumismaticsBlockEntities {
private static final CreateRegistrate REGISTRATE = Numismatics.registrate();

/* public static final BlockEntityEntry<SemaphoreBlockEntity> SEMAPHORE = REGISTRATE.blockEntity("semaphore", SemaphoreBlockEntity::new)
.validBlocks(CRBlocks.SEMAPHORE)
.renderer(() -> SemaphoreRenderer::new)
.register();*/

public static final BlockEntityEntry<AndesiteDepositorBlockEntity> ANDESITE_DEPOSITOR = REGISTRATE.blockEntity("andesite_depositor", AndesiteDepositorBlockEntity::new)
.validBlocks(NumismaticsBlocks.ANDESITE_DEPOSITOR)
.register();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ public static void init() {
ServerWorldEvents.LOAD.register((server, level) -> CommonEvents.onLoadWorld(level));
PlayerBlockBreakEvents.BEFORE.register((level, player, pos, state, entity) -> CommonEvents.onBlockBreak(level, pos, state, player));
ServerPlayConnectionEvents.JOIN.register((connection, packetSender, server) -> CommonEvents.onPlayerJoin(connection.player));
UseBlockCallback.EVENT.register((player, world, hand, hitResult) -> CommonEvents.onUseBlock(player, world, hand, hitResult));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,9 @@ public static void onPlayerJoin(PlayerEvent.PlayerLoggedInEvent event) {
if (event.getEntity() instanceof ServerPlayer serverPlayer)
CommonEvents.onPlayerJoin(serverPlayer);
}

@SubscribeEvent
public static void onRightClickBlock(PlayerInteractEvent.RightClickBlock event) {
CommonEvents.onUseBlock(event.getEntity(), event.getLevel(), event.getHand(), event.getHitVec());
}
}

0 comments on commit 54e8f8d

Please sign in to comment.