Skip to content

Commit

Permalink
Update to 1.20.1
Browse files Browse the repository at this point in the history
  • Loading branch information
acrylic-style committed Jun 17, 2023
1 parent c98bf94 commit 5dd093c
Show file tree
Hide file tree
Showing 31 changed files with 606 additions and 413 deletions.
8 changes: 4 additions & 4 deletions Blueberry-API/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ dependencies {
api("com.google.code.findbugs:jsr305:3.0.2")
api("com.google.code.gson:gson:2.10")
api("com.google.guava:guava:31.1-jre")
api("com.mojang:brigadier:1.0.18")
api("com.mojang:datafixerupper:5.0.28")
api("com.mojang:javabridge:2.0.25")
api("com.mojang:authlib:3.16.29")
api("com.mojang:brigadier:1.1.8")
api("com.mojang:datafixerupper:6.0.8")
api("com.mojang:javabridge:2.0.25") // removed in 1.20.1?
api("com.mojang:authlib:4.0.43")
api("it.unimi.dsi:fastutil:8.5.9")
api("io.netty:netty-all:4.1.82.Final")
api("org.apache.commons:commons-lang3:3.12.0")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package net.blueberrymc.client;

import com.mojang.blaze3d.vertex.PoseStack;
import com.mojang.datafixers.util.Pair;
import net.blueberrymc.client.util.GLUtils;
import net.blueberrymc.common.Blueberry;
Expand All @@ -9,9 +8,9 @@
import net.blueberrymc.common.util.Versioning;
import net.blueberrymc.util.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.font.FontManager;
import net.minecraft.client.gui.screens.LoadingOverlay;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.util.Mth;
import net.minecraft.util.profiling.InactiveProfiler;
import org.jetbrains.annotations.Contract;
Expand Down Expand Up @@ -312,7 +311,7 @@ public void run() {
glfwMakeContextCurrent(0);
}

public void renderMessagesFromGUI(@NotNull PoseStack poseStack) {
public void renderMessagesFromGUI(@NotNull GuiGraphics guiGraphics) {
blockUntilFinish();
Minecraft mc = Minecraft.getInstance();
Objects.requireNonNull(mc);
Expand All @@ -321,14 +320,12 @@ public void renderMessagesFromGUI(@NotNull PoseStack poseStack) {
loadingFont = true;
// load fonts early to show logs early
FontManager fontManager = (FontManager) ReflectionHelper.getFieldWithoutException(Minecraft.class, mc, "fontManager");
//noinspection NullableProblems
Objects.requireNonNull(fontManager)
.getReloadListener()
.reload(CompletableFuture::completedFuture, mc.getResourceManager(), InactiveProfiler.INSTANCE, InactiveProfiler.INSTANCE, Runnable::run, Runnable::run);
isFontReady = (boolean) Objects.requireNonNull(ReflectionHelper.getFieldWithoutException(LoadingOverlay.class, null, "isFontReady"));
}
if (isFontReady && mc.getWindow().getWindow() == this.window) {
renderMessages(TextRenderer.minecraft(poseStack));
renderMessages(TextRenderer.minecraft(guiGraphics));
}
}

Expand Down Expand Up @@ -403,7 +400,7 @@ private interface TextRenderer {
}

@Contract(pure = true)
static @NotNull TextRenderer minecraft(@NotNull PoseStack poseStack) {
static @NotNull TextRenderer minecraft(@NotNull GuiGraphics guiGraphics) {
return (message, color, line, alpha) -> {
if (alpha <= 0.02) {
return;
Expand All @@ -413,7 +410,7 @@ private interface TextRenderer {
int b = (int) (color[2] * 255);
int a = (int) (alpha * 255);
int rgba = (r << 16) | (g << 8) | b | (a << 24);
Screen.drawString(poseStack, Minecraft.getInstance().font, message, 10, line * 10, rgba);
guiGraphics.drawString(Minecraft.getInstance().font, message, 10, line * 10, rgba);
};
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public void register(@NotNull CommandDispatcher<CommandSourceStack> dispatcher)
private static int executeDiscordAccept(@NotNull CommandSourceStack source, long id) {
DiscordRPCTaskExecutor.submitTask(core -> core.activityManager().sendRequestReply(id, ActivityJoinRequestReply.YES, result -> {
if (result == Result.OK) {
source.sendSuccess(BlueberryText.text("blueberry", "discord.activity.join_request.accept.accepted"), false);
source.sendSuccess(() -> BlueberryText.text("blueberry", "discord.activity.join_request.accept.accepted"), false);
} else {
source.sendFailure(BlueberryText.text("blueberry", "discord.error_with_result", result.name()));
}
Expand All @@ -67,7 +67,7 @@ private static int executeDiscordAccept(@NotNull CommandSourceStack source, long
private static int executeDiscordDeny(@NotNull CommandSourceStack source, long id) {
DiscordRPCTaskExecutor.submitTask(core -> core.activityManager().sendRequestReply(id, ActivityJoinRequestReply.NO, result -> {
if (result == Result.OK) {
source.sendSuccess(BlueberryText.text("blueberry", "discord.activity.join_request.deny.denied"), false);
source.sendSuccess(() -> BlueberryText.text("blueberry", "discord.activity.join_request.deny.denied"), false);
} else {
source.sendFailure(BlueberryText.text("blueberry", "discord.error_with_result", result.name()));
}
Expand All @@ -78,7 +78,7 @@ private static int executeDiscordDeny(@NotNull CommandSourceStack source, long i
private static int executeDiscordIgnore(@NotNull CommandSourceStack source, long id) {
DiscordRPCTaskExecutor.submitTask(core -> core.activityManager().sendRequestReply(id, ActivityJoinRequestReply.IGNORE, result -> {
if (result == Result.OK) {
source.sendSuccess(BlueberryText.text("blueberry", "discord.activity.join_request.ignore.ignored"), false);
source.sendSuccess(() -> BlueberryText.text("blueberry", "discord.activity.join_request.ignore.ignored"), false);
} else {
source.sendFailure(BlueberryText.text("blueberry", "discord.error_with_result", result.name()));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package net.blueberrymc.client.gui.components;

import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiComponent;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.events.AbstractContainerEventHandler;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.util.Mth;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -180,58 +180,57 @@ protected int getMaxPosition() {
protected void clickedHeader(int i, int i2) {
}

protected void renderHeader(PoseStack poseStack, int i, int i2) {
protected void renderHeader(@NotNull GuiGraphics guiGraphics, int i, int i2) {
}

protected void renderBackground(@NotNull PoseStack poseStack) {
protected void renderBackground(@NotNull GuiGraphics guiGraphics) {
}

protected void renderDecorations(@NotNull PoseStack poseStack, int i, int i2) {
protected void renderDecorations(@NotNull GuiGraphics guiGraphics, int i, int i2) {
}

protected void enableScissor() {
enableScissor(this.left, this.bottom, this.right, this.top);
RenderSystem.enableScissor(this.left, this.bottom, this.right, this.top);
}

/**
* Renders the container.
* @param poseStack pose stack
* @param guiGraphics gui graphics
* @param mouseX mouse x position
* @param mouseY mouse y position
* @param deltaFrameTime delta frame time
*/
public void render(@NotNull PoseStack poseStack, int mouseX, int mouseY, float deltaFrameTime) {
this.renderBackground(poseStack);
public void render(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float deltaFrameTime) {
this.renderBackground(guiGraphics);
int i3 = this.getScrollbarPosition();
int i4 = i3 + 6;
//this.hovered = this.isMouseOver((double)mouseX, (double)mouseX) ? this.getEntryAtPosition((double)mouseX, (double)mouseX) : null;
if (this.renderBackground) {
RenderSystem.setShaderTexture(0, GuiComponent.BACKGROUND_LOCATION);
RenderSystem.setShaderColor(0.125F, 0.125F, 0.125F, 1.0F);
int i5 = 32;
blit(poseStack, this.left, this.top, (float)this.right, (float)(this.bottom + (int)this.getScrollAmount()), this.right - this.left, this.bottom - this.top, 32, 32);
guiGraphics.blit(Screen.BACKGROUND_LOCATION, this.left, this.top, (float)this.right, (float)(this.bottom + (int)this.getScrollAmount()), this.right - this.left, this.bottom - this.top, 32, 32);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
}

int i6 = this.getRowLeft();
int i7 = this.top + 4 - (int)this.getScrollAmount();
this.enableScissor();
if (this.renderHeader) {
this.renderHeader(poseStack, i6, i7);
this.renderHeader(guiGraphics, i6, i7);
}

this.renderList(poseStack, getRowLeft(), i6, mouseX, mouseY, deltaFrameTime);
disableScissor();
this.renderList(guiGraphics, getRowLeft(), i6, mouseX, mouseY, deltaFrameTime);
RenderSystem.disableScissor();
if (this.renderTopAndBottom) {
RenderSystem.setShaderTexture(0, GuiComponent.BACKGROUND_LOCATION);
RenderSystem.setShaderTexture(0, Screen.BACKGROUND_LOCATION);
int i8 = 32;
RenderSystem.setShaderColor(0.25F, 0.25F, 0.25F, 1.0F);
blit(poseStack, this.left, 0, 0.0F, 0.0F, this.width, this.top, 32, 32);
blit(poseStack, this.left, this.bottom, 0.0F, (float)this.bottom, this.width, this.height - this.bottom, 32, 32);
guiGraphics.blit(Screen.BACKGROUND_LOCATION, this.left, 0, 0.0F, 0.0F, this.width, this.top, 32, 32);
guiGraphics.blit(Screen.BACKGROUND_LOCATION, this.left, this.bottom, 0.0F, (float)this.bottom, this.width, this.height - this.bottom, 32, 32);
RenderSystem.setShaderColor(1.0F, 1.0F, 1.0F, 1.0F);
int i9 = 4;
fillGradient(poseStack, this.left, this.top, this.right, this.top + 4, -16777216, 0);
fillGradient(poseStack, this.left, this.bottom - 4, this.right, this.bottom, 0, -16777216);
guiGraphics.fillGradient(this.left, this.top, this.right, this.top + 4, -16777216, 0);
guiGraphics.fillGradient(this.left, this.bottom - 4, this.right, this.bottom, 0, -16777216);
}

int i10 = this.getMaxScroll();
Expand All @@ -243,14 +242,14 @@ public void render(@NotNull PoseStack poseStack, int mouseX, int mouseY, float d
i12 = this.top;
}

fill(poseStack, i3, this.top, i4, this.bottom, -16777216);
fill(poseStack, i3, i12, i4, i12 + i11, -8355712);
fill(poseStack, i3, i12, i4 - 1, i12 + i11 - 1, -4144960);
guiGraphics.fill(i3, this.top, i4, this.bottom, -16777216);
guiGraphics.fill(i3, i12, i4, i12 + i11, -8355712);
guiGraphics.fill(i3, i12, i4 - 1, i12 + i11 - 1, -4144960);
}

this.renderDecorations(poseStack, mouseX, mouseX);
this.renderDecorations(guiGraphics, mouseX, mouseX);

children.forEach(e -> e.render(poseStack, mouseX, mouseY, deltaFrameTime));
children.forEach(e -> e.render(guiGraphics, mouseX, mouseY, deltaFrameTime));

RenderSystem.disableBlend();
}
Expand Down Expand Up @@ -375,7 +374,7 @@ public boolean isMouseOver(double x, double y) {
return y >= (double)this.top && y <= (double)this.bottom && x >= (double)this.left && x <= (double)this.right;
}

protected void renderList(@NotNull PoseStack poseStack, int rowLeft, int adjustedScrollAmount, int i3, int i4, float deltaFrameTime) {
protected void renderList(@NotNull GuiGraphics guiGraphics, int rowLeft, int adjustedScrollAmount, int i3, int i4, float deltaFrameTime) {
int itemCount = this.getItemCount();
int offset = 38;
int prevY = Integer.MIN_VALUE;
Expand All @@ -385,7 +384,7 @@ protected void renderList(@NotNull PoseStack poseStack, int rowLeft, int adjuste
int rowBottom = this.getRowBottom(i);
if (rowBottom >= this.top && rowTop <= this.bottom) {
E entry = this.getEntry(i);
entry.render(poseStack, i3, i4, deltaFrameTime);
entry.render(guiGraphics, i3, i4, deltaFrameTime);
if (prevY == entry.getY()) {
offset -= 22;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package net.blueberrymc.client.gui.screens;

import com.mojang.blaze3d.vertex.PoseStack;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import net.blueberrymc.common.util.FileUtil;
import net.minecraft.ChatFormatting;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.ObjectSelectionList;
import net.minecraft.client.gui.screens.Screen;
Expand Down Expand Up @@ -54,11 +54,11 @@ public void onClose() {
}

@Override
public void render(@NotNull PoseStack poseStack, int mouseX, int mouseY, float deltaFrameTime) {
fileList.render(poseStack, mouseX, mouseY, deltaFrameTime);
drawCenteredString(poseStack, this.font, this.title, this.width / 2, 16, 16777215);
drawCenteredString(poseStack, this.font, this.description, this.width / 2, 32, 16777215);
cancelButton.render(poseStack, mouseX, mouseY, deltaFrameTime);
public void render(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float deltaFrameTime) {
fileList.render(guiGraphics, mouseX, mouseY, deltaFrameTime);
guiGraphics.drawCenteredString(this.font, this.title, this.width / 2, 16, 16777215);
guiGraphics.drawCenteredString(this.font, this.description, this.width / 2, 32, 16777215);
cancelButton.render(guiGraphics, mouseX, mouseY, deltaFrameTime);
}

public void invokeCallback(@Nullable File file) {
Expand Down Expand Up @@ -183,17 +183,17 @@ public void setSelected(@Nullable FileDialogScreen.FileList.Entry entry) {
super.setSelected(entry);
}

protected void renderBackground(@NotNull PoseStack poseStack) {
FileDialogScreen.this.renderBackground(poseStack);
protected void renderBackground(@NotNull GuiGraphics guiGraphics) {
FileDialogScreen.this.renderBackground(guiGraphics);
}

public boolean isFocused() {
return FileDialogScreen.this.getFocused() == this;
}

@Override
protected void renderList(@NotNull PoseStack poseStack, int mouseX, int mouseY, float deltaFrameTime) {
super.renderList(poseStack, mouseX, mouseY, deltaFrameTime);
protected void renderList(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float deltaFrameTime) {
super.renderList(guiGraphics, mouseX, mouseY, deltaFrameTime);
int itemCount = this.getItemCount();

for (int itemIndex = 0; itemIndex < itemCount; ++itemIndex) {
Expand All @@ -207,13 +207,13 @@ protected void renderList(@NotNull PoseStack poseStack, int mouseX, int mouseY,
cdButton.setX(getRowLeft() + rowWidth);
cdButton.setY(rowTop - 3);
cdButton.visible = true;
cdButton.render(poseStack, mouseX, mouseY, deltaFrameTime);
cdButton.render(guiGraphics, mouseX, mouseY, deltaFrameTime);
if (options.fileType() == FileDialogScreenOptions.FileType.DIRECTORY ||
options.fileType() == FileDialogScreenOptions.FileType.ALL) {
selectButton.setX(getRowLeft() + rowWidth + 22);
selectButton.setY(rowTop - 3);
selectButton.visible = true;
selectButton.render(poseStack, mouseX, mouseY, deltaFrameTime);
selectButton.render(guiGraphics, mouseX, mouseY, deltaFrameTime);
} else {
selectButton.visible = false;
}
Expand All @@ -222,7 +222,7 @@ protected void renderList(@NotNull PoseStack poseStack, int mouseX, int mouseY,
selectButton.setX(getRowLeft() + rowWidth);
selectButton.setY(rowTop - 3);
selectButton.visible = true;
selectButton.render(poseStack, mouseX, mouseY, deltaFrameTime);
selectButton.render(guiGraphics, mouseX, mouseY, deltaFrameTime);
}
}
}
Expand All @@ -247,8 +247,8 @@ public Entry(@NotNull String name, @NotNull File file) {
this.file = file;
}

public void render(@NotNull PoseStack poseStack, int i, int i2, int i3, int i4, int i5, int i6, int i7, boolean flag, float f) {
FileDialogScreen.this.font.drawShadow(poseStack, name, (float)(FileList.this.width / 2 - FileDialogScreen.this.font.width(name) / 2), (float)(i2 + 2), 16777215, false);
public void render(@NotNull GuiGraphics guiGraphics, int i, int i2, int i3, int i4, int i5, int i6, int i7, boolean flag, float f) {
guiGraphics.drawString(FileDialogScreen.this.font, name, FileList.this.width / 2 - FileDialogScreen.this.font.width(name) / 2, i2 + 2, 16777215, false);
}

public boolean mouseClicked(double d, double d2, int i) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
package net.blueberrymc.client.gui.screens;

import com.mojang.blaze3d.vertex.PoseStack;
import net.blueberrymc.common.Blueberry;
import net.blueberrymc.common.resources.BlueberryText;
import net.blueberrymc.config.ModDescriptionFile;
import net.minecraft.ChatFormatting;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.components.AbstractWidget;
import net.minecraft.client.gui.components.Button;
import net.minecraft.client.gui.components.EditBox;
Expand All @@ -26,7 +26,7 @@
public class GenerateModScreen extends BlueberryScreen {
private final Screen previousScreen;
private final List<Object> blockers = new ArrayList<>();
private final List<Consumer<PoseStack>> callbacks = new ArrayList<>();
private final List<Consumer<GuiGraphics>> callbacks = new ArrayList<>();
private String modName = "";
private String modId = "";
private String targetDirectory = "";
Expand All @@ -53,8 +53,8 @@ protected void init() {
if (textWidth > _maxWidth) _maxWidth = textWidth;
}
final int maxWidth = _maxWidth;
BiConsumer<Component, Integer> addLabel = (component, finalOffset) -> callbacks.add(poseStack -> {
drawString(poseStack, font, component, this.width / 2 - this.width / 6 - maxWidth - 6, finalOffset + 6, 0xFFFFFF);
BiConsumer<Component, Integer> addLabel = (component, finalOffset) -> callbacks.add(guiGraphics -> {
guiGraphics.drawString(font, component, this.width / 2 - this.width / 6 - maxWidth - 6, finalOffset + 6, 0xFFFFFF);
});
this.addRenderableWidget(
Button.builder(CommonComponents.GUI_BACK, (button) -> this.minecraft.setScreen(previousScreen))
Expand Down Expand Up @@ -188,9 +188,9 @@ private void unblock(Object blocker) {
}

@Override
public void render(@NotNull PoseStack poseStack, int mouseX, int mouseY, float deltaFrameTime) {
renderBackground(poseStack);
for (var callback : callbacks) callback.accept(poseStack);
super.render(poseStack, mouseX, mouseY, deltaFrameTime);
public void render(@NotNull GuiGraphics guiGraphics, int mouseX, int mouseY, float deltaFrameTime) {
renderBackground(guiGraphics);
for (var callback : callbacks) callback.accept(guiGraphics);
super.render(guiGraphics, mouseX, mouseY, deltaFrameTime);
}
}
Loading

0 comments on commit 5dd093c

Please sign in to comment.