@Override
 public void onNeighborBlockChange(World world, int i, int j, int k, int l) {
   if (l > 0
       && Block.blocksList[l].canProvidePower()
       && world.isBlockIndirectlyGettingPowered(i, j, k)
       && world.getBlockMetadata(i, j, k) != 12
       && world.getBlockMetadata(i, j, k) != 0
       && world.getBlockMetadata(i, j, k) != 15) {
     onBlockDestroyedByExplosion(world, i, j, k);
     world.setBlockWithNotify(i, j, k, 0);
   }
 }
  @Override
  public void onBlockAdded(World world, int i, int j, int k) {
    super.onBlockAdded(world, i, j, k);

    if (world.isBlockIndirectlyGettingPowered(i, j, k)
        && world.getBlockMetadata(i, j, k) != 12
        && world.getBlockMetadata(i, j, k) != 0
        && world.getBlockMetadata(i, j, k) != 15) {
      onBlockDestroyedByExplosion(world, i, j, k);
      world.setBlockWithNotify(i, j, k, 0);
    }
  }
  public ItemStack fillCustomBucket(World w, int i, int j, int k) {
    if (w.getBlockId(i, j, k) == Zoo.saltwaterStill.blockID
        || w.getBlockId(i, j, k) == Zoo.saltwaterMoving.blockID) {
      w.setBlockWithNotify(i, j, k, 0);

      EntityPlayer player = ModLoader.getMinecraftInstance().thePlayer;
      if (!player.capabilities.isCreativeMode) {
        return new ItemStack(this);
      }
    }

    return null;
  }
示例#4
0
 private void glow(World world, int i, int j, int k) {
   if (world.getBlockMetadata(i, j, k) > 11) sparkle(world, i, j, k);
   /*if (blockID == Block.oreRedstone.blockID)
   {
       world.setBlockWithNotify(i, j, k, Block.oreRedstoneGlowing.blockID);
   }*/
 }
示例#5
0
 private void sparkle(World world, int i, int j, int k) {
   Random random = world.rand;
   double d = 0.0625D;
   for (int l = 0; l < 6; l++) {
     double d1 = (float) i + random.nextFloat();
     double d2 = (float) j + random.nextFloat();
     double d3 = (float) k + random.nextFloat();
     if (l == 0 && !world.isBlockOpaqueCube(i, j + 1, k)) {
       d2 = (double) (j + 1) + d;
     }
     if (l == 1 && !world.isBlockOpaqueCube(i, j - 1, k)) {
       d2 = (double) (j + 0) - d;
     }
     if (l == 2 && !world.isBlockOpaqueCube(i, j, k + 1)) {
       d3 = (double) (k + 1) + d;
     }
     if (l == 3 && !world.isBlockOpaqueCube(i, j, k - 1)) {
       d3 = (double) (k + 0) - d;
     }
     if (l == 4 && !world.isBlockOpaqueCube(i + 1, j, k)) {
       d1 = (double) (i + 1) + d;
     }
     if (l == 5 && !world.isBlockOpaqueCube(i - 1, j, k)) {
       d1 = (double) (i + 0) - d;
     }
     if (d1 < (double) i
         || d1 > (double) (i + 1)
         || d2 < 0.0D
         || d2 > (double) (j + 1)
         || d3 < (double) k
         || d3 > (double) (k + 1)) {
       world.spawnParticle("reddust", d1, d2, d3, 0.0D, 0.0D, 0.0D);
     }
   }
 }
  @Override
  public boolean canPlaceBlockAt(World world, int i, int j, int k) {
    if (!super.canPlaceBlockAt(world, i, j, k)) {
      return false;
    }

    int l = world.getBlockId(i, j + 1, k);
    return l == 0;
  }
  @Override
  public boolean blockActivated(World world, int i, int j, int k, EntityPlayer entityplayer) {
    int arg = world.getBlockMetadata(i, j, k);

    if (entityplayer != null
        && entityplayer.getCurrentEquippedItem() != null
        && (entityplayer.getCurrentEquippedItem().itemID == Ic2Items.wrench.itemID
            || entityplayer.getCurrentEquippedItem().itemID == Ic2Items.electricWrench.itemID)) {
      this.dropBlockAsItem(world, i, j, k, arg, 1);
      world.setBlockWithNotify(i, j, k, 0);
      world.setBlockWithNotify(i, j + 1, k, 0);
      return false;
    }

    if (arg == 12 || arg == 15 || arg == 0) {
      TileEntityMissile titty = (TileEntityMissile) world.getBlockTileEntity(i, j, k);
      titty.launch(entityplayer);
    }

    return false;
  }
  @Override
  public void onBlockClicked(World world, int i, int j, int k, EntityPlayer entityplayer) {
    world.markBlockNeedsUpdate(i, j, k);
    TileEntityMissile titty = (TileEntityMissile) world.getBlockTileEntity(i, j, k);

    if (entityplayer.getCurrentEquippedItem() != null
        && entityplayer.getCurrentEquippedItem().getItem() instanceof ItemRangefinder) {
      titty.targetX = ItemRangefinder.ecks;
      titty.targetZ = ItemRangefinder.zee;
    } else {
      if ((int) Math.floor(entityplayer.posX) > i) {
        titty.targetX -= 5;
      } else if ((int) Math.floor(entityplayer.posX) < i) {
        titty.targetX += 5;
      }

      if ((int) Math.floor(entityplayer.posZ) > k) {
        titty.targetZ -= 5;
      } else if ((int) Math.floor(entityplayer.posZ) < k) {
        titty.targetZ += 5;
      }
    }

    String name;

    if (world.getBlockMetadata(i, j, k) == 12
        || world.getBlockMetadata(i, j, k) == 0
        || world.getBlockMetadata(i, j, k) == 15) {
      name = "Passenger rocket";
    } else if (world.getBlockMetadata(i, j, k) == 8) {
      name = "Nuclear missile";
    } else if (world.getBlockMetadata(i, j, k) == 4) {
      name = "Incendiary missile";
    } else if (world.getBlockMetadata(i, j, k) == 13) {
      name = "Thermonuclear missile";
    } else {
      name = "Missile";
    }

    ModLoader.getMinecraftInstance()
        .ingameGUI
        .addChatMessage(
            name
                + " targeted at ("
                + titty.targetX
                + ", "
                + titty.targetZ
                + ") relative to current position.");
  }
