net.minecraft.util.ResourceLocation#getResourcePath ( )源码实例Demo

下面列出了net.minecraft.util.ResourceLocation#getResourcePath ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: GregTech   文件: TemplateManager.java
public static Template getBuiltinTemplate(World world, ResourceLocation templateId) {
    if (templateMap.containsKey(templateId)) {
        return templateMap.get(templateId);
    }
    Template template = new Template();
    String resourcePath = "/assets/" + templateId.getResourceDomain() + "/structures/" + templateId.getResourcePath() + ".nbt";
    InputStream inputStream = TemplateManager.class.getResourceAsStream(resourcePath);
    if (inputStream != null) {
        try {
            NBTTagCompound nbttagcompound = CompressedStreamTools.readCompressed(inputStream);
            if (!nbttagcompound.hasKey("DataVersion", 99)) {
                nbttagcompound.setInteger("DataVersion", 500);
            }
            DataFixer dataFixer = world.getMinecraftServer().getDataFixer();
            template.read(dataFixer.process(FixTypes.STRUCTURE, nbttagcompound));
        } catch (IOException exception) {
            GTLog.logger.error("Failed to load builtin template {}", templateId, exception);
        } finally {
            IOUtils.closeQuietly(inputStream);
        }
    } else {
        GTLog.logger.warn("Failed to find builtin structure with path {}", resourcePath);
    }
    templateMap.put(templateId, template);
    return template;
}
 
源代码2 项目: AdvancedRocketry   文件: ModelLoader.java
@Override
public IModel loadModel(ResourceLocation resourceLocation) {
	String resourcePath = resourceLocation.getResourcePath();
	/*if (!resourcePath.startsWith(SMART_MODEL_RESOURCE_LOCATION)) {
		assert false : "loadModel expected " + SMART_MODEL_RESOURCE_LOCATION + " but found " + resourcePath;
	}*/
	String modelName = resourcePath;//.substring(SMART_MODEL_RESOURCE_LOCATION.length());

	if (modelName.contains("rocketmotor")) {
		return new ModelRocket();
	} else {
		try {
			return ModelLoaderRegistry.getModel(new ResourceLocation(modelName));
		} catch (Exception e) {
			return ModelLoaderRegistry.getMissingModel();
		}// ModelLoaderRegistry.getMissingModel();
	}
}
 
源代码3 项目: GregTech   文件: AbstractBlockModelFactory.java
@Override
public InputStream getInputStream(ResourceLocation location) throws IOException {
    String resourcePath = location.getResourcePath(); // blockstates/compressed_1.json
    resourcePath = resourcePath.substring(0, resourcePath.length() - 5); //remove .json
    resourcePath = resourcePath.substring(12); //remove blockstates/
    if (resourcePath.startsWith(blockNamePrefix)) {
        Block block = Block.REGISTRY.getObject(new ResourceLocation(location.getResourceDomain(), resourcePath));
        if (block != null && block != Blocks.AIR) {
            return FileUtility.writeInputStream(fillSample(block, blockStateSample));
        }
        throw new IllegalArgumentException("Block not found: " + resourcePath);
    }
    throw new FileNotFoundException(location.toString());
}
 
源代码4 项目: Et-Futurum   文件: NewSkinManager.java
@Override
public ResourceLocation func_152789_a(final MinecraftProfileTexture texture, final Type type, final SkinManager.SkinAvailableCallback callBack) {
	if (type != Type.SKIN)
		return super.func_152789_a(texture, type, callBack);

	final boolean isSpecialCallBack = callBack instanceof ISkinDownloadCallback;
	final ResourceLocation resLocationOld = new ResourceLocation("skins/" + texture.getHash());
	final ResourceLocation resLocation = new ResourceLocation(Reference.MOD_ID, resLocationOld.getResourcePath());
	ITextureObject itextureobject = textureManager.getTexture(resLocation);

	if (itextureobject != null) {
		if (callBack != null)
			callBack.func_152121_a(type, resLocation);
	} else {
		File file1 = new File(skinFolder, texture.getHash().substring(0, 2));
		File file2 = new File(file1, texture.getHash());
		final NewImageBufferDownload imgDownload = new NewImageBufferDownload();
		ITextureObject imgData = new NewThreadDownloadImageData(file2, texture.getUrl(), field_152793_a, imgDownload, resLocationOld, new IImageBuffer() {

			@Override
			public BufferedImage parseUserSkin(BufferedImage buffImg) {
				if (buffImg != null)
					PlayerModelManager.analyseTexture(buffImg, resLocation);
				return imgDownload.parseUserSkin(buffImg);
			}

			@Override
			public void func_152634_a() {
				imgDownload.func_152634_a();
				if (callBack != null)
					callBack.func_152121_a(type, isSpecialCallBack ? resLocation : resLocationOld);
			}
		});
		textureManager.loadTexture(resLocation, imgData);
		textureManager.loadTexture(resLocationOld, imgData); // Avoid thrown exception if the image is requested before the download is done
	}

	return isSpecialCallBack ? resLocation : resLocationOld;
}
 
