Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to 1.21.3 (Fabric) #491

Merged
merged 5 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 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
yarn_mappings=1.21+build.2
minecraft_version=1.21.3
yarn_mappings=1.21.3+build.2
fabric_loader_version=0.15.11
forge_version=1.21-51.0.8
neoforge_version=21.0.16-beta
forge_version=1.21.3-53.0.4
neoforge_version=21.3.4-beta

# Mod Properties
mod_version=1.21-v2.8.0
mod_version=1.21.3-v2.9.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.100.3+1.21
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
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 @@ -47,7 +47,14 @@ public static CompletableFuture<Void> setAllowChatSigning(boolean allow) {
if (allow && connection.chatSession == null)
return Minecraft.getInstance().getProfileKeyPairManager().prepareKeyPair()
.thenAcceptAsync(optional -> optional.ifPresent(profileKeyPair -> {
connection.setKeyPair(profileKeyPair);
Minecraft minecraft = Minecraft.getInstance();
if (minecraft.isLocalPlayer(minecraft.getGameProfile().getId())) {
if (connection.chatSession == null || !connection.chatSession.keyPair().equals(profileKeyPair)) {
connection.chatSession = LocalChatSession.create(profileKeyPair);
connection.signedMessageEncoder = connection.chatSession.createMessageEncoder(minecraft.getGameProfile().getId());
connection.send(new ServerboundChatSessionUpdatePacket(connection.chatSession.asRemote().asData()));
}
}
SIGNING_ACTIONS.forEach(Runnable::run);
SIGNING_ACTIONS.clear();
}), Minecraft.getInstance());
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,20 @@ 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);
}
}

System.out.println(maxWidth);
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,17 +1,9 @@
package com.aizistral.nochatreports.common.mixins.client;

import org.spongepowered.asm.mixin.Mixin;
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.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;
import org.spongepowered.asm.mixin.Mixin;

@Mixin(TitleScreen.class)
public class MixinTitleScreen extends Screen {
Expand All @@ -21,12 +13,13 @@ protected MixinTitleScreen() {
throw new IllegalStateException("Can't touch this");
}

@Inject(method = { "realmsButtonClicked", "method_55814", "lambda$createNormalMenuOptions$9" }, 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)));
info.cancel();
}
}
// TODO: Fix this
// @Inject(method = { "realmsButtonClicked", "method_55814", "lambda$createNormalMenuOptions$9" }, 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)));
// info.cancel();
// }
// }

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

import org.spongepowered.asm.mixin.Mixin;
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 net.minecraft.client.gui.components.toasts.SystemToast;
import net.minecraft.client.gui.components.toasts.SystemToast.SystemToastId;
import net.minecraft.client.gui.components.toasts.Toast;
import net.minecraft.client.gui.components.toasts.ToastComponent;
import net.minecraft.client.gui.components.toasts.ToastManager;
import org.spongepowered.asm.mixin.Mixin;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

@Mixin(ToastComponent.class)
@Mixin(ToastManager.class)
public class MixinToastComponent {

@Inject(method = "addToast", at = @At("HEAD"), cancellable = true)
Expand Down
Loading
Loading