net.minecraft.resource.ResourceManager Java Examples

The following examples show how to use net.minecraft.resource.ResourceManager. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: NinePatch.java    From LibGui with MIT License 6 votes vote down vote up
@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;
}
 
Example #2
Source File: NinePatch.java    From LibGui with MIT License 5 votes vote down vote up
@Override
		protected void apply(Map<Identifier, Properties> meta, ResourceManager manager, Profiler profiler) {
			properties = new HashMap<>();
			for (Map.Entry<Identifier, Properties> entry : meta.entrySet()) {
				Identifier id = entry.getKey();
				Properties props = entry.getValue();

				Mode mode = TextureProperties.DEFAULT.getMode();
//				float cornerUv = TextureProperties.DEFAULT.getCornerUv();

				if (props.containsKey("mode")) {
					String modeStr = props.getProperty("mode");
					mode = Mode.fromString(modeStr);
					if (mode == null) {
						LibGuiClient.logger.error("Invalid mode '{}' in nine-patch metadata file for texture {}", modeStr, id);
						continue;
					}
				}

//				if (props.containsKey("cornerUv")) {
//					cornerUv = Float.parseFloat(props.getProperty("cornerUv"));
//				}

				TextureProperties texProperties = new TextureProperties(mode);
				properties.put(id, texProperties);
			}
		}
 
Example #3
Source File: PonyManager.java    From MineLittlePony with MIT License 5 votes vote down vote up
@Override
public CompletableFuture<Void> reload(Synchronizer sync, ResourceManager sender,
        Profiler serverProfiler, Profiler clientProfiler,
        Executor serverExecutor, Executor clientExecutor) {

    sync.getClass();
    return sync.whenPrepared(null).thenRunAsync(() -> {
        clientProfiler.startTick();
        clientProfiler.push("Reloading all background ponies");
        poniesCache.invalidateAll();
        backgroundPonyList.reloadAll(sender);
        clientProfiler.pop();
        clientProfiler.endTick();
    }, clientExecutor);
}
 
Example #4
Source File: DefaultArmourTextureResolver.java    From MineLittlePony with MIT License 5 votes vote down vote up
private Identifier resolve(Identifier... resources) {
    // check resource packs for either texture.

    ResourceManager manager = MinecraftClient.getInstance().getResourceManager();

    for (Identifier i : resources) {
        if (manager.containsResource(i)) {
            return i;
        }
    }

    return resources[resources.length - 1];
}
 
Example #5
Source File: MixinTranslationStorage.java    From multiconnect with MIT License 4 votes vote down vote up
@Inject(method = "load(Lnet/minecraft/resource/ResourceManager;Ljava/util/List;)Lnet/minecraft/client/resource/language/TranslationStorage;",
        at = @At(value = "INVOKE", target = "Lcom/google/common/collect/ImmutableMap;copyOf(Ljava/util/Map;)Lcom/google/common/collect/ImmutableMap;", remap = false),
        locals = LocalCapture.CAPTURE_FAILHARD)
private static void onLoad(ResourceManager resourceManager, List<LanguageDefinition> languages, CallbackInfoReturnable<TranslationStorage> ci, Map<String, String> translations) {
    OldLanguageManager.addExtraTranslations(languages.get(languages.size() - 1).getCode(), translations::put);
}
 
Example #6
Source File: MixinSpriteAtlasTexture.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@Inject(method = "stitch", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/texture/SpriteAtlasTexture;loadSprites(Lnet/minecraft/resource/ResourceManager;Ljava/util/Set;)Ljava/util/Collection;", ordinal = 0), locals = LocalCapture.CAPTURE_FAILHARD)
private void onStitch(ResourceManager resourceManager, Iterable<Identifier> iterable, Profiler profiler, CallbackInfoReturnable<SpriteAtlasTexture.Data> cir, Set<Identifier> set) {
	RenderEvents.onTextureStitchPre((SpriteAtlasTexture) (Object) this, set);
}
 
Example #7
Source File: ExistingFileHelper.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
private ResourceManager getManager(ResourceType type) {
	return type == ResourceType.CLIENT_RESOURCES ? clientResources : serverData;
}
 
Example #8
Source File: BackgroundPonyList.java    From MineLittlePony with MIT License 4 votes vote down vote up
public void reloadAll(ResourceManager resourceManager) {
    backgroundPonyList.clear();
    backgroundPonyList.addAll(resourceManager.findResources("textures/entity/pony", path -> path.endsWith(".png")));
    MineLittlePony.logger.info("Detected {} background ponies installed.", backgroundPonyList.size());
}