// An example showing how to get all players currently in game and check what achievements they
  // have
  public static void printPlayerAchievements() {
    if (FMLCommonHandler.instance().getMinecraftServerInstance() == null)
      return; // Return in the server is not running. Probably not necessary

    List allPlayers =
        FMLCommonHandler.instance()
            .getMinecraftServerInstance()
            .getConfigurationManager()
            .playerEntityList;
    List allAchievements = AchievementList.achievementList;

    for (Object playerObject : allPlayers) {
      if (!(playerObject instanceof EntityPlayerMP)) continue;

      EntityPlayerMP player = (EntityPlayerMP) playerObject;
      LogHelper.info(player.getCommandSenderName()); // Prints the in game name of the player

      for (Object achievementObject : allAchievements) {
        Achievement achievement = (Achievement) achievementObject;

        LogHelper.info(
            achievement.statId); // Prints the achievement id e.g. "achievement.ae2.Facade"
        LogHelper.info(
            StatCollector.translateToLocal(
                achievement.statId)); // This will get the localized name of the achievement
        LogHelper.info(
            player
                .func_147099_x()
                .hasAchievementUnlocked(
                    achievement)); // Prints true or false depending on weather or not the player
        // has this achievement unlocked
      }
    }
  }
Пример #2
0
 @SubscribeEvent
 // Load configuration file
 public void onConfigurationChangedEvent(ConfigChangedEvent.OnConfigChangedEvent event) {
   if (event.modID.equalsIgnoreCase(Ref.MOD_ID)) {
     try {
       loadConfiguration();
       LogHelper.info("Config file LOADED");
     } catch (Exception e) {
       LogHelper.info("Config file --ERROR--");
     }
   }
 }
Пример #3
0
 public static void init(File configFile) // Create the configuration object
       // from the given configuration
       // file
     {
   if (configuration == null) {
     try {
       configuration = new Configuration(configFile);
     } catch (Exception e) {
       LogHelper.info("Config file already exists");
     } finally {
       loadConfiguration();
       LogHelper.info("Config file LOADED");
     }
   }
 }
Пример #4
0
  @EventHandler
  public void preinit(FMLPreInitializationEvent event) {
    LogHelper.info("Let's Move!");
    FLNetwork.init();

    Configuration config = new Configuration(event.getSuggestedConfigurationFile());
    config.load();
    TilePusher.maxTiles =
        config.get(Configuration.CATEGORY_GENERAL, "maximumBlocksPushed", 1024).getInt(1024);
    TilePusher.powerPerTile =
        config.get(Configuration.CATEGORY_GENERAL, "energyPerBlock", 250).getInt(250);
    Recipes.shouldAddRecipes =
        config.get(Configuration.CATEGORY_GENERAL, "addRecipes", true).getBoolean(true);
    Recipes.shouldAddFrameCopyResetRecipes =
        config
            .get(Configuration.CATEGORY_GENERAL, "addFrameCopyResetRecipes", true)
            .getBoolean(true);
    redrawChunksInstantly = config.get("client", "redrawChunksInstantly", true).getBoolean(true);
    if (config.hasChanged()) config.save();

    EntityMovingEventHandler.init();
    MoverEventHandler.init();

    for (int i = 0; i < 4; i++) {
      BlockStickyFrame.curLoadingIndex = i;
      GameRegistry.register(frame[i] = new BlockStickyFrame());
      GameRegistry.register(
          new ItemBlockFrame(frame[i]).setRegistryName(frame[i].getRegistryName()));
    }
    GameRegistry.register(moving = new BlockMoving());
    pusher = new BlockPusher();
    pusher.setUnlocalizedName("funkylocomotion:pusher");
    pusher.setRegistryName("funkylocomotion:pusher");
    GameRegistry.register(pusher);
    GameRegistry.register(new ItemBlockPusher(pusher).setRegistryName(pusher.getRegistryName()));

    GameRegistry.register(slider = new BlockSlider());
    GameRegistry.register(new ItemBlock(slider).setRegistryName(slider.getRegistryName()));
    GameRegistry.register(teleporter = new BlockTeleport());
    GameRegistry.register(
        new ItemBlockTeleporter(teleporter).setRegistryName(teleporter.getRegistryName()));
    GameRegistry.register(booster = new BlockBooster());
    GameRegistry.register(new ItemBlock(booster).setRegistryName(booster.getRegistryName()));
    GameRegistry.register(frameProjector = new BlockFrameProjector());
    GameRegistry.register(
        new ItemBlock(frameProjector).setRegistryName(frameProjector.getRegistryName()));

    GameRegistry.register(wrench = WrenchFactory.makeMeAWrench());

    GameRegistry.registerTileEntity(TileMovingServer.class, "funkylocomotion:tileMover");
    GameRegistry.registerTileEntity(TilePusher.class, "funkylocomotion:tilePusher");
    GameRegistry.registerTileEntity(TileSlider.class, "funkylocomotion:tileSlider");
    GameRegistry.registerTileEntity(TileBooster.class, "funkylocomotion:tileBooster");
    GameRegistry.registerTileEntity(TileTeleport.class, "funkylocomotion:tileTeleporter");
    GameRegistry.registerTileEntity(TileFrameProjector.class, "funkylocomotion:tileFrameProjector");

    proxy.registerRendering();

    CompatHandler.initCompat(event.getAsmData());
  }
