[CHORE] Backport from 1.20.3
This commit is contained in:
@@ -11,7 +11,6 @@ import com.mojang.blaze3d.vertex.*;
|
||||
import me.hypherionmc.moonconfig.core.conversion.SpecComment;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.screens.ConfirmScreen;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.client.renderer.GameRenderer;
|
||||
@@ -177,19 +176,19 @@ public class CraterConfigScreen extends Screen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(@NotNull GuiGraphics matrices, int mouseX, int mouseY, float delta) {
|
||||
overlayBackground(matrices.pose(), TOP, height - BOTTOM, 32);
|
||||
public void render(@NotNull PoseStack matrices, int mouseX, int mouseY, float delta) {
|
||||
overlayBackground(matrices, TOP, height - BOTTOM, 32);
|
||||
|
||||
renderScrollBar();
|
||||
|
||||
matrices.pose().pushPose();
|
||||
matrices.pose().translate(0, 0, 500.0);
|
||||
overlayBackground(matrices.pose(), 0, TOP, 64);
|
||||
overlayBackground(matrices.pose(), height - BOTTOM, height, 64);
|
||||
renderShadow(matrices.pose());
|
||||
matrices.drawCenteredString(font, getTitle(), width / 2, 9, 0xFFFFFF);
|
||||
matrices.pushPose();
|
||||
matrices.translate(0, 0, 500.0);
|
||||
overlayBackground(matrices, 0, TOP, 64);
|
||||
overlayBackground(matrices, height - BOTTOM, height, 64);
|
||||
renderShadow(matrices);
|
||||
drawCenteredString(matrices, font, getTitle(), width / 2, 9, 0xFFFFFF);
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
matrices.pose().popPose();
|
||||
matrices.popPose();
|
||||
|
||||
int y = (int) (TOP + 4 - Math.round(scrollerAmount));
|
||||
for (Option<?> option : options) {
|
||||
@@ -379,7 +378,7 @@ public class CraterConfigScreen extends Screen {
|
||||
}
|
||||
}
|
||||
|
||||
private void renderConfigTooltip(GuiGraphics stack, Font font, int mouseX, int mouseY, int startX, int startY, int sizeX, int sizeY, String title, String... description) {
|
||||
private void renderConfigTooltip(PoseStack stack, Font font, int mouseX, int mouseY, int startX, int startY, int sizeX, int sizeY, String title, String... description) {
|
||||
if (mouseX > startX && mouseX < startX + sizeX) {
|
||||
if (mouseY > startY && mouseY < startY + sizeY) {
|
||||
List<Component> list = new ArrayList<>();
|
||||
@@ -387,7 +386,7 @@ public class CraterConfigScreen extends Screen {
|
||||
for (String desc : description) {
|
||||
list.add(Component.translatable(desc));
|
||||
}
|
||||
stack.renderComponentTooltip(font, list, mouseX, mouseY);
|
||||
renderComponentTooltip(stack, list, mouseX, mouseY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,8 @@
|
||||
package com.hypherionmc.craterlib.client.gui.config.widgets;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.components.EditBox;
|
||||
|
||||
@@ -17,7 +17,7 @@ public class AbstractConfigWidget<T, W extends AbstractWidget> extends BaseWidge
|
||||
public W widget;
|
||||
|
||||
@Override
|
||||
public void render(Minecraft minecraft, Font font, int x, int y, int width, int height, GuiGraphics matrices, int mouseX, int mouseY, float delta) {
|
||||
public void render(Minecraft minecraft, Font font, int x, int y, int width, int height, PoseStack matrices, int mouseX, int mouseY, float delta) {
|
||||
super.render(minecraft, font, x, y, width, height, matrices, mouseX, mouseY, delta);
|
||||
int i = (widget instanceof EditBox ? 1 : 0);
|
||||
widget.setX(x + width - 200 - resetButtonOffset + i);
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package com.hypherionmc.craterlib.client.gui.config.widgets;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.network.chat.MutableComponent;
|
||||
@@ -39,7 +39,7 @@ public class BaseWidget<T> extends Option<T> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Minecraft minecraft, Font font, int x, int y, int width, int height, GuiGraphics matrices, int mouseX, int mouseY, float delta) {
|
||||
public void render(Minecraft minecraft, Font font, int x, int y, int width, int height, PoseStack matrices, int mouseX, int mouseY, float delta) {
|
||||
MutableComponent text = Component.literal(this.text.getString());
|
||||
boolean edited = isEdited() || hasErrors;
|
||||
if (edited) {
|
||||
@@ -50,7 +50,7 @@ public class BaseWidget<T> extends Option<T> {
|
||||
} else {
|
||||
text.withStyle(ChatFormatting.GRAY);
|
||||
}
|
||||
matrices.drawString(font, text, x, y, 0xFFFFFF);
|
||||
font.draw(matrices, text, x, y, 0xFFFFFF);
|
||||
resetButton.setX(x + width - 46);
|
||||
resetButton.setY(y + 1);
|
||||
resetButton.active = isNotDefault();
|
||||
|
@@ -1,7 +1,7 @@
|
||||
package com.hypherionmc.craterlib.client.gui.config.widgets;
|
||||
|
||||
import com.hypherionmc.craterlib.client.gui.config.CraterConfigScreen;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.gui.components.AbstractButton;
|
||||
import net.minecraft.client.gui.narration.NarratedElementType;
|
||||
import net.minecraft.client.gui.narration.NarrationElementOutput;
|
||||
@@ -23,7 +23,7 @@ public class InternalConfigButton extends AbstractButton {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(@NotNull GuiGraphics poseStack, int i, int j, float f) {
|
||||
public void render(@NotNull PoseStack poseStack, int i, int j, float f) {
|
||||
if (cancel) {
|
||||
setMessage(Component.translatable(screen.isEdited() ? "t.clc.cancel_discard" : "gui.cancel"));
|
||||
} else {
|
||||
|
@@ -1,8 +1,8 @@
|
||||
package com.hypherionmc.craterlib.client.gui.config.widgets;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.events.AbstractContainerEventHandler;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -38,7 +38,7 @@ public abstract class Option<T> extends AbstractContainerEventHandler {
|
||||
this.langKeys = langKeys;
|
||||
}
|
||||
|
||||
public abstract void render(Minecraft minecraft, Font font, int x, int y, int width, int height, GuiGraphics matrices, int mouseX, int mouseY, float delta);
|
||||
public abstract void render(Minecraft minecraft, Font font, int x, int y, int width, int height, PoseStack matrices, int mouseX, int mouseY, float delta);
|
||||
|
||||
public int height() {
|
||||
return 22;
|
||||
|
@@ -2,9 +2,9 @@ package com.hypherionmc.craterlib.client.gui.config.widgets;
|
||||
|
||||
import com.hypherionmc.craterlib.client.gui.config.CraterConfigScreen;
|
||||
import com.hypherionmc.craterlib.core.config.ModuleConfig;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import net.minecraft.network.chat.Component;
|
||||
@@ -27,7 +27,7 @@ public class SubConfigWidget<T> extends AbstractConfigWidget<T, Button> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Minecraft minecraft, Font font, int x, int y, int width, int height, GuiGraphics matrices, int mouseX, int mouseY, float delta) {
|
||||
public void render(Minecraft minecraft, Font font, int x, int y, int width, int height, PoseStack matrices, int mouseX, int mouseY, float delta) {
|
||||
this.text = Component.literal(subConfig.getClass().getSimpleName().toLowerCase());
|
||||
this.hideReset();
|
||||
super.render(minecraft, font, x, y, width, height, matrices, mouseX, mouseY, delta);
|
||||
|
@@ -1,8 +1,8 @@
|
||||
package com.hypherionmc.craterlib.client.gui.config.widgets;
|
||||
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
@@ -29,7 +29,7 @@ public class TextConfigOption<T> extends AbstractConfigWidget<T, WrappedEditBox>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(Minecraft minecraft, Font font, int x, int y, int width, int height, GuiGraphics matrices, int mouseX, int mouseY, float delta) {
|
||||
public void render(Minecraft minecraft, Font font, int x, int y, int width, int height, PoseStack matrices, int mouseX, int mouseY, float delta) {
|
||||
widget.setTextColor(hasErrors ? 16733525 : 14737632);
|
||||
super.render(minecraft, font, x, y, width, height, matrices, mouseX, mouseY, delta);
|
||||
}
|
||||
|
@@ -21,7 +21,7 @@ public class WrappedEditBox extends EditBox {
|
||||
for (GuiEventListener child : Minecraft.getInstance().screen.children()) {
|
||||
if (child instanceof TextConfigOption<?> option) {
|
||||
WrappedEditBox box = option.widget;
|
||||
super.setFocused(box == this);
|
||||
box.setFocused(box == this);
|
||||
}
|
||||
}
|
||||
super.setFocused(bl);
|
||||
|
@@ -7,7 +7,7 @@ import net.minecraft.network.chat.MutableComponent;
|
||||
public class AbstractCommand {
|
||||
|
||||
public static void replySuccess(CommandContext<CommandSourceStack> stack, MutableComponent message) {
|
||||
stack.getSource().sendSuccess(() -> message, false);
|
||||
stack.getSource().sendSuccess(message, false);
|
||||
}
|
||||
|
||||
public static void replyFailure(CommandContext<CommandSourceStack> stack, MutableComponent message) {
|
||||
|
@@ -25,13 +25,13 @@ public class AbstractFakePlayer extends CommandSourceStack {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendSuccess(Supplier<Component> component, boolean bl) {
|
||||
this.onSuccess(component.get(), bl);
|
||||
public void sendSuccess(Component component, boolean bl) {
|
||||
this.onSuccess(component, bl);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendFailure(Component component) {
|
||||
sendSuccess(() -> component, false);
|
||||
sendSuccess(component, false);
|
||||
}
|
||||
|
||||
public UUID getUuid() {
|
||||
|
@@ -4,18 +4,18 @@ import com.hypherionmc.craterlib.api.event.client.ScreenEvent;
|
||||
import com.hypherionmc.craterlib.core.event.CraterEventBus;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.screens.Screen;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
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 org.jetbrains.annotations.Nullable;
|
||||
|
||||
@Mixin(Minecraft.class)
|
||||
public class MinecraftMixin {
|
||||
|
||||
@Shadow @Nullable
|
||||
public Screen screen;
|
||||
@Shadow @Nullable public Screen screen;
|
||||
|
||||
@Inject(method = "setScreen", at = @At(value = "TAIL"))
|
||||
private void injectScreenOpeningEvent(Screen screen, CallbackInfo ci) {
|
||||
|
@@ -42,7 +42,7 @@ public class RenderUtils {
|
||||
}
|
||||
|
||||
public static int renderColorFromDye(DyeColor color) {
|
||||
return color.getMapColor().col | 0xFF000000;
|
||||
return color.getMaterialColor().col | 0xFF000000;
|
||||
}
|
||||
|
||||
public static int alphaColorFromDye(DyeColor color, float alpha) {
|
||||
|
Reference in New Issue
Block a user