@Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int side,
      float hitX,
      float hitY,
      float hitZ) {

    if (player.isSneaking()) {
      if (!world.isRemote) {
        IInventoryProvider te =
            TileEntityUtils.getTileEntity(IInventoryProvider.class, world, x, y, z);
        MalisisInventory.open((EntityPlayerMP) player, te);
      }
    } else {
      TEKnifeSwitch te = TileEntityUtils.getTileEntity(TEKnifeSwitch.class, world, x, y, z);
      if (te == null) return true;

      if (te.isMoving()) return true;

      te.pushMe();
      if (te.getState() == TEGenericControl.State.TURNINGON)
        world.playSoundEffect(
            (double) x + 0.5D, (double) y + 0.5D, (double) z + 0.5D, "random.click", 0.3F, 0.6F);
      else
        world.playSoundEffect(
            (double) x + 0.5D, (double) y + 0.5D, (double) z + 0.5D, "random.click", 0.3F, 0.5F);
    }
    return true;
  }
 public static void updateFurnaceBlockState(
     boolean flag,
     World world,
     int i,
     int j,
     int k,
     Block activeID,
     Block idleID,
     boolean sounds) {
   int l = world.getBlockMetadata(i, j, k);
   TileEntity tileentity = world.getTileEntity(i, j, k);
   setKeepInventory(true);
   if (flag) {
     if (sounds) {
       world.playSoundEffect(
           i + 0.5F,
           j + 0.5F,
           k + 0.5F,
           "mob.ghast.fireball",
           1.0F,
           0.8F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.7F);
       world.playSoundEffect(
           i + 0.5F,
           j + 0.5F,
           k + 0.5F,
           "mob.zombiepig.zpigdeath",
           0.1F,
           0.1F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.6F);
       world.playSoundEffect(
           i + 0.5F,
           j + 0.5F,
           k + 0.5F,
           "fire.ignite",
           1.5F,
           1.0F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
     }
     world.setBlock(i, j, k, activeID);
   } else {
     if (sounds)
       world.playSoundEffect(
           i + 0.5F,
           j + 0.5F,
           k + 0.5F,
           "ambient.cave.cave",
           0.1F,
           0.1F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
     world.setBlock(i, j, k, idleID);
   }
   setKeepInventory(false);
   world.setBlockMetadataWithNotify(i, j, k, l, 2);
   if (tileentity != null) {
     tileentity.validate();
     world.setTileEntity(i, j, k, tileentity);
   }
 }
Example #3
0
  /** Called upon block activation (right click on the block.) */
  public boolean onBlockActivated(
      World world,
      int par2,
      int par3,
      int par4,
      EntityPlayer par5EntityPlayer,
      int par6,
      float par7,
      float par8,
      float par9) {
    if (par5EntityPlayer.getCurrentEquippedItem().itemID == this.blockID) {

      if (world.getBlockMetadata(par2, par3, par4) == 0 /*0 = Slab at bottom half*/) {
        if (par6 == 1 /*1 = top of the block*/) {
          if (!par5EntityPlayer.capabilities.isCreativeMode) {
            --par5EntityPlayer.getCurrentEquippedItem().stackSize;
          }

          world.playSoundEffect(
              (double) ((float) par2 + 0.5F),
              (double) ((float) par3 + 0.5F),
              (double) ((float) par4 + 0.5F),
              this.stepSound.getPlaceSound(),
              (this.stepSound.getVolume() + 1.0F) / 2.0F,
              this.stepSound.getPitch() * 0.8F);
          world.setBlock(par2, par3, par4, BOPBlocks.firDoubleSlab.blockID);

          return true;
        }
      }

      if (world.getBlockMetadata(par2, par3, par4) == 8 /*8 = Slab at top half*/) {
        if (par6 == 0 /*0 = bottom of the block*/) {
          if (!par5EntityPlayer.capabilities.isCreativeMode) {
            --par5EntityPlayer.getCurrentEquippedItem().stackSize;
          }

          world.playSoundEffect(
              (double) ((float) par2 + 0.5F),
              (double) ((float) par3 + 0.5F),
              (double) ((float) par4 + 0.5F),
              this.stepSound.getPlaceSound(),
              (this.stepSound.getVolume() + 1.0F) / 2.0F,
              this.stepSound.getPitch() * 0.8F);
          world.setBlock(par2, par3, par4, BOPBlocks.firDoubleSlab.blockID);

          return true;
        }
      }
    }
    return false;
  }
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int side,
      float hitVecX,
      float hitVecY,
      float hitVecZ) {
    if (player.getCurrentEquippedItem() != null) {
      if (player.getCurrentEquippedItem().getDisplayName().toLowerCase().contains("hoe")) {
        if (world.getBlockMetadata(x, y, z) == 0) {
          Block farmland = KoentusBlocks.crystal_farmland;

          world.playSoundEffect(
              x + 0.5F,
              y + 0.5F,
              z + 0.5F,
              farmland.stepSound.getStepResourcePath(),
              (farmland.stepSound.getVolume() + 1.0F) / 2.0F,
              farmland.stepSound.getPitch() * 0.8F);

          if (!world.isRemote) {
            world.setBlock(x, y, z, farmland, 0, 2);
          }
          player.getCurrentEquippedItem().damageItem(1, player);
        } else if (world.getBlockMetadata(x, y, z) == 1) {
          Block farmland = this;

          world.playSoundEffect(
              x + 0.5F,
              y + 0.5F,
              z + 0.5F,
              farmland.stepSound.getStepResourcePath(),
              (farmland.stepSound.getVolume() + 1.0F) / 2.0F,
              farmland.stepSound.getPitch() * 0.8F);

          if (!world.isRemote) {
            world.setBlock(x, y, z, farmland, 0, 2);
          }
          player.getCurrentEquippedItem().damageItem(1, player);
        }
        return true;
      } else {
        return false;
      }
    } else {
      return false;
    }
  }
Example #5
0
 public boolean onBlockActivated(
     World worldIn,
     BlockPos pos,
     IBlockState state,
     EntityPlayer playerIn,
     EnumFacing side,
     float hitX,
     float hitY,
     float hitZ) {
   if (((Boolean) state.getValue(POWERED)).booleanValue()) {
     return true;
   } else {
     worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true)), 3);
     worldIn.markBlockRangeForRenderUpdate(pos, pos);
     worldIn.playSoundEffect(
         (double) pos.getX() + 0.5D,
         (double) pos.getY() + 0.5D,
         (double) pos.getZ() + 0.5D,
         "random.click",
         0.3F,
         0.6F);
     this.notifyNeighbors(worldIn, pos, (EnumFacing) state.getValue(FACING));
     worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
     return true;
   }
 }
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer entityplayer,
      int side,
      float hitX,
      float hitY,
      float hitZ) {
    super.onBlockActivated(world, x, y, z, entityplayer, side, hitX, hitY, hitZ);
    TileEntityQuern te = (TileEntityQuern) world.getBlockTileEntity(x, y, z);
    if (!world.isRemote) {
      if (!te.shouldRotate && hitX >= 0.65 && hitZ >= 0.65 && te.storage[2] != null) {
        te.shouldRotate = true;
        world.playSoundEffect(x, y, z, TFC_Sounds.STONEDRAG, 1, 1);
      } else if ((!te.shouldRotate && (hitX < 0.65 || hitZ < 0.65)) || te.storage[2] == null) {
        entityplayer.openGui(TerraFirmaCraft.instance, 33, world, x, y, z);
      }
    } else if (!te.shouldRotate && hitX >= 0.65 && hitZ >= 0.65 && te.hasQuern) {
      te.shouldRotate = true;
    }

    return true;
  }
