public static void initDimension(int dim) {
    WorldServer overworld = getWorld(0);
    if (overworld == null) {
      throw new RuntimeException("Cannot Hotload Dim: Overworld is not Loaded!");
    }
    try {
      DimensionManager.getProviderType(dim);
    } catch (Exception e) {
      System.err.println("Cannot Hotload Dim: " + e.getMessage());
      return; // If a provider hasn't been registered then we can't hotload the dim
    }
    MinecraftServer mcServer = overworld.getMinecraftServer();
    ISaveHandler savehandler = overworld.getSaveHandler();
    WorldSettings worldSettings = new WorldSettings(overworld.getWorldInfo());

    WorldServer world =
        (dim == 0
            ? overworld
            : new WorldServerMulti(
                mcServer,
                savehandler,
                overworld.getWorldInfo().getWorldName(),
                dim,
                worldSettings,
                overworld,
                mcServer.theProfiler));
    world.addWorldAccess(new WorldManager(mcServer, world));
    MinecraftForge.EVENT_BUS.post(new WorldEvent.Load(world));
    if (!mcServer.isSinglePlayer()) {
      world.getWorldInfo().setGameType(mcServer.getGameType());
    }

    mcServer.func_147139_a(mcServer.func_147135_j());
  }
Example #2
0
 public static boolean onLivingDrops(
     EntityLiving entity,
     DamageSource source,
     ArrayList<EntityItem> drops,
     int lootingLevel,
     boolean recentlyHit,
     int specialDropValue) {
   return MinecraftForge.EVENT_BUS.post(
       new LivingDropsEvent(entity, source, drops, lootingLevel, recentlyHit, specialDropValue));
 }
Example #3
0
  public static EntityItem onPlayerTossEvent(EntityPlayer player, ItemStack item) {
    player.captureDrops = true;
    EntityItem ret = player.dropPlayerItemWithRandomChoice(item, false);
    player.capturedDrops.clear();
    player.captureDrops = false;

    ItemTossEvent event = new ItemTossEvent(ret, player);
    if (MinecraftForge.EVENT_BUS.post(event)) {
      return null;
    }

    player.joinEntityItemWithWorld(event.entityItem);
    return event.entityItem;
  }
 /*
  * To be called by the server at the appropriate time, do not call from mod code.
  */
 public static void unloadWorlds(Hashtable<Integer, long[]> worldTickTimes) {
   for (int id : unloadQueue) {
     WorldServer w = worlds.get(id);
     try {
       if (w != null) {
         w.saveAllChunks(true, null);
       } else {
         FMLLog.warning("Unexpected world unload - world %d is already unloaded", id);
       }
     } catch (MinecraftException e) {
       e.printStackTrace();
     } finally {
       if (w != null) {
         MinecraftForge.EVENT_BUS.post(new WorldEvent.Unload(w));
         w.flush();
         setWorld(id, null);
       }
     }
   }
   unloadQueue.clear();
 }
Example #5
0
  @Mod.EventHandler
  @SideOnly(Side.CLIENT)
  public void preInit(FMLPreInitializationEvent e) {
    Configuration config = new Configuration(e.getSuggestedConfigurationFile());
    config.load();
    // 读取配置文件
    ConfigVar.onlinecheck = config.get("Online", "Check", false).getBoolean();
    ConfigVar.version = config.get("Online", "Version", 1.0).getDouble();
    ConfigVar.announcementcheck = config.get("Online", "zAnnouncementCheck", false).getBoolean();
    ConfigVar.url = config.get("Online", "Url", "http://").getString();
    ConfigVar.downloads = config.get("Online", "Downloads", "http://").getString();

    ConfigVar.IsTwoAddress = config.get("Server", "1sTwoAddress", false).getBoolean();
    ConfigVar.ServerAddress = config.get("Server", "Address1", "127.0.0.1").getString();
    ConfigVar.ServerAddress1 = config.get("Server", "Address2", "127.0.0.1").getString();
    ConfigVar.Captain = config.get("Server", "Captain", "Minecraft 1.7.10").getString();
    ConfigVar.announcement = config.get("Server", "Announcement", "").getString();
    ConfigVar.announcementmove = config.get("Server", "AnnouncementMove", false).getBoolean();
    // 结束读取
    config.save();
    Display.setTitle(ConfigVar.Captain);
    MinecraftForge.EVENT_BUS.register(NewMenuHandler.instance);
  }
Example #6
0
 public static void onLivingJump(EntityLiving entity) {
   MinecraftForge.EVENT_BUS.post(new LivingJumpEvent(entity));
 }
Example #7
0
 public static float onLivingFall(EntityLiving entity, float distance) {
   LivingFallEvent event = new LivingFallEvent(entity, distance);
   return (MinecraftForge.EVENT_BUS.post(event) ? 0.0f : event.distance);
 }
Example #8
0
 public static boolean onLivingDeath(EntityLiving entity, DamageSource src) {
   return MinecraftForge.EVENT_BUS.post(new LivingDeathEvent(entity, src));
 }
Example #9
0
 public static int onLivingHurt(EntityLiving entity, DamageSource src, int amount) {
   LivingHurtEvent event = new LivingHurtEvent(entity, src, amount);
   return (MinecraftForge.EVENT_BUS.post(event) ? 0 : event.ammount);
 }
Example #10
0
 public static boolean onLivingAttack(EntityLiving entity, DamageSource src, int amount) {
   return MinecraftForge.EVENT_BUS.post(new LivingAttackEvent(entity, src, amount));
 }
Example #11
0
 public static boolean onLivingUpdate(EntityLiving entity) {
   return MinecraftForge.EVENT_BUS.post(new LivingUpdateEvent(entity));
 }
Example #12
0
 // Optifine Helper Functions u.u, these are here specifically for Optifine
 // Note: When using Optfine, these methods are invoked using reflection, which
 // incurs a major performance penalty.
 public static void onLivingSetAttackTarget(EntityLiving entity, EntityLiving target) {
   MinecraftForge.EVENT_BUS.post(new LivingSetAttackTargetEvent(entity, target));
 }
Example #13
0
 // @Mod.Init
 public void init(FMLInitializationEvent e) {
   MinecraftForge.EVENT_BUS.register(this);
   if (client != null) client.init(e);
 }