下面列出了net.minecraft.util.profiler.Profiler#net.minecraft.resource.Resource 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
protected Map<Identifier, Properties> prepare(ResourceManager manager, Profiler profiler) {
Collection<Identifier> ids = manager.findResources("textures", s -> s.endsWith(SUFFIX));
Map<Identifier, Properties> result = new HashMap<>();
for (Identifier input : ids) {
try (Resource resource = manager.getResource(input);
InputStream stream = resource.getInputStream()) {
Properties props = new Properties();
props.load(stream);
Identifier textureId = new Identifier(input.getNamespace(), input.getPath().substring(0, input.getPath().length() - SUFFIX.length()));
result.put(textureId, props);
} catch (Exception e) {
LibGuiClient.logger.error("Error while loading metadata file {}, skipping...", input, e);
}
}
return result;
}
private <K> VillagerResourceMetadata.HatType loadHatType(Map<K, HatType> cache, String type, DefaultedRegistry<K> registry, K key) {
return cache.computeIfAbsent(key, k -> {
try (Resource res = resourceManager.getResource(findTexture(type, registry.getId(k)))) {
VillagerResourceMetadata meta = res.getMetadata(VillagerResourceMetadata.READER);
if (meta != null) {
return meta.getHatType();
}
} catch (IOException e) { }
return HatType.NONE;
});
}
@VisibleForTesting
public Resource getResource(Identifier identifier, ResourceType type, String pathSuffix, String pathPrefix) throws IOException {
return getManager(type).getResource(getLocation(identifier, pathSuffix, pathPrefix));
}