Example #7
0
  private boolean func_150946_a(
      ItemStack stack, EntityPlayer player, World world, int x, int y, int z, int side) {
    if (side == 0) y--;
    if (side == 1) y++;
    if (side == 2) z--;
    if (side == 3) z++;
    if (side == 4) x--;
    if (side == 5) x++;

    Block block = world.getBlock(x, y, z);
    int meta = world.getBlockMetadata(x, y, z);

    if (block == field_150939_a && meta != 2) {
      if (world.checkNoEntityCollision(
              field_150939_a.getCollisionBoundingBoxFromPool(world, x, y, z))
          && world.setBlockMetadataWithNotify(x, y, z, 2, 3)) {
        world.playSoundEffect(
            x + 0.5F,
            y + 0.5F,
            z + 0.5F,
            field_150939_a.stepSound.func_150496_b(),
            (field_150939_a.stepSound.getVolume() + 1.0F) / 2.0F,
            field_150939_a.stepSound.getPitch() * 0.8F);
        stack.stackSize--;
      }

      return true;
    } else return false;
  }
Example #8
0
  /** Called whenever an entity is walking on top of this block. Args: world, x, y, z, entity */
  public void onEntityWalking(World var1, int var2, int var3, int var4, Entity var5) {
    if (var5 instanceof EntityPlayer) {
      var1.playSoundEffect(
          (double) ((float) var2 + 0.5F),
          (double) ((float) var3 + 0.5F),
          (double) ((float) var4 + 0.5F),
          "aemisc.activateTrap",
          1.0F,
          1.0F);
      int var6 = MathHelper.floor_double((double) var2);
      int var7 = MathHelper.floor_double((double) var3);
      int var8 = MathHelper.floor_double((double) var4);

      if (!var1.isRemote) {
        switch (var1.getBlockMetadata(var2, var3, var4)) {
          case 0:
            EntitySentry var9 = new EntitySentry(var1);
            var9.setPosition((double) var6 + 0.5D, (double) var7 + 1.5D, (double) var8 + 0.5D);
            var1.spawnEntityInWorld(var9);

          case 1:
        }
      }

      var1.setBlock(
          var2,
          var3,
          var4,
          AetherBlocks.LockedDungeonStone.blockID,
          var1.getBlockMetadata(var2, var3, var4),
          2);
    }
  }
 /** Switches active state of button or lever at x/y/z to and notifies neighbors */
 public static void activateButton(World world, Block block, int x, int y, int z) {
   int meta = world.getBlockMetadata(x, y, z);
   world.setBlockMetadataWithNotify(x, y, z, (meta < 8 ? meta | 8 : meta & ~8), 3);
   // func_147479_m is markBlockForRenderUpdate
   world.func_147479_m(x, y, z);
   world.playSoundEffect(
       (double) x + 0.5D, (double) y + 0.5D, (double) z + 0.5D, Sounds.CLICK, 0.3F, 0.6F);
   world.scheduleBlockUpdate(x, y, z, block, block.tickRate(world));
   world.notifyBlocksOfNeighborChange(x, y, z, block);
   switch (meta & 7) {
     case 0: // 0 and 7 are ceiling levers
     case 7:
       world.notifyBlocksOfNeighborChange(x, y + 1, z, block);
       break;
     case 1:
       world.notifyBlocksOfNeighborChange(x - 1, y, z, block);
       break;
     case 2:
       world.notifyBlocksOfNeighborChange(x + 1, y, z, block);
       break;
     case 3:
       world.notifyBlocksOfNeighborChange(x, y, z - 1, block);
       break;
     case 4:
       world.notifyBlocksOfNeighborChange(x, y, z + 1, block);
       break;
     default:
       world.notifyBlocksOfNeighborChange(x, y - 1, z, block);
   }
 }
  /**
   * Lets the block know when one of its neighbor changes. Doesn't know which neighbor changed
   * (coordinates passed are their own) Args: x, y, z, neighbor blockID
   */
  @Override
  public void onNeighborBlockChange(World par1World, int x, int y, int z, int neighborBlockID) {
    super.onNeighborBlockChange(par1World, x, y, z, neighborBlockID);

    if (par1World.getBlockId(x, y, z) == this.blockID) {
      this.setNotStationary(par1World, x, y, z);
    } else if (neighborBlockID == Block.fire.blockID
        || neighborBlockID == Block.lavaMoving.blockID
        || neighborBlockID == Block.lavaStill.blockID) {
      par1World.setBlockWithNotify(x, y, z, Block.fire.blockID);
      par1World.playSoundEffect(
          (double) ((float) x + 0.5F),
          (double) ((float) y + 0.5F),
          (double) ((float) z + 0.5F),
          "random.fizz",
          0.5F,
          2.6F + (par1World.rand.nextFloat() - par1World.rand.nextFloat()) * 0.8F);
      par1World.spawnParticle(
          "largesmoke",
          (double) x + Math.random(),
          (double) y + 1.2D,
          (double) z + Math.random(),
          0.0D,
          0.0D,
          0.0D);
    }
  }
  @Override
  public boolean onBlockActivated(
      World world,
      int x,
      int y,
      int z,
      EntityPlayer player,
      int par6,
      float par7,
      float par8,
      float par9) {
    ItemStack stack = player.getCurrentEquippedItem();
    if ((stack != null) && (stack.itemID == this.blockID) && (!player.isSneaking())) {
      int meta = world.getBlockMetadata(x, y, z);
      if (meta % 4 != 3) {
        world.setBlock(x, y, z, this.blockID, meta + 1, 3);
        Block.blocksList[this.blockID].onBlockPlacedBy(world, x, y, z, player, stack);
        Block.blocksList[this.blockID].onPostBlockPlaced(world, x, y, z, meta);

        Block var9 = Block.blocksList[this.blockID];
        world.playSoundEffect(
            x + 0.5F,
            y + 0.5F,
            z + 0.5F,
            var9.stepSound.getStepSound(),
            (var9.stepSound.getVolume() + 1.0F) / 2.0F,
            var9.stepSound.getPitch() * 0.8F);
        player.swingItem();
        if (!player.capabilities.isCreativeMode) stack.stackSize -= 1;

        return true;
      }
    }
    return false;
  }
  @Override
  public void onBlockAdded(World par1World, int x, int y, int z) {
    super.onBlockAdded(par1World, x, y, z);

    for (byte i = 0; i < 6; i++) {
      Vector3 neighborPosition = new Vector3(x, y, z);
      neighborPosition.modifyPositionFromSide(ForgeDirection.getOrientation(i));

      int neighborBlockID =
          par1World.getBlockId(
              neighborPosition.intX(), neighborPosition.intY(), neighborPosition.intZ());

      if (neighborBlockID == Block.fire.blockID
          || neighborBlockID == Block.lavaMoving.blockID
          || neighborBlockID == Block.lavaStill.blockID) {
        par1World.setBlockWithNotify(x, y, z, Block.fire.blockID);
        par1World.playSoundEffect(
            (double) ((float) x + 0.5F),
            (double) ((float) y + 0.5F),
            (double) ((float) z + 0.5F),
            "random.fizz",
            0.5F,
            2.6F + (par1World.rand.nextFloat() - par1World.rand.nextFloat()) * 0.8F);
        par1World.spawnParticle(
            "largesmoke",
            (double) x + Math.random(),
            (double) y + 1.2D,
            (double) z + Math.random(),
            0.0D,
            0.0D,
            0.0D);
        return;
      }
    }
  }
