Skip to content

Commit

Permalink
Update to 1.21.4
Browse files Browse the repository at this point in the history
  • Loading branch information
shedaniel committed Dec 13, 2024
1 parent 2eaaf02 commit d698ee2
Show file tree
Hide file tree
Showing 22 changed files with 208 additions and 88 deletions.
1 change: 1 addition & 0 deletions .github/workflows/curseforge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ on:
- 15.x-1.20.5
- 16.x-1.21
- 17.x-1.21.2
- 18.x-1.21.4

jobs:
build:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@
import me.shedaniel.rei.api.common.transfer.info.stack.SlotAccessor;
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.data.models.blockstates.PropertyDispatch;
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.screens.inventory.tooltip.ClientTooltipComponent;
import net.minecraft.data.models.blockstates.PropertyDispatch;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.FormattedText;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Stream;

public class DefaultSmithingDisplay extends BasicDisplay implements SmithingDisplay {
public static final DisplaySerializer<DefaultSmithingDisplay> SERIALIZER = DisplaySerializer.of(
Expand Down Expand Up @@ -96,12 +97,12 @@ public static DefaultSmithingDisplay ofTransforming(RecipeHolder<SmithingTransfo
public static List<DefaultSmithingDisplay> fromTrimming(RecipeHolder<SmithingTrimRecipe> recipe) {
RegistryAccess registryAccess = BasicDisplay.registryAccess();
List<DefaultSmithingDisplay> displays = new ArrayList<>();
for (Holder<Item> templateItem : recipe.value().templateIngredient().map(Ingredient::items).orElse(List.of())) {
for (Holder<Item> templateItem : (Iterable<Holder<Item>>) recipe.value().templateIngredient().map(Ingredient::items).orElse(Stream.of())::iterator) {
Holder.Reference<TrimPattern> trimPattern = getPatternFromTemplate(registryAccess, templateItem)
.orElse(null);
if (trimPattern == null) continue;

for (Holder<Item> additionStack : recipe.value().additionIngredient().map(Ingredient::items).orElse(List.of())) {
for (Holder<Item> additionStack : (Iterable<Holder<Item>>) recipe.value().additionIngredient().map(Ingredient::items).orElse(Stream.of())::iterator) {
Holder.Reference<TrimMaterial> trimMaterial = getMaterialFromIngredient(registryAccess, additionStack)
.orElse(null);
if (trimMaterial == null) continue;
Expand Down
2 changes: 1 addition & 1 deletion fabric/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ unifiedPublishing {
project {
displayName = "[Fabric $rootProject.supported_version] v$project.version"
releaseType = rootProject.unstable == "false" ? "release" : "alpha"
gameVersions = ["1.21.2", "1.21.3"]
gameVersions = ["1.21.4"]
gameLoaders = ["fabric"]
changelog = rootProject.releaseChangelog

Expand Down
14 changes: 7 additions & 7 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
org.gradle.jvmargs=-Xmx6G
base_version=17.0
base_version=18.0
unstable=false
supported_version=1.21.2/3
minecraft_version=1.21.2
supported_version=1.21.4
minecraft_version=1.21.4
platforms=fabric,neoforge
forge_version=49.1.10
neoforge_version=21.2.0-beta
neoforge_version=21.4.20-beta
neoforge_pr=
fabricloader_version=0.16.7
cloth_config_version=16.0.141
cloth_config_version=17.0.144
modmenu_version=11.0.0-rc.2
fabric_api=0.106.1+1.21.2
architectury_version=14.0.3
fabric_api=0.112.0+1.21.4
architectury_version=15.0.1
api_exculde=
#api_include=me.shedaniel.cloth:cloth-events,me.shedaniel.cloth:config-2,me.sargunvohra.mcmods:autoconfig1u,org.jetbrains:annotations,net.fabricmc.fabric-api:fabric
4 changes: 2 additions & 2 deletions neoforge/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ unifiedPublishing {
project {
displayName = "[NeoForge $rootProject.supported_version] v$project.version"
releaseType = "beta"
gameVersions = ["1.21.2", "1.21.3"]
gameVersions = ["1.21.4"]
gameLoaders = ["neoforge"]
changelog = rootProject.releaseChangelog

Expand Down Expand Up @@ -208,7 +208,7 @@ unifiedPublishing {
project {
displayName = "[NeoForge $rootProject.supported_version] v$project.version"
releaseType = "release"
gameVersions = ["1.21.2", "1.21.3"]
gameVersions = ["1.21.4"]
gameLoaders = ["neoforge"]
changelog = rootProject.releaseChangelog

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@
import net.fabricmc.api.EnvType;
import net.fabricmc.api.Environment;
import net.minecraft.client.Minecraft;
import net.minecraft.client.data.models.blockstates.PropertyDispatch;
import net.minecraft.client.gui.components.EditBox;
import net.minecraft.client.gui.components.ImageButton;
import net.minecraft.client.gui.components.events.GuiEventListener;
Expand All @@ -108,7 +109,6 @@
import net.minecraft.client.gui.screens.recipebook.RecipeBookComponent;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.core.RegistryAccess;
import net.minecraft.data.models.blockstates.PropertyDispatch;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.game.ClientboundRecipeBookAddPacket;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -519,8 +519,11 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (!visible) {
return false;
}
if (draggingStack != null) {
draggingStack.mouseClicked(mouseX, mouseY, button);
}
for (GuiEventListener element : widgets) {
if (element != configButton && element != menuHolder.widget() && element != hintsWidget && element.mouseClicked(mouseX, mouseY, button)) {
if (element != configButton && element != menuHolder.widget() && element != hintsWidget && element != draggingStack && element.mouseClicked(mouseX, mouseY, button)) {
this.setFocused(element);
if (button == 0)
this.setDragging(true);
Expand Down Expand Up @@ -550,6 +553,15 @@ public boolean mouseDragged(double mouseX, double mouseY, int button, double del
return (this.getFocused() != null && this.isDragging() && button == 0) && this.getFocused().mouseDragged(mouseX, mouseY, button, deltaX, deltaY);
}

@Override
public boolean mouseReleased(double mouseX, double mouseY, int button) {
if (draggingStack != null) {
draggingStack.mouseReleased(mouseX, mouseY, button);
}

return super.mouseReleased(mouseX, mouseY, button);
}

@Override
public GuiEventListener getFocused() {
if (choosePageWidget != null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@
import org.apache.commons.lang3.mutable.MutableObject;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.function.BiConsumer;

import static me.shedaniel.rei.impl.client.gui.config.options.ConfigUtils.literal;
Expand Down Expand Up @@ -306,6 +303,25 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
return super.mouseClicked(mouseX, mouseY, button);
}

@Override
public Optional<GuiEventListener> getChildAt(double mouseX, double mouseY) {
if (menu != null) {
if (menu.containsMouse(mouseX, mouseY)) {
return Optional.of(menu);
}
}

// Reverse iteration
for (int i = widgets.size() - 1; i >= 0; i--) {
Widget widget = widgets.get(i);
if (widget.containsMouse(mouseX, mouseY)) {
return Optional.of(widget);
}
}

return Optional.empty();
}

@Override
public boolean mouseReleased(double mouseX, double mouseY, int button) {
if (menu != null && menu.mouseReleased(mouseX, mouseY, button))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public static WidgetWithBounds create(OptionCategory category, int width) {
Widget descriptionLabel = Widgets.createDrawableWidget((graphics, mouseX, mouseY, delta) -> {
renderTextScrolling(graphics, description, 0, 0, (int) ((width - 21 - 6) / 0.75), 0xFFB0B0B0);
});
Rectangle bounds = new Rectangle(0, 0, label.getBounds().getMaxX(), hasDescription ? 24 : 7 * 3);
Rectangle bounds = new Rectangle(0, 0, width, hasDescription ? 24 : 7 * 3);
return Widgets.concatWithBounds(
bounds,
label,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,12 @@ public static WidgetWithBounds create(IntSupplier width) {
Label label = Widgets.createLabel(new Point(21, 6), translatable("config.rei.texts.search_options"))
.leftAligned();
Font font = Minecraft.getInstance().font;
Rectangle bounds = new Rectangle(0, 0, label.getBounds().getMaxX(), 7 * 3);
return Widgets.concatWithBounds(
bounds,
new Widget() {
() -> new Rectangle(0, 0, width.getAsInt(), 7 * 3),
new WidgetWithBounds() {
@Override
public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
boolean hovering = new Rectangle(-1, -1, width.getAsInt() + 2, 21).contains(mouseX, mouseY);
boolean hovering = containsMouse(mouseX, mouseY);
for (Widget widget : List.of(Widgets.createFilledRectangle(new Rectangle(1, 1, width.getAsInt() - 2, 18), hovering ? 0x50FFFFFF : 0x25FFFFFF),
Widgets.createFilledRectangle(new Rectangle(-1, -1, width.getAsInt() + 2, 1), hovering ? 0x90FFFFFF : 0x45FFFFFF),
Widgets.createFilledRectangle(new Rectangle(-1, 20, width.getAsInt() + 2, 1), hovering ? 0x90FFFFFF : 0x45FFFFFF),
Expand All @@ -75,29 +74,29 @@ public List<? extends GuiEventListener> children() {

@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (new Rectangle(-1, -1, width.getAsInt() + 2, 21).contains(mouseX, mouseY)) {
Widgets.produceClickSound();
((REIConfigScreen) Minecraft.getInstance().screen).setSearching(true);
return true;
}

return false;
Widgets.produceClickSound();
((REIConfigScreen) Minecraft.getInstance().screen).setSearching(true);
return true;
}

@Override
public Rectangle getBounds() {
return new Rectangle(-1, -1, width.getAsInt() + 2, 21);
}
},
Widgets.withTranslate(label, 0, 0.5, 0),
Widgets.createTexturedWidget(ResourceLocation.parse("roughlyenoughitems:textures/gui/config/search_options.png"), new Rectangle(3, 3, 16, 16), 0, 0, 1, 1, 1, 1)

);
}

public static WidgetWithBounds createTiny() {
Rectangle bounds = new Rectangle(0, 0, 16, 16);
return Widgets.withTooltip(Widgets.concatWithBounds(
bounds,
new Widget() {
new WidgetWithBounds() {
@Override
public void render(GuiGraphics graphics, int mouseX, int mouseY, float delta) {
boolean hovering = new Rectangle(-1, -1, 18, 18).contains(mouseX, mouseY);
boolean hovering = containsMouse(mouseX, mouseY);
graphics.pose().pushPose();
graphics.pose().translate(-0.5, -0.5, 0);
for (Widget widget : List.of(Widgets.createFilledRectangle(new Rectangle(-1, -1, 18, 18), hovering ? 0x50FFFFFF : 0x25FFFFFF),
Expand All @@ -117,13 +116,14 @@ public List<? extends GuiEventListener> children() {

@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (new Rectangle(-1, -1, 18, 18).contains(mouseX, mouseY)) {
Widgets.produceClickSound();
((REIConfigScreen) Minecraft.getInstance().screen).setSearching(true);
return true;
}

return false;
Widgets.produceClickSound();
((REIConfigScreen) Minecraft.getInstance().screen).setSearching(true);
return true;
}

@Override
public Rectangle getBounds() {
return new Rectangle(-1, -1, 18, 18);
}
},
Widgets.createTexturedWidget(ResourceLocation.parse("roughlyenoughitems:textures/gui/config/search_options.png"), bounds, 0, 0, 1, 1, 1, 1)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@

package me.shedaniel.rei.impl.client.gui.modules;

import me.shedaniel.math.Rectangle;
import me.shedaniel.rei.api.client.favorites.FavoriteMenuEntry;

public abstract class AbstractMenuEntry extends FavoriteMenuEntry {
Expand All @@ -41,7 +42,7 @@ public void updateInformation(int xPos, int yPos, boolean selected, boolean cont

@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
if (isRendering() && mouseX >= getX() && mouseX <= getX() + getWidth() && mouseY >= getY() && mouseY < getY() + getEntryHeight()) {
if (containsMouse(mouseX, mouseY)) {
if (onClick(mouseX, mouseY, button)) {
return true;
}
Expand Down Expand Up @@ -76,4 +77,9 @@ public boolean containsMouse() {
public boolean isRendering() {
return rendering;
}

@Override
public boolean containsMouse(double mouseX, double mouseY) {
return isRendering() && new Rectangle(getX(), getY(), getWidth(), getEntryHeight()).contains(mouseX, mouseY);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,18 @@ private boolean handleFocuses() {

@Override
public boolean mouseClicked(double mouseX, double mouseY, int button) {
return super.mouseClicked(mouseX, mouseY, button) || (getOverlay().mouseClicked(mouseX, mouseY, button) && handleFocuses(button));
Optional<GuiEventListener> hovered = this.getChildAt(mouseX, mouseY);
if (hovered.isPresent() && hovered.get().mouseClicked(mouseX, mouseY, button)) {
this.setFocused(hovered.get());
if (button == 0) {
this.setDragging(true);
}

if (getOverlay().mouseClicked(mouseX, mouseY, button)) handleFocuses(button);
return true;
}

return getOverlay().mouseClicked(mouseX, mouseY, button) && handleFocuses(button);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,19 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
return super.mouseClicked(mouseX, mouseY, button);
}

@Override
public Optional<GuiEventListener> getChildAt(double mouseX, double mouseY) {
// Reverse iteration
for (int i = widgets.size() - 1; i >= 0; i--) {
Widget widget = widgets.get(i);
if (widget.containsMouse(mouseX, mouseY)) {
return Optional.of(widget);
}
}

return Optional.empty();
}

@Override
public boolean charTyped(char char_1, int int_1) {
for (GuiEventListener listener : children())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.mojang.blaze3d.systems.RenderSystem;
import com.mojang.blaze3d.vertex.Tesselator;
import it.unimi.dsi.fastutil.Pair;
import me.shedaniel.clothconfig2.api.ModifierKeyCode;
import me.shedaniel.clothconfig2.api.animator.ValueAnimator;
Expand Down Expand Up @@ -66,7 +65,6 @@
import net.minecraft.client.gui.components.events.GuiEventListener;
import net.minecraft.client.gui.screens.ConfirmScreen;
import net.minecraft.client.gui.screens.Screen;
import net.minecraft.client.renderer.MultiBufferSource;
import net.minecraft.client.renderer.RenderType;
import net.minecraft.client.resources.language.I18n;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -501,6 +499,19 @@ public boolean mouseClicked(double mouseX, double mouseY, int button) {
return super.mouseClicked(mouseX, mouseY, button);
}

@Override
public Optional<GuiEventListener> getChildAt(double mouseX, double mouseY) {
// Reverse iteration
for (int i = widgets.size() - 1; i >= 0; i--) {
Widget widget = widgets.get(i);
if (widget.containsMouse(mouseX, mouseY)) {
return Optional.of(widget);
}
}

return Optional.empty();
}

public static class WorkstationSlotWidget extends EntryWidget {
public WorkstationSlotWidget(int x, int y, EntryIngredient widgets) {
super(new Point(x, y));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ private static void prepare() {
nativeImage.flipY();

cachedTexture = new DynamicTexture(nativeImage);
cachedTextureLocation = minecraft.getTextureManager().register("rei_cached_entries", cachedTexture);
cachedTextureLocation = ResourceLocation.fromNamespaceAndPath("roughlyenoughitems", "rei_cached_entries");
minecraft.getTextureManager().register(cachedTextureLocation, cachedTexture);
renderType.reset();

target.destroyBuffers();
Expand Down
Loading

0 comments on commit d698ee2

Please sign in to comment.