Package net.minecraftforge.event.entity.player

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


      if( stackInSlot.getItem().hasContainerItem() ) {
        ItemStack containerStack = stackInSlot.getItem().getContainerItemStack( stackInSlot );

        if( containerStack.isItemStackDamageable() && containerStack.getItemDamage() > containerStack.getMaxDamage() ) {
          MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( player, containerStack ) );
          device.getWorld().playSoundAtEntity( player, "random.break", 0.8F, 0.8F + player.worldObj.rand.nextFloat() * 0.4F );
          containerStack = null;
        }

        if( containerStack != null ) {
View Full Code Here


        if( stack.getItem().hasContainerItem() ) {
          ItemStack itemContainer = stack.getItem().getContainerItemStack( stack );

          if( itemContainer.isItemStackDamageable() && itemContainer.getItemDamage() > itemContainer.getMaxDamage() ) {
            MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( Utils.getFakePlayerFor( this ), itemContainer ) );
            itemContainer = null;
          }

          if( itemContainer != null && (!stack.getItem().doesContainerItemLeaveCraftingGrid( stack )) ) {
            if( subGrid.getStackInSlot( i ) == null ) {
View Full Code Here

                        ingredient.stackSize -= backpackInventory.decrStackSize(j, ingredient.stackSize).stackSize;
                        if(itemstack.getItem().hasContainerItem(itemstack)) {
                            ItemStack containerItem = itemstack.getItem().getContainerItem(itemstack);

                            if(containerItem.isItemStackDamageable() && containerItem.getItemDamage() > containerItem.getMaxDamage()) {
                                MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(entityPlayer, containerItem));
                                containerItem = null;
                            }

                            if(containerItem != null) {
                                if(backpackInventory.getStackInSlot(j) == null) {
View Full Code Here

            {
                held.stackSize--;
                if (held.stackSize == 0)
                {
                    player.inventory.mainInventory[player.inventory.currentItem] = null;
                    MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, held));
                }
            }
        }
        else
        {
View Full Code Here

        return event;
    }

    public static void onPlayerDestroyItem(EntityPlayer player, ItemStack stack)
    {
        MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, stack));
    }
View Full Code Here

      removeStack = true;
    } else if (stack.getItem().isDamageable() && (stack.getItemDamage() > stack.getMaxDamage())) {
      // Item stack is destroyed.
      removeStack = true;
      if (player != null)
        MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, stack));
    }
   
    // If the stack has been depleted, set it
    // to either null, or the container item.
    if (removeStack) {
View Full Code Here

      return;

    ItemStack container = itemstack.getItem().getContainerItem(itemstack);

    if (container.isItemStackDamageable() && container.getItemDamage() > container.getMaxDamage()) {
      MinecraftForge.EVENT_BUS.post(new PlayerDestroyItemEvent(player, container));
      container = null;
    }

    if (container != null) {
View Full Code Here

      {
        held.stackSize--;
        if ( held.stackSize == 0 )
        {
          player.inventory.mainInventory[player.inventory.currentItem] = null;
          MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( player, held ) );
        }
      }
    }
    else
    {
View Full Code Here

      item.damageItem( 1, getPlayerInv().player );

      if ( item.stackSize == 0 )
      {
        getPlayerInv().mainInventory[getPlayerInv().currentItem] = null;
        MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( getPlayerInv().player, item ) );
      }

      return true;
    }
    return false;
