diff options
Diffstat (limited to 'runtime/src/main/java')
61 files changed, 344 insertions, 514 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java index 96a697253..de49c9a29 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsCoreClient.java @@ -152,7 +152,7 @@ public class RoughlyEnoughItemsCoreClient { String type = object.getString(FavoriteEntry.TYPE_KEY); ResourceLocation id = new ResourceLocation(type); FavoriteEntryType<FavoriteEntry> entryType = FavoriteEntryType.registry().get(id); - if (entryType == null) return DataResult.error("Unknown favorite type: " + id + ", json: " + object); + if (entryType == null) return DataResult.error(() -> "Unknown favorite type: " + id + ", json: " + object); return entryType.read(object); }, "favoriteEntryFromJson"); ClientInternals.attachInstance((BiFunction<@Nullable Point, Collection<Tooltip.Entry>, Tooltip>) QueuedTooltip::impl, "tooltipProvider"); diff --git a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java index f76efdd65..b9d79cf83 100644 --- a/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java +++ b/runtime/src/main/java/me/shedaniel/rei/RoughlyEnoughItemsNetwork.java @@ -104,7 +104,7 @@ public class RoughlyEnoughItemsNetwork { AbstractContainerMenu menu = player.containerMenu; ItemStack itemStack = buf.readItem(); ItemStack stack = itemStack.copy(); - if (!menu.getCarried().isEmpty() && ItemStack.isSameIgnoreDurability(menu.getCarried(), stack) && ItemStack.tagMatches(menu.getCarried(), stack)) { + if (!menu.getCarried().isEmpty() && ItemStack.isSameItemSameTags(menu.getCarried(), stack)) { stack.setCount(Mth.clamp(stack.getCount() + menu.getCarried().getCount(), 1, stack.getMaxStackSize())); } else if (!menu.getCarried().isEmpty()) { return; diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java index 47253199a..9c185764e 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/ClientHelperImpl.java @@ -70,7 +70,6 @@ import org.apache.commons.lang3.StringUtils; import org.jetbrains.annotations.ApiStatus; import org.jetbrains.annotations.Nullable; -import java.lang.reflect.InvocationTargetException; import java.time.LocalDateTime; import java.util.*; import java.util.function.Supplier; @@ -237,13 +236,7 @@ public class ClientHelperImpl implements ClientHelper { madeUpCommand = og.replaceAll("\\{player_name}", Minecraft.getInstance().player.getScoreboardName()).replaceAll("\\{item_name}", identifier.getPath()).replaceAll("\\{item_identifier}", identifier.toString()).replaceAll("\\{nbt}", "").replaceAll("\\{count}", String.valueOf(cheatedStack.getCount())); Minecraft.getInstance().player.displayClientMessage(Component.translatable("text.rei.too_long_nbt"), false); } - try { - Class.forName("me.shedaniel.rei.impl.client.%s.CommandSenderImpl".formatted(Platform.isForge() ? "forge" : "fabric")) - .getDeclaredMethod("sendCommand", String.class) - .invoke(null, StringUtils.removeStart(madeUpCommand, "/")); - } catch (IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) { - throw new RuntimeException(e); - } + Minecraft.getInstance().player.connection.sendCommand(StringUtils.removeStart(madeUpCommand, "/")); return true; } } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/addon/ConfigAddonsScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/addon/ConfigAddonsScreen.java index 25342ee31..c98745dcd 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/addon/ConfigAddonsScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/addon/ConfigAddonsScreen.java @@ -30,17 +30,21 @@ import me.shedaniel.rei.api.client.config.addon.ConfigAddon; import me.shedaniel.rei.api.client.config.addon.ConfigAddonRegistry; import me.shedaniel.rei.impl.client.gui.InternalTextures; import net.minecraft.client.Minecraft; +import net.minecraft.client.gui.ComponentPath; import net.minecraft.client.gui.components.Button; import net.minecraft.client.gui.components.events.GuiEventListener; import net.minecraft.client.gui.narration.NarratableEntry; +import net.minecraft.client.gui.navigation.FocusNavigationEvent; import net.minecraft.client.gui.screens.Screen; import net.minecraft.locale.Language; import net.minecraft.network.chat.Component; import net.minecraft.network.chat.FormattedText; import net.minecraft.resources.ResourceLocation; +import org.jetbrains.annotations.Nullable; import java.util.Collections; import java.util.List; +import java.util.function.Supplier; public class ConfigAddonsScreen extends Screen { private AddonsList rulesList; @@ -56,9 +60,9 @@ public class ConfigAddonsScreen extends Screen { super.init(); { Component backText = Component.literal("↩ ").append(Component.translatable("gui.back")); - addRenderableWidget(new Button(4, 4, Minecraft.getInstance().font.width(backText) + 10, 20, backText, button -> { + addRenderableWidget(Button.builder(backText, button -> { minecraft.setScreen(parent); - })); + }).bounds(4, 4, Minecraft.getInstance().font.width(backText) + 10, 20).build()); } rulesList = addWidget(new AddonsList(minecraft, width, height, 30, height, BACKGROUND_LOCATION)); ConfigAddonRegistryImpl addonRegistry = (ConfigAddonRegistryImpl) ConfigAddonRegistry.getInstance(); @@ -82,22 +86,6 @@ public class ConfigAddonsScreen extends Screen { } @Override - public boolean changeFocus(boolean lookForwards) { - if (!this.inFocus && this.getItemCount() == 0) { - return false; - } else { - this.inFocus = !this.inFocus; - if (this.inFocus && this.getSelectedItem() == null && this.getItemCount() > 0) { - this.moveSelection(1); - } else if (this.inFocus && this.getSelectedItem() != null) { - this.getSelectedItem(); - } - - return this.inFocus; - } - } - - @Override protected boolean isSelected(int index) { return false; } @@ -125,8 +113,9 @@ public class ConfigAddonsScreen extends Screen { } @Override - public boolean changeFocus(boolean lookForwards) { - return false; + @Nullable + public ComponentPath nextFocusPath(FocusNavigationEvent focusNavigationEvent) { + return null; } } @@ -138,12 +127,12 @@ public class ConfigAddonsScreen extends Screen { this.addon = addon; this.configureButton = new Button(0, 0, 20, 20, Component.nullToEmpty(null), button -> { Minecraft.getInstance().setScreen(this.addon.createScreen(Minecraft.getInstance().screen)); - }) { + }, Supplier::get) { @Override - protected void renderBg(PoseStack matrices, Minecraft client, int mouseX, int mouseY) { - super.renderBg(matrices, client, mouseX, mouseY); + public void render(PoseStack matrices, int mouseX, int mouseY, float delta) { + super.render(matrices, mouseX, mouseY, delta); RenderSystem.setShaderTexture(0, InternalTextures.CHEST_GUI_TEXTURE); - blit(matrices, x + 3, y + 3, 0, 0, 14, 14); + blit(matrices, getX() + 3, getY() + 3, 0, 0, 14, 14); } }; } @@ -171,8 +160,8 @@ public class ConfigAddonsScreen extends Screen { client.font.drawShadow(matrices, subtitle.getVisualOrderText(), x + 2, y + 12, 8421504); } } - configureButton.x = x + entryWidth - 25; - configureButton.y = y + 1; + configureButton.setX(x + entryWidth - 25); + configureButton.setY(y + 1); configureButton.render(matrices, mouseX, mouseY, delta); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigAddonsEntry.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigAddonsEntry.java index 1ec6671e5..6513cd8c3 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigAddonsEntry.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigAddonsEntry.java @@ -40,13 +40,14 @@ import org.jetbrains.annotations.ApiStatus; import java.util.List; import java.util.Optional; +import java.util.function.Supplier; @ApiStatus.Internal public class ConfigAddonsEntry extends AbstractConfigListEntry<Unit> { private int width; private AbstractWidget buttonWidget = new Button(0, 0, 0, 20, Component.empty(), button -> { Minecraft.getInstance().setScreen(new ConfigAddonsScreen(Minecraft.getInstance().screen)); - }); + }, Supplier::get) {}; private List<AbstractWidget> children = ImmutableList.of(buttonWidget); public ConfigAddonsEntry(int width) { @@ -77,8 +78,8 @@ public class ConfigAddonsEntry extends AbstractConfigListEntry<Unit> { Window window = Minecraft.getInstance().getWindow(); this.buttonWidget.active = REIRuntime.getInstance().getPreviousContainerScreen() != null && Minecraft.getInstance().getConnection() != null && Minecraft.getInstance().getConnection().getRecipeManager() != null && this.isEditable(); - this.buttonWidget.y = y; - this.buttonWidget.x = x + entryWidth / 2 - width / 2; + this.buttonWidget.setY(y); + this.buttonWidget.setX(x + entryWidth / 2 - width / 2); this.buttonWidget.setWidth(width); this.buttonWidget.render(matrices, mouseX, mouseY, delta); } diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigureCategoriesScreen.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigureCategoriesScreen.java index d922212e1..4270ffac5 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigureCategoriesScreen.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/config/entries/ConfigureCategoriesScreen.java @@ -45,6 +45,7 @@ import net.minecraft.resources.ResourceLocation; import net.minecraft.sounds.SoundEvents; import java.util.*; +import java.util.function.Supplier; public class ConfigureCategoriesScreen extends Screen { private final Map<CategoryIdentifier<?>, Boolean> filteringQuickCraftCategories; @@ -86,7 +87,7 @@ public class ConfigureCategoriesScreen extends Screen { addRenderableWidget(new Button(4, 4, Minecraft.getInstance().font.width(backText) + 10, 20, backText, button -> { minecraft.setScreen(parent); this.parent = null; - })); + }, Supplier::get) {}); } listWidget = addWidget(new ListWidget(minecraft, width, height, 30, height, BACKGROUND_LOCATION)); this.resetListEntries(); @@ -124,22 +125,6 @@ public class ConfigureCategoriesScreen extends Screen { } @Override - public boolean changeFocus(boolean lookForwards) { - if (!this.inFocus && this.getItemCount() == 0) { - return false; - } else { - this.inFocus = !this.inFocus; - if (this.inFocus && this.getSelectedItem() == null && this.getItemCount() > 0) { - this.moveSelection(1); - } else if (this.inFocus && this.getSelectedItem() != null) { - this.getSelectedItem(); - } - - return this.inFocus; - } - } |
