Java 类net.minecraftforge.event.entity.player.PlayerInteractEvent.LeftClickBlock 实例源码

项目:minecraft-territorialdealings    文件:EventListener.java   
@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
    }
}
项目:minecraft-territorialdealings    文件:EventListener.java   
@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
    }
}
项目:wizards-of-lua    文件:TestEnvironmentTest.java   
@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);
}
项目:wizards-of-lua    文件:EventRecorder.java   
@SubscribeEvent
public void onEvent(LeftClickBlock evt) {
  // TODO can we remove this check?
  if (evt.getWorld().isRemote) {
    return;
  }
  addEvent(evt);
}
项目:KalStuff    文件:CoreEventHandler.java   
@SubscribeEvent
public void onBlockClicked(LeftClickBlock event)
{
    if (event.getEntityPlayer().isCreative())
        if (event.getEntityPlayer().getHeldItemMainhand().getItem() instanceof ItemDagger)
            event.setCanceled(true);

}
项目:HardVox    文件:SelectionListener.java   
@SubscribeEvent
public void onLeftClickBlock(LeftClickBlock event) {
    dueProcess(event, RegionSelector::selectPrimary);
}
项目:EZStorage2    文件:SecurityEvents.java   
/** Left click event */
@SubscribeEvent
public void onRightClickSystem(LeftClickBlock e) {
    securityCanceler(e);
}