Skip to content

Commit

Permalink
fix: 1.16.5 changes
Browse files Browse the repository at this point in the history
  • Loading branch information
SiongSng committed Feb 27, 2023
1 parent 2aedcc4 commit 33ce422
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,14 +96,14 @@ public void render(PoseStack matrixStack, int i, CallbackInfo ci) {
ResourceLocation location = ChatComponentData.INSTANCE.getAvatarCache().getOrDefault(getAvatarUrl(chatComponent), null);

if (location == null) return;
RenderSystem.color4f(1, 1, 1, ChatComponentData.INSTANCE.getLastOpacity());
RenderSystem.blendColor(1, 1, 1, ChatComponentData.INSTANCE.getLastOpacity());
minecraft.getTextureManager().bind(location);
RenderSystem.enableBlend();
// Draw base layer
GuiComponent.blit(matrixStack, 0, ChatComponentData.INSTANCE.getLastY(), 8, 8, 8.0F, 8, 8, 8, 8, 8);
// Draw hat
GuiComponent.blit(matrixStack, 0, ChatComponentData.INSTANCE.getLastY(), 8, 8, 40.0F, 8, 8, 8, 8, 8);
RenderSystem.color4f(1, 1, 1, 1);
RenderSystem.blendColor(1, 1, 1, 1);
RenderSystem.disableBlend();
} catch (Exception e) {
RPMTWPlatformMod.LOGGER.warn("Rending universe chat component failed\n" + e);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
package com.rpmtw.rpmtw_platform_mod.events

import com.rpmtw.rpmtw_platform_mod.config.RPMTWConfig
import dev.architectury.event.events.common.PlayerEvent
import me.shedaniel.architectury.event.events.PlayerEvent
import net.minecraft.ChatFormatting
import net.minecraft.network.chat.ClickEvent
import net.minecraft.network.chat.Component
import net.minecraft.network.chat.HoverEvent
import net.minecraft.network.chat.TextComponent
import net.minecraft.network.chat.TranslatableComponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.rpmtw.rpmtw_platform_mod.handlers

import com.rpmtw.rpmtw_platform_mod.events.*
import me.shedaniel.architectury.event.events.GuiEvent
import me.shedaniel.architectury.event.events.PlayerEvent
import me.shedaniel.architectury.event.events.TooltipEvent
import me.shedaniel.architectury.event.events.client.ClientLifecycleEvent
import me.shedaniel.architectury.event.events.client.ClientRawInputEvent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand Down Expand Up @@ -60,7 +60,7 @@ private void findFiles(String dir, List<ResourceLocation> list, CallbackInfo ci)
}

@Inject(at = @At("HEAD"), method = "loadJson", cancellable = true, remap = false)
private void loadJson(Book book, ResourceLocation file, @Nullable ResourceLocation fallback, CallbackInfoReturnable<InputStream> callback) {
private void loadJson(ResourceLocation file, ResourceLocation fallback, CallbackInfoReturnable<InputStream> callback) {
RPMTWPlatformMod.LOGGER.debug("[Patchouli] Loading {}", file);
ResourceManager manager = Minecraft.getInstance().getResourceManager();
try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.packs.resources.ResourceManager;
import org.jetbrains.annotations.Nullable;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.injection.At;
Expand Down Expand Up @@ -41,22 +42,22 @@ private void findFiles(String dir, List<ResourceLocation> list, CallbackInfo ci)
Collection<ResourceLocation> files = Minecraft.getInstance().getResourceManager().listResources(prefix, p -> p.endsWith(".json"));

files.stream()
.distinct()
.filter(file -> file.getNamespace().equals(book.id.getNamespace()))
.map(file -> {
// caller expects list to contain logical id's, not file paths.
// we end up going from path -> id -> back to path, but it's okay as a transitional measure
Preconditions.checkArgument(file.getPath().startsWith(prefix));
Preconditions.checkArgument(file.getPath().endsWith(".json"));
String newPath = file.getPath().substring(prefix.length(), file.getPath().length() - ".json".length());
// Vanilla expects `prefix` above to not have a trailing slash, so we
// have to remove it ourselves from the path
if (newPath.startsWith("/")) {
newPath = newPath.substring(1);
}
return new ResourceLocation(file.getNamespace(), newPath);
})
.forEach(list::add);
.distinct()
.filter(file -> file.getNamespace().equals(book.id.getNamespace()))
.map(file -> {
// caller expects list to contain logical id's, not file paths.
// we end up going from path -> id -> back to path, but it's okay as a transitional measure
Preconditions.checkArgument(file.getPath().startsWith(prefix));
Preconditions.checkArgument(file.getPath().endsWith(".json"));
String newPath = file.getPath().substring(prefix.length(), file.getPath().length() - ".json".length());
// Vanilla expects `prefix` above to not have a trailing slash, so we
// have to remove it ourselves from the path
if (newPath.startsWith("/")) {
newPath = newPath.substring(1);
}
return new ResourceLocation(file.getNamespace(), newPath);
})
.forEach(list::add);
}

@Inject(at = @At("HEAD"), method = "loadJson", cancellable = true, remap = false)
Expand Down

0 comments on commit 33ce422

Please sign in to comment.