aboutsummaryrefslogtreecommitdiff
path: root/default-plugin/src
diff options
context:
space:
mode:
Diffstat (limited to 'default-plugin/src')
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java77
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultCompostingCategory.java2
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultInformationCategory.java2
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultSmithingCategory.java18
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/DefaultTagCategory.java6
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/ValueTagNodeWidget.java4
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/CommandSender.java39
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java8
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java8
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java8
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultCampfireDisplay.java2
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultSmithingDisplay.java92
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultStoneCuttingDisplay.java2
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/cooking/DefaultCookingDisplay.java2
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/crafting/DefaultCraftingDisplay.java4
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/crafting/DefaultShapedDisplay.java3
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/crafting/DefaultShapelessDisplay.java3
-rw-r--r--default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/tag/TagNodes.java11
18 files changed, 188 insertions, 103 deletions
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java
index bf1541003..84be2cdb4 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/DefaultClientPlugin.java
@@ -23,12 +23,11 @@
package me.shedaniel.rei.plugin.client;
-import com.google.common.collect.Iterators;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
+import com.google.common.collect.*;
import dev.architectury.event.EventResult;
import dev.architectury.networking.NetworkManager;
import dev.architectury.platform.Platform;
+import it.unimi.dsi.fastutil.objects.Reference2ObjectOpenHashMap;
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet;
import it.unimi.dsi.fastutil.objects.ReferenceSet;
import me.shedaniel.math.Rectangle;
@@ -42,6 +41,7 @@ import me.shedaniel.rei.api.client.registry.screen.ExclusionZones;
import me.shedaniel.rei.api.client.registry.screen.ScreenRegistry;
import me.shedaniel.rei.api.client.registry.transfer.TransferHandlerRegistry;
import me.shedaniel.rei.api.client.registry.transfer.simple.SimpleTransferHandler;
+import me.shedaniel.rei.api.common.display.basic.BasicDisplay;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
import me.shedaniel.rei.api.common.entry.EntryStack;
import me.shedaniel.rei.api.common.util.EntryIngredients;
@@ -82,6 +82,8 @@ import net.minecraft.client.Minecraft;
import net.minecraft.client.gui.screens.inventory.*;
import net.minecraft.client.gui.screens.recipebook.RecipeUpdateListener;
import net.minecraft.core.Registry;
+import net.minecraft.core.registries.BuiltInRegistries;
+import net.minecraft.core.registries.Registries;
import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.tags.BlockTags;
@@ -127,14 +129,45 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin
@Override
public void registerEntries(EntryRegistry registry) {
- for (Item item : Registry.ITEM) {
- try {
- registry.addEntries(EntryIngredients.ofItemStacks(registry.appendStacksForItem(item)));
- } catch (Exception ignored) {
- registry.addEntry(EntryStacks.of(item));
+ if (Minecraft.getInstance().player == null || Minecraft.getInstance().player.connection == null)
+ return;
+ Minecraft.getInstance().executeBlocking(() -> {
+ CreativeModeTabs.tryRebuildTabContents(Minecraft.getInstance().player.connection.enabledFeatures(),
+ Minecraft.getInstance().options.operatorItemsTab().get() && Minecraft.getInstance().player.canUseGameMasterBlocks(),
+ BasicDisplay.registryAccess());
+ });
+ Multimap<Item, EntryStack<ItemStack>> items = Multimaps.newListMultimap(new Reference2ObjectOpenHashMap<>()
+ , ArrayList::new);
+
+ for (CreativeModeTab tab : CreativeModeTabs.allTabs()) {
+ if (tab.getType() != CreativeModeTab.Type.HOTBAR && tab.getType() != CreativeModeTab.Type.INVENTORY) {
+ try {
+ for (ItemStack stack : tab.getDisplayItems()) {
+ try {
+ items.put(stack.getItem(), EntryStacks.of(stack));
+ } catch (Exception ignore) {
+ }
+ }
+ } catch (Exception exception) {
+ exception.printStackTrace();
+ }
+ }
+ }
+
+ for (Item item : BuiltInRegistries.ITEM) {
+ Collection<EntryStack<ItemStack>> stacks = items.get(item);
+ if (stacks.isEmpty()) {
+ try {
+ registry.addEntry(EntryStacks.of(item.getDefaultInstance()));
+ } catch (Exception ignore) {
+ registry.addEntry(EntryStacks.of(item));
+ }
+ } else {
+ registry.addEntries(stacks);
}
}
- for (Fluid fluid : Registry.FLUID) {
+
+ for (Fluid fluid : BuiltInRegistries.FLUID) {
FluidState state = fluid.defaultFluidState();
if (!state.isEmpty() && state.isSource()) {
registry.addEntry(EntryStacks.of(fluid));
@@ -223,7 +256,7 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin
}
private static EntryIngredient getTag(ResourceLocation tagId) {
- return EntryIngredients.ofItemTag(TagKey.create(Registry.ITEM_REGISTRY, tagId));
+ return EntryIngredients.ofItemTag(TagKey.create(Registries.ITEM, tagId));
}
@Override
@@ -236,15 +269,17 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin
registry.registerRecipeFiller(BlastingRecipe.class, RecipeType.BLASTING, DefaultBlastingDisplay::new);
registry.registerRecipeFiller(CampfireCookingRecipe.class, RecipeType.CAMPFIRE_COOKING, DefaultCampfireDisplay::new);
registry.registerRecipeFiller(StonecutterRecipe.class, RecipeType.STONECUTTING, DefaultStoneCuttingDisplay::new);
- registry.registerRecipeFiller(UpgradeRecipe.class, RecipeType.SMITHING, DefaultSmithingDisplay::new);
+ registry.registerRecipeFiller(LegacyUpgradeRecipe.class, RecipeType.SMITHING, DefaultSmithingDisplay::new);
+ registry.registerRecipeFiller(SmithingTransformRecipe.class, RecipeType.SMITHING, DefaultSmithingDisplay::new);
+ registry.registerRecipeFiller(SmithingTrimRecipe.class, RecipeType.SMITHING, DefaultSmithingDisplay::new);
registry.registerFiller(AnvilRecipe.class, DefaultAnvilDisplay::new);
registry.registerFiller(BrewingRecipe.class, DefaultBrewingDisplay::new);
registry.registerFiller(TagKey.class, tagKey -> {
- if (tagKey.isFor(Registry.ITEM_REGISTRY)) {
+ if (tagKey.isFor(Registries.ITEM)) {
return DefaultTagDisplay.ofItems(tagKey);
- } else if (tagKey.isFor(Registry.BLOCK_REGISTRY)) {
+ } else if (tagKey.isFor(Registries.BLOCK)) {
return DefaultTagDisplay.ofItems(tagKey);
- } else if (tagKey.isFor(Registry.FLUID_REGISTRY)) {
+ } else if (tagKey.isFor(Registries.FLUID)) {
return DefaultTagDisplay.ofFluids(tagKey);
}
@@ -280,24 +315,24 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin
List<EntryIngredient> entries = iterator.next();
registry.add(new DefaultCompostingDisplay(entries, Collections.singletonList(EntryIngredients.of(new ItemStack(Items.BONE_MEAL)))));
}
- DummyAxeItem.getStrippedBlocksMap().entrySet().stream().sorted(Comparator.comparing(b -> Registry.BLOCK.getKey(b.getKey()))).forEach(set -> {
+ DummyAxeItem.getStrippedBlocksMap().entrySet().stream().sorted(Comparator.comparing(b -> BuiltInRegistries.BLOCK.getKey(b.getKey()))).forEach(set -> {
registry.add(new DefaultStrippingDisplay(EntryStacks.of(set.getKey()), EntryStacks.of(set.getValue())));
});
- DummyShovelItem.getPathBlocksMap().entrySet().stream().sorted(Comparator.comparing(b -> Registry.BLOCK.getKey(b.getKey()))).forEach(set -> {
+ DummyShovelItem.getPathBlocksMap().entrySet().stream().sorted(Comparator.comparing(b -> BuiltInRegistries.BLOCK.getKey(b.getKey()))).forEach(set -> {
registry.add(new DefaultPathingDisplay(EntryStacks.of(set.getKey()), EntryStacks.of(set.getValue().getBlock())));
});
registry.add(new DefaultBeaconBaseDisplay(Collections.singletonList(EntryIngredients.ofItemTag(BlockTags.BEACON_BASE_BLOCKS)), Collections.emptyList()));
registry.add(new DefaultBeaconPaymentDisplay(Collections.singletonList(EntryIngredients.ofItemTag(ItemTags.BEACON_PAYMENT_ITEMS)), Collections.emptyList()));
- HoneycombItem.WAXABLES.get().entrySet().stream().sorted(Comparator.comparing(b -> Registry.BLOCK.getKey(b.getKey()))).forEach(set -> {
+ HoneycombItem.WAXABLES.get().entrySet().stream().sorted(Comparator.comparing(b -> BuiltInRegistries.BLOCK.getKey(b.getKey()))).forEach(set -> {
registry.add(new DefaultWaxingDisplay(EntryStacks.of(set.getKey()), EntryStacks.of(set.getValue())));
});
- HoneycombItem.WAX_OFF_BY_BLOCK.get().entrySet().stream().sorted(Comparator.comparing(b -> Registry.BLOCK.getKey(b.getKey()))).forEach(set -> {
+ HoneycombItem.WAX_OFF_BY_BLOCK.get().entrySet().stream().sorted(Comparator.comparing(b -> BuiltInRegistries.BLOCK.getKey(b.getKey()))).forEach(set -> {
registry.add(new DefaultWaxScrapingDisplay(EntryStacks.of(set.getKey()), EntryStacks.of(set.getValue())));
});
- WeatheringCopper.NEXT_BY_BLOCK.get().entrySet().stream().sorted(Comparator.comparing(b -> Registry.BLOCK.getKey(b.getKey()))).forEach(set -> {
+ WeatheringCopper.NEXT_BY_BLOCK.get().entrySet().stream().sorted(Comparator.comparing(b -> BuiltInRegistries.BLOCK.getKey(b.getKey()))).forEach(set -> {
registry.add(new DefaultOxidizingDisplay(EntryStacks.of(set.getKey()), EntryStacks.of(set.getValue())));
});
- WeatheringCopper.PREVIOUS_BY_BLOCK.get().entrySet().stream().sorted(Comparator.comparing(b -> Registry.BLOCK.getKey(b.getKey()))).forEach(set -> {
+ WeatheringCopper.PREVIOUS_BY_BLOCK.get().entrySet().stream().sorted(Comparator.comparing(b -> BuiltInRegistries.BLOCK.getKey(b.getKey()))).forEach(set -> {
registry.add(new DefaultOxidationScrapingDisplay(EntryStacks.of(set.getKey()), EntryStacks.of(set.getValue())));
});
if (Platform.isFabric()) {
@@ -333,7 +368,7 @@ public class DefaultClientPlugin implements REIClientPlugin, BuiltinClientPlugin
registerForgePotions(registry, this);
}
- for (Registry<?> reg : Registry.REGISTRY) {
+ for (Registry<?> reg : BuiltInRegistries.REGISTRY) {
reg.getTags().forEach(tagPair -> registry.add(tagPair.getFirst()));
}
}
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultCompostingCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultCompostingCategory.java
index 6f5c942c2..c0d2a08b6 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultCompostingCategory.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultCompostingCategory.java
@@ -98,7 +98,7 @@ public class DefaultCompostingCategory implements DisplayCategory<DefaultCompost
ItemStack firstStack = (ItemStack) entryIngredient.get(0).getValue();
float chance = ComposterBlock.COMPOSTABLES.getFloat(firstStack.getItem());
if (chance > 0.0f) {
- entryIngredient = entryIngredient.map(stack -> stack.copy().tooltip(Component.translatable("text.rei.composting.chance", Mth.clamp(Mth.fastFloor(chance * 100), 0, 100)).withStyle(ChatFormatting.YELLOW)));
+ entryIngredient = entryIngredient.map(stack -> stack.copy().tooltip(Component.translatable("text.rei.composting.chance", Mth.clamp(Mth.floor(chance * 100), 0, 100)).withStyle(ChatFormatting.YELLOW)));
}
}
widgets.add(Widgets.createSlot(new Point(bounds.getCenterX() - 72 + 9 + x * 18, bounds.y + 12 + y * 18)).entries(entryIngredient).markInput());
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultInformationCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultInformationCategory.java
index 025dcffc4..7c7399df0 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultInformationCategory.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultInformationCategory.java
@@ -26,7 +26,6 @@ package me.shedaniel.rei.plugin.client.categories;
import com.google.common.collect.Lists;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.*;
-import com.mojang.math.Matrix4f;
import me.shedaniel.clothconfig2.ClothConfigInitializer;
import me.shedaniel.clothconfig2.api.scroll.ScrollingContainer;
import me.shedaniel.math.Point;
@@ -51,6 +50,7 @@ import net.minecraft.client.renderer.GameRenderer;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.FormattedText;
import net.minecraft.util.FormattedCharSequence;
+import org.joml.Matrix4f;
import java.util.Collections;
import java.util.List;
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultSmithingCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultSmithingCategory.java
index 9e9f5e72b..982221600 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultSmithingCategory.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/DefaultSmithingCategory.java
@@ -60,11 +60,19 @@ public class DefaultSmithingCategory implements DisplayCategory<DefaultSmithingD
Point startPoint = new Point(bounds.getCenterX() - 31, bounds.getCenterY() - 13);
List<Widget> widgets = Lists.newArrayList();
widgets.add(Widgets.createRecipeBase(bounds));
- widgets.add(Widgets.createArrow(new Point(startPoint.x + 27, startPoint.y + 4)));
- widgets.add(Widgets.createResultSlotBackground(new Point(startPoint.x + 61, startPoint.y + 5)));
- widgets.add(Widgets.createSlot(new Point(startPoint.x + 4 - 22, startPoint.y + 5)).entries(display.getInputEntries().get(0)).markInput());
- widgets.add(Widgets.createSlot(new Point(startPoint.x + 4, startPoint.y + 5)).entries(display.getInputEntries().get(1)).markInput());
- widgets.add(Widgets.createSlot(new Point(startPoint.x + 61, startPoint.y + 5)).entries(display.getOutputEntries().get(0)).disableBackground().markOutput());
+ boolean legacy = display.getInputEntries().size() <= 2;
+ int offsetX = legacy ? 0 : 5;
+ widgets.add(Widgets.createArrow(new Point(startPoint.x + 27 + offsetX, startPoint.y + 4)));
+ widgets.add(Widgets.createResultSlotBackground(new Point(startPoint.x + 61 + offsetX, startPoint.y + 5)));
+ if (!legacy) {
+ widgets.add(Widgets.createSlot(new Point(startPoint.x + 4 - 18 * 2 + offsetX, startPoint.y + 5)).entries(display.getInputEntries().get(0)).markInput());
+ widgets.add(Widgets.createSlot(new Point(startPoint.x + 4 - 18 + offsetX, startPoint.y + 5)).entries(display.getInputEntries().get(1)).markInput());
+ widgets.add(Widgets.createSlot(new Point(startPoint.x + 4 + offsetX, startPoint.y + 5)).entries(display.getInputEntries().get(2)).markInput());
+ } else {
+ widgets.add(Widgets.createSlot(new Point(startPoint.x + 4 - 22 + offsetX, startPoint.y + 5)).entries(display.getInputEntries().get(0)).markInput());
+ widgets.add(Widgets.createSlot(new Point(startPoint.x + 4 + offsetX, startPoint.y + 5)).entries(display.getInputEntries().get(1)).markInput());
+ }
+ widgets.add(Widgets.createSlot(new Point(startPoint.x + 61 + offsetX, startPoint.y + 5)).entries(display.getOutputEntries().get(0)).disableBackground().markOutput());
return widgets;
}
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/DefaultTagCategory.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/DefaultTagCategory.java
index 911293985..f14b1d833 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/DefaultTagCategory.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/DefaultTagCategory.java
@@ -25,7 +25,6 @@ package me.shedaniel.rei.plugin.client.categories.tag;
import com.mojang.blaze3d.platform.Window;
import com.mojang.blaze3d.vertex.PoseStack;
-import com.mojang.math.Matrix4f;
import me.shedaniel.clothconfig2.api.animator.ValueAnimator;
import me.shedaniel.math.FloatingRectangle;
import me.shedaniel.math.Point;
@@ -51,6 +50,7 @@ import net.minecraft.network.chat.Component;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.item.Items;
import org.jetbrains.annotations.Nullable;
+import org.joml.Matrix4f;
import java.util.ArrayList;
import java.util.List;
@@ -191,9 +191,9 @@ public class DefaultTagCategory implements DisplayCategory<DefaultTagDisplay<?,
}
}, 0, 0, 10));
- Matrix4f translateMatrix = Matrix4f.createTranslateMatrix(0, 0, 200);
+ Matrix4f translateMatrix = new Matrix4f().translate(0, 0, 200);
Matrix4f identity = new Matrix4f();
- identity.setIdentity();
+ identity.identity();
return CollectionUtils.map(widgets, widget -> Widgets.withTranslate(widget, () ->
expanded[0] || !boundsAnimator.value().equals(boundsAnimator.target()) ? translateMatrix : identity));
}
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/ValueTagNodeWidget.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/ValueTagNodeWidget.java
index f2daae995..3f8ae3b9e 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/ValueTagNodeWidget.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/categories/tag/ValueTagNodeWidget.java
@@ -25,7 +25,6 @@ package me.shedaniel.rei.plugin.client.categories.tag;
import com.google.common.base.Predicates;
import com.mojang.blaze3d.vertex.PoseStack;
-import com.mojang.math.Matrix4f;
import me.shedaniel.math.Point;
import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.client.gui.widgets.*;
@@ -35,6 +34,7 @@ import me.shedaniel.rei.plugin.common.displays.tag.TagNode;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.core.Holder;
import net.minecraft.core.HolderSet;
+import org.joml.Matrix4f;
import java.util.ArrayList;
import java.util.Collections;
@@ -71,7 +71,7 @@ public class ValueTagNodeWidget<S, T> extends TagNodeWidget<S, T> {
i++;
}
this.widget = Widgets.withTranslate(Widgets.concat(this.widgets),
- $ -> Matrix4f.createTranslateMatrix(getBounds().x, getBounds().y, 0));
+ $ -> new Matrix4f().translate(getBounds().x, getBounds().y, 0));
this.children = Collections.singletonList(this.widget);
}
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/CommandSender.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/CommandSender.java
deleted file mode 100644
index 0cf4b2076..000000000
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/CommandSender.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * This file is licensed under the MIT License, part of Roughly Enough Items.
- * Copyright (c) 2018, 2019, 2020, 2021, 2022, 2023 shedaniel
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in all
- * copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
- * SOFTWARE.
- */
-
-package me.shedaniel.rei.plugin.client.favorites;
-
-import dev.architectury.platform.Platform;
-
-import java.lang.reflect.InvocationTargetException;
-
-class CommandSender {
- static void sendCommand(String command) {
- try {
- Class.forName("me.shedaniel.rei.impl.client.%s.CommandSenderImpl".formatted(Platform.isForge() ? "forge" : "fabric"))
- .getDeclaredMethod("sendCommand", String.class).invoke(null, command);
- } catch (IllegalAccessException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException e) {
- throw new RuntimeException(e);
- }
- }
-}
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java
index 1975d119b..85accd118 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/GameModeFavoriteEntry.java
@@ -147,7 +147,7 @@ public class GameModeFavoriteEntry extends FavoriteEntry {
if (mode == null) {
mode = GameType.byId(Minecraft.getInstance().gameMode.getPlayerMode().getId() + 1 % 4);
}
- CommandSender.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getGamemodeCommand().replaceAll("\\{gamemode}", mode.name().toLowerCase(Locale.ROOT)), "/"));
+ Minecraft.getInstance().player.connection.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getGamemodeCommand().replaceAll("\\{gamemode}", mode.name().toLowerCase(Locale.ROOT)), "/"));
Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
return true;
}
@@ -198,9 +198,9 @@ public class GameModeFavoriteEntry extends FavoriteEntry {
@Override
public DataResult<GameModeFavoriteEntry> fromArgs(Object... args) {
- if (args.length == 0) return DataResult.error("Cannot create GameModeFavoriteEntry from empty args!");
+ if (args.length == 0) return DataResult.error(() -> "Cannot create GameModeFavoriteEntry from empty args!");
if (!(args[0] instanceof GameType type))
- return DataResult.error("Creation of GameModeFavoriteEntry from args expected GameType as the first argument!");
+ return DataResult.error(() -> "Creation of GameModeFavoriteEntry from args expected GameType as the first argument!");
return DataResult.success(new GameModeFavoriteEntry(type), Lifecycle.stable());
}
@@ -275,7 +275,7 @@ public class GameModeFavoriteEntry extends FavoriteEntry {
public boolean mouseClicked(double mouseX, double mouseY, int button) {
boolean disabled = this.minecraft.gameMode.getPlayerMode() == gameMode;
if (!disabled && rendering && mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 12) {
- CommandSender.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getGamemodeCommand().replaceAll("\\{gamemode}", gameMode.name().toLowerCase(Locale.ROOT)), "/"));
+ Minecraft.getInstance().player.connection.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getGamemodeCommand().replaceAll("\\{gamemode}", gameMode.name().toLowerCase(Locale.ROOT)), "/"));
minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
closeMenu();
return true;
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java
index 19051bf04..69f5c9aa9 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/TimeFavoriteEntry.java
@@ -181,7 +181,7 @@ public class TimeFavoriteEntry extends FavoriteEntry {
if (time == null) {
time = nextTime();
}
- CommandSender.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getTimeCommand().replaceAll("\\{time}", time.getPart().toLowerCase(Locale.ROOT)), "/"));
+ Minecraft.getInstance().player.connection.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getTimeCommand().replaceAll("\\{time}", time.getPart().toLowerCase(Locale.ROOT)), "/"));
Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
return true;
}
@@ -232,9 +232,9 @@ public class TimeFavoriteEntry extends FavoriteEntry {
@Override
public DataResult<TimeFavoriteEntry> fromArgs(Object... args) {
- if (args.length == 0) return DataResult.error("Cannot create GameModeFavoriteEntry from empty args!");
+ if (args.length == 0) return DataResult.error(() -> "Cannot create GameModeFavoriteEntry from empty args!");
if (!(args[0] instanceof Time type))
- return DataResult.error("Creation of GameModeFavoriteEntry from args expected Time as the first argument!");
+ return DataResult.error(() -> "Creation of GameModeFavoriteEntry from args expected Time as the first argument!");
return DataResult.success(new TimeFavoriteEntry(type), Lifecycle.stable());
}
@@ -303,7 +303,7 @@ public class TimeFavoriteEntry extends FavoriteEntry {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (rendering && mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 12) {
- CommandSender.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getTimeCommand().replaceAll("\\{time}", time.getPart().toLowerCase(Locale.ROOT)), "/"));
+ Minecraft.getInstance().player.connection.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getTimeCommand().replaceAll("\\{time}", time.getPart().toLowerCase(Locale.ROOT)), "/"));
minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
closeMenu();
return true;
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java
index 9adba8377..ce5fac685 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/client/favorites/WeatherFavoriteEntry.java
@@ -154,7 +154,7 @@ public class WeatherFavoriteEntry extends FavoriteEntry {
public boolean doAction(int button) {
if (button == 0) {
if (weather != null) {
- CommandSender.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getWeatherCommand().replaceAll("\\{weather}", weather.name().toLowerCase(Locale.ROOT)), "/"));
+ Minecraft.getInstance().player.connection.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getWeatherCommand().replaceAll("\\{weather}", weather.name().toLowerCase(Locale.ROOT)), "/"));
Minecraft.getInstance().getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
}
return true;
@@ -206,9 +206,9 @@ public class WeatherFavoriteEntry extends FavoriteEntry {
@Override
public DataResult<WeatherFavoriteEntry> fromArgs(Object... args) {
- if (args.length == 0) return DataResult.error("Cannot create WeatherFavoriteEntry from empty args!");
+ if (args.length == 0) return DataResult.error(() -> "Cannot create WeatherFavoriteEntry from empty args!");
if (!(args[0] instanceof Weather weather))
- return DataResult.error("Creation of WeatherFavoriteEntry from args expected Weather as the first argument!");
+ return DataResult.error(() -> "Creation of WeatherFavoriteEntry from args expected Weather as the first argument!");
return DataResult.success(new WeatherFavoriteEntry(weather), Lifecycle.stable());
}
@@ -312,7 +312,7 @@ public class WeatherFavoriteEntry extends FavoriteEntry {
@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (rendering && mouseX >= x && mouseX <= x + width && mouseY >= y && mouseY <= y + 12) {
- CommandSender.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getWeatherCommand().replaceAll("\\{weather}", weather.name().toLowerCase(Locale.ROOT)), "/"));
+ Minecraft.getInstance().player.connection.sendCommand(StringUtils.removeStart(ConfigObject.getInstance().getWeatherCommand().replaceAll("\\{weather}", weather.name().toLowerCase(Locale.ROOT)), "/"));
minecraft.getSoundManager().play(SimpleSoundInstance.forUI(SoundEvents.UI_BUTTON_CLICK, 1.0F));
closeMenu();
return true;
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultCampfireDisplay.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultCampfireDisplay.java
index fe8c605d3..3119c8f85 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultCampfireDisplay.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultCampfireDisplay.java
@@ -40,7 +40,7 @@ public class DefaultCampfireDisplay extends BasicDisplay {
private double cookTime;
public DefaultCampfireDisplay(CampfireCookingRecipe recipe) {
- this(EntryIngredients.ofIngredients(recipe.getIngredients()), Collections.singletonList(EntryIngredients.of(recipe.getResultItem())),
+ this(EntryIngredients.ofIngredients(recipe.getIngredients()), Collections.singletonList(EntryIngredients.of(recipe.getResultItem(BasicDisplay.registryAccess()))),
Optional.ofNullable(recipe).map(CampfireCookingRecipe::getId), recipe.getCookingTime());
}
diff --git a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultSmithingDisplay.java b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultSmithingDisplay.java
index db3e7c46b..67210568b 100644
--- a/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultSmithingDisplay.java
+++ b/default-plugin/src/main/java/me/shedaniel/rei/plugin/common/displays/DefaultSmithingDisplay.java
@@ -28,22 +28,100 @@ import me.shedaniel.rei.api.common.display.basic.BasicDisplay;
import me.shedaniel.rei.api.common.entry.EntryIngredient;
import me.shedaniel.rei.api.common.util.EntryIngredients;
import me.shedaniel.rei.plugin.common.BuiltinPlugin;
+import net.minecraft.core.Holder;
+import net.minecraft.core.RegistryAccess;
import net.minecraft.resources.ResourceLocation;
-import net.minecraft.world.item.crafting.UpgradeRecipe;
+import net.minecraft.world.item.Item;
+import net.minecraft.world.item.ItemStack;
+import net.minecraft.world.item.armortrim.*;
+import net.minecraft.world.item.crafting.LegacyUpgradeRecipe;
+import net.minecraft.world.item.crafting.SmithingRecipe;
+import net.minecraft.world.item.crafting.SmithingTransformRecipe;
+import net.minecraft.world.item.crafting.SmithingTrimRecipe;
+import org.jetbrains.annotations.ApiStatus;
-import java.util.Arrays;
-import java.util.Collections;
import java.util.List;
import java.util.Optional;
+import java.util.function.Supplier;
public class DefaultSmithingDisplay extends BasicDisplay {
- public DefaultSmithingDisplay(UpgradeRecipe recipe) {