Example #1
0
  @Override
  public boolean onBlockActivated(
      World par1World,
      int par2,
      int par3,
      int par4,
      EntityPlayer par5EntityPlayer,
      int par6,
      float par7,
      float par8,
      float par9) {
    if (par5EntityPlayer.isSneaking()) {
      TileRuneAltar altar = (TileRuneAltar) par1World.getTileEntity(par2, par3, par4);

      if (altar.manaToGet == 0)
        for (int i = altar.getSizeInventory() - 1; i >= 0; i--) {
          ItemStack stackAt = altar.getStackInSlot(i);
          if (stackAt != null) {
            ItemStack copy = stackAt.copy();
            if (!par5EntityPlayer.inventory.addItemStackToInventory(copy))
              par5EntityPlayer.dropPlayerItemWithRandomChoice(copy, false);
            altar.setInventorySlotContents(i, null);
            par1World.func_147453_f(par2, par3, par4, this);
            break;
          }
        }
    } else {
      ItemStack stack = par5EntityPlayer.getCurrentEquippedItem();
      if (stack != null)
        return ((TileRuneAltar) par1World.getTileEntity(par2, par3, par4))
            .addItem(par5EntityPlayer, stack);
    }
    return false;
  }
  /**
   * Called on server worlds only when the block has been replaced by a different block ID, or the
   * same block with a different metadata value, but before the new metadata value is set. Args:
   * World, x, y, z, old block ID, old metadata
   */
  public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) {
    TileEntityBoundChest tileentitychest =
        (TileEntityBoundChest) par1World.getTileEntity(par2, par3, par4);

    if (tileentitychest != null) {
      this.dropItem(
          new ItemStack(
              ThaumicExploration.blankSeal,
              1,
              15
                  - ((TileEntityBoundChest) par1World.getTileEntity(par2, par3, par4))
                      .getSealColor()),
          par1World,
          par2,
          par3,
          par4);
      for (int j1 = 0; j1 < tileentitychest.getSizeInventory(); ++j1) {
        ItemStack itemstack = tileentitychest.getStackInSlot(j1);
        this.dropItem(itemstack, par1World, par2, par3, par4);
      }

      par1World.func_147453_f(par2, par3, par4, par5);
    }

    super.breakBlock(par1World, par2, par3, par4, par5, par6);
  }
Example #3
0
  @Override
  public void breakBlock(World world, int x, int y, int z, Block par5, int par6) {
    DummyTile dummy = (DummyTile) world.getTileEntity(x, y, z);
    AbstractCore core = dummy.getCore();

    if (core != null && !world.isRemote) {
      core.setDirty();
    }

    Block block = dummy.getStoredBlock();
    int meta = dummy.getMetadata();

    if (world.isAirBlock(x, y, z)) {
      float f = world.rand.nextFloat() * 0.8F + 0.1F;
      float f1 = world.rand.nextFloat() * 0.8F + 0.1F;
      float f2 = world.rand.nextFloat() * 0.8F + 0.1F;

      EntityItem entityitem =
          new EntityItem(
              world,
              (double) x + f,
              (double) y + f1,
              (double) z + f2,
              new ItemStack(block, 1, meta));
      world.spawnEntityInWorld(entityitem);
      world.func_147453_f(x, y, z, par5);
    }
    super.breakBlock(world, x, y, z, par5, par6);
  }
  @Override
  public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) {
    TileEntity tile = par1World.getTileEntity(par2, par3, par4);
    OrderExchanger tileentity = null;
    if (tile != null && tile instanceof OrderExchanger) {
      tileentity = (OrderExchanger) tile;
    }

    if (tileentity != null) {

      ItemStack drop = new ItemStack(this, 1, 0);
      NBTTagCompound tag = new NBTTagCompound();
      tag = tileentity.getNBT(tag);
      drop.setTagCompound(tag);
      EntityItem entityitem =
          new EntityItem(par1World, par2 + 0.5D, par3 + 0.5D, par4 + 0.5D, drop);
      float f3 = 0.05F;
      entityitem.motionX = (float) this.rand.nextGaussian() * f3;
      entityitem.motionY = (float) this.rand.nextGaussian() * f3 + 0.2F;
      entityitem.motionZ = (float) this.rand.nextGaussian() * f3;
      par1World.spawnEntityInWorld(entityitem);

      par1World.func_147453_f(par2, par3, par4, par5);
    }
  }
  @Override
  public void breakBlock(
      World p_149749_1_,
      int p_149749_2_,
      int p_149749_3_,
      int p_149749_4_,
      Block p_149749_5_,
      int p_149749_6_) {
    if (!keepInventory) {
      TileEntityLaunchPad tileentityfurnace =
          (TileEntityLaunchPad) p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);

      if (tileentityfurnace != null) {
        for (int i1 = 0; i1 < tileentityfurnace.getSizeInventory(); ++i1) {
          ItemStack itemstack = tileentityfurnace.getStackInSlot(i1);

          if (itemstack != null) {
            float f = LaunchPad.field_149933_a.nextFloat() * 0.8F + 0.1F;
            float f1 = LaunchPad.field_149933_a.nextFloat() * 0.8F + 0.1F;
            float f2 = LaunchPad.field_149933_a.nextFloat() * 0.8F + 0.1F;

            while (itemstack.stackSize > 0) {
              int j1 = LaunchPad.field_149933_a.nextInt(21) + 10;

              if (j1 > itemstack.stackSize) {
                j1 = itemstack.stackSize;
              }

              itemstack.stackSize -= j1;
              EntityItem entityitem =
                  new EntityItem(
                      p_149749_1_,
                      p_149749_2_ + f,
                      p_149749_3_ + f1,
                      p_149749_4_ + f2,
                      new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));

              if (itemstack.hasTagCompound()) {
                entityitem
                    .getEntityItem()
                    .setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
              }

              float f3 = 0.05F;
              entityitem.motionX = (float) LaunchPad.field_149933_a.nextGaussian() * f3;
              entityitem.motionY = (float) LaunchPad.field_149933_a.nextGaussian() * f3 + 0.2F;
              entityitem.motionZ = (float) LaunchPad.field_149933_a.nextGaussian() * f3;
              p_149749_1_.spawnEntityInWorld(entityitem);
            }
          }
        }

        p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
      }
    }

    super.breakBlock(p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
  }
