@SubscribeEvent public void onLeftClickBlock(LeftClickBlock event) { if (event.getWorld().isRemote) { return; } if (Main.isPlayerInteractionAllowed()) { return; } // Not my business Main.console("[TERRITORIAL DEALINGS] Block at x " + event.getPos().getX() + " / y " + event.getPos().getY() + " / z " + event.getPos().getZ() + " hit by player " + event.getEntityPlayer().getName() + "."); Chunk chunk = event.getEntityPlayer().worldObj.getChunkFromBlockCoords(event.getPos()); if (TerritoryHandler.canPlayerEditChunk(event.getEntityPlayer(), chunk)) // Checks out { Main.console("[TERRITORIAL DEALINGS] Player is allowed to interact with this chunk. Doing nothing."); } else { Main.console("[TERRITORIAL DEALINGS] Player is not allowed to interact with this chunk. Cancelling."); event.setCanceled(true); // Not having it } }
@SubscribeEvent public void onLeftClickBlock(LeftClickBlock event) { if (event.getWorld().isRemote) { return; } // Not doing this on client side if (!Main.shouldCheckInteraction()) { return; } // Not my business Main.console("Block at x" + event.getPos().getX() + " y" + event.getPos().getY() + " z" + event.getPos().getZ() + " hit by player " + event.getEntityPlayer().getName() + " (ID " + event.getEntityPlayer().getGameProfile().getId() + ")."); Chunk chunk = event.getEntityPlayer().worldObj.getChunkFromBlockCoords(event.getPos()); if (TerritoryHandler.canPlayerEditChunk(event.getEntityPlayer().worldObj, event.getEntityPlayer(), chunk)) // Checks out { Main.console("Player is allowed to interact with this chunk. Doing nothing."); } else { Main.console("Player is not allowed to interact with this chunk. Cancelling."); event.setCanceled(true); // Not having it } }
@Test public void test_player_can_leftclick_on_blockpos() { // Given: mc().player().setPosition(playerPos); mc().player().setRotationYaw(0); mc().setBlock(clickPos, Blocks.DIRT); EnumFacing facing = EnumFacing.UP; // When: mc().player().leftclick(clickPos, facing); // Then: LeftClickBlock act = mc().waitFor(LeftClickBlock.class); assertThat(act.getPos()).isEqualTo(clickPos); assertThat(act.getFace()).isEqualTo(facing); }
@SubscribeEvent public void onEvent(LeftClickBlock evt) { // TODO can we remove this check? if (evt.getWorld().isRemote) { return; } addEvent(evt); }
@SubscribeEvent public void onBlockClicked(LeftClickBlock event) { if (event.getEntityPlayer().isCreative()) if (event.getEntityPlayer().getHeldItemMainhand().getItem() instanceof ItemDagger) event.setCanceled(true); }
@SubscribeEvent public void onLeftClickBlock(LeftClickBlock event) { dueProcess(event, RegionSelector::selectPrimary); }
/** Left click event */ @SubscribeEvent public void onRightClickSystem(LeftClickBlock e) { securityCanceler(e); }