示例#9
0
 public void updateTick(World world, int i, int j, int k, Random random) {
   if (world.isRemote) {
     return;
   }
   if (world.getBlockLightValue(i, j + 1, k) < 4
       && Block.lightOpacity[world.getBlockId(i, j + 1, k)] > 2) {
     world.setBlockWithNotify(i, j, k, Block.dirt.blockID);
   } else if (world.getBlockLightValue(i, j + 1, k) >= 9) {
     for (int l = 0; l < 4; l++) {
       int i1 = (i + random.nextInt(3)) - 1;
       int j1 = (j + random.nextInt(5)) - 3;
       int k1 = (k + random.nextInt(3)) - 1;
       int l1 = world.getBlockId(i1, j1 + 1, k1);
       if (world.getBlockId(i1, j1, k1) == Block.dirt.blockID
           && world.getBlockLightValue(i1, j1 + 1, k1) >= 4
           && Block.lightOpacity[l1] <= 2) {
         if (blockID == ZooDirts.savannah.blockID) {
           world.setBlockWithNotify(i1, j1, k1, ZooDirts.savannah.blockID);
         }
         if (blockID == ZooDirts.tropical.blockID) {
           world.setBlockWithNotify(i1, j1, k1, ZooDirts.tropical.blockID);
         }
         if (blockID == ZooDirts.coniferous.blockID) {
           world.setBlockWithNotify(i1, j1, k1, ZooDirts.coniferous.blockID);
         }
         if (blockID == ZooDirts.deciduous.blockID) {
           world.setBlockWithNotify(i1, j1, k1, ZooDirts.deciduous.blockID);
         }
       }
     }
   }
 }
 @Override
 public void onBlockDestroyedByExplosion(World world, int i, int j, int k) {
   TileEntityMissile titty = (TileEntityMissile) world.getBlockTileEntity(i, j, k);
   titty.launch(null);
 }
 @Override
 public void onBlockPlaced(World world, int i, int j, int k, int l) {
   world.setBlockWithNotify(i, j + 1, k, mod_RocketScience.blockWarheadId);
   world.setBlockMetadata(i, j + 1, k, world.getBlockMetadata(i, j, k));
 }