Example #13
0
  /**
   * Called when the block receives a BlockEvent - see World.addBlockEvent. By default, passes it on
   * to the tile entity at this location. Args: world, x, y, z, blockID, EventID, event parameter
   */
  public boolean onBlockEventReceived(
      World par1World, int par2, int par3, int par4, int par5, int par6) {
    float f = (float) Math.pow(2.0D, (double) (par6 - 12) / 12.0D);
    String s = "harp";

    if (par5 == 1) {
      s = "bd";
    }

    if (par5 == 2) {
      s = "snare";
    }

    if (par5 == 3) {
      s = "hat";
    }

    if (par5 == 4) {
      s = "bassattack";
    }

    par1World.playSoundEffect(
        (double) par2 + 0.5D, (double) par3 + 0.5D, (double) par4 + 0.5D, "note." + s, 3.0F, f);
    par1World.spawnParticle(
        "note",
        (double) par2 + 0.5D,
        (double) par3 + 1.2D,
        (double) par4 + 0.5D,
        (double) par6 / 24.0D,
        0.0D,
        0.0D);
    return true;
  }
  @Override
  public boolean onItemUseFirst(
      ItemStack stack,
      EntityPlayer player,
      World world,
      BlockPos pos,
      EnumFacing side,
      float hitX,
      float hitY,
      float hitZ) {
    if (!world.isRemote) {
      BlockPos pos1 = pos.offset(side);

      if (SugiBlocks.sugi_portal.func_176548_d(world, pos1)) {
        world.playSoundEffect(
            pos1.getX() + 0.5D,
            pos1.getY() + 0.5D,
            pos1.getZ() + 0.5D,
            SugiBlocks.sugi_portal.stepSound.getPlaceSound(),
            1.0F,
            2.0F);

        if (!player.capabilities.isCreativeMode && --stack.stackSize <= 0) {
          player.inventory.setInventorySlotContents(player.inventory.currentItem, null);
        }

        return true;
      }
    }

    return super.onItemUseFirst(stack, player, world, pos, side, hitX, hitY, hitZ);
  }
  /**
   * Callback for item usage. If the item does something special on right clicking, he will have one
   * of those. Return True if something happen and false if it don't. This is for ITEMS, not BLOCKS
   */
  public boolean onItemUse(
      ItemStack par1ItemStack,
      EntityPlayer par2EntityPlayer,
      World par3World,
      int par4,
      int par5,
      int par6,
      int par7,
      float par8,
      float par9,
      float par10) {
    if (this.field_150948_b) {
      return super.onItemUse(
          par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7, par8, par9, par10);
    } else if (par1ItemStack.stackSize == 0) {
      return false;
    } else if (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) {
      return false;
    } else {
      Block block = par3World.getBlock(par4, par5, par6);
      int i1 = par3World.getBlockMetadata(par4, par5, par6);
      int j1 = i1 & 7;
      boolean flag = (i1 & 8) != 0;

      if ((par7 == 1 && !flag || par7 == 0 && flag)
          && block == this.field_150949_c
          && j1 == par1ItemStack.getItemDamage()) {
        if (par3World.checkNoEntityCollision(
                this.field_150947_d.getCollisionBoundingBoxFromPool(par3World, par4, par5, par6))
            && par3World.setBlock(par4, par5, par6, this.field_150947_d, j1, 3)) {
          par3World.playSoundEffect(
              (double) ((float) par4 + 0.5F),
              (double) ((float) par5 + 0.5F),
              (double) ((float) par6 + 0.5F),
              this.field_150947_d.stepSound.func_150496_b(),
              (this.field_150947_d.stepSound.getVolume() + 1.0F) / 2.0F,
              this.field_150947_d.stepSound.getPitch() * 0.8F);
          --par1ItemStack.stackSize;
        }

        return true;
      } else {
        return this.func_150946_a(
                par1ItemStack, par2EntityPlayer, par3World, par4, par5, par6, par7)
            ? true
            : super.onItemUse(
                par1ItemStack,
                par2EntityPlayer,
                par3World,
                par4,
                par5,
                par6,
                par7,
                par8,
                par9,
                par10);
      }
    }
  }
