<commit_before>package net.minecraft.src;

import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import net.minecraft.client.Minecraft;
import watson.Controller;
import watson.EntityWatson;
import watson.RenderWatson;
import watson.chat.ChatProcessor;
import watson.debug.Log;

// --------------------------------------------------------------------------
/**
 * A ModLoader mod that displays LogBlock results as wireframe boxes.
 * 
 * TODO: Keep a map from (world,player) to EntityWatson instances.
 */
public class mod_Watson extends BaseMod
{
  // --------------------------------------------------------------------------
  /**
   * Constructor.
   */
  public mod_Watson()
  {
  }

  // --------------------------------------------------------------------------
  /**
   * Implements inherited method.
   */
  @Override
  public String getVersion()
  {
    return VERSION;
  }

  // --------------------------------------------------------------------------
  /**
   * And now for a game of "Guess the ModLoader API".
   */
  public String getPriorities()
  {
    return "required-before:mod_ClientCommands";
  }

  // --------------------------------------------------------------------------
  /**
   * Do the following initialisation when the mod is loaded:
   * <ul>
   * <li>Check that the ModLoader version matches and abort if not.</li>
   * <li>Call setInGameHook() to register this mod for regular onTickInGame()
   * calls.</li>
   * </ul>
   */
  @Override
  public void load()
  {
    Controller.createDirectories();

    Log.setDebug(true);
    Log.info("Loading Watson version " + VERSION);

    // Bail out if this mod's version doesn't match the ModLoader version.
    if (!getVersion().equals(getModLoaderVersion()))
    {
      Log.severe("mismatched ModLoader version: (" + getModLoaderVersion()
                 + ")");
      return;
    }

    Controller.instance.initialise();

    // The second true signifies that onTickInGame() should only be called
    // if the world clock has advanced.
    ModLoader.setInGameHook(this, true, true);
  } // load

  // --------------------------------------------------------------------------
  /**
   * Register WatsonRenderer as the renderer for WatsonEntity instances.
   */
  @Override
  @SuppressWarnings({"rawtypes", "unchecked"})
  public void addRenderer(Map entityClassToRenderMap)
  {
    entityClassToRenderMap.put(EntityWatson.class, new RenderWatson());
  }

  // --------------------------------------------------------------------------
  /**
   * Checks if the world or player has changed from the last time we checked. If
   * it's changed, spawn a new render entity and update accordingly.
   * 
   * All removes any chat messages in _chatQueue and passes them to the
   * _chatClassifier, where they will end up being handled by Sherlock and may
   * ultimately be rendered.
   * 
   * @param partialticks
   * @param mc
   * @return true to signify that we want to continue receiving callbacks
   *         (rather than be de-registered).
   */
  @Override
  public boolean onTickInGame(float partialticks, Minecraft mc)
  {
    if (mc.theWorld != _lastWorld || mc.thePlayer != _lastPlayer)
    {
      Log.debug("setting up EntityWatson");
      _lastWorld = mc.theWorld;
      _lastPlayer = mc.thePlayer;

      _watsonEntity = new EntityWatson(mc);
      mc.theWorld.spawnEntityInWorld(_watsonEntity);
    }

    ChatProcessor.getInstance().processChatQueue();
    return true;
  } // onTickInGame

  // --------------------------------------------------------------------------
  /**
   * Return the numeric portion of the ModLoader version.
   * 
   * The current (as of 1.3.1) form of the ModLoader version string is
   * "ModLoader 1.3.1", whereas this method just returns "1.3.1".
   * 
   * @return the numeric portion of the ModLoader version, or the empty string
   *         if there is none.
   */
  public String getModLoaderVersion()
  {
    final Pattern PATTERN = Pattern.compile("\\d(\\.\\d)+$");
    Matcher matcher = PATTERN.matcher(ModLoader.VERSION);
    return (matcher.find()) ? matcher.group() : "";
  }

  // --------------------------------------------------------------------------
  /**
   * Version string; should match Minecraft version or bail out.
   */
  private static final String VERSION = "1.3.2";

  // --------------------------------------------------------------------------
  /**
   * The world at the time that the last Entity used to render the edits was
   * spawned.
   */
  protected World             _lastWorld;

  /**
   * The player at the time that the last Entity used to render the edits was
   * spawned.
   */
  protected EntityPlayerSP    _lastPlayer;

  /**
   * An entity that depicts all of the edits currently under examination.
   */
  protected EntityWatson      _watsonEntity;

} // class mod_Watson<commit_msg>Updated to 1.4.2.<commit_after>package net.minecraft.src;

