[CHORE] Backport from 1.20.3
This commit is contained in:
@@ -8,6 +8,7 @@ import com.hypherionmc.craterlib.core.config.annotations.SubConfig;
|
||||
import com.hypherionmc.craterlib.core.config.annotations.Tooltip;
|
||||
import com.mojang.blaze3d.systems.RenderSystem;
|
||||
import com.mojang.blaze3d.vertex.*;
|
||||
import com.mojang.math.Matrix4f;
|
||||
import me.hypherionmc.moonconfig.core.conversion.SpecComment;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.client.gui.Font;
|
||||
@@ -19,7 +20,6 @@ import net.minecraft.resources.ResourceLocation;
|
||||
import net.minecraft.util.Mth;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.joml.Matrix4f;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
@@ -20,8 +20,8 @@ public class AbstractConfigWidget<T, W extends AbstractWidget> extends BaseWidge
|
||||
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);
|
||||
widget.setY(y + i + 1);
|
||||
widget.x = (x + width - 200 - resetButtonOffset + i);
|
||||
widget.y = (y + i + 1);
|
||||
widget.render(matrices, mouseX, mouseY, delta);
|
||||
}
|
||||
}
|
||||
|
@@ -16,7 +16,7 @@ import net.minecraft.network.chat.TextColor;
|
||||
public class BaseWidget<T> extends Option<T> {
|
||||
|
||||
public static final int resetButtonOffset = 48;
|
||||
private final Button resetButton = addChild(Button.builder(Component.literal("Reset"), this::onResetPressed).size(46, 20).build());
|
||||
private final Button resetButton = addChild(new Button(0, 0, 46, 20, Component.literal("Reset"), this::onResetPressed));
|
||||
private boolean hideReset = false;
|
||||
|
||||
private boolean isSubConfig = false;
|
||||
@@ -51,8 +51,8 @@ public class BaseWidget<T> extends Option<T> {
|
||||
text.withStyle(ChatFormatting.GRAY);
|
||||
}
|
||||
font.draw(matrices, text, x, y, 0xFFFFFF);
|
||||
resetButton.setX(x + width - 46);
|
||||
resetButton.setY(y + 1);
|
||||
resetButton.x = (x + width - 46);
|
||||
resetButton.y = (y + 1);
|
||||
resetButton.active = isNotDefault();
|
||||
if (!hideReset) {
|
||||
resetButton.render(matrices, mouseX, mouseY, delta);
|
||||
|
@@ -34,11 +34,6 @@ public class InternalConfigButton extends AbstractButton {
|
||||
super.render(poseStack, i, j, f);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateWidgetNarration(NarrationElementOutput narrationElementOutput) {
|
||||
narrationElementOutput.add(NarratedElementType.USAGE, getMessage());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPress() {
|
||||
if (cancel) {
|
||||
@@ -49,4 +44,8 @@ public class InternalConfigButton extends AbstractButton {
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void updateNarration(NarrationElementOutput narrationElementOutput) {
|
||||
narrationElementOutput.add(NarratedElementType.USAGE, getMessage());
|
||||
}
|
||||
}
|
||||
|
@@ -6,8 +6,8 @@ import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.components.events.AbstractContainerEventHandler;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
@@ -23,7 +23,7 @@ public class SubConfigWidget<T> extends AbstractConfigWidget<T, Button> {
|
||||
this.subConfig = subConfig;
|
||||
this.screen = screen;
|
||||
|
||||
this.widget = addChild(Button.builder(Component.translatable("t.clc.opensubconfig"), this::openSubConfig).size(200, buttonHeight).build());
|
||||
this.widget = addChild(new Button(0, 0, 200, buttonHeight, Component.translatable("t.clc.opensubconfig"), this::openSubConfig));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -18,7 +18,7 @@ public class ToggleButton<T> extends AbstractConfigWidget<T, Button> {
|
||||
public ToggleButton(List<T> options, Function<T, Component> toComponent) {
|
||||
this.options = options;
|
||||
this.toComponent = toComponent;
|
||||
this.widget = addChild(Button.builder(Component.empty(), this::switchNext).size(buttonWidth, buttonHeight).build());
|
||||
this.widget = addChild(new Button(0, 0, buttonWidth, buttonHeight, Component.empty(), this::switchNext));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -9,7 +9,6 @@ import net.minecraft.world.phys.Vec2;
|
||||
import net.minecraft.world.phys.Vec3;
|
||||
|
||||
import java.util.UUID;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class AbstractFakePlayer extends CommandSourceStack {
|
||||
|
||||
|
@@ -19,7 +19,7 @@ public class ServerGamePacketListenerImplMixin {
|
||||
|
||||
@Inject(method = "broadcastChatMessage", at = @At("HEAD"), cancellable = true)
|
||||
private void injectChatEvent(PlayerChatMessage chatMessage, CallbackInfo ci) {
|
||||
CraterServerChatEvent event = new CraterServerChatEvent(this.player, chatMessage.decoratedContent().getString(), chatMessage.decoratedContent());
|
||||
CraterServerChatEvent event = new CraterServerChatEvent(this.player, chatMessage.serverContent().getString(), chatMessage.serverContent());
|
||||
CraterEventBus.INSTANCE.postEvent(event);
|
||||
if (event.wasCancelled())
|
||||
ci.cancel();
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package com.hypherionmc.craterlib.util;
|
||||
|
||||
import com.mojang.math.Vector4f;
|
||||
import net.minecraft.ChatFormatting;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.world.item.DyeColor;
|
||||
import org.joml.Vector4f;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
|
Reference in New Issue
Block a user