Пример #1
0
  /** Attempts to place the liquid contained inside the bucket. */
  public boolean tryPlaceContainedLiquid(
      World par1World, double par2, double par4, double par6, int par8, int par9, int par10) {
    if (this.isFull <= 0) {
      return false;
    } else if (!par1World.isAirBlock(par8, par9, par10)
        && par1World.getBlockMaterial(par8, par9, par10).isSolid()) {
      return false;
    } else {
      if (par1World.provider.isHellWorld && this.isFull == Block.waterMoving.blockID) {
        par1World.playSoundEffect(
            par2 + 0.5D,
            par4 + 0.5D,
            par6 + 0.5D,
            "random.fizz",
            0.5F,
            2.6F + (par1World.rand.nextFloat() - par1World.rand.nextFloat()) * 0.8F);

        for (int var11 = 0; var11 < 8; ++var11) {
          par1World.spawnParticle(
              "largesmoke",
              (double) par8 + Math.random(),
              (double) par9 + Math.random(),
              (double) par10 + Math.random(),
              0.0D,
              0.0D,
              0.0D);
        }
      } else {
        par1World.setBlock(par8, par9, par10, this.isFull, 0, 3);
      }

      return true;
    }
  }
Пример #2
0
  @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;
  }
Пример #3
0
 public boolean onItemUse(
     ItemStack itemstack, EntityPlayer entityplayer, World world, int i, int j, int k, int l) {
   int i1 = world.getBlockId(i, j, k);
   if (i1 == Block.snow.blockID) {
     l = 0;
   } else if (i1 != Block.vine.blockID) {
     if (l == 0) {
       j--;
     }
     if (l == 1) {
       j++;
     }
     if (l == 2) {
       k--;
     }
     if (l == 3) {
       k++;
     }
     if (l == 4) {
       i--;
     }
     if (l == 5) {
       i++;
     }
   }
   if (itemstack.stackSize == 0) {
     return false;
   }
   if (!entityplayer.canPlayerEdit(i, j, k)) {
     return false;
   }
   if (j == world.worldYMax - 1 && Block.blocksList[blockID].blockMaterial.isSolid()) {
     return false;
   }
   if (world.canBlockBePlacedAt(blockID, i, j, k, false, l)) {
     Block block = Block.blocksList[blockID];
     if (world.setBlockAndMetadataWithNotify(
         i, j, k, blockID, getMetadata(itemstack.getItemDamage()))) {
       if (world.getBlockId(i, j, k) == blockID) {
         Block.blocksList[blockID].onBlockPlaced(world, i, j, k, l);
         Block.blocksList[blockID].onBlockPlacedBy(world, i, j, k, entityplayer);
       }
       world.playSoundEffect(
           (float) i + 0.5F,
           (float) j + 0.5F,
           (float) k + 0.5F,
           block.stepSound.stepSoundDir(),
           (block.stepSound.getVolume() + 1.0F) / 2.0F,
           block.stepSound.getPitch() * 0.8F);
       itemstack.stackSize--;
     }
     return true;
   } else {
     return false;
   }
 }
Пример #4
0
  /** Creates fizzing sound and smoke. Used when lava flows over block or mixes with water. */
  protected void triggerLavaMixEffects(World par1World, int par2, int par3, int par4) {
    par1World.playSoundEffect(
        (double) ((float) par2 + 0.5F),
        (double) ((float) par3 + 0.5F),
        (double) ((float) par4 + 0.5F),
        "random.fizz",
        0.5F,
        2.6F + (par1World.rand.nextFloat() - par1World.rand.nextFloat()) * 0.8F);

    for (int var5 = 0; var5 < 8; ++var5) {
      par1World.spawnParticle(
          "largesmoke",
          (double) par2 + Math.random(),
          (double) par3 + 1.2D,
          (double) par4 + Math.random(),
          0.0D,
          0.0D,
          0.0D);
    }
  }