源代码5 项目: YUNoMakeGoodMap   文件: StructureUtil.java
public static Template loadTemplate(ResourceLocation loc, WorldServer world, boolean allowNull)
{
    boolean config = "/config/".equals(loc.getResourceDomain());
    File file = new File(YUNoMakeGoodMap.instance.getStructFolder(), loc.getResourcePath() + ".nbt");

    if (config && file.exists())
    {
        try
        {
            return loadTemplate(new FileInputStream(file));
        }
        catch (FileNotFoundException e) //literally cant happen but whatever..
        {
            e.printStackTrace();
            return allowNull ? null : getDefault(world);
        }
    }
    else
    {
        ResourceLocation res = config ? new ResourceLocation(YUNoMakeGoodMap.MODID + ":" + loc.getResourcePath()) : loc;
        Template ret = loadTemplate(StructureLoader.class.getResourceAsStream("/assets/" + res.getResourceDomain() + "/structures/" + res.getResourcePath() + ".nbt")); //We're on the server we don't have Resource Packs.
        if (ret != null)
            return ret;

        //Cant find it, lets load the one shipped with this mod.
        (new FileNotFoundException(file.toString())).printStackTrace();
        return allowNull ? null : getDefault(world);
    }
}
 
源代码6 项目: IGW-mod   文件: WikiRegistry.java
public static String getPageForEntityClass(Class<? extends Entity> entityClass){
    String page = entityPageEntries.get(entityClass);
    if(page != null) {
        return page;
    } else {
        ResourceLocation entityName = EntityList.getKey(entityClass);
        return entityName == null ? null : "entity/" + entityName.getResourcePath();
    }
}
 
源代码7 项目: Kettle   文件: CraftNamespacedKey.java
public static NamespacedKey fromMinecraft(ResourceLocation minecraft) {
    return new NamespacedKey(minecraft.getResourceDomain(), minecraft.getResourcePath());
}
 
源代码8 项目: NOVA-Core   文件: AssetConverter.java
@Override
public Asset toNova(ResourceLocation resource) {
	return new Asset(resource.getResourceDomain(), resource.getResourcePath()) {};
}
 
源代码9 项目: NOVA-Core   文件: AssetConverter.java
public Texture toNovaTexture(ResourceLocation resource) {
	return new Texture(resource.getResourceDomain(), resource.getResourcePath());
}
 
源代码10 项目: NOVA-Core   文件: AssetConverter.java
@Override
public Asset toNova(ResourceLocation resource) {
	return new Asset(resource.getResourceDomain(), resource.getResourcePath());
}
 
源代码11 项目: NOVA-Core   文件: AssetConverter.java
public Texture toNovaTexture(ResourceLocation resource) {
	return new Texture(resource.getResourceDomain(), resource.getResourcePath());
}
 
源代码12 项目: NOVA-Core   文件: AssetConverter.java
@Override
public Asset toNova(ResourceLocation resource) {
	return new Asset(resource.getResourceDomain(), resource.getResourcePath());
}
 
源代码13 项目: NOVA-Core   文件: AssetConverter.java
public Asset toNovaTexture(ResourceLocation resource) {
	return new Texture(resource.getResourceDomain(), resource.getResourcePath());
}
 
源代码14 项目: OpenModsLib   文件: HitboxManager.java
public Holder(ResourceLocation location) {
	this.location = new ResourceLocation(location.getResourceDomain(), "hitboxes/" + location.getResourcePath() + ".json");
}