Example #16
0
  private void checkForArrows(World worldIn, BlockPos pos, IBlockState state) {
    this.updateBlockBounds(state);
    List<? extends Entity> list =
        worldIn.<Entity>getEntitiesWithinAABB(
            EntityArrow.class,
            new AxisAlignedBB(
                (double) pos.getX() + this.minX,
                (double) pos.getY() + this.minY,
                (double) pos.getZ() + this.minZ,
                (double) pos.getX() + this.maxX,
                (double) pos.getY() + this.maxY,
                (double) pos.getZ() + this.maxZ));
    boolean flag = !list.isEmpty();
    boolean flag1 = ((Boolean) state.getValue(POWERED)).booleanValue();

    if (flag && !flag1) {
      worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(true)));
      this.notifyNeighbors(worldIn, pos, (EnumFacing) state.getValue(FACING));
      worldIn.markBlockRangeForRenderUpdate(pos, pos);
      worldIn.playSoundEffect(
          (double) pos.getX() + 0.5D,
          (double) pos.getY() + 0.5D,
          (double) pos.getZ() + 0.5D,
          "random.click",
          0.3F,
          0.6F);
    }

    if (!flag && flag1) {
      worldIn.setBlockState(pos, state.withProperty(POWERED, Boolean.valueOf(false)));
      this.notifyNeighbors(worldIn, pos, (EnumFacing) state.getValue(FACING));
      worldIn.markBlockRangeForRenderUpdate(pos, pos);
      worldIn.playSoundEffect(
          (double) pos.getX() + 0.5D,
          (double) pos.getY() + 0.5D,
          (double) pos.getZ() + 0.5D,
          "random.click",
          0.3F,
          0.5F);
    }

    if (flag) {
      worldIn.scheduleUpdate(pos, this, this.tickRate(worldIn));
    }
  }
  private boolean func_150946_a(
      ItemStack p_150946_1_,
      EntityPlayer p_150946_2_,
      World p_150946_3_,
      int p_150946_4_,
      int p_150946_5_,
      int p_150946_6_,
      int p_150946_7_) {
    if (p_150946_7_ == 0) {
      --p_150946_5_;
    }

    if (p_150946_7_ == 1) {
      ++p_150946_5_;
    }

    if (p_150946_7_ == 2) {
      --p_150946_6_;
    }

    if (p_150946_7_ == 3) {
      ++p_150946_6_;
    }

    if (p_150946_7_ == 4) {
      --p_150946_4_;
    }

    if (p_150946_7_ == 5) {
      ++p_150946_4_;
    }

    Block block = p_150946_3_.getBlock(p_150946_4_, p_150946_5_, p_150946_6_);
    int i1 = p_150946_3_.getBlockMetadata(p_150946_4_, p_150946_5_, p_150946_6_);
    int j1 = i1 & 7;

    if (block == this.field_150949_c && j1 == p_150946_1_.getItemDamage()) {
      if (p_150946_3_.checkNoEntityCollision(
              this.field_150947_d.getCollisionBoundingBoxFromPool(
                  p_150946_3_, p_150946_4_, p_150946_5_, p_150946_6_))
          && p_150946_3_.setBlock(
              p_150946_4_, p_150946_5_, p_150946_6_, this.field_150947_d, j1, 3)) {
        p_150946_3_.playSoundEffect(
            (double) ((float) p_150946_4_ + 0.5F),
            (double) ((float) p_150946_5_ + 0.5F),
            (double) ((float) p_150946_6_ + 0.5F),
            this.field_150947_d.stepSound.func_150496_b(),
            (this.field_150947_d.stepSound.getVolume() + 1.0F) / 2.0F,
            this.field_150947_d.stepSound.getPitch() * 0.8F);
        --p_150946_1_.stackSize;
      }

      return true;
    } else {
      return false;
    }
  }
  @Override
  public ItemStack onFocusRightClick(
      ItemStack itemstack, World world, EntityPlayer player, MovingObjectPosition mop) {
    player.swingItem();
    if (mop != null
        && ThaumcraftApiHelper.consumeVisFromWand(itemstack, player, visCost.copy(), true, false)) {
      int x = mop.blockX;
      int y = mop.blockY;
      int z = mop.blockZ;

      switch (mop.sideHit) {
        case (0):
          {
            y--;
            break;
          }
        case (1):
          {
            y++;
            break;
          }
        case (2):
          {
            z--;
            break;
          }
        case (3):
          {
            z++;
            break;
          }
        case (4):
          {
            x--;
            break;
          }
        case (5):
          {
            x++;
            break;
          }
      }

      if (world.getBlock(x, y, z).isReplaceable(world, x, y, z) || world.isAirBlock(x, y, z)) {
        ItemStack focusStack = ((ItemWandCasting) itemstack.getItem()).getFocusItem(itemstack);

        world.setBlock(x, y, z, TCBlocks.nitorColour);
        TileColouredNitor te = (TileColouredNitor) world.getTileEntity(x, y, z);
        te.setColour(getColour(focusStack));
        world.playSoundEffect(
            mop.blockX + 0.5D, mop.blockY + 0.5D, mop.blockZ + 0.5D, "thaumcraft:zap", 0.25F, 1.0F);
      }
    }

    return itemstack;
  }
  private void cutBlock(World world, int x, int y, int z, Coordinate c, Material mat) {
    // ReikaItemHelper.dropItems(world, dropx, y-0.25, dropz, dropBlocks.getDrops(world, c.xCoord,
    // c.yCoord, c.zCoord, dropmeta, 0));
    this.dropBlocks(world, c.xCoord, c.yCoord, c.zCoord);
    c.setBlock(world, Blocks.air);
    ReikaSoundHelper.playBreakSound(world, c.xCoord, c.yCoord, c.zCoord, Blocks.log);

    if (mat == Material.leaves)
      world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "dig.grass", 0.5F + rand.nextFloat(), 1F);
    else world.playSoundEffect(x + 0.5, y + 0.5, z + 0.5, "dig.wood", 0.5F + rand.nextFloat(), 1F);
    if (tree.getTreeType() == ModWoodList.SLIME
        && c.getBlock(world) == tree.getTreeType().getLogID()) {
      jam++;
      jamColor =
          0xff000000
              | ReikaColorAPI.mixColors(
                  ModWoodList.SLIME.logColor, 0xffffff, (float) jam / MAX_JAM);
    }
  }
  @Override
  public boolean onItemUse(
      ItemStack stack,
      EntityPlayer player,
      World world,
      BlockPos pos,
      EnumFacing side,
      float hitX,
      float hitY,
      float hitZ) {
    IBlockState iblockstate = world.getBlockState(pos);
    Block localBlock = iblockstate.getBlock();
    BlockPos posThere = pos;
    BlockPos posOffset = pos.offset(side);

    if (localBlock == Blocks.snow_layer && localBlock.isReplaceable(world, pos))
      side = EnumFacing.UP;
    else if (!localBlock.isReplaceable(world, pos)) pos = pos.offset(side);

    TileEntityIESlab stackSlab = null;
    if (side.getAxis().isVertical()
        && this.block.equals(world.getBlockState(posThere).getBlock())
        && world.getBlockState(posThere).getBlock().getMetaFromState(world.getBlockState(posThere))
            == stack.getItemDamage()) {
      TileEntity te = world.getTileEntity(posThere);
      if (te instanceof TileEntityIESlab && ((TileEntityIESlab) te).slabType + side.ordinal() == 1)
        stackSlab = ((TileEntityIESlab) te);
    } else if (this.block.equals(world.getBlockState(posOffset).getBlock())
        && world
                .getBlockState(posOffset)
                .getBlock()
                .getMetaFromState(world.getBlockState(posOffset))
            == stack.getItemDamage()) {
      TileEntity te = world.getTileEntity(posOffset);
      if (te instanceof TileEntityIESlab) {
        int type = ((TileEntityIESlab) te).slabType;
        if ((type == 0 && (side == EnumFacing.DOWN || hitY >= .5))
            || (type == 1 && (side == EnumFacing.UP || hitY <= .5)))
          stackSlab = ((TileEntityIESlab) te);
      }
    } else return super.onItemUse(stack, player, world, pos, side, hitX, hitY, hitZ);
    if (stackSlab != null) {
      stackSlab.slabType = 2;
      world.markBlockForUpdate(stackSlab.getPos());
      world.playSoundEffect(
          stackSlab.getPos().getX() + .5,
          stackSlab.getPos().getY() + .5,
          stackSlab.getPos().getZ() + .5,
          this.block.stepSound.getPlaceSound(),
          (this.block.stepSound.getVolume() + 1.0F) / 2.0F,
          this.block.stepSound.getFrequency() * 0.8F);
      --stack.stackSize;
      return true;
    } else return super.onItemUse(stack, player, world, pos, side, hitX, hitY, hitZ);
  }
 public void grind(World world, int x, int y, int z, int meta) {
   if (y <= 0) return;
   if (!world.isRemote) {
     if (world.getBlockId(harvestx, harvesty, harvestz) == 7) {
       world.playSoundEffect(
           x + 0.5D, y + 0.5D, z + 0.5D, "dig.stone", 0.5F, par5Random.nextFloat() * 0.4F + 0.8F);
       ReikaWorldHelper.legacySetBlockAndMetadataWithNotify(
           world, harvestx, harvesty, harvestz, RotaryCraft.bedrockslice.blockID, 0);
     } else {
       int rockmetadata = world.getBlockMetadata(harvestx, harvesty, harvestz);
       if (rockmetadata < 15) {
         world.playSoundEffect(
             x + 0.5D,
             y + 0.5D,
             z + 0.5D,
             "dig.stone",
             0.5F,
             par5Random.nextFloat() * 0.4F + 0.8F);
         ReikaWorldHelper.legacySetBlockAndMetadataWithNotify(
             world,
             harvestx,
             harvesty,
             harvestz,
             RotaryCraft.bedrockslice.blockID,
             rockmetadata + 1);
       } else {
         world.playSoundEffect(
             x + 0.5D,
             y + 0.5D,
             z + 0.5D,
             "mob.blaze.hit",
             0.5F,
             par5Random.nextFloat() * 0.4F + 0.8F);
         ReikaWorldHelper.legacySetBlockWithNotify(world, harvestx, harvesty, harvestz, 0);
         if (this.isInventoryFull())
           this.dropItem(world, x, y, z, meta, ItemStacks.bedrockdust.copy());
         else ReikaInventoryHelper.addOrSetStack(ItemStacks.bedrockdust, inv, 0);
         RotaryAchievements.BEDROCKBREAKER.triggerAchievement(this.getPlacer());
       }
     }
   }
 }