import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import net.minecraft.client.Minecraft;
import watson.Controller;
import watson.EntityWatson;
import watson.RenderWatson;
import watson.chat.ChatProcessor;
import watson.debug.Log;

// --------------------------------------------------------------------------
/**
 * A ModLoader mod that displays LogBlock results as wireframe boxes.
 * 
 * TODO: Keep a map from (world,player) to EntityWatson instances.
 */
public class mod_Watson extends BaseMod
{
  // --------------------------------------------------------------------------
  /**
   * Constructor.
   */
  public mod_Watson()
  {
  }

  // --------------------------------------------------------------------------
  /**
   * Implements inherited method.
   */
  @Override
  public String getVersion()
  {
    return VERSION;
  }

  // --------------------------------------------------------------------------
  /**
   * And now for a game of "Guess the ModLoader API".
   */
  public String getPriorities()
  {
    return "required-before:mod_ClientCommands";
  }

  // --------------------------------------------------------------------------
  /**
   * Do the following initialisation when the mod is loaded:
   * <ul>
   * <li>Check that the ModLoader version matches and abort if not.</li>
   * <li>Call setInGameHook() to register this mod for regular onTickInGame()
   * calls.</li>
   * </ul>
   */
  @Override
  public void load()
  {
    Controller.createDirectories();

    Log.setDebug(true);
    Log.info("Loading Watson version " + VERSION);

    // Bail out if this mod's version doesn't match the ModLoader version.
    if (!getVersion().equals(getModLoaderVersion()))
    {
      Log.severe("mismatched ModLoader version: (" + getModLoaderVersion()
                 + ")");
      return;
    }

    Controller.instance.initialise();

    // The second true signifies that onTickInGame() should only be called
    // if the world clock has advanced.
    ModLoader.setInGameHook(this, true, true);
  } // load

  // --------------------------------------------------------------------------
  /**
   * Register WatsonRenderer as the renderer for WatsonEntity instances.
   */
  @Override
  @SuppressWarnings({"rawtypes", "unchecked"})
  public void addRenderer(Map entityClassToRenderMap)
  {
    entityClassToRenderMap.put(EntityWatson.class, new RenderWatson());
  }

  // --------------------------------------------------------------------------
  /**
   * Checks if the world or player has changed from the last time we checked. If
   * it's changed, spawn a new render entity and update accordingly.
   * 
   * All removes any chat messages in _chatQueue and passes them to the
   * _chatClassifier, where they will end up being handled by Sherlock and may
   * ultimately be rendered.
   * 
   * @param partialticks
   * @param mc
   * @return true to signify that we want to continue receiving callbacks
   *         (rather than be de-registered).
   */
  @Override
  public boolean onTickInGame(float partialticks, Minecraft mc)
  {
    if (mc.theWorld != _lastWorld || mc.thePlayer != _lastPlayer)
    {
      Log.debug("setting up EntityWatson");
      _lastWorld = mc.theWorld;
      _lastPlayer = mc.thePlayer;

      _watsonEntity = new EntityWatson(mc);
      mc.theWorld.spawnEntityInWorld(_watsonEntity);
    }

    ChatProcessor.getInstance().processChatQueue();
    return true;
  } // onTickInGame

  // --------------------------------------------------------------------------
  /**
   * Return the numeric portion of the ModLoader version.
   * 
   * The current (as of 1.3.1) form of the ModLoader version string is
   * "ModLoader 1.3.1", whereas this method just returns "1.3.1".
   * 
   * @return the numeric portion of the ModLoader version, or the empty string
   *         if there is none.
   */
  public String getModLoaderVersion()
  {
    final Pattern PATTERN = Pattern.compile("\\d(\\.\\d)+$");
    Matcher matcher = PATTERN.matcher(ModLoader.VERSION);
    return (matcher.find()) ? matcher.group() : "";
  }

  // --------------------------------------------------------------------------
  /**
   * Version string; should match Minecraft version or bail out.
   */
  private static final String VERSION = "1.4.2";

  // --------------------------------------------------------------------------
  /**
   * The world at the time that the last Entity used to render the edits was
   * spawned.
   */
  protected World             _lastWorld;

  /**
   * The player at the time that the last Entity used to render the edits was
   * spawned.
   */
  protected EntityPlayerSP    _lastPlayer;

  /**
   * An entity that depicts all of the edits currently under examination.
   */
  protected EntityWatson      _watsonEntity;

} // class mod_Watson
{'fraction_non_alphanumeric': 0.24076342110634824, 'fraction_numerical': 0.0027556644213104714, 'mean_word_length': 1.6512445887445888, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4876375', 'n_tokens_mistral': 2616, 'n_tokens_neox': 2518, 'n_words': 787}