Skip to content

Commit

Permalink
fix(client): use ResourceLocationUtil and BufferUploader#end for <=1.…
Browse files Browse the repository at this point in the history
…18.2
  • Loading branch information
Apehum committed Jun 8, 2024
1 parent 3fe1c4c commit e88d0e9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,12 @@ public static void disableScissor() {
}

public static void drawBuffer(@NotNull BufferBuilder buffer) {
//#if MC>11802
BufferUploader.drawWithShader(buffer.end());
//#else
//$$ buffer.end();
//$$ BufferUploader.end(buffer);
//#endif
}

public static void bindTexture(int index, @NotNull ResourceLocation location) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import su.plo.lib.mod.client.ResourceLocationUtil;
import su.plo.slib.api.entity.player.McGameProfile;

import java.util.Map;
Expand All @@ -38,7 +39,7 @@ public static synchronized void loadSkin(@NotNull UUID playerId,
if (skinLocation != null) return;

if (fallback != null) {
ResourceLocation fallbackIdentifier = ResourceLocation.tryBuild(
ResourceLocation fallbackIdentifier = ResourceLocationUtil.tryBuild(
"plasmovoice",
"skins/" + Hashing.sha1().hashUnencodedChars(nick.toLowerCase())
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.PoseStack;
import su.plo.lib.mod.client.ResourceLocationUtil;
import su.plo.slib.api.chat.component.McTextComponent;
import net.minecraft.resources.ResourceLocation;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -53,7 +54,7 @@ public TabButton(int x,
this.shadowColor = shadowColor;

this.iconLocation = iconLocation;
this.disabledIconLocation = ResourceLocation.tryBuild(
this.disabledIconLocation = ResourceLocationUtil.tryBuild(
iconLocation.getNamespace(),
iconLocation.getPath().replace(".png", "_disabled.png")
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package su.plo.lib.mod.client

import net.minecraft.resources.ResourceLocation

object ResourceLocationUtil {
@JvmStatic
fun tryBuild(namespace: String, location: String): ResourceLocation? =
//#if MC>11802
ResourceLocation.tryBuild(namespace, location)
//#else
//$$ ResourceLocation(namespace, location)
//#endif
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.mojang.authlib.minecraft.MinecraftProfileTexture
import net.minecraft.client.Minecraft
import net.minecraft.client.renderer.texture.HttpTexture
import net.minecraft.resources.ResourceLocation
import su.plo.lib.mod.client.ResourceLocationUtil
import su.plo.lib.mod.client.render.texture.ModPlayerSkins
import su.plo.voice.client.meta.PlasmoVoiceMeta
import java.io.File
Expand Down Expand Up @@ -77,7 +78,7 @@ object DeveloperCapeManager {

private fun getCapeLocationAsync(playerName: String): CompletableFuture<ResourceLocation?> =
CompletableFuture.supplyAsync {
val capeLocation = ResourceLocation.tryBuild("plasmovoice", "developer_capes/${playerName.lowercase()}")!!
val capeLocation = ResourceLocationUtil.tryBuild("plasmovoice", "developer_capes/${playerName.lowercase()}")!!

val url = URL("https://plasmovoice.com/capes/$playerName.png")

Expand Down

0 comments on commit e88d0e9

Please sign in to comment.