Example #6
0
  @Override
  public void breakBlock(World par1World, int par2, int par3, int par4, Block par5, int par6) {
    TileEntity tile = par1World.getTileEntity(par2, par3, par4);
    if (!(tile instanceof TileSimpleInventory)) return;

    TileSimpleInventory inv = (TileSimpleInventory) tile;

    if (inv != null) {
      for (int j1 = 0; j1 < inv.getSizeInventory(); ++j1) {
        ItemStack itemstack = inv.getStackInSlot(j1);

        if (itemstack != null) {
          float f = random.nextFloat() * 0.8F + 0.1F;
          float f1 = random.nextFloat() * 0.8F + 0.1F;
          EntityItem entityitem;

          for (float f2 = random.nextFloat() * 0.8F + 0.1F;
              itemstack.stackSize > 0;
              par1World.spawnEntityInWorld(entityitem)) {
            int k1 = random.nextInt(21) + 10;

            if (k1 > itemstack.stackSize) k1 = itemstack.stackSize;

            itemstack.stackSize -= k1;
            entityitem =
                new EntityItem(
                    par1World,
                    par2 + f,
                    par3 + f1,
                    par4 + f2,
                    new ItemStack(itemstack.getItem(), k1, itemstack.getItemDamage()));
            float f3 = 0.05F;
            entityitem.motionX = (float) random.nextGaussian() * f3;
            entityitem.motionY = (float) random.nextGaussian() * f3 + 0.2F;
            entityitem.motionZ = (float) random.nextGaussian() * f3;

            if (itemstack.hasTagCompound())
              entityitem
                  .getEntityItem()
                  .setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
          }
        }
      }

      par1World.func_147453_f(par2, par3, par4, par5);
    }

    super.breakBlock(par1World, par2, par3, par4, par5, par6);
  }
Example #7
0
  public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
    if (!isBurning) {
      Crusher_TileEntity Crusher_TileEntity = (Crusher_TileEntity) world.getTileEntity(x, y, z);

      if (Crusher_TileEntity != null) {
        for (int i = 0; i < Crusher_TileEntity.getSizeInventory(); ++i) {
          ItemStack itemstack = Crusher_TileEntity.getStackInSlot(i);

          if (itemstack != null) {
            float f = this.random.nextFloat() * 0.6F + 0.1F;
            float f1 = this.random.nextFloat() * 0.6F + 0.1F;
            float f2 = this.random.nextFloat() * 0.6F + 0.1F;

            while (itemstack.stackSize > 0) {
              int j = this.random.nextInt(21) + 10;

              if (j > itemstack.stackSize) {
                j = itemstack.stackSize;
              }

              itemstack.stackSize -= j;
              EntityItem entityitem =
                  new EntityItem(
                      world,
                      (double) ((float) x + f),
                      (double) ((float) y + f1),
                      (double) ((float) z + f2),
                      new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));

              if (itemstack.hasTagCompound()) {
                entityitem
                    .getEntityItem()
                    .setTagCompound(((NBTTagCompound) itemstack.getTagCompound().copy()));
              }

              float f3 = 0.025F;
              entityitem.motionX = (double) ((float) this.random.nextGaussian() * f3);
              entityitem.motionY = (double) ((float) this.random.nextGaussian() * f3 + 0.1F);
              entityitem.motionZ = (double) ((float) this.random.nextGaussian() * f3);
              world.spawnEntityInWorld(entityitem);
            }
          }
        }
        world.func_147453_f(x, y, z, block);
      }
    }
    super.breakBlock(world, x, y, z, block, meta);
  }
