Skip to content

Commit ab29224

Browse files
1.19.1 port. (Fix #167)
1 parent 9fb08cd commit ab29224

File tree

4 files changed

+51
-27
lines changed

4 files changed

+51
-27
lines changed

gradle.properties

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
org.gradle.jvmargs=-Xmx2048m
22
# Fabric Properties
33
# check these on https://fabricmc.net/develop/
4-
minecraft_version=1.19
5-
yarn_mappings=1.19+build.2
6-
loader_version=0.14.7
4+
minecraft_version=1.19.1
5+
yarn_mappings=1.19.1+build.1
6+
loader_version=0.14.8
77

88
# Mod Properties
99
mod_version = 1.4.2
1010
maven_group = me.juancarloscp52
1111
archives_base_name = bedrockify
1212

1313
# Dependencies
14-
fabric_version=0.55.3+1.19
15-
modmenu_version=4.0.0
16-
cloth_config_version=7.0.72
14+
fabric_version=0.58.5+1.19.1
15+
modmenu_version=4.0.5
16+
cloth_config_version=7.0.73
1717
apple_skin=mc1.19-2.4.0

src/main/java/me/juancarloscp52/bedrockify/mixin/client/features/chat/ChatHudMixin.java

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import net.minecraft.client.gui.DrawableHelper;
88
import net.minecraft.client.gui.hud.ChatHud;
99
import net.minecraft.client.gui.hud.ChatHudLine;
10+
import net.minecraft.client.gui.hud.MessageIndicator;
11+
import net.minecraft.client.network.message.MessageHandler;
1012
import net.minecraft.client.util.math.MatrixStack;
1113
import net.minecraft.text.OrderedText;
1214
import net.minecraft.text.Style;
@@ -26,8 +28,8 @@
2628
@Mixin(ChatHud.class)
2729
public abstract class ChatHudMixin extends DrawableHelper {
2830

29-
@Shadow protected abstract void processMessageQueue();
30-
@Shadow @Final private List<ChatHudLine<OrderedText>> visibleMessages;
31+
//@Shadow protected abstract void processMessageQueue();
32+
@Shadow @Final private List<ChatHudLine.Visible> visibleMessages;
3133
@Shadow protected abstract boolean isChatFocused();
3234
@Shadow public abstract double getChatScale();
3335
@Shadow public abstract int getWidth();
@@ -36,12 +38,18 @@ public abstract class ChatHudMixin extends DrawableHelper {
3638
@Shadow private static double getMessageOpacityMultiplier(int age) {
3739
return 0;
3840
}
39-
@Shadow @Final private Deque<Text> messageQueue;
41+
//@Shadow @Final private Deque<Text> messageQueue;
4042
@Shadow private boolean hasUnreadNewMessages;
4143
@Shadow public abstract int getVisibleLineCount();
4244
@Shadow protected abstract boolean isChatHidden();
4345
@Shadow public abstract void addMessage(Text message);
44-
@Shadow private long lastMessageAddedTime;
46+
//@Shadow private long lastMessageAddedTime;
47+
48+
@Shadow protected abstract int getLineHeight();
49+
50+
@Shadow protected abstract int getIndicatorX(ChatHudLine.Visible line);
51+
52+
@Shadow protected abstract void drawIndicatorIcon(MatrixStack matrices, int x, int y, MessageIndicator.Icon icon);
4553

4654
private int counter1 =0;
4755
BedrockifySettings settings = Bedrockify.getInstance().settings;
@@ -55,7 +63,6 @@ private void render(MatrixStack matrixStack, int ticks, CallbackInfo info){
5563
return;
5664

5765
if (!this.isChatHidden()) {
58-
this.processMessageQueue();
5966
int visibleLines = Math.min(this.getVisibleLineCount(),this.getAvailableLines());
6067
int visibleMessagesCount = this.visibleMessages.size();
6168
if (visibleMessagesCount > 0) {
@@ -67,17 +74,19 @@ private void render(MatrixStack matrixStack, int ticks, CallbackInfo info){
6774
matrixStack.push();
6875
matrixStack.translate(safeArea, (float) (48-MinecraftClient.getInstance().getWindow().getScaledHeight() + (counter1*(9.0D * chatScale* (this.client.options.getChatLineSpacing().getValue() + 1.0D))))+ posY, 0.0F);
6976
matrixStack.scale(chatScale, chatScale, 1.0F);
70-
double textOpacity = this.client.options.getChtOpacity().getValue() * 0.9D + 0.1D;
77+
double textOpacity = this.client.options.getChatOpacity().getValue() * 0.9D + 0.1D;
7178
double backgroundOpacity = this.client.options.getTextBackgroundOpacity().getValue();
72-
double chatLineSpacing1 = 9.0D * (this.client.options.getChatLineSpacing().getValue() + 1.0D);
79+
//double chatLineSpacing1 = 9.0D * (this.client.options.getChatLineSpacing().getValue() + 1.0D);
80+
double chatLineSpacing1 = this.getLineHeight();
81+
7382
double chatLineSpacing2 = -8.0D * (this.client.options.getChatLineSpacing().getValue() + 1.0D) + 4.0D * this.client.options.getChatLineSpacing().getValue();
7483
counter1 = 0; //Shown messages
7584

7685
for(int i = 0; i + this.scrolledLines < this.visibleMessages.size() && i < visibleLines; ++i) {
77-
ChatHudLine<OrderedText> chatHudLine = this.visibleMessages.get(i + this.scrolledLines);
86+
ChatHudLine.Visible chatHudLine = this.visibleMessages.get(i + this.scrolledLines);
7887
if (chatHudLine != null) {
7988
int ticksSinceCreation;
80-
ticksSinceCreation = ticks - chatHudLine.getCreationTick();
89+
ticksSinceCreation = ticks - chatHudLine.addedTime();
8190
if (ticksSinceCreation < 200 || isChatFocused) {
8291
double opacityMultiplayer = isChatFocused ? 1.0D : getMessageOpacityMultiplier(ticksSinceCreation);
8392
int finalTextOpacity = (int)(255.0D * opacityMultiplayer * textOpacity);
@@ -87,10 +96,23 @@ private void render(MatrixStack matrixStack, int ticks, CallbackInfo info){
8796
double currentMessageHeight = (double)(-i) * chatLineSpacing1;
8897
matrixStack.push();
8998
matrixStack.translate(0, 0, 0);
90-
fill(matrixStack, 0, (int)currentMessageHeight, scaledChatWidth + 4, (int)(currentMessageHeight - chatLineSpacing1), finalBackgroundOpacity << 24);
99+
ChatHud.fill(matrixStack, 0, (int)currentMessageHeight, scaledChatWidth + 6, (int)(currentMessageHeight - chatLineSpacing1), finalBackgroundOpacity << 24);
100+
101+
// Message security indicator
102+
MessageIndicator messageIndicator = chatHudLine.indicator();
103+
if (messageIndicator != null) {
104+
int indicatorColor = messageIndicator.indicatorColor() | finalTextOpacity << 24;
105+
ChatHud.fill(matrixStack, 0, (int)currentMessageHeight, 2, (int)(currentMessageHeight - chatLineSpacing1), indicatorColor);
106+
if (isChatFocused() && chatHudLine.endOfEntry() && messageIndicator.icon() != null) {
107+
int w = this.getIndicatorX(chatHudLine);
108+
int x = (int)currentMessageHeight + this.client.textRenderer.fontHeight;
109+
this.drawIndicatorIcon(matrixStack, w, x, messageIndicator.icon());
110+
}
111+
}
112+
91113
RenderSystem.enableBlend();
92114
matrixStack.translate(0, 0, 0);
93-
this.client.textRenderer.drawWithShadow(matrixStack, chatHudLine.getText(), 2F, (float)((int)(currentMessageHeight + chatLineSpacing2)), 16777215 + (finalTextOpacity << 24));
115+
this.client.textRenderer.drawWithShadow(matrixStack, chatHudLine.content(), 4F, (float)((int)(currentMessageHeight + chatLineSpacing2)), 16777215 + (finalTextOpacity << 24));
94116
RenderSystem.disableBlend();
95117
matrixStack.pop();
96118
}
@@ -99,21 +121,23 @@ private void render(MatrixStack matrixStack, int ticks, CallbackInfo info){
99121
}
100122

101123
//Unread Messages:
102-
if (!this.messageQueue.isEmpty()) {
124+
long unprocessedMessageCount = this.client.getMessageHandler().getUnprocessedMessageCount();
125+
if (unprocessedMessageCount>0) {
103126
int textOpacityFinal = (int)(128.0D * textOpacity);
104127
int backgroundOpacityFinal = (int)(255.0D * backgroundOpacity);
105128
matrixStack.push();
106129
matrixStack.translate(0.0D, 0.0D, 50.0D);
107130
fill(matrixStack, -2, 0, scaledChatWidth + 4, 9, backgroundOpacityFinal << 24);
108131
RenderSystem.enableBlend();
109132
matrixStack.translate(0.0D, 0.0D, 50.0D);
110-
this.client.textRenderer.drawWithShadow(matrixStack, Text.translatable("chat.queue", this.messageQueue.size()), 2F, 1.0F, 16777215 + (textOpacityFinal << 24));
133+
this.client.textRenderer.drawWithShadow(matrixStack, Text.translatable("chat.queue", unprocessedMessageCount), 2F, 1.0F, 16777215 + (textOpacityFinal << 24));
111134
matrixStack.pop();
112135
RenderSystem.disableBlend();
113136
}
114137

115138
if (isChatFocused) {
116-
int textSize = 9;
139+
//int textSize = 9;
140+
int textSize = this.getLineHeight();
117141
int x = visibleMessagesCount * textSize + visibleMessagesCount;
118142
int renderedMessages = counter1 * textSize + counter1;
119143
int z = this.scrolledLines * renderedMessages / visibleMessagesCount;
@@ -139,16 +163,16 @@ private void render(MatrixStack matrixStack, int ticks, CallbackInfo info){
139163
public void mouseClicked(double x, double y, CallbackInfoReturnable<Boolean> info){
140164
if(!settings.isBedrockChatEnabled() || client.options.debugEnabled)
141165
return;
142-
if(this.isChatFocused() && !this.client.options.hudHidden && !this.isChatHidden() && !this.messageQueue.isEmpty()){
166+
MessageHandler messageHandler = this.client.getMessageHandler();
167+
if(this.isChatFocused() && !this.client.options.hudHidden && !this.isChatHidden() && messageHandler.getUnprocessedMessageCount() != 0L){
143168
int safeArea = settings.overlayIgnoresSafeArea? 0: settings.getScreenSafeArea();
144169
int posY = 2+settings.getPositionHUDHeight() + (settings.getPositionHUDHeight()<50? 50:0) + (settings.isShowPositionHUDEnabled() ? 10 : 0) + (settings.getFPSHUDoption()==2 ? 10 : 0) + safeArea;
145170
double lineSize = 9.0D * (this.client.options.getChatLineSpacing().getValue() + 1.0D);
146171
double chatX= x - safeArea;
147172
double chatY = posY+(counter1*lineSize) - y;
148173

149174
if(chatX<=MathHelper.floor(this.getWidth() / this.getChatScale()) && chatY < 0.0D && chatY > (double)MathHelper.floor(-9.0D * this.getChatScale())){
150-
this.addMessage(this.messageQueue.remove());
151-
this.lastMessageAddedTime = System.currentTimeMillis();
175+
messageHandler.process();
152176
info.setReturnValue(true);
153177
}else{
154178
info.setReturnValue(false);
@@ -177,8 +201,8 @@ public void getText(double x, double y, CallbackInfoReturnable<Style> info){
177201
if(chatY < 9*lines+lines){
178202
int line = (int)(chatY/9.0D + this.scrolledLines);
179203
if(line>=0 && line<this.visibleMessages.size()){
180-
ChatHudLine<OrderedText> chatHudLine = this.visibleMessages.get(line);
181-
info.setReturnValue(this.client.textRenderer.getTextHandler().getStyleAt(chatHudLine.getText(), (int)chatX));
204+
ChatHudLine.Visible chatHudLine = this.visibleMessages.get(line);
205+
info.setReturnValue(this.client.textRenderer.getTextHandler().getStyleAt(chatHudLine.content(), (int)chatX));
182206
return;
183207
}
184208
}

src/main/java/me/juancarloscp52/bedrockify/mixin/client/features/loadingScreens/LevelLoadingScreenMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public void render(MatrixStack matrices, int mouseX, int mouseY, float delta, Ca
4545
long l = Util.getMeasuringTimeMs();
4646
if (l - this.lastNarrationTime > 2000L) {
4747
this.lastNarrationTime = l;
48-
NarratorManager.INSTANCE.narrate((Text.translatable("narrator.loading", new Object[]{string})).getString());
48+
this.narrateScreenIfNarrationEnabled(true);
4949
}
5050

5151
if (Bedrockify.getInstance().settings.isShowChunkMapEnabled())

src/main/java/me/juancarloscp52/bedrockify/mixin/client/features/screenSafeArea/InGameHudMixin.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public void renderStatusEffectOverlay(MatrixStack matrixStack, CallbackInfo info
185185
}
186186

187187
// Apply screen borders to Titles, subtitles and other messages.
188-
@ModifyArg(method = "render", at = @At(value = "INVOKE",target = "Lnet/minecraft/client/font/TextRenderer;draw(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/text/Text;FFI)I",ordinal = 0),index = 3)
188+
@ModifyArg(method = "render", at = @At(value = "INVOKE",target = "Lnet/minecraft/client/font/TextRenderer;drawWithShadow(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/text/Text;FFI)I",ordinal = 0),index = 3)
189189
public float modifyOverlayMessage(float y){
190190
return y-screenBorder;
191191
}

0 commit comments

Comments
 (0)