diff --git a/common/CHANGELOG.md b/common/CHANGELOG.md index 52c7aa7b..b2f83f2e 100644 --- a/common/CHANGELOG.md +++ b/common/CHANGELOG.md @@ -3,6 +3,8 @@ - mob spawner entities can now variate their textures again. - moved some temp rework code into more compatible mixins for mod compatibility +- more stable implementation of the 5.0 rework changes for emissives +- random properties now also allow ranges with the format - instead of only - *(OptiFine parity)* [5.0] diff --git a/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/generic_properties/FloatRangeFromStringArrayProperty.java b/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/generic_properties/FloatRangeFromStringArrayProperty.java index 2bcdb404..4bd913ff 100644 --- a/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/generic_properties/FloatRangeFromStringArrayProperty.java +++ b/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/generic_properties/FloatRangeFromStringArrayProperty.java @@ -15,9 +15,15 @@ protected FloatRangeFromStringArrayProperty(String string) throws RandomProperty try { if (possibleRange.matches("([\\d.]+|-[\\d.]+)-([\\d.]+|-[\\d.]+)")) { String[] str = possibleRange.split("(? value >= small && value <= big; + float left = Float.parseFloat(str[0].replaceAll("[^0-9.-]", "")); + float right = Float.parseFloat(str[1].replaceAll("[^0-9.-]", "")); + if(left == right){ + return (value) -> value == left; + } else if (right > left) { + return (value) -> value >= left && value <= right; + } else { + return (value) -> value >= right && value <= left; + } } else { float single = Float.parseFloat(possibleRange.replaceAll("[^0-9.-]", "")); return (value) -> value == single; diff --git a/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/generic_properties/LongRangeFromStringArrayProperty.java b/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/generic_properties/LongRangeFromStringArrayProperty.java new file mode 100644 index 00000000..39ad7f25 --- /dev/null +++ b/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/generic_properties/LongRangeFromStringArrayProperty.java @@ -0,0 +1,37 @@ +package traben.entity_texture_features.features.property_reading.properties.generic_properties; + +import org.jetbrains.annotations.Nullable; + +public abstract class LongRangeFromStringArrayProperty extends NumberRangeFromStringArrayProperty { + + + protected LongRangeFromStringArrayProperty(String string) throws RandomPropertyException { + super(string); + } + + + @Override + protected @Nullable RangeTester getRangeTesterFromString(String possibleRange) { + try { + if (possibleRange.matches("(\\d+|-\\d+)-(\\d+|-\\d+)")) { + String[] str = possibleRange.split("(? value == left; + } else if (right > left) { + return (value) -> value >= left && value <= right; + } else { + return (value) -> value >= right && value <= left; + } + } else { + long single = Long.parseLong(possibleRange.replaceAll("[^0-9-]", "")); + return (value) -> value == single; + } + } catch (Exception ignored) { + } + return null; + } + + +} diff --git a/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/generic_properties/SimpleIntegerArrayProperty.java b/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/generic_properties/SimpleIntegerArrayProperty.java index 066447b8..2c7d893e 100644 --- a/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/generic_properties/SimpleIntegerArrayProperty.java +++ b/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/generic_properties/SimpleIntegerArrayProperty.java @@ -98,7 +98,19 @@ protected String getPrintableRuleInfo() { return String.valueOf(ARRAY); } - public record IntRange(int lower, int higher) { + public static class IntRange { + final int lower; + final int higher; + + public IntRange(int left, int right){ + if(left > right){ + higher = left; + lower = right; + }else{ + higher = right; + lower = left; + } + } public boolean isWithinRange(int value) { return value >= lower && value <= higher; } @@ -109,7 +121,7 @@ public Integer[] getAllWithinRangeAsList() { } ArrayList builder = new ArrayList<>(); - for (int i = Math.min(lower, higher); i <= Math.max(lower, higher); i++) { + for (int i = lower; i <= higher; i++) { builder.add(i); } return builder.toArray(new Integer[0]); diff --git a/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/optifine_properties/TimeOfDayProperty.java b/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/optifine_properties/TimeOfDayProperty.java index aa9b59eb..954ca465 100644 --- a/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/optifine_properties/TimeOfDayProperty.java +++ b/common/src/main/java/traben/entity_texture_features/features/property_reading/properties/optifine_properties/TimeOfDayProperty.java @@ -2,14 +2,14 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; -import traben.entity_texture_features.features.property_reading.properties.generic_properties.NumberRangeFromStringArrayProperty; +import traben.entity_texture_features.features.property_reading.properties.generic_properties.LongRangeFromStringArrayProperty; import traben.entity_texture_features.utils.ETFEntity; import java.util.Properties; import static traben.entity_texture_features.ETFClientCommon.ETFConfigData; -public class TimeOfDayProperty extends NumberRangeFromStringArrayProperty { +public class TimeOfDayProperty extends LongRangeFromStringArrayProperty { protected TimeOfDayProperty(Properties properties, int propertyNum) throws RandomPropertyException { @@ -33,22 +33,6 @@ protected Long getRangeValueFromEntity(ETFEntity entity) { return null; } - @Override - protected @Nullable RangeTester getRangeTesterFromString(String possibleRange) { - try { - if (possibleRange.matches("(\\d+|-\\d+)-(\\d+|-\\d+)")) { - String[] str = possibleRange.split("(? value >= small && value <= big; - } else { - long single = Long.parseLong(possibleRange.replaceAll("[^0-9-]", "")); - return (value) -> value == single; - } - } catch (Exception ignored) { - } - return null; - } @Override