Example #8
0
  public void breakBlock(World world, int x, int y, int z, Block oldblock, int oldMetadata) {
    if (!keepInventory) {
      TileEntityIBROIFurnace tileentity = (TileEntityIBROIFurnace) world.getTileEntity(x, y, z);

      if (tileentity != null) {
        for (int i = 0; i < tileentity.getSizeInventory(); i++) {
          ItemStack itemstack = tileentity.getStackInSlot(i);

          if (itemstack != null) {
            float f = this.rand.nextFloat() * 0.8F + 0.1F;
            float f1 = this.rand.nextFloat() * 0.8F + 0.1F;
            float f2 = this.rand.nextFloat() * 0.8F + 0.1F;

            while (itemstack.stackSize > 0) {
              int j = this.rand.nextInt(21) + 10;

              if (j > itemstack.stackSize) {
                j = itemstack.stackSize;
              }

              itemstack.stackSize -= j;

              EntityItem item =
                  new EntityItem(
                      world,
                      (double) ((float) x + f),
                      (double) ((float) y + f1),
                      (double) ((float) z + f2),
                      new ItemStack(itemstack.getItem(), j, itemstack.getItemDamage()));

              if (itemstack.hasTagCompound()) {
                item.getEntityItem()
                    .setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
              }

              world.spawnEntityInWorld(item);
            }
          }
        }

        world.func_147453_f(x, y, z, oldblock);
      }
    }

    super.breakBlock(world, x, y, z, oldblock, oldMetadata);
  }
Example #9
0
  @Override
  public void breakBlock(World world, int x, int y, int z, Block block, int meta) {
    if (world.getTileEntity(x, y, z) instanceof TEHopper) {
      TEHopper te = (TEHopper) world.getTileEntity(x, y, z);

      for (int i1 = 0; i1 < te.getSizeInventory(); ++i1) {
        ItemStack itemstack = te.getStackInSlot(i1);

        if (itemstack != null) {
          while (itemstack.stackSize > 0) {
            int j1 = this.random.nextInt(21) + 10;

            if (j1 > itemstack.stackSize) {
              j1 = itemstack.stackSize;
            }

            itemstack.stackSize -= j1;
            EntityItem entityitem =
                new EntityItem(
                    world,
                    x + 0.5f,
                    y + 0.5f,
                    z + 0.5f,
                    new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));

            if (itemstack.hasTagCompound()) {
              entityitem
                  .getEntityItem()
                  .setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
            }

            // float f3 = 0.05F;
            world.spawnEntityInWorld(entityitem);
          }
        }
      }
      if (te.pressBlock != null) {
        EntityItem entityitem = new EntityItem(world, x + 0.5, y + 0.5, z + 0.5, te.pressBlock);
        world.spawnEntityInWorld(entityitem);
      }
      world.func_147453_f(x, y, z, block);
    }

    super.breakBlock(world, x, y, z, block, meta);
  }
