コード例 #1
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;
  }
コード例 #2
0
  @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.");
  }
コード例 #3
0
 @Override
 public void onBlockDestroyedByExplosion(World world, int i, int j, int k) {
   TileEntityMissile titty = (TileEntityMissile) world.getBlockTileEntity(i, j, k);
   titty.launch(null);
 }