Skip to content

Commit

Permalink
Port to 1.21
Browse files Browse the repository at this point in the history
  • Loading branch information
odeyaio committed Sep 28, 2024
1 parent 3265d55 commit ab0727f
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/main/java/net/vulkanmod/config/gui/ConfigScreen.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.gui.screens.VideoSettingsScreen;
import net.minecraft.client.gui.screens.options.VideoSettingsScreen;
import net.minecraft.network.chat.Component;
import net.vulkanmod.Initializer;
import net.vulkanmod.config.gui.container.OptionList;
Expand Down Expand Up @@ -259,7 +259,7 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
if (!(getFocused() instanceof SearchFieldWidget)
&& keyCode == GLFW.GLFW_KEY_P
&& (modifiers & GLFW.GLFW_MOD_SHIFT) != 0) {
Minecraft.getInstance().setScreen(new VideoSettingsScreen(this, Minecraft.getInstance().options));
Minecraft.getInstance().setScreen(new VideoSettingsScreen(this, Minecraft.getInstance(), Minecraft.getInstance().options));

return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
import java.util.List;

public class PageList extends AbstractWidgetContainer {
private static final ResourceLocation ICON = new ResourceLocation("vulkanmod", "vlogo_transparent.png");
private static final ResourceLocation ICON = ResourceLocation.fromNamespaceAndPath("vulkanmod", "vlogo_transparent.png");
private static final int ICON_SIZE = GuiConstants.WIDGET_HEIGHT - 3;

private static OptionPage currentPage;
Expand Down Expand Up @@ -73,7 +73,7 @@ public OptionPage getCurrentPage() {
if (pages.isEmpty())
currentPage = OptionPage.getDummy();
if (currentPage == null || (!pages.contains(currentPage) && !pages.isEmpty()))
currentPage = pages.get(0);
currentPage = pages.getFirst();

return currentPage;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import com.mojang.blaze3d.platform.InputConstants;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.BufferBuilder;
import com.mojang.blaze3d.vertex.DefaultVertexFormat;
import com.mojang.blaze3d.vertex.Tesselator;
import com.mojang.blaze3d.vertex.VertexFormat;
import com.mojang.blaze3d.vertex.*;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.GameRenderer;
Expand Down Expand Up @@ -89,7 +86,7 @@ private void renderBars() {

private void renderArrow(Dimension<Float> arrowDim, double mouseX, double mouseY) {
Tesselator tesselator = Tesselator.getInstance();
BufferBuilder bufferBuilder = tesselator.getBuilder();
BufferBuilder bufferBuilder = tesselator.begin(VertexFormat.Mode.TRIANGLE_STRIP, DefaultVertexFormat.POSITION);

RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);

Expand All @@ -105,25 +102,23 @@ private void renderArrow(Dimension<Float> arrowDim, double mouseX, double mouseY
else if (this.isActive())
RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 0.8f);

bufferBuilder.begin(VertexFormat.Mode.TRIANGLE_STRIP, DefaultVertexFormat.POSITION);

if (arrowDim == leftArrowDim) {
if (valueIndex == 0 || !this.isActive())
RenderSystem.setShaderColor(0.3f, 0.3f, 0.3f, 0.8f);

bufferBuilder.vertex(matrix4f, arrowDim.x(), arrowDim.centerY(), 0).endVertex();
bufferBuilder.vertex(matrix4f, arrowDim.xLimit(), arrowDim.yLimit(), 0).endVertex();
bufferBuilder.vertex(matrix4f, arrowDim.xLimit(), arrowDim.y(), 0).endVertex();
bufferBuilder.addVertex(matrix4f, arrowDim.x(), arrowDim.centerY(), 0);
bufferBuilder.addVertex(matrix4f, arrowDim.xLimit(), arrowDim.yLimit(), 0);
bufferBuilder.addVertex(matrix4f, arrowDim.xLimit(), arrowDim.y(), 0);
} else if (arrowDim == rightArrowDim) {
if (valueIndex == values.size() - 1 || !this.isActive())
RenderSystem.setShaderColor(0.3f, 0.3f, 0.3f, 0.8f);

bufferBuilder.vertex(matrix4f, arrowDim.x(), arrowDim.y(), 0).endVertex();
bufferBuilder.vertex(matrix4f, arrowDim.x(), arrowDim.yLimit(), 0).endVertex();
bufferBuilder.vertex(matrix4f, arrowDim.xLimit(), arrowDim.centerY(), 0).endVertex();
bufferBuilder.addVertex(matrix4f, arrowDim.x(), arrowDim.y(), 0);
bufferBuilder.addVertex(matrix4f, arrowDim.x(), arrowDim.yLimit(), 0);
bufferBuilder.addVertex(matrix4f, arrowDim.xLimit(), arrowDim.centerY(), 0);
}

tesselator.end();
BufferUploader.drawWithShader(bufferBuilder.buildOrThrow());

RenderSystem.setShaderColor(1.0f, 1.0f, 1.0f, 1.0f);
RenderSystem.setShader(GameRenderer::getPositionTexShader);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package net.vulkanmod.config.gui.util;

import net.minecraft.SharedConstants;
import net.minecraft.Util;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.util.Mth;
import net.minecraft.util.StringUtil;
import net.vulkanmod.config.gui.GuiRenderer;

import java.util.function.Consumer;
Expand Down Expand Up @@ -39,7 +39,7 @@ public void write(String text) {
int currentWidth = GuiRenderer.font.width(query.toString());
int remainingWidth = innerWidth - currentWidth + GuiRenderer.font.width(query.substring(start, end));

String filteredText = SharedConstants.filterText(text);
String filteredText = StringUtil.filterText(text);
int textWidth = GuiRenderer.font.width(filteredText);

if (textWidth > remainingWidth) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package net.vulkanmod.config.gui.widget;

import com.mojang.blaze3d.systems.RenderSystem;
import net.minecraft.SharedConstants;
import net.minecraft.Util;
import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.GuiGraphics;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.network.chat.Component;
import net.minecraft.util.Mth;
import net.minecraft.util.StringUtil;
import net.vulkanmod.config.gui.GuiRenderer;
import net.vulkanmod.config.gui.util.GuiConstants;
import net.vulkanmod.config.gui.util.SearchFieldTextModel;
Expand Down Expand Up @@ -112,7 +112,7 @@ private boolean isCursorVisible() {

@Override
public boolean charTyped(char chr, int modifiers) {
if (this.isFocused() && SharedConstants.isAllowedChatCharacter(chr)) {
if (this.isFocused() && StringUtil.isAllowedChatCharacter(chr)) {
model.write(Character.toString(chr));
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static List<VideoMode> getVideoModes() {
}

public static VideoMode getFirstAvailable() {
return videoModes.get(videoModes.size() - 1);
return videoModes.getLast();
}

public static VideoMode getOsVideoMode() {
Expand Down

0 comments on commit ab0727f

Please sign in to comment.