-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
399ad70
commit 49cfec1
Showing
10 changed files
with
121 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/net/frozenblock/lib/cape/client/api/ClientCapeUtil.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package net.frozenblock.lib.cape.client.api; | ||
|
||
import com.google.gson.JsonIOException; | ||
import java.nio.file.Path; | ||
import java.util.concurrent.CompletableFuture; | ||
import net.fabricmc.api.EnvType; | ||
import net.fabricmc.api.Environment; | ||
import net.fabricmc.fabric.api.resource.ResourceManagerHelper; | ||
import net.fabricmc.fabric.api.resource.SimpleSynchronousResourceReloadListener; | ||
import net.minecraft.client.Minecraft; | ||
import net.minecraft.client.renderer.texture.HttpTexture; | ||
import net.minecraft.client.resources.DefaultPlayerSkin; | ||
import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.server.packs.PackType; | ||
import net.minecraft.server.packs.resources.ResourceManager; | ||
import org.jetbrains.annotations.NotNull; | ||
|
||
@Environment(EnvType.CLIENT) | ||
public class ClientCapeUtil { | ||
public static final Path CAPE_CACHE_PATH = Minecraft.getInstance().gameDirectory.toPath().resolve("frozenlib_cape_cache"); | ||
|
||
public static void registerCapeTextureFromURL( | ||
@NotNull ResourceLocation capeLocation, ResourceLocation capeTextureLocation, String textureURL | ||
) throws JsonIOException { | ||
ResourceManagerHelper.get(PackType.CLIENT_RESOURCES).registerReloadListener(new SimpleSynchronousResourceReloadListener() { | ||
@Override | ||
public ResourceLocation getFabricId() { | ||
return capeLocation; | ||
} | ||
|
||
@Override | ||
public void onResourceManagerReload(@NotNull ResourceManager resourceManager) { | ||
CompletableFuture<ResourceLocation> completableFuture = new CompletableFuture<>(); | ||
HttpTexture httpTexture = new HttpTexture( | ||
CAPE_CACHE_PATH.resolve(capeLocation.getNamespace()).resolve(capeLocation.getPath() + ".png").toFile(), | ||
textureURL, | ||
DefaultPlayerSkin.getDefaultTexture(), | ||
false, | ||
() -> completableFuture.complete(capeTextureLocation) | ||
); | ||
Minecraft.getInstance().getTextureManager().register(capeTextureLocation, httpTexture); | ||
} | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed
BIN
-512 Bytes
src/main/resources/assets/frozenlib/textures/cape/frozenblock.png
Binary file not shown.
Binary file removed
BIN
-147 Bytes
src/main/resources/assets/frozenlib/textures/cape/very_blue_cape.png
Binary file not shown.