Skip to content

Commit

Permalink
Support for 1.19.4
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinthegreat1 committed Mar 14, 2023
1 parent 7b9fa0d commit 79cd8ef
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 47 deletions.
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@ org.gradle.jvmargs=-Xmx1G

# Fabric Properties
# check these on https://fabricmc.net/develop
minecraft_version = 1.19.3
yarn_mappings = 1.19.3+build.1
loader_version = 0.14.11
minecraft_version = 1.19.4
yarn_mappings = 1.19.4+build.1
loader_version = 0.14.17

# Mod Properties
mod_version = 1.1.2
mod_version = 1.1.3
maven_group = com.kevinthegreat
archives_base_name = organizable-play-screens

# Dependencies
fabric_version = 0.69.1+1.19.3
modmenu_version = 5.0.2
essential_version = 11767+gf9bcb54c0
fabric_version = 0.75.3+1.19.4
modmenu_version = 6.1.0-rc.1
essential_version = 12086+g2a8bd058e
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static void renderFolderEntry(MatrixStack matrices, int index, int y, int
}
}
OrganizablePlayScreensOptions options = OrganizablePlayScreens.getInstance().options;
buttonMoveInto.setPos(options.getValue(options.moveEntryIntoButtonX), y + options.moveEntryIntoButtonY.getValue());
buttonMoveInto.setPosition(options.getValue(options.moveEntryIntoButtonX), y + options.moveEntryIntoButtonY.getValue());
buttonMoveInto.render(matrices, mouseX, mouseY, tickDelta);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public EditFolderScreen(BooleanConsumer callback, Mutable<String> folderName, bo
protected void init() {
nameField = new TextFieldWidget(textRenderer, width / 2 - 100, 90, 200, 20, ENTER_FOLDER_NAME_TEXT);
nameField.setMaxLength(128);
nameField.setTextFieldFocused(true);
nameField.setFocused(true);
nameField.setText(folderName.getValue());
nameField.setChangedListener(this::updateDoneButton);
addSelectableChild(nameField);
Expand Down Expand Up @@ -103,7 +103,7 @@ private void updateDoneButton(String text) {
@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
renderBackground(matrices);
drawCenteredText(matrices, textRenderer, title, width / 2, 20, 0xffffff);
drawCenteredTextWithShadow(matrices, textRenderer, title, width / 2, 20, 0xffffff);
drawTextWithShadow(matrices, textRenderer, ENTER_FOLDER_NAME_TEXT, width / 2 - 100, 80, 0xa0a0a0);
nameField.render(matrices, mouseX, mouseY, delta);
super.render(matrices, mouseX, mouseY, delta);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ protected void init() {
int y = height / 6 - 1 + i * 36;
for (Pair<String, SimpleOption<?>> namedOption : optionRow) {
int x = width / 2 - 155 + j * 135;
addDrawableChild(namedOption.getRight().createButton(gameOptions, x, y, 125));
addDrawableChild(namedOption.getRight().createWidget(gameOptions, x, y, 125));
j++;
}
ButtonWidget resetButton = ButtonWidget.builder(Text.translatable("controls.reset"), (buttonWidget) -> {
Expand All @@ -84,7 +84,7 @@ protected void init() {
}
}
resetButtons = resetButtonsBuilder.build();
addDrawableChild(options.buttonType.createButton(gameOptions, width / 2 - 155, height - 28, 150));
addDrawableChild(options.buttonType.createWidget(gameOptions, width / 2 - 155, height - 28, 150));
addDrawableChild(ButtonWidget.builder(ScreenTexts.DONE, (buttonWidget) -> {
options.save();
client.setScreen(parent);
Expand Down Expand Up @@ -115,10 +115,10 @@ public void clearAndInit() {
@Override
public void render(MatrixStack matrices, int mouseX, int mouseY, float delta) {
renderBackground(matrices);
drawCenteredText(matrices, textRenderer, title, width / 2, 12, 0xFFFFFF);
drawCenteredTextWithShadow(matrices, textRenderer, title, width / 2, 12, 0xFFFFFF);
int i = 0;
for (String key : OrganizablePlayScreensOptions.KEYS) {
drawCenteredText(matrices, textRenderer, Text.translatable(key), width / 2, height / 6 - 12 + i, 0xFFFFFF);
drawCenteredTextWithShadow(matrices, textRenderer, Text.translatable(key), width / 2, height / 6 - 12 + i, 0xFFFFFF);
i += 36;
}
if (options.buttonType.getValue()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -244,9 +244,9 @@ private void organizableplayscreens_keyPressed(int keyCode, int scanCode, int mo
*
* @see MultiplayerServerListWidgetMixin#organizableplayscreens_currentPath currentPath
*/
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;drawCenteredText(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;III)V", shift = At.Shift.AFTER))
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/multiplayer/MultiplayerScreen;drawCenteredTextWithShadow(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;III)V", shift = At.Shift.AFTER))
private void organizableplayscreens_renderPath(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) {
drawCenteredText(matrices, textRenderer, serverListWidgetAccessor.organizableplayscreens_getCurrentPath(), width / 2, 6, 0xa0a0a0);
drawCenteredTextWithShadow(matrices, textRenderer, serverListWidgetAccessor.organizableplayscreens_getCurrentPath(), width / 2, 6, 0xa0a0a0);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ public void organizableplayscreens_swapEntries(int i, int j) {
Collections.swap(organizableplayscreens_currentFolder.getEntries(), i, j);
organizableplayscreens_updateAndSave();
setSelected(children().get(j));
ensureSelectedEntryVisible();
ensureVisible(getSelectedOrNull());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private void organizableplayscreens_setWorldListWidgetAccessor(CallbackInfo ci)
* The 'move entry back' button moves the selected entry to the parent folder.
* The 'new folder' button opens a screen to create a new folder and stores it in {@link #organizableplayscreens_newFolder newFolder}.
*/
@Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/world/SelectWorldScreen;worldSelected(Z)V"))
@Inject(method = "init", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/world/SelectWorldScreen;worldSelected(ZZ)V"))
private void organizableplayscreens_addButtons(CallbackInfo ci) {
OrganizablePlayScreensOptions options = OrganizablePlayScreens.getInstance().options;
organizableplayscreens_buttonBack = addDrawableChild(ButtonWidget.builder(Text.of("←"), buttonWidget -> {
Expand Down Expand Up @@ -244,16 +244,16 @@ private int organizableplayscreens_modifyTitleY(int original) {
*
* @see WorldListWidgetMixin#organizableplayscreens_currentPath currentPath
*/
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/world/SelectWorldScreen;drawCenteredText(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;III)V", shift = At.Shift.AFTER))
@Inject(method = "render", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/world/SelectWorldScreen;drawCenteredTextWithShadow(Lnet/minecraft/client/util/math/MatrixStack;Lnet/minecraft/client/font/TextRenderer;Lnet/minecraft/text/Text;III)V", shift = At.Shift.AFTER))
private void organizableplayscreens_renderPath(MatrixStack matrices, int mouseX, int mouseY, float delta, CallbackInfo ci) {
drawCenteredText(matrices, textRenderer, worldListWidgetAccessor.organizableplayscreens_getCurrentPath(), width / 2, 2, 0xa0a0a0);
drawCenteredTextWithShadow(matrices, textRenderer, worldListWidgetAccessor.organizableplayscreens_getCurrentPath(), width / 2, 2, 0xa0a0a0);
}

/**
* Updates the activation states of buttons. Called at the end of {@link #init()} and every time an entry is selected.
*/
@Inject(method = "worldSelected", at = @At("RETURN"))
private void organizableplayscreens_updateButtonStates(boolean active, CallbackInfo ci) {
private void organizableplayscreens_updateButtonStates(boolean buttonsActive, boolean deleteButtonActive, CallbackInfo ci) {
WorldListWidget.Entry entry = levelList.getSelectedOrNull();
if (entry instanceof WorldListWidget.WorldEntry) {
selectButton.setMessage(Text.translatable("selectWorld.select"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,11 @@
import org.spongepowered.asm.mixin.gen.Accessor;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Inject;
import org.spongepowered.asm.mixin.injection.ModifyArg;
import org.spongepowered.asm.mixin.injection.callback.CallbackInfo;

import java.io.File;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.function.Predicate;

@Mixin(WorldListWidget.class)
public abstract class WorldListWidgetMixin extends AlwaysSelectedEntryListWidget<WorldListWidget.Entry> implements WorldListWidgetAccessor {
Expand Down Expand Up @@ -318,14 +316,6 @@ public boolean keyPressed(int keyCode, int scanCode, int modifiers) {
return entry != null && entry.keyPressed(keyCode, scanCode, modifiers) || super.keyPressed(keyCode, scanCode, modifiers);
}

/**
* Allows moving selection to unavailable worlds to move them across folders.
*/
@ModifyArg(method = "moveSelection", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/gui/screen/world/WorldListWidget;moveSelectionIf(Lnet/minecraft/client/gui/widget/EntryListWidget$MoveDirection;Ljava/util/function/Predicate;)Z"))
protected Predicate<WorldListWidget.Entry> organizableplayscreens_allowMoveSelectionToWorldEntry(Predicate<WorldListWidget.Entry> predicate) {
return predicate.or(WorldListWidget.WorldEntry.class::isInstance);
}

/**
* Updates the displayed entries with specified search string.
*/
Expand All @@ -343,7 +333,7 @@ public void organizableplayscreens_swapEntries(int i, int j) {
Collections.swap(organizableplayscreens_currentFolder.getFolderEntries(), i, j);
organizableplayscreens_updateAndSave();
setSelected(children().get(j));
ensureSelectedEntryVisible();
ensureVisible(getSelectedOrNull());
}

/**
Expand All @@ -363,7 +353,7 @@ private void organizableplayscreens_updateEntries(String search) {
SingleplayerFolderEntry folderEntry = organizableplayscreens_worlds.get(worldEntry);
if (folderEntry != null) {
organizableplayscreens_currentFolder = folderEntry;
parent.worldSelected(true);
parent.worldSelected(true, true);
}
}
children().addAll(organizableplayscreens_currentFolder.getFolderEntries());
Expand All @@ -376,10 +366,12 @@ private void organizableplayscreens_updateEntries(String search) {
}
}
}
if (getSelectedOrNull() == null) {
WorldListWidget.Entry selected = getSelectedOrNull();
if (selected == null) {
setScrollAmount(0);
} else {
ensureVisible(selected);
}
ensureSelectedEntryVisible();
narrateScreenIfNarrationEnabled();
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package com.kevinthegreat.organizableplayscreens.option;

import com.mojang.serialization.Codec;
import com.mojang.serialization.DataResult;
import net.minecraft.client.gui.widget.ClickableWidget;
import net.minecraft.client.option.GameOptions;
import net.minecraft.client.option.SimpleOption;
Expand Down Expand Up @@ -50,11 +49,11 @@ public int maxInclusive() {
}

@Override
public Function<SimpleOption<Integer>, ClickableWidget> getButtonCreator(SimpleOption.TooltipFactory<Integer> tooltipFactory, GameOptions gameOptions, int x, int y, int width, Consumer<Integer> changeCallback) {
public Function<SimpleOption<Integer>, ClickableWidget> getWidgetCreator(SimpleOption.TooltipFactory<Integer> tooltipFactory, GameOptions gameOptions, int x, int y, int width, Consumer<Integer> changeCallback) {
if (buttonType.getValue()) {
return option -> new OptionIntTextFieldWidgetImpl(x + 20, y, width - 20, 20, option, this, tooltipFactory);
} else {
return SimpleOption.IntSliderCallbacks.super.getButtonCreator(tooltipFactory, gameOptions, x, y, width, changeCallback);
return SimpleOption.IntSliderCallbacks.super.getWidgetCreator(tooltipFactory, gameOptions, x, y, width, changeCallback);
}
}

Expand All @@ -65,14 +64,6 @@ public Optional<Integer> validate(Integer integer) {

@Override
public Codec<Integer> codec() {
Function<Integer, DataResult<Integer>> function = value -> {
int minInclusive = minSupplier.getAsInt();
int maxInclusive = maxSupplier.getAsInt() + 1;
if (value.compareTo(minInclusive) >= 0 && value.compareTo(maxInclusive) <= 0) {
return DataResult.success(value);
}
return DataResult.error("Value " + value + " outside of range [" + minInclusive + ":" + maxInclusive + "]", value);
};
return Codec.INT.flatXmap(function, function);
return Codec.intRange(Integer.MIN_VALUE, Integer.MAX_VALUE);
}
}

0 comments on commit 79cd8ef

Please sign in to comment.