Update to 1.21.8

This commit is contained in:
2025-07-20 10:25:56 +02:00
parent 73aa86a862
commit 998f7e2ba6
4 changed files with 30 additions and 16 deletions

View File

@@ -1,5 +1,5 @@
plugins {
id 'fabric-loom' version '1.10-SNAPSHOT'
id 'fabric-loom' version '1.11-SNAPSHOT'
id 'maven-publish'
}

View File

@@ -1,11 +1,11 @@
# Done to increase the memory available to gradle.
org.gradle.jvmargs=-Xmx1G
minecraft_version=1.21.5
yarn_mappings=1.21.5+build.1
loader_version=0.16.13
minecraft_version=1.21.8
yarn_mappings=1.21.8+build.1
loader_version=0.16.14
# Fabric API
fabric_version=0.120.0+1.21.5
fabric_version=0.129.0+1.21.8
# Mod Properties
mod_version=1.6.3
mod_version=1.6.4
maven_group=systems.brn
archives_base_name=RegexingHoppers

View File

@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME

View File

@@ -1,12 +1,19 @@
package systems.brn.regexinghoppers;
import com.mojang.datafixers.types.Type;
import net.fabricmc.api.ModInitializer;
import net.minecraft.block.entity.HopperBlockEntity;
import net.minecraft.inventory.Inventory;
import net.minecraft.screen.NamedScreenHandlerFactory;
import net.minecraft.text.MutableText;
import net.minecraft.text.Text;
import net.minecraft.text.TextContent;
import net.minecraft.text.TranslatableTextContent;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import systems.brn.regexinghoppers.mixin.HopperBlockEntityAccessor;
import java.util.Objects;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
@@ -22,20 +29,27 @@ public class RegexingHoppers implements ModInitializer {
// This code runs as soon as Minecraft is in a mod-load-ready state.
// However, some things (like resources) may still be uninitialized.
// Proceed with mild caution.
LOGGER.debug("RegexingHoppers initialized!");
LOGGER.info("RegexingHoppers initialized!");
}
public static boolean shouldNotMove(Inventory hopper, String itemName) {
// Log entering the method with given parameters
LOGGER.debug("Entering shouldNotMove with itemName: {}", itemName);
boolean isDefaultName = false;
if (hopper instanceof NamedScreenHandlerFactory factory) {
String customName = factory.getDisplayName().getLiteralString();
Text name = factory.getDisplayName();
if (name instanceof MutableText mutableText) {
if (mutableText.getContent() instanceof TranslatableTextContent textContent) {
isDefaultName = textContent.getKey().startsWith("container.");
}
}
String customName = name.getString();
// Log the custom name used for matching
LOGGER.debug("Custom regex pattern from hopper: {}", customName);
if (customName != null && !customName.isEmpty()) {
if (customName != null && !customName.isEmpty() && !isDefaultName) {
if (hopper instanceof HopperBlockEntity) {
HopperBlockEntityAccessor hopperAccessor = (HopperBlockEntityAccessor) hopper;
if (hopperAccessor.getTransferCooldown() > 1) {
@@ -43,12 +57,13 @@ public class RegexingHoppers implements ModInitializer {
}
}
try {
LOGGER.info("Entering shouldNotMove with itemName: {}, pattern: {}", itemName, customName);
Pattern pattern = Pattern.compile(customName);
Matcher matcher = pattern.matcher(itemName);
// Log the result of the regex matching
boolean matches = matcher.matches();
LOGGER.debug("Regex matching result: {}", matches);
LOGGER.info("Regex matching result: {}", matches);
if (!matches) {
if (hopper instanceof HopperBlockEntity) {
@@ -59,15 +74,14 @@ public class RegexingHoppers implements ModInitializer {
return !matches;
} catch (PatternSyntaxException e) {
// Log exception if regex pattern is invalid
LOGGER.debug("Invalid regex pattern: {}", customName, e);
LOGGER.info("Invalid regex pattern: {}", customName, e);
}
} else {
// Log case when custom name is null or empty
LOGGER.debug("Custom name is null or empty, not performing regex matching.");
}
} else {
// Log if hopper is not an instance of NamedScreenHandlerFactory
LOGGER.debug("Hopper is not an instance of NamedScreenHandlerFactory.");
LOGGER.info("Hopper is not an instance of NamedScreenHandlerFactory.");
}
// Default return value in case no conditions are met