Example #22
0
 @Override
 public void playCrashSound(World world, EntityMeteor meteor) {
   EntityPlayer player = FMLClientHandler.instance().getClient().thePlayer;
   if (player.worldObj.getWorldInfo().getDimension() != 0) return;
   double xDiff = meteor.posX - player.posX;
   double zDiff = meteor.posZ - player.posZ;
   double xMod = xDiff / 128.0D * 4.0D;
   double zMod = zDiff / 128.0D * 4.0D;
   world.playSoundEffect(
       player.posX + xMod, player.posY + 1.0D, player.posZ + zMod, "meteor.crash", 1.0F, 1.0F);
 }
Example #23
0
 @Override
 public boolean onBlockActivated(
     World world,
     int x,
     int y,
     int z,
     EntityPlayer entityPlayer,
     int side,
     float hitX,
     float hitY,
     float hitZ) {
   world.playSoundEffect(x, y, z, Sounds.flagFlap, 1.0F, entityPlayer.getRNG().nextFloat() + 0.5F);
   return true;
 }
  public boolean onItemUse(
      ItemStack stack,
      EntityPlayer playerIn,
      World worldIn,
      BlockPos pos,
      EnumFacing side,
      float hitX,
      float hitY,
      float hitZ) {
    IBlockState var9 = worldIn.getBlockState(pos);
    Block var10 = var9.getBlock();
    if (var10 == Blocks.snow_layer
        && ((Integer) var9.getValue(BlockSnow.LAYERS_PROP)).intValue() < 1) {
      side = EnumFacing.UP;
    } else if (!var10.isReplaceable(worldIn, pos)) {
      pos = pos.offset(side);
    }

    if (stack.stackSize == 0) {
      return false;
    } else if (!playerIn.func_175151_a(pos, side, stack)) {
      return false;
    } else if (pos.getY() == 255 && this.block.getMaterial().isSolid()) {
      return false;
    } else if (worldIn.canBlockBePlaced(this.block, pos, false, side, (Entity) null, stack)) {
      int var11 = this.getMetadata(stack.getMetadata());
      IBlockState var12 =
          this.block.onBlockPlaced(worldIn, pos, side, hitX, hitY, hitZ, var11, playerIn);
      if (worldIn.setBlockState(pos, var12, 3)) {
        var12 = worldIn.getBlockState(pos);
        if (var12.getBlock() == this.block) {
          setTileEntityNBT(worldIn, pos, stack);
          this.block.onBlockPlacedBy(worldIn, pos, var12, playerIn, stack);
        }

        worldIn.playSoundEffect(
            (double) ((float) pos.getX() + 0.5F),
            (double) ((float) pos.getY() + 0.5F),
            (double) ((float) pos.getZ() + 0.5F),
            this.block.stepSound.getPlaceSound(),
            (this.block.stepSound.getVolume() + 1.0F) / 2.0F,
            this.block.stepSound.getFrequency() * 0.8F);
        --stack.stackSize;
      }

      return true;
    } else {
      return false;
    }
  }
 public void grind(World world, int mx, int my, int mz, int x, int y, int z, int meta) {
   if (this.processBlock(world, x, y, z)) {
     if (this.isBedrock(world, x, y, z)) {
       world.playSoundEffect(
           x + 0.5D, y + 0.5D, z + 0.5D, "dig.stone", 0.5F, rand.nextFloat() * 0.4F + 0.8F);
       world.setBlock(x, y, z, BlockRegistry.BEDROCKSLICE.getBlockInstance(), 0, 3);
     } else {
       int rockmetadata = world.getBlockMetadata(x, y, z);
       if (rockmetadata < 15) {
         world.playSoundEffect(
             x + 0.5D, y + 0.5D, z + 0.5D, "dig.stone", 0.5F, rand.nextFloat() * 0.4F + 0.8F);
         world.setBlockMetadataWithNotify(x, y, z, rockmetadata + 1, 3);
       } else {
         world.playSoundEffect(
             x + 0.5D, y + 0.5D, z + 0.5D, "mob.blaze.hit", 0.5F, rand.nextFloat() * 0.4F + 0.8F);
         ItemStack is = this.getDrops(world, x, y, z);
         world.setBlockToAir(x, y, z);
         if (!this.chestCheck(world, x, y, z, is)) {
           if (this.isInventoryFull()) ReikaItemHelper.dropItem(world, dropx, dropy, dropz, is);
           else ReikaInventoryHelper.addOrSetStack(is, inv, 0);
         }
         RotaryAchievements.BEDROCKBREAKER.triggerAchievement(this.getPlacer());
         MinecraftForge.EVENT_BUS.post(new BedrockDigEvent(this, x, y, z));
         if (!world.isRemote) this.incrementStep(world, mx, my, mz);
       }
     }
   } else {
     Block b = world.getBlock(x, y, z);
     if (b != Blocks.air && b.getBlockHardness(world, x, y, z) >= 0) {
       ReikaSoundHelper.playBreakSound(world, x, y, z, b);
       if (FMLCommonHandler.instance().getEffectiveSide() == Side.CLIENT)
         ReikaRenderHelper.spawnDropParticles(world, x, y, z, b, world.getBlockMetadata(x, y, z));
       world.setBlockToAir(x, y, z);
     }
     if (!world.isRemote) this.incrementStep(world, mx, my, mz);
   }
 }
  /**
   * Callback for item usage. If the item does something special on right clicking, he will have one
   * of those. Return True if something happen and false if it don't. This is for ITEMS, not BLOCKS
   */
  public boolean onItemUse(
      ItemStack var1,
      EntityPlayer var2,
      World var3,
      int var4,
      int var5,
      int var6,
      int var7,
      float var8,
      float var9,
      float var10) {
    if (!var2.canPlayerEdit(var4, var5, var6, var7, var1)) {
      return false;
    } else {
      UseHoeEvent var11 = new UseHoeEvent(var2, var1, var3, var4, var5, var6);

      if (MinecraftForge.EVENT_BUS.post(var11)) {
        return false;
      } else if (var11.getResult() == Result.ALLOW) {
        var1.damageItem(1, var2);
        return true;
      } else {
        int var12 = var3.getBlockId(var4, var5, var6);
        int var13 = var3.getBlockId(var4, var5 + 1, var6);

        if ((var7 == 0 || var13 != 0 || var12 != Block.grass.blockID)
            && var12 != Block.dirt.blockID) {
          return false;
        } else {
          Block var14 = Block.tilledField;
          var3.playSoundEffect(
              (double) ((float) var4 + 0.5F),
              (double) ((float) var5 + 0.5F),
              (double) ((float) var6 + 0.5F),
              var14.stepSound.getStepSound(),
              (var14.stepSound.getVolume() + 1.0F) / 2.0F,
              var14.stepSound.getPitch() * 0.8F);

          if (var3.isRemote) {
            return true;
          } else {
            var3.setBlock(var4, var5, var6, var14.blockID);
            var1.damageItem(1, var2);
            return true;
          }
        }
      }
    }
  }
 @Override
 public void onBlockClicked(World world, int x, int y, int z, EntityPlayer player) {
   if (world.isRemote) return;
   TileEntity tile = world.getTileEntity(x, y, z);
   int meta = world.getBlockMetadata(x, y, z);
   OrderExchanger safe = null;
   if (tile != null && tile instanceof OrderExchanger) {
     safe = (OrderExchanger) tile;
     if (safe.canHandleMP(player)) {
       world.playSoundEffect(
           x + 0.5D, y + 0.5D, z + 0.5D, "random.pop", 0.5F, this.rand.nextFloat() * 0.15F + 1.2F);
       world.setBlockToAir(x, y, z);
     }
   }
 }