Example #10
0
 /*     */ public void breakBlock(
     World p_149749_1_,
     int p_149749_2_,
     int p_149749_3_,
     int p_149749_4_,
     Block p_149749_5_,
     int p_149749_6_)
       /*     */ {
   /*  43 */ if (!field_149934_M)
   /*     */ {
     /*  45 */ TileEntityPamApiary tileentitypamapiary =
         (TileEntityPamApiary) p_149749_1_.getTileEntity(p_149749_2_, p_149749_3_, p_149749_4_);
     /*     */
     /*  47 */ if (tileentitypamapiary != null)
     /*     */ {
       /*  49 */ for (int i1 = 0; i1 < tileentitypamapiary.getSizeInventory(); i1++)
       /*     */ {
         /*  51 */ ItemStack itemstack = tileentitypamapiary.getStackInSlot(i1);
         /*     */
         /*  53 */ if (itemstack != null)
         /*     */ {
           /*  55 */ float f = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
           /*  56 */ float f1 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
           /*  57 */ float f2 = this.field_149933_a.nextFloat() * 0.8F + 0.1F;
           /*     */
           /*  59 */ while (itemstack.stackSize > 0)
           /*     */ {
             /*  61 */ int j1 = this.field_149933_a.nextInt(21) + 10;
             /*     */
             /*  63 */ if (j1 > itemstack.stackSize)
             /*     */ {
               /*  65 */ j1 = itemstack.stackSize;
               /*     */ }
             /*     */
             /*  68 */ itemstack.stackSize -= j1;
             /*  69 */ EntityItem entityitem =
                 new EntityItem(
                     p_149749_1_,
                     p_149749_2_ + f,
                     p_149749_3_ + f1,
                     p_149749_4_ + f2,
                     new ItemStack(itemstack.getItem(), j1, itemstack.getItemDamage()));
             /*     */
             /*  71 */ if (itemstack.hasTagCompound())
             /*     */ {
               /*  73 */ entityitem
                   .getEntityItem()
                   .setTagCompound((NBTTagCompound) itemstack.getTagCompound().copy());
               /*     */ }
             /*     */
             /*  76 */ float f3 = 0.05F;
             /*  77 */ entityitem.motionX = ((float) this.field_149933_a.nextGaussian() * f3);
             /*  78 */ entityitem.motionY =
                 ((float) this.field_149933_a.nextGaussian() * f3 + 0.2F);
             /*  79 */ entityitem.motionZ = ((float) this.field_149933_a.nextGaussian() * f3);
             /*  80 */ p_149749_1_.spawnEntityInWorld(entityitem);
             /*     */ }
           /*     */ }
         /*     */ }
       /*     */
       /*  85 */ p_149749_1_.func_147453_f(p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_);
       /*     */ }
     /*     */ }
   /*     */
   /*  89 */ super.breakBlock(
       p_149749_1_, p_149749_2_, p_149749_3_, p_149749_4_, p_149749_5_, p_149749_6_);
   /*     */ }
Example #11
0
  @Override
  public boolean onBlockActivated(
      World par1World,
      int par2,
      int par3,
      int par4,
      EntityPlayer par5EntityPlayer,
      int par6,
      float par7,
      float par8,
      float par9) {
    ItemStack stack = par5EntityPlayer.getCurrentEquippedItem();
    TileAltar tile = (TileAltar) par1World.getTileEntity(par2, par3, par4);

    if (par5EntityPlayer.isSneaking()) {
      for (int i = tile.getSizeInventory() - 1; i >= 0; i--) {
        ItemStack stackAt = tile.getStackInSlot(i);
        if (stackAt != null) {
          ItemStack copy = stackAt.copy();
          if (!par5EntityPlayer.inventory.addItemStackToInventory(copy))
            par5EntityPlayer.dropPlayerItemWithRandomChoice(copy, false);
          tile.setInventorySlotContents(i, null);
          par1World.func_147453_f(par2, par3, par4, this);
          break;
        }
      }
    } else if (tile.isEmpty() && tile.hasWater && stack == null)
      tile.trySetLastRecipe(par5EntityPlayer);
    else {
      if (stack != null
          && (isValidWaterContainer(stack)
              || stack.getItem() == ModItems.waterRod
                  && ManaItemHandler.requestManaExact(
                      stack, par5EntityPlayer, ItemWaterRod.COST, false))) {
        if (!tile.hasWater) {
          if (stack.getItem() == ModItems.waterRod)
            ManaItemHandler.requestManaExact(stack, par5EntityPlayer, ItemWaterRod.COST, true);
          else if (!par5EntityPlayer.capabilities.isCreativeMode)
            par5EntityPlayer.inventory.setInventorySlotContents(
                par5EntityPlayer.inventory.currentItem, getContainer(stack));

          tile.setWater(true);
          par1World.func_147453_f(par2, par3, par4, this);
        }

        return true;
      } else if (stack != null && stack.getItem() == Items.lava_bucket) {
        if (!par5EntityPlayer.capabilities.isCreativeMode)
          par5EntityPlayer.inventory.setInventorySlotContents(
              par5EntityPlayer.inventory.currentItem, getContainer(stack));

        tile.setLava(true);
        tile.setWater(false);
        par1World.func_147453_f(par2, par3, par4, this);

        return true;
      } else if (stack != null
          && stack.getItem() == Items.bucket
          && (tile.hasWater || tile.hasLava)
          && !Botania.gardenOfGlassLoaded) {
        ItemStack bucket =
            tile.hasLava ? new ItemStack(Items.lava_bucket) : new ItemStack(Items.water_bucket);
        if (stack.stackSize == 1)
          par5EntityPlayer.inventory.setInventorySlotContents(
              par5EntityPlayer.inventory.currentItem, bucket);
        else {
          if (!par5EntityPlayer.inventory.addItemStackToInventory(bucket))
            par5EntityPlayer.dropPlayerItemWithRandomChoice(bucket, false);
          stack.stackSize--;
        }

        if (tile.hasLava) tile.setLava(false);
        else tile.setWater(false);
        par1World.func_147453_f(par2, par3, par4, this);

        return true;
      }
    }

    return false;
  }