Пример #5
0
  /**
   * 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 (!par2EntityPlayer.canPlayerEdit(par4, par5, par6, par7, par1ItemStack)) {
      return false;
    } else {
      int var11 = par3World.getBlockId(par4, par5, par6);
      int var12 = par3World.getBlockId(par4, par5 + 1, par6);

      if ((par7 == 0 || var12 != 0 || var11 != Block.grass.blockID)
          && var11 != Block.dirt.blockID) {
        return false;
      } else {
        Block var13 = Block.tilledField;
        par3World.playSoundEffect(
            (double) ((float) par4 + 0.5F),
            (double) ((float) par5 + 0.5F),
            (double) ((float) par6 + 0.5F),
            var13.stepSound.getStepSound(),
            (var13.stepSound.getVolume() + 1.0F) / 2.0F,
            var13.stepSound.getPitch() * 0.8F);

        if (par3World.isRemote) {
          return true;
        } else {
          par3World.setBlockWithNotify(par4, par5, par6, var13.blockID);
          par1ItemStack.damageItem(1, par2EntityPlayer);
          return true;
        }
      }
    }
  }
Пример #6
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 void onBlockEventReceived(
      World par1World, int par2, int par3, int par4, int par5, int par6) {
    float var7 = (float) Math.pow(2.0D, (double) (par6 - 12) / 12.0D);
    String var8 = "harp";

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

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

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

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

    par1World.playSoundEffect(
        (double) par2 + 0.5D,
        (double) par3 + 0.5D,
        (double) par4 + 0.5D,
        "note." + var8,
        3.0F,
        var7);
    par1World.spawnParticle(
        "note",
        (double) par2 + 0.5D,
        (double) par3 + 1.2D,
        (double) par4 + 0.5D,
        (double) par6 / 24.0D,
        0.0D,
        0.0D);
  }
  public void randomDisplayTick(World world, int i, int j, int k, Random random) {
    if (random.nextInt(24) == 0) {
      world.playSoundEffect(
          (float) i + 0.5F,
          (float) j + 0.5F,
          (float) k + 0.5F,
          "fire.fire",
          1.0F + random.nextFloat(),
          random.nextFloat() * 0.7F + 0.3F);
    }
    if (world.isBlockOpaqueCube(i, j - 1, k) || Block.fire.canBlockCatchFire(world, i, j - 1, k)) {
      for (int l = 0; l < 3; l++) {
        float f = (float) i + random.nextFloat();
        float f6 = (float) j + random.nextFloat() * 0.5F + 0.5F;
        float f12 = (float) k + random.nextFloat();
        world.spawnParticle("largesmoke", f, f6, f12, 0.0D, 0.0D, 0.0D);
      }

    } else {
      if (Block.fire.canBlockCatchFire(world, i - 1, j, k)) {
        for (int i1 = 0; i1 < 2; i1++) {
          float f1 = (float) i + random.nextFloat() * 0.1F;
          float f7 = (float) j + random.nextFloat();
          float f13 = (float) k + random.nextFloat();
          world.spawnParticle("largesmoke", f1, f7, f13, 0.0D, 0.0D, 0.0D);
        }
      }
      if (Block.fire.canBlockCatchFire(world, i + 1, j, k)) {
        for (int j1 = 0; j1 < 2; j1++) {
          float f2 = (float) (i + 1) - random.nextFloat() * 0.1F;
          float f8 = (float) j + random.nextFloat();
          float f14 = (float) k + random.nextFloat();
          world.spawnParticle("largesmoke", f2, f8, f14, 0.0D, 0.0D, 0.0D);
        }
      }
      if (Block.fire.canBlockCatchFire(world, i, j, k - 1)) {
        for (int k1 = 0; k1 < 2; k1++) {
          float f3 = (float) i + random.nextFloat();
          float f9 = (float) j + random.nextFloat();
          float f15 = (float) k + random.nextFloat() * 0.1F;
          world.spawnParticle("largesmoke", f3, f9, f15, 0.0D, 0.0D, 0.0D);
        }
      }
      if (Block.fire.canBlockCatchFire(world, i, j, k + 1)) {
        for (int l1 = 0; l1 < 2; l1++) {
          float f4 = (float) i + random.nextFloat();
          float f10 = (float) j + random.nextFloat();
          float f16 = (float) (k + 1) - random.nextFloat() * 0.1F;
          world.spawnParticle("largesmoke", f4, f10, f16, 0.0D, 0.0D, 0.0D);
        }
      }
      if (Block.fire.canBlockCatchFire(world, i, j + 1, k)) {
        for (int i2 = 0; i2 < 2; i2++) {
          float f5 = (float) i + random.nextFloat();
          float f11 = (float) (j + 1) - random.nextFloat() * 0.1F;
          float f17 = (float) k + random.nextFloat();
          world.spawnParticle("largesmoke", f5, f11, f17, 0.0D, 0.0D, 0.0D);
        }
      }
    }
  }
  public void powerBlock(World par1World, int par2, int par3, int par4, int par5, int par6) {
    ignoreUpdates = true;
    int i = par6;

    if (par5 == 0) {
      if (tryExtend(par1World, par2, par3, par4, i)) {
        par1World.setBlockMetadataWithNotify(par2, par3, par4, i | 8);
        par1World.playSoundEffect(
            (double) par2 + 0.5D,
            (double) par3 + 0.5D,
            (double) par4 + 0.5D,
            "tile.piston.out",
            0.5F,
            par1World.rand.nextFloat() * 0.25F + 0.6F);
      } else {
        par1World.setBlockMetadata(par2, par3, par4, i);
      }
    } else if (par5 == 1) {
      TileEntity tileentity =
          par1World.getBlockTileEntity(
              par2 + Facing.offsetsXForSide[i],
              par3 + Facing.offsetsYForSide[i],
              par4 + Facing.offsetsZForSide[i]);

      if (tileentity != null && (tileentity instanceof TileEntityPiston)) {
        ((TileEntityPiston) tileentity).clearPistonTileEntity();
      }

      par1World.setBlockAndMetadata(par2, par3, par4, Block.pistonMoving.blockID, i);
      par1World.setBlockTileEntity(
          par2, par3, par4, BlockPistonMoving.getTileEntity(blockID, i, i, false, true));

      if (isSticky) {
        int j = par2 + Facing.offsetsXForSide[i] * 2;
        int k = par3 + Facing.offsetsYForSide[i] * 2;
        int l = par4 + Facing.offsetsZForSide[i] * 2;
        int i1 = par1World.getBlockId(j, k, l);
        int j1 = par1World.getBlockMetadata(j, k, l);
        boolean flag = false;

        if (i1 == Block.pistonMoving.blockID) {
          TileEntity tileentity1 = par1World.getBlockTileEntity(j, k, l);

          if (tileentity1 != null && (tileentity1 instanceof TileEntityPiston)) {
            TileEntityPiston tileentitypiston = (TileEntityPiston) tileentity1;

            if (tileentitypiston.getPistonOrientation() == i && tileentitypiston.isExtending()) {
              tileentitypiston.clearPistonTileEntity();
              i1 = tileentitypiston.getStoredBlockID();
              j1 = tileentitypiston.getBlockMetadata();
              flag = true;
            }
          }
        }

        if (((i1 > 0 && (flag || canPushBlock(i1, par1World, j, k, l, false)) && dupe)
                || (!flag && i1 > 0 && canPushBlock(i1, par1World, j, k, l, false) && !dupe))
            && (Block.blocksList[i1].getMobilityFlag() == 0
                || i1 == Block.pistonBase.blockID
                || i1 == Block.pistonStickyBase.blockID)) {
          par2 += Facing.offsetsXForSide[i];
          par3 += Facing.offsetsYForSide[i];
          par4 += Facing.offsetsZForSide[i];
          par1World.setBlockAndMetadata(par2, par3, par4, Block.pistonMoving.blockID, j1);
          par1World.setBlockTileEntity(
              par2, par3, par4, BlockPistonMoving.getTileEntity(i1, j1, i, false, false));
          ignoreUpdates = false;
          par1World.setBlockWithNotify(j, k, l, 0);
          ignoreUpdates = true;
        } else if (!flag) {
          ignoreUpdates = false;
          par1World.setBlockWithNotify(
              par2 + Facing.offsetsXForSide[i],
              par3 + Facing.offsetsYForSide[i],
              par4 + Facing.offsetsZForSide[i],
              0);
          ignoreUpdates = true;
        }
      } else {
        ignoreUpdates = false;
        par1World.setBlockWithNotify(
            par2 + Facing.offsetsXForSide[i],
            par3 + Facing.offsetsYForSide[i],
            par4 + Facing.offsetsZForSide[i],
            0);
        ignoreUpdates = true;
      }

      par1World.playSoundEffect(
          (double) par2 + 0.5D,
          (double) par3 + 0.5D,
          (double) par4 + 0.5D,
          "tile.piston.in",
          0.5F,
          par1World.rand.nextFloat() * 0.15F + 0.6F);
    }

    ignoreUpdates = false;
  }
Пример #9
0
 private void setStateIfMobInteractsWithPlate(World world, int i, int j, int k) {
   boolean flag = world.getBlockMetadata(i, j, k) == 1;
   boolean flag1 = false;
   float f = 0.125F;
   List list = null;
   if (triggerMobType == EnumMobType.everything) {
     list =
         world.getEntitiesWithinAABBExcludingEntity(
             null,
             AxisAlignedBB.getBoundingBoxFromPool(
                 (float) i + f,
                 j,
                 (float) k + f,
                 (float) (i + 1) - f,
                 (double) j + 0.25D,
                 (float) (k + 1) - f));
   }
   if (triggerMobType == EnumMobType.mobs) {
     list =
         world.getEntitiesWithinAABB(
             net.minecraft.src.EntityLiving.class,
             AxisAlignedBB.getBoundingBoxFromPool(
                 (float) i + f,
                 j,
                 (float) k + f,
                 (float) (i + 1) - f,
                 (double) j + 0.25D,
                 (float) (k + 1) - f));
   }
   if (triggerMobType == EnumMobType.players) {
     list =
         world.getEntitiesWithinAABB(
             net.minecraft.src.EntityPlayer.class,
             AxisAlignedBB.getBoundingBoxFromPool(
                 (float) i + f,
                 j,
                 (float) k + f,
                 (float) (i + 1) - f,
                 (double) j + 0.25D,
                 (float) (k + 1) - f));
   }
   if (list.size() > 0) {
     flag1 = true;
   }
   if (flag1 && !flag) {
     world.setBlockMetadataWithNotify(i, j, k, 1);
     world.notifyBlocksOfNeighborChange(i, j, k, blockID);
     world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
     world.markBlocksDirty(i, j, k, i, j, k);
     world.playSoundEffect(
         (double) i + 0.5D,
         (double) j + 0.10000000000000001D,
         (double) k + 0.5D,
         "random.click",
         0.3F,
         0.6F);
   }
   if (!flag1 && flag) {
     world.setBlockMetadataWithNotify(i, j, k, 0);
     world.notifyBlocksOfNeighborChange(i, j, k, blockID);
     world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
     world.markBlocksDirty(i, j, k, i, j, k);
     world.playSoundEffect(
         (double) i + 0.5D,
         (double) j + 0.10000000000000001D,
         (double) k + 0.5D,
         "random.click",
         0.3F,
         0.5F);
   }
   if (flag1) {
     world.scheduleBlockUpdate(i, j, k, blockID, tickRate());
   }
 }
Пример #10
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) {
    if (!par1World.isRemote) {
      boolean var7 = this.isIndirectlyPowered(par1World, par2, par3, par4, par6);

      if (var7 && par5 == 1) {
        par1World.setBlockMetadataWithNotify(par2, par3, par4, par6 | 8, 2);
        return false;
      }

      if (!var7 && par5 == 0) {
        return false;
      }
    }

    if (par5 == 0) {
      if (!this.tryExtend(par1World, par2, par3, par4, par6)) {
        return false;
      }

      par1World.setBlockMetadataWithNotify(par2, par3, par4, par6 | 8, 2);
      par1World.playSoundEffect(
          (double) par2 + 0.5D,
          (double) par3 + 0.5D,
          (double) par4 + 0.5D,
          "tile.piston.out",
          0.5F,
          par1World.rand.nextFloat() * 0.25F + 0.6F);
    } else if (par5 == 1) {
      TileEntity var16 =
          par1World.getBlockTileEntity(
              par2 + Facing.offsetsXForSide[par6],
              par3 + Facing.offsetsYForSide[par6],
              par4 + Facing.offsetsZForSide[par6]);

      if (var16 instanceof TileEntityPiston) {
        ((TileEntityPiston) var16).clearPistonTileEntity();
      }

      par1World.setBlock(par2, par3, par4, Block.pistonMoving.blockID, par6, 3);
      par1World.setBlockTileEntity(
          par2, par3, par4, BlockPistonMoving.getTileEntity(this.blockID, par6, par6, false, true));

      if (this.isSticky) {
        int var8 = par2 + Facing.offsetsXForSide[par6] * 2;
        int var9 = par3 + Facing.offsetsYForSide[par6] * 2;
        int var10 = par4 + Facing.offsetsZForSide[par6] * 2;
        int var11 = par1World.getBlockId(var8, var9, var10);
        int var12 = par1World.getBlockMetadata(var8, var9, var10);
        boolean var13 = false;

        if (var11 == Block.pistonMoving.blockID) {
          TileEntity var14 = par1World.getBlockTileEntity(var8, var9, var10);

          if (var14 instanceof TileEntityPiston) {
            TileEntityPiston var15 = (TileEntityPiston) var14;

            if (var15.getPistonOrientation() == par6 && var15.isExtending()) {
              var15.clearPistonTileEntity();
              var11 = var15.getStoredBlockID();
              var12 = var15.getBlockMetadata();
              var13 = true;
            }
          }
        }

        if (!var13
            && var11 > 0
            && canPushBlock(var11, par1World, var8, var9, var10, false)
            && (Block.blocksList[var11].getMobilityFlag() == 0
                || var11 == Block.pistonBase.blockID
                || var11 == Block.pistonStickyBase.blockID)) {
          par2 += Facing.offsetsXForSide[par6];
          par3 += Facing.offsetsYForSide[par6];
          par4 += Facing.offsetsZForSide[par6];
          par1World.setBlock(par2, par3, par4, Block.pistonMoving.blockID, var12, 3);
          par1World.setBlockTileEntity(
              par2, par3, par4, BlockPistonMoving.getTileEntity(var11, var12, par6, false, false));
          par1World.setBlockToAir(var8, var9, var10);
        } else if (!var13) {
          par1World.setBlockToAir(
              par2 + Facing.offsetsXForSide[par6],
              par3 + Facing.offsetsYForSide[par6],
              par4 + Facing.offsetsZForSide[par6]);
        }
      } else {
        par1World.setBlockToAir(
            par2 + Facing.offsetsXForSide[par6],
            par3 + Facing.offsetsYForSide[par6],
            par4 + Facing.offsetsZForSide[par6]);
      }

      par1World.playSoundEffect(
          (double) par2 + 0.5D,
          (double) par3 + 0.5D,
          (double) par4 + 0.5D,
          "tile.piston.in",
          0.5F,
          par1World.rand.nextFloat() * 0.15F + 0.6F);
    }

    return true;
  }
Пример #11
0
  public ItemStack onItemRightClick(ItemStack itemstack, World world, EntityPlayer player) {
    float var4 = 1.0F;
    double var5 = player.prevPosX + (player.posX - player.prevPosX) * (double) var4;
    double var7 =
        player.prevPosY
            + (player.posY - player.prevPosY) * (double) var4
            + 1.62D
            - (double) player.yOffset;
    double var9 = player.prevPosZ + (player.posZ - player.prevPosZ) * (double) var4;
    boolean var11 = this.isFull == 0;
    MovingObjectPosition mop = this.getMovingObjectPositionFromPlayer(world, player, var11);

    if (mop == null) {
      return itemstack;
    }
    if (mop.typeOfHit == EnumMovingObjectType.TILE) {
      int x = mop.blockX;
      int y = mop.blockY;
      int z = mop.blockZ;
      if (!world.canMineBlock(player, x, y, z)) {
        return itemstack;
      }
      if (isFull == 0) {
        int bID = world.getBlockId(x, y, z);
        if ((bID == Block.waterMoving.blockID || bID == Block.waterStill.blockID)
            && world.getBlockMetadata(x, y, z) == 0) {
          world.setBlockWithNotify(x, y, z, 0);
          return new ItemStack(mod_InfiTools.goldBucketWater);
        }
        if ((bID == Block.lavaMoving.blockID || bID == Block.lavaStill.blockID)
            && world.getBlockMetadata(x, y, z) == 0) {
          world.setBlockWithNotify(x, y, z, 0);
          return new ItemStack(mod_InfiTools.goldBucketLava);
        }
        if (bID == Block.sand.blockID) {
          world.setBlockWithNotify(x, y, z, 0);
          return new ItemStack(mod_InfiTools.goldBucketSand);
        }
        if (bID == Block.gravel.blockID) {
          world.setBlockWithNotify(x, y, z, 0);
          return new ItemStack(mod_InfiTools.goldBucketGravel);
        }
      } else {
        if (isFull < 0) {
          return new ItemStack(mod_InfiTools.goldBucketEmpty);
        }
        if (mop.sideHit == 0) {
          y--;
        }
        if (mop.sideHit == 1) {
          y++;
        }
        if (mop.sideHit == 2) {
          z--;
        }
        if (mop.sideHit == 3) {
          z++;
        }
        if (mop.sideHit == 4) {
          x--;
        }
        if (mop.sideHit == 5) {
          x++;
        }
        if (world.isAirBlock(x, y, z) || !world.getBlockMaterial(x, y, z).isSolid()) {
          if (world.worldProvider.isHellWorld && isFull == Block.waterMoving.blockID) {
            world.playSoundEffect(
                x + 0.5D,
                y + 0.5D,
                z + 0.5D,
                "random.fizz",
                0.5F,
                2.6F + (world.rand.nextFloat() - world.rand.nextFloat()) * 0.8F);
            for (int l = 0; l < 8; l++) {
              world.spawnParticle(
                  "largesmoke",
                  (double) x + Math.random(),
                  (double) y + Math.random(),
                  (double) z + Math.random(),
                  0.0D,
                  0.0D,
                  0.0D);
            }
          } else {
            world.setBlockAndMetadataWithNotify(x, y, z, isFull, 0);
          }
          return new ItemStack(mod_InfiTools.goldBucketEmpty);
        }
      }
    } else if (isFull == 0 && (mop.entityHit instanceof EntityCow)) {
      return new ItemStack(mod_InfiTools.goldBucketMilk);
    }
    return itemstack;
  }