• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java FileResourcePack类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ReachableMethods类代码示例发布时间:2022-05-22
下一篇:
Java CompoundComparator类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap