@Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int par6,
      float par7,
      float par8,
      float par9) {
    if (player.isSneaking()) return true;
    else if (world.isSideSolid(x, y + 1, z, ForgeDirection.DOWN)) return true;
    else {
      if (!world.isRemote) {
        TileEntityMagneticChest tileMagneticChest =
            (TileEntityMagneticChest) world.getTileEntity(x, y, z);

        if (tileMagneticChest != null) {
          player.displayGUIChest(tileMagneticChest);
        }
      }

      return true;
    }
  }
  /** First layer of player interaction */
  public boolean interactFirst(EntityPlayer playerIn) {
    if (net.minecraftforge.common.MinecraftForge.EVENT_BUS.post(
        new net.minecraftforge.event.entity.minecart.MinecartInteractEvent(this, playerIn)))
      return true;
    if (!this.worldObj.isRemote) {
      playerIn.displayGUIChest(this);
    }

    return true;
  }
 @Override
 public boolean onBlockActivated(
     World w, int x, int y, int z, EntityPlayer p, int i, float f, float f1, float f2) {
   if (w.isRemote) {
     return true;
   } else {
     IInventory iinventory = getInventory(w, x, y, z);
     if (iinventory != null) {
       p.displayGUIChest(iinventory);
     }
     return true;
   }
 }
