Examples of PlayerInteractEvent


Examples of net.minecraftforge.event.entity.player.PlayerInteractEvent

  // Copied from ItemInWorldManager, seems to do the trick.
  private void startBreaking(Block block, int meta) {
    int side = SIDES[(getBlockMetadata() & 7) - 2].getOpposite().ordinal();
    ChunkCoordinates coords = getTargetLoc();

    PlayerInteractEvent event = ForgeEventFactory.onPlayerInteract(player, Action.LEFT_CLICK_BLOCK, coords.posX, coords.posY, coords.posZ, side,worldObj);
    if (event.isCanceled()) {
      stopBreaking();
      return;
    }

    initialDamage = curblockDamage;
View Full Code Here

Examples of net.minecraftforge.event.entity.player.PlayerInteractEvent

  }
 
  @Override
  public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset)
  {
    PlayerInteractEvent e = new PlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, x, y, z, side);
    if(MinecraftForge.EVENT_BUS.post(e) || e.getResult() == Result.DENY || e.useBlock == Result.DENY)
    {
      return false;
    }
   
    if(MFRUtil.isHoldingHammer(player))
View Full Code Here

Examples of net.minecraftforge.event.entity.player.PlayerInteractEvent

  }
 
  @Override
  public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset)
  {
    PlayerInteractEvent e = new PlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, x, y, z, side);
    if(MinecraftForge.EVENT_BUS.post(e) || e.getResult() == Result.DENY || e.useBlock == Result.DENY)
    {
      return false;
    }
   
    TileEntity te = world.getBlockTileEntity(x, y, z);
View Full Code Here

Examples of net.minecraftforge.event.entity.player.PlayerInteractEvent

  }
 
  @Override
  public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer entityplayer, int side, float xOffset, float yOffset, float zOffset)
  {
    PlayerInteractEvent e = new PlayerInteractEvent(entityplayer, Action.RIGHT_CLICK_BLOCK, x, y, z, side);
    if(MinecraftForge.EVENT_BUS.post(e) || e.getResult() == Result.DENY || e.useBlock == Result.DENY)
    {
      return false;
    }
   
    TileEntity te = world.getBlockTileEntity(x, y, z);
View Full Code Here

Examples of net.minecraftforge.event.entity.player.PlayerInteractEvent

  }
 
  @Override
  public boolean onBlockActivated(World world, int x, int y, int z, EntityPlayer player, int side, float xOffset, float yOffset, float zOffset)
  {
    PlayerInteractEvent e = new PlayerInteractEvent(player, Action.RIGHT_CLICK_BLOCK, x, y, z, side);
    if(MinecraftForge.EVENT_BUS.post(e) || e.getResult() == Result.DENY || e.useBlock == Result.DENY)
    {
      return false;
    }
   
    ItemStack s = player.inventory.getCurrentItem();
View Full Code Here

Examples of net.minecraftforge.event.entity.player.PlayerInteractEvent

    {
        return onPlayerInteract(player, action, x, y, z, face, null);
    }
    public static PlayerInteractEvent onPlayerInteract(EntityPlayer player, Action action, int x, int y, int z, int face, World world)
    {
        PlayerInteractEvent event = new PlayerInteractEvent(player, action, x, y, z, face, world);
        MinecraftForge.EVENT_BUS.post(event);
        return event;
    }
View Full Code Here

Examples of net.minecraftforge.event.entity.player.PlayerInteractEvent

    }

    @Override
    public int emitRedstoneOnEvent(Event event, TileEntity sensor, int range, int toolX, int toolY, int toolZ){
        if(event instanceof PlayerInteractEvent) {
            PlayerInteractEvent interactEvent = (PlayerInteractEvent)event;
            if(interactEvent.x == toolX && interactEvent.y == toolY && interactEvent.z == toolZ) {
                return 15;
            }
        }
        return 0;
View Full Code Here

Examples of org.bukkit.event.player.PlayerInteractEvent

    public static boolean canUse(Player player, Location loc, BlockFace face, Action action) {

        if (!shouldUseProtection()) return true;
        if (CraftBookPlugin.inst().getConfiguration().advancedBlockChecks) {

            PlayerInteractEvent event = new PlayerInteractEvent(player, action == null ? Action.RIGHT_CLICK_BLOCK : action, player.getItemInHand(), loc.getBlock(), face == null ? BlockFace.SELF : face);
            EventUtil.ignoreEvent(event);
            CraftBookPlugin.inst().getServer().getPluginManager().callEvent(event);
            return !event.isCancelled();
        }
        if (!CraftBookPlugin.inst().getConfiguration().obeyWorldguard) return true;
        return CraftBookPlugin.plugins.getWorldGuard() == null || CraftBookPlugin.plugins.getWorldGuard().createProtectionQuery().testBlockInteract(player, loc.getBlock());
    }
View Full Code Here

Examples of org.bukkit.event.player.PlayerInteractEvent

        EventExecutor executor = new EventExecutor() {
            public void execute(Listener listener, Event event) {}
        };
        TestPlugin plugin = new TestPlugin("Test");

        PlayerInteractEvent interactEvent = new PlayerInteractEvent(null, null, null, null, null);
        PlayerMoveEvent moveEvent = new PlayerMoveEvent(null, null, null);
        BlockBreakEvent breakEvent = new BlockBreakEvent(null, null);

        TimedRegisteredListener trl = new TimedRegisteredListener(listener, executor, EventPriority.NORMAL, plugin, false);
View Full Code Here

Examples of org.bukkit.event.player.PlayerInteractEvent

            Block eventBlock = block;
            if (player.getLocation().distanceSquared(block.getLocation()) > 36 || block.getTypeId() == 0) {
                action = Action.LEFT_CLICK_AIR;
                eventBlock = null;
            }
            PlayerInteractEvent interactEvent = EventFactory.onPlayerInteract(player, action, eventBlock, face);

            // blocks don't get interacted with on left click, so ignore that
            // attempt to use item in hand, that is, dig up the block
            if (!BlockPlacementHandler.selectResult(interactEvent.useItemInHand(), true)) {
                // the event was cancelled, get out of here
                revert = true;
            } else {
                // emit damage event - cancel by default if holding a sword
                boolean instaBreak = player.getGameMode() == GameMode.CREATIVE;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.