Skip to content

Commit

Permalink
Fix some visual bugs on 1.20.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaming32 committed Oct 2, 2023
1 parent 83d1656 commit b960ae5
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -165,11 +165,7 @@ public void render(
//#endif
int mouseX, int mouseY, float delta
) {
//#if MC < 1.20.2
//$$ renderBackground(context);
//#else
renderBackground(context, mouseX, mouseY, delta);
//#endif
whRenderBackground(context, mouseX, mouseY, delta);
drawCenteredString(context, font, title, width / 2, 20, 0xffffff);
drawString(context, font, FRIEND_USERNAME_TEXT, width / 2 - 100, 50, 0xa0a0a0);
usernameField.render(context, mouseX, mouseY, delta);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@
//$$ import com.mojang.blaze3d.vertex.PoseStack;
//#endif

//#if MC >= 1.20.2
import net.minecraft.client.renderer.RenderType;
//#endif

public class FriendsScreen extends WorldHostScreen {
public static final Component ADD_FRIEND_TEXT = Components.translatable("world-host.add_friend");
private static final Component ADD_SILENTLY_TEXT = Components.translatable("world-host.friends.add_silently");
Expand Down Expand Up @@ -140,11 +144,7 @@ public void render(
//#endif
int mouseX, int mouseY, float delta
) {
//#if MC < 1.20.2
//$$ renderBackground(context);
//#else
renderBackground(context, mouseX, mouseY, delta);
//#endif
whRenderBackground(context, mouseX, mouseY, delta);
list.render(context, mouseX, mouseY, delta);
drawCenteredString(context, font, title, width / 2, 15, 0xffffff);
if (WorldHost.BEDROCK_SUPPORT) {
Expand Down Expand Up @@ -178,6 +178,20 @@ public FriendsList(int i, int j, int k, int l, int m) {
super(FriendsScreen.this.minecraft, i, j, k, l, m);
}

//#if MC >= 1.20.2
@Override
protected void renderDecorations(@NotNull GuiGraphics graphics, int mouseX, int mouseY) {
super.renderDecorations(graphics, mouseX, mouseY);
graphics.setColor(0.25f, 0.25f, 0.25f, 1f);
graphics.blit(BACKGROUND_LOCATION, x0, 0, 0f, 0f, width, y0, 32, 32);
graphics.blit(BACKGROUND_LOCATION, x0, y1, 0f, y1, width, height - y1, 32, 32);
graphics.setColor(1f, 1f, 1f, 1f);
graphics.fillGradient(RenderType.guiOverlay(), x0, y0, x1, y0 + 4, 0xff000000, 0, 0);
graphics.fillGradient(RenderType.guiOverlay(), x0, y1 - 4, x1, y1, 0, 0xff000000, 0);
}

//#endif

@Override
public void setSelected(@Nullable FriendsEntry entry) {
super.setSelected(entry);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,7 @@ public void render(
//#endif
int mouseX, int mouseY, float delta
) {
//#if MC < 1.20.2
//$$ renderBackground(context);
//#else
renderBackground(context, mouseX, mouseY, delta);
//#endif
whRenderBackground(context, mouseX, mouseY, delta);
drawCenteredString(context, font, status, width / 2, height / 2 - 50, 0xffffff);
super.render(context, mouseX, mouseY, delta);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,7 @@ public void render(
int mouseX, int mouseY, float delta
) {
tooltip = null;
//#if MC < 1.20.2
//$$ renderBackground(context);
//#else
renderBackground(context, mouseX, mouseY, delta);
//#endif
whRenderBackground(context, mouseX, mouseY, delta);
list.render(context, mouseX, mouseY, delta);
drawCenteredString(context, font, title, width / 2, 15, 0xffffff);
super.render(context, mouseX, mouseY, delta);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,7 @@ public void render(
//#endif
int mouseX, int mouseY, float delta
) {
//#if MC < 1.20.2
//$$ renderBackground(context);
//#else
renderBackground(context, mouseX, mouseY, delta);
//#endif
whRenderBackground(context, mouseX, mouseY, delta);
super.render(context, mouseX, mouseY, delta);
drawCenteredString(context, font, title, width / 2, 15, 0xffffff);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -372,4 +372,34 @@ public static void sendRepeatEvents(@SuppressWarnings("unused") boolean sendRepe
//$$ Minecraft.getInstance().keyboardHandler.setSendRepeatsToGui(sendRepeatEvents);
//#endif
}

@Override
public void renderBackground(
@NotNull
//#if MC < 1.20.0
//$$ PoseStack context
//#else
GuiGraphics context
//#endif
//#if MC >= 1.20.2
, int mouseX, int mouseY, float delta
//#endif
) {
}

public void whRenderBackground(
@NotNull
//#if MC < 1.20.0
//$$ PoseStack context,
//#else
GuiGraphics context,
//#endif
int mouseX, int mouseY, float delta
) {
//#if MC < 1.20.2
//$$ super.renderBackground(context);
//#else
super.renderBackground(context, mouseX, mouseY, delta);
//#endif
}
}

0 comments on commit b960ae5

Please sign in to comment.