Exemple #4
0
  @Override
  public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) {
    super.onItemRightClick(stack, world, player);

    McInvWorld worldObj =
        McPlayerInvManager.getInstance((world.isRemote) ? Side.CLIENT : Side.SERVER)
            .getPlayerInventory(player)
            .getWorld();
    EVecInt pos = new EVecInt(McInvWorld.getX(stack), McInvWorld.getY(stack));
    IEMachineryBag bag = (IEMachineryBag) worldObj.getItemEntity(worldObj.toEntry(pos));
    player.displayGUIChest(bag);

    return stack;
  }
  /** Called upon block activation (right click on the block.) */
  public boolean onBlockActivated(
      World world, int x, int y, int z, EntityPlayer player, int i, float f1, float f2, float f3) {
    if (world.isRemote) {
      return true;
    } else {
      IInventory iinventory = this.func_149951_m(world, x, y, z);

      if (iinventory != null) {
        player.displayGUIChest(iinventory);
      }

      return true;
    }
  }
  @Override
  /** Called upon block activation (right click on the block.) */
  protected void postOnBlockActivated(
      TEBase TE,
      EntityPlayer entityPlayer,
      int side,
      float hitX,
      float hitY,
      float hitZ,
      List<Boolean> altered,
      List<Boolean> decInv) {
    if (!Safe.isOpen(TE) && canPlayerActivate(TE, entityPlayer)) {

      TECarpentersSafe TE_safe = (TECarpentersSafe) TE;
      ItemStack itemStack = entityPlayer.getHeldItem();

      if (itemStack != null && itemStack.getItem().equals(Items.gold_ingot)) {
        if (!TE_safe.hasUpgrade()) {
          if (TE_safe.incSizeInventory()) {
            TE.getWorldObj().markBlockForUpdate(TE.xCoord, TE.yCoord, TE.zCoord);
            decInv.add(true);
            return;
          }
        }
      }

      if (!decInv.contains(true)) {
        entityPlayer.displayGUIChest((TECarpentersSafe) TE);
      }
    } else {
      ChatHandler.sendMessageToPlayer("message.block_lock.name", entityPlayer);
    }

    /*
     * Safe should always return true because it either warns the player
     * that it is locked, or it returns the GUI.
     */
    altered.add(true);
  }
  @Override
  public boolean interact(EntityPlayer entityPlayer) {
    // Only the owner can interact with extended spiders.
    if (owner.equals(entityPlayer.getUniqueID())) {
      // Pack spider displays its inventory.
      if (spiderType == EnumSpiderType.PACK) {
        entityPlayer.displayGUIChest(inventory);
      }

      // Rider spider causes the player to mount it.
      else if (spiderType == EnumSpiderType.RIDER) {
        entityPlayer.rotationYaw = rotationYaw;
        entityPlayer.rotationPitch = rotationPitch;

        if (!worldObj.isRemote) {
          entityPlayer.mountEntity(this);
        }
      }
    }

    return true;
  }
  public boolean onBlockActivated(
      World worldIn,
      BlockPos pos,
      IBlockState state,
      EntityPlayer playerIn,
      EnumFacing side,
      float hitX,
      float hitY,
      float hitZ) {
    if (worldIn.isRemote) {
      return true;
    } else {
      TileEntity tileentity = worldIn.getTileEntity(pos);

      if (tileentity instanceof TileEntityBrewingStand) {
        playerIn.displayGUIChest((TileEntityBrewingStand) tileentity);
        playerIn.triggerAchievement(StatList.field_181729_M);
      }

      return true;
    }
  }
  /** Called upon block activation (right click on the block.) */
  public boolean onBlockActivated(
      World par1World,
      int par2,
      int par3,
      int par4,
      EntityPlayer par5EntityPlayer,
      int par6,
      float par7,
      float par8,
      float par9) {
    if (par1World.isRemote) {

      return true;
    } else {
      IInventory iinventory = this.getInventory(par1World, par2, par3, par4);

      if (iinventory != null) {
        par5EntityPlayer.displayGUIChest(iinventory);
      }

      return true;
    }
  }
  @Override
  public boolean onBlockActivated(
      World par1World,
      int par2,
      int par3,
      int par4,
      EntityPlayer par5EntityPlayer,
      int par6,
      float par7,
      float par8,
      float par9) {
    Object var10 = par1World.getTileEntity(par2, par3, par4);

    if (var10 == null) {
      return true;
    } else if (par1World.isSideSolid(par2, par3 + 1, par4, ForgeDirection.DOWN)) {
      return true;
    } else if (T10TreasureChest.isOcelotBlockingChest(par1World, par2, par3, par4)) {
      return true;
    } else if (par1World.getBlock(par2 - 1, par3, par4) == this
        && (par1World.isSideSolid(par2 - 1, par3 + 1, par4, ForgeDirection.DOWN)
            || T10TreasureChest.isOcelotBlockingChest(par1World, par2 - 1, par3, par4))) {
      return true;
    } else if (par1World.getBlock(par2 + 1, par3, par4) == this
        && (par1World.isSideSolid(par2 + 1, par3 + 1, par4, ForgeDirection.DOWN)
            || T10TreasureChest.isOcelotBlockingChest(par1World, par2 + 1, par3, par4))) {
      return true;
    } else if (par1World.getBlock(par2, par3, par4 - 1) == this
        && (par1World.isSideSolid(par2, par3 + 1, par4 - 1, ForgeDirection.DOWN)
            || T10TreasureChest.isOcelotBlockingChest(par1World, par2, par3, par4 - 1))) {
      return true;
    } else if (par1World.getBlock(par2, par3, par4 + 1) == this
        && (par1World.isSideSolid(par2, par3 + 1, par4 + 1, ForgeDirection.DOWN)
            || T10TreasureChest.isOcelotBlockingChest(par1World, par2, par3, par4 + 1))) {
      return true;
    } else {
      if (par1World.getBlock(par2 - 1, par3, par4) == this) {
        var10 =
            new InventoryLargeChest(
                "container.chestDouble",
                (TileEntityT10TreasureChest) par1World.getTileEntity(par2 - 1, par3, par4),
                (IInventory) var10);
      }

      if (par1World.getBlock(par2 + 1, par3, par4) == this) {
        var10 =
            new InventoryLargeChest(
                "container.chestDouble",
                (IInventory) var10,
                (TileEntityT10TreasureChest) par1World.getTileEntity(par2 + 1, par3, par4));
      }

      if (par1World.getBlock(par2, par3, par4 - 1) == this) {
        var10 =
            new InventoryLargeChest(
                "container.chestDouble",
                (TileEntityT10TreasureChest) par1World.getTileEntity(par2, par3, par4 - 1),
                (IInventory) var10);
      }

      if (par1World.getBlock(par2, par3, par4 + 1) == this) {
        var10 =
            new InventoryLargeChest(
                "container.chestDouble",
                (IInventory) var10,
                (TileEntityT10TreasureChest) par1World.getTileEntity(par2, par3, par4 + 1));
      }

      if (par1World.isRemote) {
        return true;
      } else {
        par5EntityPlayer.displayGUIChest((IInventory) var10);
        return true;
      }
    }
  }