Skip to content

Commit

Permalink
Update to 1.21.3 (Fabric) (#491)
Browse files Browse the repository at this point in the history
* Fabric: It runs

* Fabric: renders now semi correctly

* Remove debug stuff

Oups, forgot to remove the debug stuff

* Transform `setKeyPair` method instead of copying contents

---------

Co-authored-by: Aizistral <admin@aizistral.com>
  • Loading branch information
Onako2 and Aizistral authored Oct 29, 2024
1 parent cb05b3c commit b630c1f
Show file tree
Hide file tree
Showing 13 changed files with 92 additions and 113 deletions.
4 changes: 3 additions & 1 deletion forge/src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ public net.minecraft.client.gui.components.Tooltip <init>(Lnet/minecraft/network
#public-f net.minecraft.client.gui.components.CycleButton m_257795_()V #updateTooltip

public-f net.minecraft.client.gui.components.AbstractWidget m_88315_(Lnet/minecraft/client/gui/GuiGraphics;IIF)V #render
public net.minecraft.client.gui.components.WidgetTooltipHolder m_323619_(Lnet/minecraft/client/gui/navigation/ScreenRectangle;ZZ)Lnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipPositioner; #createTooltipPositioner
public net.minecraft.client.gui.components.WidgetTooltipHolder m_323619_(Lnet/minecraft/client/gui/navigation/ScreenRectangle;ZZ)Lnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipPositioner; #createTooltipPositioner

public net.minecraft.client.multiplayer.ClientPacketListener m_260951_(Lnet/minecraft/world/entity/player/ProfileKeyPair;)V #setKeyPair
20 changes: 10 additions & 10 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ org.gradle.jvmargs=-Xmx4G
org.gradle.daemon=false

# Toolchain Properties
minecraft_version=1.21.1
yarn_mappings=1.21.1+build.3
fabric_loader_version=0.16.7
forge_version=1.21.1-52.0.24
neoforge_version=21.1.73
minecraft_version=1.21.3
yarn_mappings=1.21.3+build.2
fabric_loader_version=0.15.11
forge_version=1.21.3-53.0.4
neoforge_version=21.3.4-beta

# Mod Properties
mod_version=1.21.1-v2.9.0
mod_version=1.21.3-v2.10.0
maven_group=com.aizistral.nochatreports
archives_base_name=NoChatReports-FABRIC
mod_id=nochatreports
Expand All @@ -23,12 +23,12 @@ mod_icon=assets/nochatreports/textures/misc/ncr_logo.png
mod_license=WTFPL

# Dependencies
fabric_version=0.107.0+1.21.1
mod_menu_version=11.0.0-rc.4
cloth_config_version=15.0.127
fabric_version=0.107.0+1.21.3
mod_menu_version=12.0.0-beta.1
cloth_config_version=16.0.141

# Dependencies in mods.toml
dep_forge=[47,)
dep_forge=[53,)
dep_neoforge=[21.0.0,)
dep_minecraft=[1.21,)

Expand Down
4 changes: 3 additions & 1 deletion neoforge/src/main/resources/META-INF/accesstransformer.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,6 @@ public net.minecraft.client.gui.components.Tooltip <init>(Lnet/minecraft/network
#public-f net.minecraft.client.gui.components.CycleButton updateTooltip()V

public-f net.minecraft.client.gui.components.AbstractWidget render(Lnet/minecraft/client/gui/GuiGraphics;IIF)V
public net.minecraft.client.gui.components.WidgetTooltipHolder createTooltipPositioner(Lnet/minecraft/client/gui/navigation/ScreenRectangle;ZZ)Lnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipPositioner;
public net.minecraft.client.gui.components.WidgetTooltipHolder createTooltipPositioner(Lnet/minecraft/client/gui/navigation/ScreenRectangle;ZZ)Lnet/minecraft/client/gui/screens/inventory/tooltip/ClientTooltipPositioner;

public net.minecraft.client.multiplayer.ClientPacketListener setKeyPair(Lnet/minecraft/world/entity/player/ProfileKeyPair;)V
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
package com.aizistral.nochatreports.common.core;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;

import org.jetbrains.annotations.Nullable;

import com.aizistral.nochatreports.common.gui.UnsafeServerScreen;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.Minecraft;
import net.minecraft.client.multiplayer.resolver.ServerAddress;
import net.minecraft.network.chat.LocalChatSession;
import net.minecraft.network.protocol.game.ServerboundChatSessionUpdatePacket;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;

/**
* All this global state is questionable, but we have to...
Expand Down Expand Up @@ -41,16 +41,19 @@ public static boolean allowChatSigning() {

public static CompletableFuture<Void> setAllowChatSigning(boolean allow) {
if (ALLOW_CHAT_SIGNING.compareAndSet(!allow, allow)) {
if (Minecraft.getInstance().player != null) {
var connection = Minecraft.getInstance().player.connection;
Minecraft mc = Minecraft.getInstance();

if (mc.player != null) {
var connection = mc.player.connection;

if (allow && connection.chatSession == null)
return Minecraft.getInstance().getProfileKeyPairManager().prepareKeyPair()
return mc.getProfileKeyPairManager().prepareKeyPair()
.thenAcceptAsync(optional -> optional.ifPresent(profileKeyPair -> {
connection.setKeyPair(profileKeyPair);

SIGNING_ACTIONS.forEach(Runnable::run);
SIGNING_ACTIONS.clear();
}), Minecraft.getInstance());
}), mc);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
package com.aizistral.nochatreports.common.gui;

import com.mojang.blaze3d.vertex.PoseStack;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.ImageButton;
import net.minecraft.client.gui.components.Tooltip;
import net.minecraft.client.gui.components.WidgetSprites;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;

Expand Down Expand Up @@ -40,7 +37,7 @@ public ResourceLocation getCurrentTexture() {

@Override
public void renderWidget(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
graphics.blitSprite(this.getCurrentTexture(), this.getX(), this.getY(), this.width, this.height);
graphics.blitSprite(RenderType::guiTextured, this.getCurrentTexture(), this.getX(), this.getY(), this.width, this.height);

if (this.isHovered)
if (this.tooltip instanceof AdvancedWidgetTooltipHolder holder && holder.hasCustomRender()) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,38 +1,21 @@
package com.aizistral.nochatreports.common.gui;

import java.util.List;
import java.util.function.Supplier;
import java.util.stream.Collectors;

import org.jetbrains.annotations.Nullable;
import org.joml.Matrix4f;
import org.joml.Vector2ic;

import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.BufferUploader;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexFormat;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Tooltip;
import net.minecraft.client.gui.navigation.ScreenRectangle;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.inventory.tooltip.BelowOrAboveWidgetTooltipPositioner;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipPositioner;
import net.minecraft.client.gui.screens.inventory.tooltip.DefaultTooltipPositioner;
import net.minecraft.client.gui.screens.inventory.tooltip.MenuTooltipPositioner;
import net.minecraft.client.gui.screens.inventory.tooltip.TooltipRenderUtil;
import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.network.chat.Component;
import net.minecraft.util.FormattedCharSequence;
import org.jetbrains.annotations.Nullable;
import org.joml.Vector2ic;

import java.util.List;
import java.util.function.Supplier;
import java.util.stream.Collectors;

@Environment(EnvType.CLIENT)
public class AdvancedTooltip extends Tooltip {
Expand Down Expand Up @@ -89,17 +72,17 @@ public static List<FormattedCharSequence> splitTooltip(Minecraft minecraft, Comp

public void doCustomRender(Screen screen, GuiGraphics graphics, int x, int y, ClientTooltipPositioner positioner) {
if (this.renderWithoutGap) {
this.renderTooltipNoGap(screen, graphics, splitTooltip(screen.minecraft, this.getMessage(), this.maxWidth), x, y, positioner);
this.renderTooltipNoGap(screen, graphics, splitTooltip(screen.minecraft, this.getMessage(), this.maxWidth), this.getMessage(), x, y, positioner);
} else
throw new UnsupportedOperationException("This tooltip doesn't support custom render!");
}

protected void renderTooltipNoGap(Screen screen, GuiGraphics poseStack, List<? extends FormattedCharSequence> list, int x, int y, ClientTooltipPositioner positioner) {
this.renderTooltipInternalNoGap(screen, poseStack, list.stream().map(ClientTooltipComponent::create).collect(Collectors.toList()), x, y, positioner);
protected void renderTooltipNoGap(Screen screen, GuiGraphics poseStack, List<? extends FormattedCharSequence> list, Component component, int x, int y, ClientTooltipPositioner positioner) {
this.renderTooltipInternalNoGap(screen, poseStack, list.stream().map(ClientTooltipComponent::create).collect(Collectors.toList()), component, x, y, positioner);
}

// Originates from GuiGraphics
protected void renderTooltipInternalNoGap(Screen screen, GuiGraphics graphics, List<ClientTooltipComponent> list, int i, int j, ClientTooltipPositioner clientTooltipPositioner) {
protected void renderTooltipInternalNoGap(Screen screen, GuiGraphics graphics, List<ClientTooltipComponent> list, Component component, int i, int j, ClientTooltipPositioner clientTooltipPositioner) {
ClientTooltipComponent clientTooltipComponent2;
int t;
if (list.isEmpty())
Expand All @@ -111,7 +94,7 @@ protected void renderTooltipInternalNoGap(Screen screen, GuiGraphics graphics, L
if (m > k) {
k = m;
}
l += clientTooltipComponent.getHeight();
l += clientTooltipComponent.getHeight(screen.font);
}
int n = k;
int o = l;
Expand All @@ -120,20 +103,19 @@ protected void renderTooltipInternalNoGap(Screen screen, GuiGraphics graphics, L
int q = vector2ic.y();
graphics.pose().pushPose();
int r = 400;
graphics.drawManaged(() -> TooltipRenderUtil.renderTooltipBackground(graphics, p, q, n, o, 400));
graphics.pose().translate(0.0f, 0.0f, 400.0f);
int s = q;
for (t = 0; t < list.size(); ++t) {
clientTooltipComponent2 = list.get(t);
clientTooltipComponent2.renderText(screen.font, p, s, graphics.pose().last().pose(), graphics.bufferSource());
s += clientTooltipComponent2.getHeight() + /*(t == 0 ? 2 : 0)*/ 0;
}
s = q;

int maxWidth = 0;

for (t = 0; t < list.size(); ++t) {
clientTooltipComponent2 = list.get(t);
clientTooltipComponent2.renderImage(screen.font, p, s, graphics);
s += clientTooltipComponent2.getHeight() + /*(t == 0 ? 2 : 0)*/ 0;
if (clientTooltipComponent2.getWidth(screen.font) > maxWidth) {
maxWidth = clientTooltipComponent2.getWidth(screen.font);
}
}

graphics.renderTooltip(screen.font, splitTooltip(screen.minecraft, component), p + maxWidth , q, null);

graphics.pose().popPose();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,30 +1,23 @@
package com.aizistral.nochatreports.common.gui;

import java.util.Objects;

import com.aizistral.nochatreports.common.config.NCRConfig;
import com.aizistral.nochatreports.common.config.NCRConfigEncryption;
import com.aizistral.nochatreports.common.encryption.Encryption;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;

import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.gui.Font;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.Checkbox;
import net.minecraft.client.gui.components.CycleButton;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.components.ImageButton;
import net.minecraft.client.gui.components.MultiLineLabel;
import net.minecraft.client.gui.components.WidgetSprites;
import net.minecraft.client.gui.components.*;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.network.chat.CommonComponents;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.StringUtil;

import java.util.Objects;

@Environment(EnvType.CLIENT)
public class EncryptionConfigScreen extends Screen {
private static final Component HEADER = Component.translatable("gui.nochatreports.encryption_config.header");
Expand Down Expand Up @@ -200,7 +193,7 @@ public void render(GuiGraphics graphics, int i, int j, float f) {
graphics.drawString(this.font, PASS_NOT_ALLOWED, this.passField.getX() + 4,
this.passField.getY() + 5, 0x999999);
RenderSystem.enableDepthTest();
graphics.blitSprite(CROSSMARK, this.passField.getX() - 20, this.passField.getY() + 3, 14, 13);
graphics.blitSprite(RenderType::guiTextured, CROSSMARK, this.passField.getX() - 20, this.passField.getY() + 3, 14, 13);
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
package com.aizistral.nochatreports.common.mixins.client;

import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

import com.mojang.brigadier.ParseResults;

import net.minecraft.client.multiplayer.ClientPacketListener;
import net.minecraft.commands.SharedSuggestionProvider;
import net.minecraft.world.entity.player.ProfileKeyPair;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.gen.Invoker;

@Mixin(ClientPacketListener.class)
public interface AccessorClientPacketListener {

@Invoker("parseCommand")
public ParseResults<SharedSuggestionProvider> invokeParseCommand(String string);

@Invoker("setKeyPair")
public void invokeSetKeyPair(ProfileKeyPair profileKeyPair);
}
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
package com.aizistral.nochatreports.common.mixins.client;

import java.util.ArrayList;
import java.util.stream.Collectors;

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;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import com.aizistral.nochatreports.common.config.NCRConfig;
import com.aizistral.nochatreports.common.core.ServerDataExtension;
import com.aizistral.nochatreports.common.gui.FontHelper;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;

import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.multiplayer.JoinMultiplayerScreen;
import net.minecraft.client.gui.screens.multiplayer.ServerSelectionList;
import net.minecraft.client.multiplayer.ServerData;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.locale.Language;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import org.spongepowered.asm.mixin.Final;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.Shadow;
import org.spongepowered.asm.mixin.Unique;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.util.ArrayList;
import java.util.stream.Collectors;

@Mixin(ServerSelectionList.OnlineServerEntry.class)
public abstract class MixinOnlineServerEntry extends ServerSelectionList.Entry {
@Unique
private static final ResourceLocation VERIFIED_ICON = ResourceLocation.fromNamespaceAndPath("nochatreports", "verified_server");

@Shadow @Final
Expand All @@ -47,7 +47,7 @@ private void onRender(GuiGraphics graphics, int i, int j, int k, int l, int m, i
yOffset = NCRConfig.getClient().getVerifiedIconOffsetY();

RenderSystem.enableBlend();
graphics.blitSprite(VERIFIED_ICON, k + l - 35 + xOffset, j - 1 + yOffset, 14, 14);
graphics.blitSprite(RenderType::guiTextured, VERIFIED_ICON, k + l - 35 + xOffset, j - 1 + yOffset, 14, 14);
RenderSystem.disableBlend();

int t = n - k;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.aizistral.nochatreports.common.mixins.client;

import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.TitleScreen;
import net.minecraft.network.chat.CommonComponents;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
Expand All @@ -8,11 +12,6 @@
import com.aizistral.nochatreports.common.gui.RealmsWarningScreen;
import com.mojang.realmsclient.RealmsMainScreen;

import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.TitleScreen;
import net.minecraft.network.chat.CommonComponents;

@Mixin(TitleScreen.class)
public class MixinTitleScreen extends Screen {

Expand All @@ -21,7 +20,7 @@ protected MixinTitleScreen() {
throw new IllegalStateException("Can't touch this");
}

@Inject(method = { "realmsButtonClicked", "method_55814", "lambda$createNormalMenuOptions$9" }, at = @At("HEAD"), cancellable = true)
@Inject(method = { "realmsButtonClicked", "method_55814", "lambda$createNormalMenuOptions$10" }, at = @At("HEAD"), cancellable = true)
private void onRealmsButtonClicked(Button button, CallbackInfo info) {
if (RealmsWarningScreen.shouldShow()) {
this.minecraft.setScreen(new RealmsWarningScreen(new TitleScreen(), new RealmsMainScreen(this)));
Expand Down
Loading

0 comments on commit b630c1f

Please sign in to comment.