Exemplo n.º 1
0
 /**
  * Called upon block activation (left or right click on the block.). The three integers represent
  * x,y,z of the block.
  */
 public boolean blockActivated(World var1, int var2, int var3, int var4, EntityPlayer var5) {
   Random var6 = new Random();
   var1.playSoundEffect(
       (double) ((float) var2 + 0.5F),
       (double) ((float) var3 + 0.5F),
       (double) ((float) var4 + 0.5F),
       "mob.pig",
       1.0F + var6.nextFloat(),
       var6.nextFloat() * 0.7F + 0.3F);
   return true;
 }
  @Override
  public boolean onBlockActivated(
      World world,
      int i,
      int j,
      int k,
      EntityPlayer entityplayer,
      int something1,
      float something2,
      float something3,
      float something4) {
    if (world.isRemote) {
      return true;
    }

    TileEntityCamoFull entity = (TileEntityCamoFull) world.getBlockTileEntity(i, j, k);
    System.out.println("ACTIVATED: " + entity.getCopyID());

    int l = world.getBlockMetadata(i, j, k);
    int i1 = l & 7;
    int j1 = 8 - (l & 8);
    world.setBlockMetadataWithNotify(i, j, k, i1 + j1);
    world.markBlocksDirty(i, j, k, i, j, k);
    world.playSoundEffect(
        (double) i + 0.5D,
        (double) j + 0.5D,
        (double) k + 0.5D,
        "random.click",
        0.3F,
        j1 <= 0 ? 0.5F : 0.6F);
    world.notifyBlocksOfNeighborChange(i, j, k, blockID);
    world.markBlockNeedsUpdate(i, j, k);

    if (i1 == 1) {
      world.notifyBlocksOfNeighborChange(i - 1, j, k, blockID);
    } else if (i1 == 2) {
      world.notifyBlocksOfNeighborChange(i + 1, j, k, blockID);
    } else if (i1 == 3) {
      world.notifyBlocksOfNeighborChange(i, j, k - 1, blockID);
    } else if (i1 == 4) {
      world.notifyBlocksOfNeighborChange(i, j, k + 1, blockID);
    } else {
      world.notifyBlocksOfNeighborChange(i, j - 1, k, blockID);
    }

    return true;
  }
Exemplo n.º 3
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;
  }