当前位置: 首页>>代码示例>>Java>>正文


Java FileResourcePack类代码示例

本文整理汇总了Java中net.minecraft.client.resources.FileResourcePack的典型用法代码示例。如果您正苦于以下问题:Java FileResourcePack类的具体用法?Java FileResourcePack怎么用?Java FileResourcePack使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FileResourcePack类属于net.minecraft.client.resources包,在下文中一共展示了FileResourcePack类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: inject

import net.minecraft.client.resources.FileResourcePack; //导入依赖的package包/类
/**
 * Inserts the resource pack into the game. Enabling the resource pack will
 * not be required, it will load automatically.
 * <p>
 * A cache of the pack zip will be kept in "resourcepack/[pack name].zip"
 * where "resourcepack" is a folder at the same level as the directory passed
 * into the constructor.
 */
public void inject() {
  if (FMLCommonHandler.instance().getEffectiveSide().isClient()) {
    try {
      if (defaultResourcePacks == null) {
        defaultResourcePacks = ReflectionHelper.getPrivateValue(Minecraft.class, Minecraft.getMinecraft(), "defaultResourcePacks", "field_110449_ao", "ap");
      }

      File dest = new File(dir.getParent() + "/resourcepack/" + zip.getName());
      EnderFileUtils.safeDelete(dest);
      FileUtils.copyFile(zip, dest);
      EnderFileUtils.safeDelete(zip);
      writeNewFile(new File(dest.getParent() + "/readme.txt"),
          EnderCore.lang.localize("resourcepack.readme") + "\n\n" + EnderCore.lang.localize("resourcepack.readme2"));
      defaultResourcePacks.add(new FileResourcePack(dest));
    } catch (Exception e) {
      EnderCore.logger.error("Failed to inject resource pack for mod {}", modid, e);
    }
  } else {
    EnderCore.logger.info("Skipping resource pack, we are on a dedicated server.");
  }
}
 
开发者ID:SleepyTrousers,项目名称:EnderCore,代码行数:30,代码来源:ResourcePackAssembler.java

示例2: generateSoundJSON

import net.minecraft.client.resources.FileResourcePack; //导入依赖的package包/类
/**
 * Dynamically generates a sound JSON file based on a resource pack's file structure.
 *
 * If it's a folder, then load it as a sound collection.
 * A sound collection falls under the same resource name. When called to play, it will pick a random sound from the collection to play it.
 *
 * If it's just a sound file, then load the sound file
 *
 * @param pack The resource pack to generate the sound JSON for.
 * @return The generated sound JSON.
 */
public static String generateSoundJSON(AbstractResourcePack pack) {
	StringWriter sw = new StringWriter();
	try (JsonGenerator json = Json.createGenerator(sw);) {
		json.writeStartObject();
		if (pack instanceof FileResourcePack) {
			//For zip resource packs
			try {
				generateSoundJSON((FileResourcePack) pack, json);
			} catch (Exception e) {
				Error error = new ExceptionInInitializerError("Error generating fake sound JSON file.");
				error.addSuppressed(e);
				throw error;
			}
		} else if (pack instanceof FolderResourcePack) {
			//For folder resource packs
			generateSoundJSON((FolderResourcePack) pack, json);
		}
		json.writeEnd().flush();
		return sw.toString();
	}
}
 
开发者ID:NOVA-Team,项目名称:NOVA-Core,代码行数:33,代码来源:NovaMinecraftPreloader.java

示例3: func_110516_a

import net.minecraft.client.resources.FileResourcePack; //导入依赖的package包/类
public void func_110516_a() throws IOException {
   this.field_110524_c = (ResourcePack)(this.field_110523_b.isDirectory()?new FolderResourcePack(this.field_110523_b):new FileResourcePack(this.field_110523_b));
   this.field_110521_d = (PackMetadataSection)this.field_110524_c.func_135058_a(this.field_110525_a.field_110621_c, "pack");

   try {
      this.field_110522_e = this.field_110524_c.func_110586_a();
   } catch (IOException var2) {
      ;
   }

   if(this.field_110522_e == null) {
      this.field_110522_e = this.field_110525_a.field_110620_b.func_110586_a();
   }

   this.func_110517_b();
}
 
开发者ID:HATB0T,项目名称:RuneCraftery,代码行数:17,代码来源:ResourcePackRepositoryEntry.java

示例4: createResourcePack

import net.minecraft.client.resources.FileResourcePack; //导入依赖的package包/类
private static IResourcePack createResourcePack(File file)
{
    if(file.isDirectory())
    {
        return new FolderResourcePack(file);
    }
    else
    {
        return new FileResourcePack(file);
    }
}
 
开发者ID:F1r3w477,项目名称:CustomWorldGen,代码行数:12,代码来源:SplashProgress.java

示例5: getZipEntryForResourcePack

import net.minecraft.client.resources.FileResourcePack; //导入依赖的package包/类
public static ZipEntry getZipEntryForResourcePack(FileResourcePack pack, String path) throws IOException {
	if (pack instanceof NovaFileResourcePack) {
		Optional<ZipEntry> entry = ((NovaFileResourcePack) pack).findFileCaseInsensitive(path);
		if (entry.isPresent())
			return entry.get();
	}

	try (ZipFile zf = new ZipFile(pack.resourcePackFile)) {
		return zf.getEntry(path);
	}
}
 
开发者ID:NOVA-Team,项目名称:NOVA-Core,代码行数:12,代码来源:NovaMinecraftPreloader.java

示例6: injectZipAsResource

import net.minecraft.client.resources.FileResourcePack; //导入依赖的package包/类
@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void injectZipAsResource(String zipDir)
{

    Object value = ObfuscationReflectionHelper.getPrivateValue(Minecraft.class, FMLClientHandler.instance().getClient(), "field_110449_ao", "defaultResourcePacks");

    if (value instanceof List)
    {
        FileResourcePack pack = new FileResourcePack(new File(zipDir));

        ((List) value).add(pack);
    }
}
 
开发者ID:TeamMetallurgy,项目名称:Metallurgy4,代码行数:15,代码来源:ClientProxy.java


注:本文中的net.minecraft.client.resources.FileResourcePack类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。