net.minecraft.resource.ResourceType Java Examples

The following examples show how to use net.minecraft.resource.ResourceType. 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: AddonFolderResourcePack.java    From Sandbox with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public Set<String> getNamespaces(ResourceType type) {
    Set<String> namespaces = Sets.newHashSet();
    File baseFile = new File(this.base, type.getDirectory());
    File[] files = baseFile.listFiles((FilenameFilter) DirectoryFileFilter.DIRECTORY);
    if (files != null) {
        for (File file : files) {
            String path = relativize(baseFile, file);
            if (path.equals(path.toLowerCase(Locale.ROOT))) {
                namespaces.add(path.substring(0, path.length() - 1));
            } else {
                this.warnNonLowercaseNamespace(path);
            }
        }
    }

    return namespaces;
}
 
Example #2
Source File: MineLittlePony.java    From MineLittlePony with MIT License 6 votes vote down vote up
@Override
public void onInitializeClient() {
    hasHdSkins = FabricLoader.getInstance().isModLoaded("hdskins");
    hasModMenu = FabricLoader.getInstance().isModLoaded("modmenu");

    config = new ClientPonyConfig(GamePaths.getConfigDirectory().resolve("minelp.json"));
    ponyManager = new PonyManager(config);

    KeyBindingHelper.registerKeyBinding(keyBinding);

    ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(ponyManager);

    // convert legacy pony skins
    SkinFilterCallback.EVENT.register(new LegacySkinConverter());

    // general events
    ClientReadyCallback.Handler.register();
    ClientTickCallback.EVENT.register(this::onTick);
    ClientReadyCallback.EVENT.register(this::onClientReady);
    ScreenInitCallback.EVENT.register(this::onScreenInit);
    config.ponyskulls.onChanged(PonySkullRenderer::resolve);

    config.load();

    ModelType.bootstrap();
}
 
Example #3
Source File: TheHallowClient.java    From the-hallow with MIT License 5 votes vote down vote up
@Override
public void onInitializeClient() {
	HallowedEntityRenderers.init();
	HallowedBlockEntityRenderers.init();
	HallowedRenderLayers.init();
	HallowedClientNetworking.init();
	HallowedColors.init();

	ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(new FluidResourceLoader());
}
 
Example #4
Source File: ExistingFileHelper.java    From patchwork-api with GNU Lesser General Public License v2.1 5 votes vote down vote up
public ExistingFileHelper(Collection<Path> existingPacks, boolean enable) {
	this.clientResources = new ReloadableResourceManagerImpl(ResourceType.CLIENT_RESOURCES, Thread.currentThread());
	this.serverData = new ReloadableResourceManagerImpl(ResourceType.SERVER_DATA, Thread.currentThread());
	this.clientResources.addPack(new DefaultResourcePack("minecraft", "realms"));
	this.serverData.addPack(new DefaultResourcePack("minecraft"));

	for (Path existing : existingPacks) {
		File file = existing.toFile();
		ResourcePack pack = file.isDirectory() ? new DirectoryResourcePack(file) : new ZipResourcePack(file);
		this.clientResources.addPack(pack);
		this.serverData.addPack(pack);
	}

	this.enable = enable;
}
 
Example #5
Source File: LibGuiClient.java    From LibGui with MIT License 4 votes vote down vote up
@Override
public void onInitializeClient() {
	config = loadConfig();

	ResourceManagerHelper.get(ResourceType.CLIENT_RESOURCES).registerReloadListener(NinePatch.MetadataLoader.INSTANCE);
}
 
Example #6
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 #7
Source File: ExistingFileHelper.java    From patchwork-api with GNU Lesser General Public License v2.1 4 votes vote down vote up
@VisibleForTesting
public Resource getResource(Identifier identifier, ResourceType type, String pathSuffix, String pathPrefix) throws IOException {
	return getManager(type).getResource(getLocation(identifier, pathSuffix, pathPrefix));
}
 
Example #8
Source File: SandboxResources.java    From Sandbox with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public Set<String> getNamespaces(ResourceType var1) {
    return Sets.newHashSet("minecraft", "sandbox");
}
 
Example #9
Source File: ExistingFileHelper.java    From patchwork-api with GNU Lesser General Public License v2.1 3 votes vote down vote up
/**
 * Check if a given resource exists in the known resource packs.
 *
 * @param identifier the base identifier of the resource, e.g. {@code "minecraft:block/stone"}
 * @param type       the type of resources to check
 * @param pathSuffix a string to append after the path, e.g. {@code ".json"}
 * @param pathPrefix a string to append before the path, before a slash, e.g. {@code "models"}
 * @return {@code true} if the resource exists in any pack, {@code false} otherwise
 */
public boolean exists(Identifier identifier, ResourceType type, String pathSuffix, String pathPrefix) {
	if (!enable) {
		return true;
	}

	return getManager(type).containsResource(getLocation(identifier, pathSuffix, pathPrefix));
}