diff options
| author | Unknown <shekwancheung0528@gmail.com> | 2019-05-01 13:22:23 +0800 |
|---|---|---|
| committer | Unknown <shekwancheung0528@gmail.com> | 2019-05-01 13:22:23 +0800 |
| commit | c1de02e7d2d42123cb207f9fa8e869c8a25fcdf6 (patch) | |
| tree | 8dd9f6ea157ae0bf85561e7f85b085b9565141de | |
| parent | 6345d24492242ba9ea26c6b83163aa81464c8cfd (diff) | |
| parent | c57ef35f9d99ec64ec1501932a70cab40fcc5107 (diff) | |
| download | RoughlyEnoughItems-c1de02e7d2d42123cb207f9fa8e869c8a25fcdf6.tar.gz RoughlyEnoughItems-c1de02e7d2d42123cb207f9fa8e869c8a25fcdf6.tar.bz2 RoughlyEnoughItems-c1de02e7d2d42123cb207f9fa8e869c8a25fcdf6.zip | |
Merge branch '1.14-dev' into 1.14
15 files changed, 255 insertions, 71 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md index c6fa009c5..30a4eafb9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,8 @@ View full changelog [here](https://github.com/shedaniel/RoughlyEnoughItems/blob/1.14/CHANGELOG.md). +## v2.8.1+build.101 +- Updated [#77](https://github.com/shedaniel/RoughlyEnoughItems/pull/77): Updated Simplified Chinese by XuyuEre +- Updated: Updated Traditional Chinese by XuyuEre & Danielshe +- New: Better Exclusion Zone Handling ## v2.8.0+build.100 - Fixed [#76](https://github.com/shedaniel/RoughlyEnoughItems/issues/76): Laggy Changing Pages - New: Better Server Support (You can now drop REI into server mods) diff --git a/gradle.properties b/gradle.properties index 74d86497a..d1d55f417 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -mod_version=2.8.0+build.100 +mod_version=2.8.1+build.101 minecraft_version=1.14 yarn_version=1.14+build.5 fabricloader_version=0.4.6+build.141 diff --git a/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java b/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java new file mode 100644 index 000000000..83cf9163c --- /dev/null +++ b/src/main/java/me/shedaniel/rei/api/BaseBoundsHandler.java @@ -0,0 +1,16 @@ +package me.shedaniel.rei.api; + +import net.minecraft.client.gui.Screen; + +import java.awt.*; +import java.util.List; + +public interface BaseBoundsHandler extends DisplayHelper.DisplayBoundsHandler<Screen> { + List<Rectangle> getCurrentExclusionZones(Class<? extends Screen> currentScreenClass, boolean isOnRightSide); + + void registerExclusionZones(Class<? extends Screen> screenClass, ExclusionZoneSupplier supplier); + + public static interface ExclusionZoneSupplier { + List<Rectangle> apply(boolean isOnRightSide); + } +} diff --git a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java index edb319d76..5d4fda8a4 100644 --- a/src/main/java/me/shedaniel/rei/api/DisplayHelper.java +++ b/src/main/java/me/shedaniel/rei/api/DisplayHelper.java @@ -16,6 +16,8 @@ public interface DisplayHelper { void registerBoundsHandler(DisplayBoundsHandler handler); + BaseBoundsHandler getBaseBoundsHandler(); + public static interface DisplayBoundsHandler<T> { Class getBaseSupportedClass(); @@ -31,6 +33,10 @@ public interface DisplayHelper { return new Rectangle(rectangle.x + 2, rectangle.y + 24, rectangle.width - 4, rectangle.height - (RoughlyEnoughItemsCore.getConfigManager().getConfig().sideSearchField ? 27 + 22 : 27)); } + default boolean shouldRecalculateArea(boolean isOnRightSide, Rectangle rectangle) { + return false; + } + default float getPriority() { return 0f; } diff --git a/src/main/java/me/shedaniel/rei/client/BaseBoundsHandlerImpl.java b/src/main/java/me/shedaniel/rei/client/BaseBoundsHandlerImpl.java new file mode 100644 index 000000000..2548d23ab --- /dev/null +++ b/src/main/java/me/shedaniel/rei/client/BaseBoundsHandlerImpl.java @@ -0,0 +1,93 @@ +package me.shedaniel.rei.client; + +import com.google.common.collect.Lists; +import me.shedaniel.rei.api.BaseBoundsHandler; +import net.minecraft.client.MinecraftClient; +import net.minecraft.client.gui.Screen; +import net.minecraft.util.ActionResult; +import net.minecraft.util.Pair; + +import java.awt.*; +import java.util.Comparator; +import java.util.List; +import java.util.function.Function; +import java.util.stream.Collectors; + +public class BaseBoundsHandlerImpl implements BaseBoundsHandler { + + private static final Function<Rectangle, String> RECTANGLE_STRING_FUNCTION = rectangle -> rectangle.x + "," + rectangle.y + "," + rectangle.width + "," + rectangle.height; + private static final Comparator<Rectangle> RECTANGLE_COMPARATOR = BaseBoundsHandlerImpl::compare; + private static final Comparator<Pair<Pair<Class<? extends Screen>, Float>, ExclusionZoneSupplier>> LIST_PAIR_COMPARATOR; + + static { + Comparator<Pair<Pair<Class<? extends Screen>, Float>, ExclusionZoneSupplier>> comparator = Comparator.comparingDouble(value -> value.getLeft().getRight()); + LIST_PAIR_COMPARATOR = comparator.reversed(); + } + + private String lastArea = null; + private List<Pair<Pair<Class<? extends Screen>, Float>, ExclusionZoneSupplier>> list = Lists.newArrayList(); + + private static int compare(Rectangle o1, Rectangle o2) {return RECTANGLE_STRING_FUNCTION.apply(o1).compareTo(RECTANGLE_STRING_FUNCTION.apply(o2));} + + @Override + public Class getBaseSupportedClass() { + return Screen.class; + } + + @Override + public Rectangle getLeftBounds(Screen screen) { + return new Rectangle(); + } + + @Override + public Rectangle getRightBounds(Screen screen) { + return new Rectangle(); + } + + @Override + public float getPriority() { + return -5f; + } + + @Override + public boolean shouldRecalculateArea(boolean isOnRightSide, Rectangle rectangle) { + if (lastArea == null) { + lastArea = getStringFromAreas(rectangle, getCurrentExclusionZones(MinecraftClient.getInstance().currentScreen.getClass(), isOnRightSide)); + return false; + } + String fromAreas = getStringFromAreas(rectangle, getCurrentExclusionZones(MinecraftClient.getInstance().currentScreen.getClass(), isOnRightSide)); + if (lastArea.contentEquals(fromAreas)) + return false; + lastArea = fromAreas; + return true; + } + + @Override + public ActionResult canItemSlotWidgetFit(boolean isOnRightSide, int left, int top, Screen screen, Rectangle fullBounds) { + List<Rectangle> currentExclusionZones = getCurrentExclusionZones(MinecraftClient.getInstance().currentScreen.getClass(), isOnRightSide); + for(Rectangle currentExclusionZone : currentExclusionZones) + if (left + 18 >= currentExclusionZone.x && top + 18 >= currentExclusionZone.y && left <= currentExclusionZone.x + currentExclusionZone.width && top <= currentExclusionZone.y + currentExclusionZone.height) + return ActionResult.FAIL; + return ActionResult.PASS; + } + + public List<Rectangle> getCurrentExclusionZones(Class<? extends Screen> currentScreenClass, boolean isOnRightSide) { + List<Pair<Pair<Class<? extends Screen>, Float>, ExclusionZoneSupplier>> only = list.stream().filter(pair -> pair.getLeft().getLeft().isAssignableFrom(currentScreenClass)).collect(Collectors.toList()); + only.sort(LIST_PAIR_COMPARATOR); + List<Rectangle> rectangles = Lists.newArrayList(); + only.forEach(pair -> rectangles.addAll(pair.getRight().apply(isOnRightSide))); + return rectangles; + } + + @Override + public void registerExclusionZones(Class<? extends Screen> screenClass, ExclusionZoneSupplier supplier) { + list.add(new Pair<>(new Pair<>(screenClass, 0f), supplier)); + } + + public String getStringFromAreas(Rectangle rectangle, List<Rectangle> exclusionZones) { + List<Rectangle> sorted = Lists.newArrayList(exclusionZones); + sorted.sort(RECTANGLE_COMPARATOR); + return RECTANGLE_STRING_FUNCTION.apply(rectangle) + ":" + sorted.stream().map(RECTANGLE_STRING_FUNCTION::apply).collect(Collectors.joining("|")); + } + +} diff --git a/src/main/java/me/shedaniel/rei/client/DisplayHelperImpl.java b/src/main/java/me/shedaniel/rei/client/DisplayHelperImpl.java index e1f6c8144..28c5f5e43 100644 --- a/src/main/java/me/shedaniel/rei/client/DisplayHelperImpl.java +++ b/src/main/java/me/shedaniel/rei/client/DisplayHelperImpl.java @@ -2,6 +2,7 @@ package me.shedaniel.rei.client; import com.google.common.collect.Lists; import com.google.common.collect.Maps; +import me.shedaniel.rei.api.BaseBoundsHandler; import me.shedaniel.rei.api.DisplayHelper; import java.awt.*; @@ -33,9 +34,15 @@ public class DisplayHelperImpl implements DisplayHelper { public Rectangle getRightBounds(Object screen) { return new Rectangle(); } + + @Override + public float getPriority() { + return -10f; + } }; private List<DisplayBoundsHandler> screenDisplayBoundsHandlerMap = Lists.newArrayList(); private Map<Class, DisplayBoundsHandler> handlerCache = Maps.newHashMap(); + private BaseBoundsHandler baseBoundsHandler; @Override public List<DisplayBoundsHandler> getSortedBoundsHandlers(Class screenClass) { @@ -59,6 +66,15 @@ public class DisplayHelperImpl implements DisplayHelper { screenDisplayBoundsHandlerMap.add(handler); } + @Override + public BaseBoundsHandler getBaseBoundsHandler() { + return baseBoundsHandler; + } + + public void setBaseBoundsHandler(BaseBoundsHandler baseBoundsHandler) { + this.baseBoundsHandler = baseBoundsHandler; + } + public void resetCache() { handlerCache.clear(); } diff --git a/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java b/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java index 22df089ea..ec5b211d0 100644 --- a/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java +++ b/src/main/java/me/shedaniel/rei/client/RecipeHelperImpl.java @@ -185,6 +185,9 @@ public class RecipeHelperImpl implements RecipeHelper { this.categoryDisplaySettingsMap.clear(); this.displayVisibilityHandlers.clear(); ((DisplayHelperImpl) RoughlyEnoughItemsCore.getDisplayHelper()).resetCache(); + BaseBoundsHandler baseBoundsHandler = new BaseBoundsHandlerImpl(); + RoughlyEnoughItemsCore.getDisplayHelper().registerBoundsHandler(baseBoundsHandler); + ((DisplayHelperImpl) RoughlyEnoughItemsCore.getDisplayHelper()).setBaseBoundsHandler(baseBoundsHandler); long startTime = System.currentTimeMillis(); List<REIPluginEntry> plugins = new LinkedList<>(RoughlyEnoughItemsCore.getPlugins()); plugins.sort((first, second) -> { @@ -196,16 +199,20 @@ public class RecipeHelperImpl implements RecipeHelper { PluginDisabler pluginDisabler = RoughlyEnoughItemsCore.getPluginDisabler(); plugins.forEach(plugin -> { Identifier identifier = plugin.getPluginIdentifier(); - if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_ITEMS)) - plugin.registerItems(RoughlyEnoughItemsCore.getItemRegisterer()); - if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_CATEGORIES)) - plugin.registerPluginCategories(this); - if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_RECIPE_DISPLAYS)) - plugin.registerRecipeDisplays(this); - if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_BOUNDS)) - plugin.registerBounds(RoughlyEnoughItemsCore.getDisplayHelper()); - if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_OTHERS)) - plugin.registerOthers(this); + try { + if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_ITEMS)) + plugin.registerItems(RoughlyEnoughItemsCore.getItemRegisterer()); + if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_CATEGORIES)) + plugin.registerPluginCategories(this); + if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_RECIPE_DISPLAYS)) + plugin.registerRecipeDisplays(this); + if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_BOUNDS)) + plugin.registerBounds(RoughlyEnoughItemsCore.getDisplayHelper()); + if (pluginDisabler.isFunctionEnabled(identifier, PluginFunction.REGISTER_OTHERS)) + plugin.registerOthers(this); + } catch (Exception e) { + RoughlyEnoughItemsCore.LOGGER.error("[REI] %s plugin failed to load: %s", identifier.toString(), e.getLocalizedMessage()); + } }); if (getDisplayVisibilityHandlers().size() == 0) registerRecipeVisibilityHandler(new DisplayVisibilityHandler() { diff --git a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java index 41bd9b9ec..8c60ac015 100644 --- a/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java +++ b/src/main/java/me/shedaniel/rei/gui/ContainerScreenOverlay.java @@ -327,7 +327,7 @@ public class ContainerScreenOverlay extends AbstractParentElement implements Dra @Override public void render(int mouseX, int mouseY, float delta) { List<ItemStack> currentStacks = ClientHelper.getInventoryItemsTypes(); - if (getLeft() != lastLeft) + if (RoughlyEnoughItemsCore.getDisplayHelper().getBaseBoundsHandler() != null && RoughlyEnoughItemsCore.getDisplayHelper().getBaseBoundsHandler().shouldRecalculateArea(!RoughlyEnoughItemsCore.getConfigManager().getConfig().mirrorItemPanel, rectangle)) init(true); else if (RoughlyEnoughItemsCore.getConfigManager().isCraftableOnlyEnabled() && (!hasSameListContent(new LinkedList<>(ScreenHelper.inventoryStacks), currentStacks) || (currentStacks.size() != ScreenHelper.inventoryStacks.size()))) { ScreenHelper.inventoryStacks = ClientHelper.getInventoryItemsTypes(); diff --git a/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java b/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java index 345342ef0..0c8a50f1b 100644 --- a/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java +++ b/src/main/java/me/shedaniel/rei/gui/widget/ItemListOverlay.java @@ -27,7 +27,6 @@ import org.apache.commons.lang3.StringUtils; import java.awt.*; import java.util.Arrays; import java.util.Collections; -import java.util.LinkedList; import java.util.List; import java.util.stream.Collectors; @@ -98,45 +97,49 @@ public class ItemListOverlay extends Widget { int startX = (int) rectangle.getCenterX() - width * 9; int startY = (int) rectangle.getCenterY() - height * 9; this.listArea = new Rectangle((int) startX, (int) startY, width * 18, height * 18); - int fitSlotsPerPage = getTotalFitSlotsPerPage(listArea.x, listArea.y, listArea); + int fitSlotsPerPage = getTotalFitSlotsPerPage(startX, startY, listArea); int j = page * fitSlotsPerPage; - for(int i = 0; i < getFullTotalSlotsPerPage(); i++) { - j++; + for(int yy = 0; yy < height; yy++) { + for(int xx = 0; xx < width; xx++) { + int x = startX + xx * 18, y = startY + yy * 18; + if (!canBeFit(x, y, listArea)) + continue; + j++; + if (j > currentDisplayed.size()) + break; + widgets.add(new ItemSlotWidget(x, y, Collections.singletonList(currentDisplayed.get(j - 1)), false, true, true) { + @Override + protected void queueTooltip(ItemStack itemStack, float delta) { + ClientPlayerEntity player = minecraft.player; + if (!ClientHelper.isCheating() || player.inventory.getCursorStack().isEmpty()) + super.queueTooltip(itemStack, delta); + } + + @Override + public boolean mouseClicked(double mouseX, double mouseY, int button) { + if (isHighlighted(mouseX, mouseY)) { + if (ClientHelper.isCheating()) { + if (getCurrentStack() != null && !getCurrentStack().isEmpty()) { + ItemStack cheatedStack = getCurrentStack().copy(); + if (RoughlyEnoughItemsCore.getConfigManager().getConfig().itemCheatingMode == ItemCheatingMode.REI_LIKE) + cheatedStack.setAmount(button != 1 ? 1 : cheatedStack.getMaxAmount()); + else if (RoughlyEnoughItemsCore.getConfigManager().getConfig().itemCheatingMode == ItemCheatingMode.JEI_LIKE) + cheatedStack.setAmount(button != 0 ? 1 : cheatedStack.getMaxAmount()); + else + cheatedStack.setAmount(1); + return ClientHelper.tryCheatingStack(cheatedStack); + } + } else if (button == 0) + return ClientHelper.executeRecipeKeyBind(getCurrentStack().copy()); + else if (button == 1) + return ClientHelper.executeUsageKeyBind(getCurrentStack().copy()); + } + return false; + } + }); + } if (j > currentDisplayed.size()) break; - int x = startX + (i % width) * 18, y = startY + MathHelper.floor(i / width) * 18; - if (!canBeFit(x, y, listArea)) - continue; - widgets.add(new ItemSlotWidget(x, y, Collections.singletonList(currentDisplayed.get(j - 1)), false, true, true) { - @Override - protected void queueTooltip(ItemStack itemStack, float delta) { - ClientPlayerEntity player = minecraft.player; - if (!ClientHelper.isCheating() || player.inventory.getCursorStack().isEmpty()) - super.queueTooltip(itemStack, delta); - } - - @Override - public boolean mouseClicked(double mouseX, double mouseY, int button) { - if (isHighlighted(mouseX, mouseY)) { - if (ClientHelper.isCheating()) { - if (getCurrentStack() != null && !getCurrentStack().isEmpty()) { - ItemStack cheatedStack = getCurrentStack().copy(); - if (RoughlyEnoughItemsCore.getConfigManager().getConfig().itemCheatingMode == ItemCheatingMode.REI_LIKE) - cheatedStack.setAmount(button != 1 ? 1 : cheatedStack.getMaxAmount()); - else if (RoughlyEnoughItemsCore.getConfigManager().getConfig().itemCheatingMode == ItemCheatingMode.JEI_LIKE) - cheatedStack.setAmount(button != 0 ? 1 : cheatedStack.getMaxAmount()); - else - cheatedStack.setAmount(1); - return ClientHelper.tryCheatingStack(cheatedStack); - } - } else if (button == 0) - return ClientHelper.executeRecipeKeyBind(getCurrentStack().copy()); - else if (button == 1) - return ClientHelper.executeUsageKeyBind(getCurrentStack().copy()); - } - return false; - } - }); } } @@ -149,9 +152,10 @@ public class ItemListOverlay extends Widget { public int getTotalFitSlotsPerPage(int startX, int startY, Rectangle listArea) { int slots = 0; - for(int i = 0; i < getFullTotalSlotsPerPage(); i++) - if (canBeFit(startX + (i % width) * 18, startY + MathHelper.floor(i / width) * 18, listArea)) - slots++; + for(int x = 0; x < width; x++) + for(int y = 0; y < height; y++) + if (canBeFit(startX + x * 18, startY + y * 18, listArea)) + slots++; return slots; } diff --git a/src/main/java/me/shedaniel/rei/listeners/RecipeBookGuiHooks.java b/src/main/java/me/shedaniel/rei/listeners/RecipeBookGuiHooks.java index 4737b2c9d..c76eb2b6e 100644 --- a/src/main/java/me/shedaniel/rei/listeners/RecipeBookGuiHooks.java +++ b/src/main/java/me/shedaniel/rei/listeners/RecipeBookGuiHooks.java @@ -1,12 +1,17 @@ package me.shedaniel.rei.listeners; +import net.minecraft.client.gui.recipebook.GroupButtonWidget; import net.minecraft.client.gui.widget.RecipeBookGhostSlots; import net.minecraft.client.gui.widget.TextFieldWidget; +import java.util.List; + public interface RecipeBookGuiHooks { RecipeBookGhostSlots rei_getGhostSlots(); TextFieldWidget rei_getSearchField(); + List<GroupButtonWidget> rei_getTabButtons(); + } diff --git a/src/main/java/me/shedaniel/rei/mixin/MixinRecipeBookGui.java b/src/main/java/me/shedaniel/rei/mixin/MixinRecipeBookGui.java index 1cc1baf8a..7d17d3c8e 100644 --- a/src/main/java/me/shedaniel/rei/mixin/MixinRecipeBookGui.java +++ b/src/main/java/me/shedaniel/rei/mixin/MixinRecipeBookGui.java @@ -1,6 +1,7 @@ package me.shedaniel.rei.mixin; import me.shedaniel.rei.listeners.RecipeBookGuiHooks; +import net.minecraft.client.gui.recipebook.GroupButtonWidget; import net.minecraft.client.gui.recipebook.RecipeBookGui; import net.minecraft.client.gui.widget.RecipeBookGhostSlots; import net.minecraft.client.gui.widget.TextFieldWidget; @@ -8,6 +9,8 @@ import org.spongepowered.asm.mixin.Final; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.Shadow; +import java.util.List; + @Mixin(RecipeBookGui.class) public class MixinRecipeBookGui implements RecipeBookGuiHooks { @@ -18,6 +21,10 @@ public class MixinRecipeBookGui implements RecipeBookGuiHooks { @Shadow private TextFieldWidget searchField; + @Shadow + @Final + private List<GroupButtonWidget> tabButtons; + public RecipeBookGhostSlots rei_getGhostSlots() { return ghostSlots; } @@ -27,4 +34,10 @@ public class MixinRecipeBookGui implements RecipeBookGuiHooks { return searchField; } + @Override + public List<GroupButtonWidget> rei_getTabButtons() { + return tabButtons; + } + + } diff --git a/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java b/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java index 87c1c51f1..a6b7e19a7 100644 --- a/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java +++ b/src/main/java/me/shedaniel/rei/plugin/DefaultPlugin.java @@ -5,6 +5,7 @@ import me.shedaniel.rei.RoughlyEnoughItemsCore; import me.shedaniel.rei.api.*; import me.shedaniel.rei.client.ScreenHelper; import me.shedaniel.rei.gui.RecipeViewingScreen; +import me.shedaniel.rei.listeners.ContainerScreenHooks; import me.shedaniel.rei.listeners.RecipeBookGuiHooks; import net.minecraft.client.MinecraftClient; import net.minecraft.client.gui.ContainerScreen; @@ -15,6 +16,8 @@ import net.minecraft.client.gui.container.FurnaceScreen; import net.minecraft.client.gui.container.SmokerScreen; import net.minecraft.client.gui.ingame.CreativePlayerInventoryScreen; import net.minecraft.client.gui.ingame.PlayerInventoryScreen; +import net.minecraft.client.gui.ingame.RecipeBookProvider; +import net.minecraft.client.gui.recipebook.RecipeBookGui; import net.minecraft.enchantment.Enchantment; import net.minecraft.enchantment.EnchantmentHelper; import net.minecraft.item.ItemStack; @@ -28,7 +31,6 @@ import net.minecraft.recipe.cooking.SmeltingRecipe; import net.minecraft.recipe.cooking.SmokingRecipe; import net.minecraft.recipe.crafting.ShapedRecipe; import net.minecraft.recipe.crafting.ShapelessRecipe; -import net.minecraft.util.ActionResult; import net.minecraft.util.Identifier; import net.minecraft.util.registry.Registry; @@ -142,6 +144,17 @@ public class DefaultPlugin implements REIPluginEntry { @Override public void registerBounds(DisplayHelper displayHelper) { + displayHelper.getBaseBoundsHandler().registerExclusionZones(ContainerScreen.class, isOnRightSide -> { + if (isOnRightSide || !MinecraftClient.getInstance().player.getRecipeBook().isGuiOpen() || !(MinecraftClient.getInstance().currentScreen instanceof RecipeBookProvider)) + return Collections.emptyList(); + ContainerScreenHooks screenHooks = ScreenHelper.getLastContainerScreenHooks(); + List l = Lists.newArrayList(new Rectangle(screenHooks.rei_getContainerLeft() - 4 - 145, screenHooks.rei_getContainerTop(), 4 + 145 + 30, screenHooks.rei_getContainerHeight())); + RecipeBookGui recipeBookGui = ((RecipeBookProvider) MinecraftClient.getInstance().currentScreen).getRecipeBookGui(); + int size = ((RecipeBookGuiHooks) recipeBookGui).rei_getTabButtons().size(); + if (size > 0) + l.add(new Rectangle(screenHooks.rei_getContainerLeft() - 4 - 145 - 30, screenHooks.rei_getContainerTop(), 30, (size - 1) * 27)); + return l; + }); displayHelper.registerBoundsHandler(new DisplayHelper.DisplayBoundsHandler<ContainerScreen>() { @Override public Class getBaseSupportedClass() { @@ -160,15 +173,6 @@ public class DefaultPlugin implements REIPluginEntry { } @Override - public ActionResult canItemSlotWidgetFit(boolean isOnRightSide, int left, int top, ContainerScreen screen, Rectangle fullBounds) { - if (!isOnRightSide) - if (MinecraftClient.getInstance().player.getRecipeBook().isGuiOpen() && left + 18 > ScreenHelper.getLastContainerScreenHooks().rei_getContainerLeft() - 4 - 145 - 30) - if (top + 18 >= ScreenHelper.getLastContainerScreenHooks().rei_getContainerTop() && top <= ScreenHelper.getLastContainerScreenHooks().rei_getContainerTop() + ScreenHelper.getLastContainerScreenHooks().rei_getContainerHeight()) - return ActionResult.FAIL; - return ActionResult.PASS; - } - - @Override public float getPriority() { return -1.0f; } diff --git a/src/main/resources/assets/roughlyenoughitems/lang/en_us.json b/src/main/resources/assets/roughlyenoughitems/lang/en_us.json index 20b83be95..6e598ff76 100755 --- a/src/main/resources/assets/roughlyenoughitems/lang/en_us.json +++ b/src/main/resources/assets/roughlyenoughitems/lang/en_us.json @@ -92,5 +92,5 @@ "text.rei.config_api_failed": "You arrived here either if Cloth Config API failed or you don't have it installed!\nUpdate / Install the API and report to the bug tracker.", "text.rei.back": "Back", "_comment": "Don't change / translate the credit down below if you are doing it :)", - "text.rei.credit.text": "§lRoughly Enough Items\n§7Originally a fork for Almost Enough Items.\n\n§lDevelopers\n - Originally by ZenDarva\n - Created by Danielshe\n - Plugin Support by TehNut\n\n§lLanguage Translation\n English - Danielshe\n Simplified Chinese - Danielshe\n Traditional Chinese - hugoalh, gxy17886 & Danielshe\n French - Yanis48\n German - MelanX\n Estonian - Madis0\n Portuguese - thiagokenis\n LOLCAT - Danielshe\n Upside Down - Danielshe\n Brazilian Portuguese - thiagokenis\n Bulgarian - geniiii\n\n§lLicense\n§7Roughly Enough Items is using MIT." + "text.rei.credit.text": "§lRoughly Enough Items\n§7Originally a fork for Almost Enough Items.\n\n§lDevelopers\n - Originally by ZenDarva\n - Created by Danielshe\n - Plugin Support by TehNut\n\n§lLanguage Translation\n English - Danielshe\n Simplified Chinese - XuyuEre & Danielshe\n Traditional Chinese - hugoalh, gxy17886 & Danielshe\n French - Yanis48\n German - MelanX\n Estonian - Madis0\n Portuguese - thiagokenis\n LOLCAT - Danielshe\n Upside Down - Danielshe\n Brazilian Portuguese - thiagokenis\n Bulgarian - geniiii\n\n§lLicense\n§7Roughly Enough Items is using MIT." } diff --git a/src/main/resources/assets/roughlyenoughitems/lang/zh_cn.json b/src/main/resources/assets/roughlyenoughitems/lang/zh_cn.json index e1bdc9abf..5a90b2307 100644 --- a/src/main/resources/assets/roughlyenoughitems/lang/zh_cn.json +++ b/src/main/resources/assets/roughlyenoughitems/lang/zh_cn.json @@ -3,9 +3,15 @@ "key.roughlyenoughitems.recipe_keybind": "显示配方", "key.roughlyenoughitems.hide_keybind": "隐藏/显示 REI", "key.roughlyenoughitems.usage_keybind": "显示用途", - "text.rei.config.general": "一般", + "text.rei.config.general": "常规", + "text.rei.config.action": "功能", "text.rei.config.cheating": "作弊:", "text.rei.cheating": "作弊", + "text.rei.cheating_disabled": "§7作弊已禁用", + "text.rei.cheating_enabled": "§c作弊已启用", + "text.rei.cheating_limited_enabled": "§b作弊已启用(使用命令)", + "text.rei.cheating_enabled_no_perms": "§7作弊已§c启用§7(无权限)", + "text.rei.no_permission_cheat": "作弊给予物品需要OP权限", "category.rei.crafting": "合成", "category.rei.smelting": "冶炼", "category.rei.smelting.fuel": "§e燃料", @@ -52,8 +58,8 @@ "text.rei.give_command.suggestion": "输入指令.", "text.rei.view_all_categories": "查看全部类别", "text.rei.go_back_first_page": "回到第 1 页", - "text.rei.config.appearance": "外貌", - "text.rei.config.modules": "组件", + "text.rei.config.appearance": "外观", + "text.rei.config.modules": "模块", "text.rei.config.advanced": "高级", "text.rei.config.disable_recipe_book": "禁用合成书:", "text.rei.choose_page": "选择页面", @@ -78,9 +84,11 @@ "text.rei.config.title": "Roughly Enough Items 配置", "text.rei.config.enable_legacy_speedcraft_support": "启用旧版插件支持: ", "text.rei.config.april_fools": "愚人节", - "text.rei.config.april_fools.2019": "强制启用REI 2019 愚人节的玩笑: ", + "text.rei.config.april_fools.2019": "强制启用REI 2019愚人节玩笑: ", "text.rei.config.item_cheating_mode": "物品作弊数量模式:", "text.rei.config.item_cheating_mode.rei_like": "标准", "text.rei.config.item_cheating_mode.jei_like": "反转", - "text.rei.no_config_api": "Cloth Config API 不存在!\n请安装它以显示游戏中的配置界面!" + "text.rei.config.light_gray_recipe_border": "浅灰色配方边框:", + "text.rei.config_api_failed": "如果Cloth Config API装载失败了或你没有安装它,你就会到达这个界面!\n升级/安装API或向bug跟踪器报告.", + "text.rei.back": "返回" } diff --git a/src/main/resources/assets/roughlyenoughitems/lang/zh_tw.json b/src/main/resources/assets/roughlyenoughitems/lang/zh_tw.json index d82d82935..a1a449a32 100644 --- a/src/main/resources/assets/roughlyenoughitems/lang/zh_tw.json +++ b/src/main/resources/assets/roughlyenoughitems/lang/zh_tw.json @@ -3,9 +3,15 @@ "key.roughlyenoughitems.recipe_keybind": "顯示配方", "key.roughlyenoughitems.hide_keybind": "隱藏/顯示 REI", "key.roughlyenoughitems.usage_keybind": "顯示用途", - "text.rei.config.general": "一般", + "text.rei.config.general": "常規", + "text.rei.config.action": "功能", "text.rei.config.cheating": "作弊:", "text.rei.cheating": "作弊", + "text.rei.cheating_disabled": "§7作弊已禁用", + "text.rei.cheating_enabled": "§c作弊已啟用", + "text.rei.cheating_limited_enabled": "§b作弊已啟用(使用命令)", + "text.rei.cheating_enabled_no_perms": "§7作弊已§c啟用§7(無權限)", + "text.rei.no_permission_cheat": "作弊給予物品需要OP權限", "category.rei.crafting": "合成", "category.rei.smelting": "冶煉", "category.rei.smelting.fuel": "§e燃料", @@ -78,9 +84,11 @@ "text.rei.config.title": "Roughly Enough Items 配置", "text.rei.config.enable_legacy_speedcraft_support": "啟用舊版插件支持: ", "text.rei.config.april_fools": "愚人節", - "text.rei.config.april_fools.2019": "強制啟用REI 2019 愚人節的玩笑: ", + "text.rei.config.april_fools.2019": "強制啟用REI 2019愚人節的玩笑: ", "text.rei.config.item_cheating_mode": "物品作弊數量模式:", "text.rei.config.item_cheating_mode.rei_like": "標准", "text.rei.config.item_cheating_mode.jei_like": "反轉", - "text.rei.no_config_api": "Cloth Config API 不存在!\n請安裝它以顯示游戲中的配置界面!" + "text.rei.config.light_gray_recipe_border": "淺灰色配方邊框:", + "text.rei.config_api_failed": "如果Cloth Config API裝載失敗了或你沒有安裝它,你就會到達這個界面!\n升級/安裝API或向bug跟踪器報告.", + "text.rei.back": "返回" } |