Example #28
0
  public boolean onItemUse(
      ItemStack itemstack,
      EntityPlayer player,
      World world,
      int x,
      int y,
      int z,
      int side,
      float par8,
      float par9,
      float par10) {
    if (side == 0) {
      y--;
    }
    if (side == 1) {
      y++;
    }
    if (side == 2) {
      z--;
    }
    if (side == 3) {
      z++;
    }
    if (side == 4) {
      x--;
    }
    if (side == 5) {
      x++;
    }

    if (!player.canPlayerEdit(x, y, z, side, itemstack)) {
      return false;
    } else {
      if (world.isAirBlock(x, y, z)) {
        world.playSoundEffect(
            (double) x + 0.5D,
            (double) y + 0.5D,
            (double) z + 0.5D,
            "fire.ignite",
            1F,
            itemRand.nextFloat() * 0.4F + 0.8F);
        world.setBlock(x, y, z, ModBlocks.darkaxFire);
      }

      itemstack.damageItem(1, player);
      return true;
    }
  }
 @Override
 public void onBlockHarvested(World world, BlockPos pos, IBlockState state, EntityPlayer player) {
   TileEntityPresent present = (TileEntityPresent) world.getTileEntity(pos);
   if (present != null) {
     world.playSoundEffect(pos.getX(), pos.getY(), pos.getZ(), "random.levelup", 0.75F, 1.0F);
     player.addChatComponentMessage(
         new ChatComponentText(
             EnumChatFormatting.GREEN
                 + "Merry Christmas"
                 + EnumChatFormatting.RESET
                 + " from "
                 + EnumChatFormatting.RED
                 + present.ownerName));
     player.triggerAchievement(FurnitureAchievements.unwrapPresent);
   }
 }
  /** Does the second part of the explosion (sounds, particles, drop spawn) */
  @Override
  public void doExplosionB(boolean par1) {
    worldObj.playSoundEffect(
        explosionX,
        explosionY,
        explosionZ,
        "random.explode",
        4.0F,
        (1.0F + (worldObj.rand.nextFloat() - worldObj.rand.nextFloat()) * 0.2F) * 0.7F);

    if (explosionSize >= 2.0F && field_82755_b) {
      worldObj.spawnParticle("hugeexplosion", explosionX, explosionY, explosionZ, 1.0D, 0.0D, 0.0D);
    } else {
      worldObj.spawnParticle("largeexplode", explosionX, explosionY, explosionZ, 1.0D, 0.0D, 0.0D);
    }
  }