View Full Code Here

                {
                  held.stackSize--;
                  if ( held.stackSize == 0 )
                  {
                    player.inventory.mainInventory[player.inventory.currentItem] = null;
                    MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( player, held ) );
                  }
                }
                return true;
              }
            }
          }
          else
          {
            player.swingItem();
            NetworkHandler.instance.sendToServer( new PacketPartPlacement( x, y, z, face, getEyeOffset( player ) ) );
            return true;
          }
        }
        return false;
      }
    }

    if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
      host = ((IFMP) AppEng.instance.getIntegration( IntegrationType.FMP )).getOrCreateHost( tile );

    if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.ImmibisMicroblocks ) )
      host = ((IImmibisMicroblocks) AppEng.instance.getIntegration( IntegrationType.ImmibisMicroblocks )).getOrCreateHost( player, face, tile );

    // if ( held == null )
    {
      Block block = world.getBlock( x, y, z );
      if ( host != null && player.isSneaking() && block != null )
      {
        LookDirection dir = Platform.getPlayerRay( player, getEyeOffset( player ) );
        MovingObjectPosition mop = block.collisionRayTrace( world, x, y, z, dir.a, dir.b );
        if ( mop != null )
        {
          mop.hitVec = mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ );
          SelectedPart sPart = selectPart( player, host, mop.hitVec );
          if ( sPart != null && sPart.part != null )
            if ( sPart.part.onShiftActivate( player, mop.hitVec ) )
            {
              if ( world.isRemote )
              {
                NetworkHandler.instance.sendToServer( new PacketPartPlacement( x, y, z, face, getEyeOffset( player ) ) );
              }
              return true;
            }
        }
      }

    }

    if ( held == null || !(held.getItem() instanceof IPartItem) )
      return false;

    int te_x = x;
    int te_y = y;
    int te_z = z;

    if ( host == null && pass == PlaceType.PLACE_ITEM )
    {
      ItemStack is = AEApi.instance().blocks().blockMultiPart.stack( 1 );
      ItemBlock ib = (ItemBlock) is.getItem();
      ForgeDirection offset = ForgeDirection.UNKNOWN;

      Block blkID = world.getBlock( x, y, z );
      if ( blkID != null && !blkID.isReplaceable( world, x, y, z ) )
      {
        offset = side;
        if ( Platform.isServer() )
          side = side.getOpposite();
      }

      te_x = x + offset.offsetX;
      te_y = y + offset.offsetY;
      te_z = z + offset.offsetZ;

      tile = world.getTileEntity( te_x, te_y, te_z );
      if ( tile instanceof IPartHost )
        host = (IPartHost) tile;

      if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
        host = ((IFMP) AppEng.instance.getIntegration( IntegrationType.FMP )).getOrCreateHost( tile );

      if ( host == null && tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.ImmibisMicroblocks ) )
        host = ((IImmibisMicroblocks) AppEng.instance.getIntegration( IntegrationType.ImmibisMicroblocks )).getOrCreateHost( player, face, tile );

      if ( host == null && AEApi.instance().blocks().blockMultiPart.block().canPlaceBlockAt( world, te_x, te_y, te_z )
          && ib.placeBlockAt( is, player, world, te_x, te_y, te_z, side.ordinal(), 0.5f, 0.5f, 0.5f, 0 ) )
      {
        if ( !world.isRemote )
        {
          tile = world.getTileEntity( te_x, te_y, te_z );

          if ( tile instanceof IPartHost )
            host = (IPartHost) tile;

          pass = PlaceType.INTERACT_SECOND_PASS;
        }
        else
        {
          player.swingItem();
          NetworkHandler.instance.sendToServer( new PacketPartPlacement( x, y, z, face, getEyeOffset( player ) ) );
          return true;
        }
      }
      else if ( host != null && !host.canAddPart( held, side ) )
        return false;
    }

    if ( host == null )
      return false;

    if ( !host.canAddPart( held, side ) )
    {
      if ( pass == PlaceType.INTERACT_FIRST_PASS || pass == PlaceType.PLACE_ITEM )
      {
        te_x = x + side.offsetX;
        te_y = y + side.offsetY;
        te_z = z + side.offsetZ;

        Block blkID = world.getBlock( te_x, te_y, te_z );
        tile = world.getTileEntity( te_x, te_y, te_z );

        if ( tile != null && AppEng.instance.isIntegrationEnabled( IntegrationType.FMP ) )
          host = ((IFMP) AppEng.instance.getIntegration( IntegrationType.FMP )).getOrCreateHost( tile );

        if ( (blkID == null || blkID.isReplaceable( world, te_x, te_y, te_z ) || host != null) && side != ForgeDirection.UNKNOWN )
          return place( held, te_x, te_y, te_z, side.getOpposite().ordinal(), player, world,
              pass == PlaceType.INTERACT_FIRST_PASS ? PlaceType.INTERACT_SECOND_PASS : PlaceType.PLACE_ITEM, depth + 1 );
      }
      return false;
    }

    if ( !world.isRemote )
    {
      Block block = world.getBlock( x, y, z );
      LookDirection dir = Platform.getPlayerRay( player, getEyeOffset( player ) );
      MovingObjectPosition mop = block.collisionRayTrace( world, x, y, z, dir.a, dir.b );
      if ( mop != null )
      {
        SelectedPart sp = selectPart( player, host, mop.hitVec.addVector( -mop.blockX, -mop.blockY, -mop.blockZ ) );

        if ( sp.part != null )
        {
          if ( !player.isSneaking() && sp.part.onActivate( player, mop.hitVec ) )
            return false;
        }
      }

      DimensionalCoord dc = host.getLocation();
      if ( !Platform.hasPermissions( dc, player ) )
        return false;

      ForgeDirection mySide = host.addPart( held, side, player );
      if ( mySide != null )
      {
        SoundType ss = AEApi.instance().blocks().blockMultiPart.block().stepSound;

        // ss.getPlaceSound()
        world.playSoundEffect( 0.5 + x, 0.5 + y, 0.5 + z, ss.func_150496_b(), (ss.getVolume() + 1.0F) / 2.0F, ss.getPitch() * 0.8F );

        if ( !player.capabilities.isCreativeMode )
        {
          held.stackSize--;
          if ( held.stackSize == 0 )
          {
            player.inventory.mainInventory[player.inventory.currentItem] = null;
            MinecraftForge.EVENT_BUS.post( new PlayerDestroyItemEvent( player, held ) );
          }
        }
      }
    }
    else
View Full Code Here

TOP

Related Classes of net.minecraftforge.event.entity.player.PlayerDestroyItemEvent

Copyright © 2018 www.massapicom. 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.