Пример #5
0
 @SuppressWarnings("deprecation")
 private void registerKeyBindings() {
   LogHelper.info("Watching your keys");
   FMLCommonHandler.instance().bus().register(new KeyHandler());
   ClientRegistry.registerKeyBinding(KeyHandler.drafting);
   ClientRegistry.registerKeyBinding(KeyHandler.makeSelection);
 }
Пример #6
0
  @Override
  public ItemStack onItemRightClick(ItemStack itemStack, World world, EntityPlayer entityPlayer) {
    LogHelper.info("CoolDown: " + coolDown);
    LogHelper.info("World.isRemote: " + world.isRemote);
    LogHelper.info("entityPlayer.worldObj.isRemote: " + entityPlayer.worldObj.isRemote);

    coolDown();

    if (entityPlayer.isSneaking()
        && entityPlayer.capabilities.isCreativeMode) // Change command in creative (MOVE THIS!)
    {
      NBTHelper.setInteger(itemStack, "commandID", NBTHelper.getInt(itemStack, "commandID") + 1);
      if (NBTHelper.getInt(itemStack, "commandID") > 4)
        NBTHelper.setInteger(itemStack, "commandID", 0);
    } else {
      if (!world.isRemote) {

        if (NBTHelper.getBoolean(itemStack, "isSet")) {
          LogHelper.info("Entered Function"); // DEBUG

          if (NBTHelper.getString(itemStack, "owner") == entityPlayer.getDisplayName()) {
            runCommand(itemStack, world, entityPlayer);
            ChatHelper.send(entityPlayer, "Command: " + NBTHelper.getString(itemStack, "command"));
            --itemStack.stackSize;
          } else {
            ChatHelper.send(entityPlayer, "You do not understand the symbols on the page.");
          }

        } else {
          NBTHelper.setBoolean(itemStack, "isSet", true);
          LogHelper.info("Entered Else"); // DEBUG
          ChatHelper.send(
              entityPlayer, EnumChatFormatting.BLUE + "The scroll reveals its true power!");
          NBTHelper.setBoolean(itemStack, "isSet", true);
          NBTHelper.setString(itemStack, "owner", entityPlayer.getDisplayName());
          NBTHelper.setString(itemStack, "command", getCommand(itemStack));
        }
      }
    }
    return itemStack;
  }
Пример #7
0
 /**
  * Attempts to read or write data from or to a file.
  *
  * <p>If the file is found to be missing or the reset parameter is set to true, the file will be
  * written with the default data, and the default data will be returned.
  *
  * <p>If the file is found to be a regular, readable file, the file is read in, and its contents
  * returned.
  *
  * <p>If the method runs into an error while attempting any of this, a message is printed to the
  * log, and the default data is returned.
  *
  * @param directory the directory the file is in.
  * @param fileName the name of the file, without the .txt ending.
  * @param defaultData the data to write to the file, or default to.
  * @param reset if the file should be overwritten with the default data.
  * @return the data contained in the file, or the default data.
  */
 public static String readOrWrite(
     String directory, String fileName, String defaultData, boolean reset) {
   Path path = Paths.get(directory, fileName + ".txt");
   try {
     if (Files.isRegularFile(path) && !reset) {
       return new String(Files.readAllBytes(path));
     } else {
       Files.write(path, defaultData.getBytes());
     }
   } catch (IOException e) {
     LogHelper.info("Caught IOException when reading " + path.getFileName());
   }
   return defaultData;
 }
Пример #8
0
  private static void loadConfiguration() // Configuration Elements
      {
    if (ConfigUtil.DebugMode) {
      LogHelper.info("Config Parameters --- BEGIN ---");
    } else {
    }

    // Debug Mode
    DebugMode = configuration.getBoolean("DebugMode", debug, Debug, Debug_comment);

    if (ConfigUtil.DebugMode) {
      LogHelper.info("Debug Mode: " + DebugMode);

      LogHelper.info("Config Parameters --- END ---");
    } else {
    }

    if (configuration.hasChanged()) // Save the configuration file
    {
      configuration.save();
      LogHelper.info("Config Saved");
    }
  }