mirror of
https://github.com/chylex/Better-Controls.git
synced 2025-04-22 09:15:46 +02:00
Update for Minecraft 1.20
This commit is contained in:
parent
970558911d
commit
481e9906bc
src/main/java/chylex/bettercontrols
@ -11,10 +11,10 @@ import chylex.bettercontrols.input.ModifierKey;
|
||||
import chylex.bettercontrols.input.SprintMode;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.mojang.blaze3d.platform.InputConstants;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import it.unimi.dsi.fastutil.booleans.BooleanConsumer;
|
||||
import net.minecraft.client.KeyMapping;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.Button;
|
||||
import net.minecraft.client.gui.components.CycleButton;
|
||||
import net.minecraft.client.gui.components.events.GuiEventListener;
|
||||
@ -257,11 +257,11 @@ public class BetterControlsScreen extends OptionsSubScreen {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(final @NotNull PoseStack matrices, final int mouseX, final int mouseY, final float delta) {
|
||||
renderBackground(matrices);
|
||||
optionsWidget.render(matrices, mouseX, mouseY, delta);
|
||||
drawCenteredString(matrices, font, title, width / 2, 8, (255 << 16) | (255 << 8) | 255);
|
||||
super.render(matrices, mouseX, mouseY, delta);
|
||||
public void render(final @NotNull GuiGraphics graphics, final int mouseX, final int mouseY, final float delta) {
|
||||
renderBackground(graphics);
|
||||
optionsWidget.render(graphics, mouseX, mouseY, delta);
|
||||
graphics.drawCenteredString(font, title, width / 2, 8, TextWidget.WHITE);
|
||||
super.render(graphics, mouseX, mouseY, delta);
|
||||
}
|
||||
|
||||
private void startEditingKeyBinding(final KeyBindingWidget widget) {
|
||||
|
@ -1,8 +1,8 @@
|
||||
package chylex.bettercontrols.gui;
|
||||
|
||||
import chylex.bettercontrols.gui.OptionListWidget.Entry;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.client.gui.components.AbstractWidget;
|
||||
import net.minecraft.client.gui.components.ContainerObjectSelectionList;
|
||||
import net.minecraft.client.gui.components.Renderable;
|
||||
@ -96,7 +96,7 @@ public final class OptionListWidget extends ContainerObjectSelectionList<Entry>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(final @NotNull PoseStack matrices, final int index, final int y, final int x, final int entryWidth, final int entryHeight, final int mouseX, final int mouseY, final boolean hovered, final float tickDelta) {
|
||||
public void render(final @NotNull GuiGraphics graphics, final int index, final int y, final int x, final int entryWidth, final int entryHeight, final int mouseX, final int mouseY, final boolean hovered, final float tickDelta) {
|
||||
for (final GuiEventListener element : elements) {
|
||||
final Offset offset = offsets.get(element);
|
||||
|
||||
@ -110,7 +110,7 @@ public final class OptionListWidget extends ContainerObjectSelectionList<Entry>
|
||||
}
|
||||
|
||||
if (element instanceof final Renderable renderable) {
|
||||
renderable.render(matrices, mouseX, mouseY, tickDelta);
|
||||
renderable.render(graphics, mouseX, mouseY, tickDelta);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,20 @@
|
||||
package chylex.bettercontrols.gui.elements;
|
||||
|
||||
import chylex.bettercontrols.gui.OptionListWidget.OptionWidget;
|
||||
import com.mojang.blaze3d.vertex.PoseStack;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.gui.Font;
|
||||
import net.minecraft.client.gui.GuiComponent;
|
||||
import net.minecraft.client.gui.GuiGraphics;
|
||||
import net.minecraft.network.chat.Component;
|
||||
import net.minecraft.util.FormattedCharSequence;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import java.util.List;
|
||||
|
||||
public final class TextWidget extends GuiComponent implements OptionWidget {
|
||||
public final class TextWidget implements OptionWidget {
|
||||
public static final int LEFT = 0;
|
||||
public static final int CENTER = 1;
|
||||
|
||||
public static final int WHITE = 0xFF_FF_FF;
|
||||
|
||||
private final Component text;
|
||||
private int x;
|
||||
private int y;
|
||||
@ -67,7 +68,7 @@ public final class TextWidget extends GuiComponent implements OptionWidget {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void render(final @NotNull PoseStack matrices, final int mouseX, final int mouseY, final float delta) {
|
||||
public void render(final @NotNull GuiGraphics graphics, final int mouseX, final int mouseY, final float delta) {
|
||||
final Font textRenderer = Minecraft.getInstance().font;
|
||||
final List<FormattedCharSequence> lines = textRenderer.split(text, width);
|
||||
final int lineHeight = textRenderer.lineHeight + 1;
|
||||
@ -76,8 +77,7 @@ public final class TextWidget extends GuiComponent implements OptionWidget {
|
||||
final int finalY = y + (height / 2) - (lineHeight * lines.size() / 2) + 1;
|
||||
|
||||
for (int i = 0; i < lines.size(); i++) {
|
||||
final FormattedCharSequence line = lines.get(i);
|
||||
textRenderer.drawShadow(matrices, line, finalX, finalY + (i * lineHeight), (255 << 16) | (255 << 8) | 255);
|
||||
graphics.drawString(textRenderer, lines.get(i), finalX, finalY + (i * lineHeight), WHITE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -212,7 +212,7 @@ public final class PlayerTicker {
|
||||
public void afterSuperCall(final LocalPlayer player) {
|
||||
if (FlightHelper.shouldFlyOnGround(player)) {
|
||||
final boolean isSneaking = player.isShiftKeyDown();
|
||||
final boolean isOnGround = player.isOnGround();
|
||||
final boolean isOnGround = player.onGround();
|
||||
|
||||
if (!isSneaking) {
|
||||
wasSneakingBeforeTouchingGround = false;
|
||||
|
Loading…
Reference in New Issue
Block a user