コード例 #1
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;
  }
コード例 #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.");
  }