mirror of
https://github.com/FalsePattern/FalsePatternLib.git
synced 2026-11-16 00:14:45 +00:00
Deprecate the StableAPI annotations, switch to JB annotations
This commit is contained in:
96 files changed
+1079
-762
No files matched your search
@@ -27,23 +27,33 @@ import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use the jetbrains annotations/jspecify instead!
|
||||
* <p>
|
||||
* Used together with {@link Deprecated} to specify when an API was marked stable, and when it was marked for deprecation.
|
||||
* Deprecated classes MAY be removed after a full deprecation cycle as described inside the {@link StableAPI} javadoc.
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@Deprecated(since = "1.7.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public @interface DeprecationDetails {
|
||||
@StableAPI.Expose String deprecatedSince();
|
||||
|
||||
@StableAPI.Expose(since = "0.11.0") String replacement() default "";
|
||||
String deprecatedSince();
|
||||
|
||||
/**
|
||||
* This marks an API for removal in a future version.
|
||||
* @since 0.11.0
|
||||
*/
|
||||
String replacement() default "";
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use the jetbrains annotations/jspecify instead!
|
||||
* <p>
|
||||
* This marks an API for removal in a future version.
|
||||
*
|
||||
* @since 0.12.0
|
||||
*/
|
||||
@Deprecated(since = "1.7.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@StableAPI(since = "0.12.0")
|
||||
@interface RemovedInVersion {
|
||||
String value();
|
||||
}
|
||||
|
||||
@@ -28,6 +28,8 @@ import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use the jetbrains annotations/jspecify instead!
|
||||
* <p>
|
||||
* Anything annotated with this annotation will be considered stable, and the class/method/field will not get breaking
|
||||
* changes without a full deprecation cycle.
|
||||
* <p>
|
||||
@@ -52,18 +54,21 @@ import java.lang.annotation.Target;
|
||||
* is highly experimental and may be removed or change at any time, however, using it in third party projects is not an
|
||||
* error, unlike __INTERNAL__, but if any issues arise from the usage of the API or the API changing, the API developer
|
||||
* shall not be blamed for it.
|
||||
* @since 0.6.0
|
||||
*/
|
||||
@Deprecated(since = "1.7.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@StableAPI(since = "0.6.0")
|
||||
public @interface StableAPI {
|
||||
/**
|
||||
* The version this API was introduced/stabilized in. Used for library version tracking.
|
||||
*/
|
||||
@StableAPI.Expose String since();
|
||||
String since();
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use the jetbrains annotations/jspecify instead!
|
||||
* <p>
|
||||
* You may use this annotation if you want a member to have an equal effective {@link #since()} value as its owner
|
||||
* class.
|
||||
* <p>
|
||||
@@ -72,24 +77,30 @@ public @interface StableAPI {
|
||||
* <p>
|
||||
* Also note that this only works for class members (methods and fields),
|
||||
* inner classes still need to use {@link StableAPI}.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@Deprecated(since = "1.7.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
|
||||
@StableAPI(since = "0.10.0")
|
||||
@interface Expose {
|
||||
@StableAPI.Expose String since() default "__PARENT__";
|
||||
String since() default "__PARENT__";
|
||||
}
|
||||
|
||||
/**
|
||||
* DEPRECATED: Use the jetbrains annotations/jspecify instead!
|
||||
* <p>
|
||||
* Use this if you want to explicitly mark specific members of a {@link StableAPI} class as internal-use only.
|
||||
* <p>
|
||||
* Library consumers should never use class members marked with this annotation, as said members can be freely
|
||||
* changed or removed in any version in the library without prior notice.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@Deprecated(since = "1.7.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR})
|
||||
@StableAPI(since = "0.10.0")
|
||||
@interface Internal {}
|
||||
}
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.asm;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.asm.exceptions.AsmClassNotFoundException;
|
||||
import com.falsepattern.lib.asm.exceptions.AsmFieldNotFoundException;
|
||||
import com.falsepattern.lib.asm.exceptions.AsmMethodNotFoundException;
|
||||
@@ -44,9 +43,7 @@ import org.objectweb.asm.tree.MethodNode;
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public class ASMUtil {
|
||||
@StableAPI.Expose
|
||||
public static FieldNode findFieldStandard(ClassNode cn, String name, boolean optional) {
|
||||
for (final FieldNode ret : cn.fields) {
|
||||
if (name.equals(ret.name)) {
|
||||
@@ -60,7 +57,6 @@ public class ASMUtil {
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@StableAPI.Expose
|
||||
public static FieldNode findFieldFromMCP(ClassNode cn, String fieldName, boolean optional) {
|
||||
val classMapping = discoverClassMappingType(cn);
|
||||
if (classMapping == null) {
|
||||
@@ -76,7 +72,6 @@ public class ASMUtil {
|
||||
optional);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static FieldNode findFieldFromUniversal(ClassNode cn, UniversalField field, boolean optional) {
|
||||
String[] possibilities = CoreLoadingPlugin.isObfuscated() ? new String[]{field.getName(MappingType.SRG),
|
||||
field.getName(MappingType.Notch)}
|
||||
@@ -93,7 +88,6 @@ public class ASMUtil {
|
||||
possibilities.length == 1 ? possibilities[0] : Arrays.toString(possibilities));
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static MethodNode findMethodStandard(ClassNode cn, String name, String descriptor, boolean optional) {
|
||||
for (final MethodNode ret : cn.methods) {
|
||||
if (name.equals(ret.name) && descriptor.equals(ret.desc)) {
|
||||
@@ -107,7 +101,6 @@ public class ASMUtil {
|
||||
}
|
||||
|
||||
@SneakyThrows
|
||||
@StableAPI.Expose
|
||||
public static MethodNode findMethodFromMCP(ClassNode cn, String mcpName, String mcpDescriptor, boolean optional) {
|
||||
val classMapping = discoverClassMappingType(cn);
|
||||
if (classMapping == null) {
|
||||
@@ -121,7 +114,6 @@ public class ASMUtil {
|
||||
return findMethodStandard(cn, method.getName(classMapping), method.getDescriptor(classMapping), optional);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static MethodNode findMethodFromUniversal(ClassNode cn, UniversalMethod method, boolean optional) {
|
||||
String[] possibleNames = CoreLoadingPlugin.isObfuscated() ? new String[]{method.getName(MappingType.SRG),
|
||||
method.getName(MappingType.Notch)}
|
||||
@@ -142,7 +134,6 @@ public class ASMUtil {
|
||||
possibleDescriptors.length == 1 ? possibleDescriptors[0] : Arrays.toString(possibleDescriptors));
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static MappingType discoverClassMappingType(ClassNode cn) {
|
||||
if (!CoreLoadingPlugin.isObfuscated()) {
|
||||
if (MappingManager.containsClass(NameType.Internal, MappingType.MCP, cn.name)) {
|
||||
@@ -156,7 +147,6 @@ public class ASMUtil {
|
||||
return null;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static UniversalClass toUniversalClass(ClassNode cn) {
|
||||
if (!CoreLoadingPlugin.isObfuscated()) {
|
||||
try {
|
||||
@@ -177,7 +167,6 @@ public class ASMUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static ClassNode parseClass(byte[] bytes, int readerFlags) {
|
||||
val cn = new ClassNode(Opcodes.ASM5);
|
||||
val reader = new ClassReader(bytes);
|
||||
@@ -185,14 +174,12 @@ public class ASMUtil {
|
||||
return cn;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static byte[] serializeClass(ClassNode cn, int writerFlags) {
|
||||
val writer = new ClassWriter(writerFlags);
|
||||
cn.accept(writer);
|
||||
return writer.toByteArray();
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static boolean anyEquals(String str, String... options) {
|
||||
for (val option : options) {
|
||||
if (Objects.equals(str, option)) {
|
||||
|
||||
@@ -21,29 +21,21 @@
|
||||
*/
|
||||
package com.falsepattern.lib.asm;
|
||||
|
||||
import com.falsepattern.lib.DeprecationDetails;
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
/**
|
||||
* See: {@link com.falsepattern.lib.turboasm.TurboClassTransformer}.
|
||||
* This class will not be removed, for backwards compatibility reasons.
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
@Deprecated
|
||||
@DeprecationDetails(deprecatedSince = "1.2.0")
|
||||
@Deprecated(since = "1.2.0")
|
||||
public interface IClassNodeTransformer {
|
||||
@StableAPI.Expose
|
||||
String getName();
|
||||
|
||||
@StableAPI.Expose
|
||||
boolean shouldTransform(ClassNode cn, String transformedName, boolean obfuscated);
|
||||
|
||||
@StableAPI.Expose
|
||||
default int internalSortingOrder() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
void transform(ClassNode cn, String transformedName, boolean obfuscated);
|
||||
}
|
||||
@@ -21,8 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.asm;
|
||||
|
||||
import com.falsepattern.lib.DeprecationDetails;
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.asm.CoreLoadingPlugin;
|
||||
import lombok.val;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
@@ -39,14 +37,10 @@ import java.util.List;
|
||||
* See: {@link com.falsepattern.lib.turboasm.MergeableTurboTransformer}.
|
||||
* This class will not be removed, for backwards compatibility reasons.
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
@Deprecated
|
||||
@DeprecationDetails(deprecatedSince = "1.2.0")
|
||||
@Deprecated(since = "1.2.0")
|
||||
public interface SmartTransformer extends IClassTransformer {
|
||||
@StableAPI.Expose
|
||||
Logger logger();
|
||||
|
||||
@StableAPI.Expose
|
||||
List<IClassNodeTransformer> transformers();
|
||||
|
||||
@Override
|
||||
|
||||
@@ -21,11 +21,10 @@
|
||||
*/
|
||||
package com.falsepattern.lib.asm.exceptions;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public class AsmClassNotFoundException extends AsmTransformException {
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public AsmClassNotFoundException(final String clazz) {
|
||||
super("can't find class " + clazz);
|
||||
}
|
||||
|
||||
@@ -21,11 +21,10 @@
|
||||
*/
|
||||
package com.falsepattern.lib.asm.exceptions;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public class AsmFieldNotFoundException extends AsmTransformException {
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public AsmFieldNotFoundException(final String field) {
|
||||
super("can't find field " + field);
|
||||
}
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
*/
|
||||
package com.falsepattern.lib.asm.exceptions;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public class AsmMethodNotFoundException extends AsmTransformException {
|
||||
@ApiStatus.Internal
|
||||
public AsmMethodNotFoundException(final String method) {
|
||||
super("can't find method " + method);
|
||||
}
|
||||
|
||||
@@ -21,21 +21,15 @@
|
||||
*/
|
||||
package com.falsepattern.lib.asm.exceptions;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public class AsmTransformException extends RuntimeException {
|
||||
@StableAPI.Expose
|
||||
public AsmTransformException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public AsmTransformException(final Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public AsmTransformException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
package com.falsepattern.lib.asm.exceptions;
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
package com.falsepattern.lib.asm;
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.compat;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.util.MathUtil;
|
||||
import com.google.common.collect.AbstractIterator;
|
||||
import lombok.Getter;
|
||||
@@ -47,12 +46,10 @@ import static net.minecraft.util.EnumFacing.UP;
|
||||
import static net.minecraft.util.EnumFacing.WEST;
|
||||
|
||||
@Immutable
|
||||
@StableAPI(since = "0.6.0")
|
||||
public class BlockPos extends Vec3i {
|
||||
/**
|
||||
* An immutable block pos with zero as all coordinates.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static final BlockPos ORIGIN = new BlockPos(0, 0, 0);
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
private static final int NUM_X_BITS = 1 + MathUtil.log2(MathUtil.smallestEncompassingPowerOfTwo(30000000));
|
||||
@@ -64,27 +61,22 @@ public class BlockPos extends Vec3i {
|
||||
private static final long Z_MASK = (1L << NUM_Z_BITS) - 1L;
|
||||
private static final long X_MASK = (1L << NUM_X_BITS) - 1L;
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos(@NonNull Entity source) {
|
||||
this(source.posX, source.posY, source.posZ);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos(double x, double y, double z) {
|
||||
super(x, y, z);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos(@NonNull Vec3 vec) {
|
||||
this(vec.xCoord, vec.yCoord, vec.zCoord);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos(@NonNull Vec3i source) {
|
||||
this(source.getX(), source.getY(), source.getZ());
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos(int x, int y, int z) {
|
||||
super(x, y, z);
|
||||
}
|
||||
@@ -92,7 +84,6 @@ public class BlockPos extends Vec3i {
|
||||
/**
|
||||
* Create a BlockPos from a serialized long value (created by toLong)
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static BlockPos fromLong(long serialized) {
|
||||
return new BlockPos((int) (serialized << 64 - X_SHIFT - NUM_X_BITS >> 64 - NUM_X_BITS),
|
||||
(int) (serialized << 64 - Y_SHIFT - NUM_Y_BITS >> 64 - NUM_Y_BITS),
|
||||
@@ -114,7 +105,6 @@ public class BlockPos extends Vec3i {
|
||||
* @see #getAllInBox(int, int, int, int, int, int)
|
||||
* @see #getAllInBoxMutable(BlockPos, BlockPos)
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static Iterable<BlockPos> getAllInBox(@NonNull BlockPos from, @NonNull BlockPos to) {
|
||||
return getAllInBox(Math.min(from.getX(), to.getX()),
|
||||
Math.min(from.getY(), to.getY()),
|
||||
@@ -143,7 +133,6 @@ public class BlockPos extends Vec3i {
|
||||
* @see #getAllInBox(BlockPos, BlockPos)
|
||||
* @see #getAllInBoxMutable(BlockPos, BlockPos)
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static Iterable<BlockPos> getAllInBox(final int x0, final int y0, final int z0, final int x1, final int y1, final int z1) {
|
||||
return () -> new AbstractIterator<BlockPos>() {
|
||||
private boolean first = true;
|
||||
@@ -194,7 +183,6 @@ public class BlockPos extends Vec3i {
|
||||
* @see #getAllInBox(int, int, int, int, int, int)
|
||||
* @see #getAllInBoxMutable(BlockPos, BlockPos)
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static Iterable<BlockPos.MutableBlockPos> getAllInBoxMutable(@NonNull BlockPos from, @NonNull BlockPos to) {
|
||||
return getAllInBoxMutable(Math.min(from.getX(), to.getX()),
|
||||
Math.min(from.getY(), to.getY()),
|
||||
@@ -224,7 +212,6 @@ public class BlockPos extends Vec3i {
|
||||
* @see #getAllInBox(int, int, int, int, int, int)
|
||||
* @see #getAllInBoxMutable(BlockPos, BlockPos)
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static Iterable<BlockPos.MutableBlockPos> getAllInBoxMutable(final int x0, final int y0, final int z0, final int x1, final int y1, final int z1) {
|
||||
return () -> new AbstractIterator<MutableBlockPos>() {
|
||||
private MutableBlockPos pos;
|
||||
@@ -253,7 +240,6 @@ public class BlockPos extends Vec3i {
|
||||
};
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public long toLong() {
|
||||
return ((long) x & X_MASK) << X_SHIFT | ((long) y & Y_MASK) << Y_SHIFT | ((long) z & Z_MASK);
|
||||
}
|
||||
@@ -261,7 +247,6 @@ public class BlockPos extends Vec3i {
|
||||
/**
|
||||
* Add the given coordinates to the coordinates of this BlockPos
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public BlockPos add(double x, double y, double z) {
|
||||
if (x == 0.0D && y == 0.0D && z == 0.0D) {
|
||||
return this;
|
||||
@@ -272,7 +257,6 @@ public class BlockPos extends Vec3i {
|
||||
/**
|
||||
* Add the given Vector to this BlockPos
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public BlockPos add(@NonNull Vec3i vec) {
|
||||
return add(vec.getX(), vec.getY(), vec.getZ());
|
||||
}
|
||||
@@ -280,7 +264,6 @@ public class BlockPos extends Vec3i {
|
||||
/**
|
||||
* Add the given coordinates to the coordinates of this BlockPos
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public BlockPos add(int x, int y, int z) {
|
||||
if (x == 0 && y == 0 && z == 0) {
|
||||
return this;
|
||||
@@ -291,22 +274,18 @@ public class BlockPos extends Vec3i {
|
||||
/**
|
||||
* Subtract the given Vector from this BlockPos
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public BlockPos subtract(@NonNull Vec3i vec) {
|
||||
return add(-vec.getX(), -vec.getY(), -vec.getZ());
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos up() {
|
||||
return up(1);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos up(int blocks) {
|
||||
return offset(UP, blocks);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos offset(@NonNull EnumFacing facing, int blocks) {
|
||||
if (blocks == 0) {
|
||||
return this;
|
||||
@@ -316,73 +295,61 @@ public class BlockPos extends Vec3i {
|
||||
z + facing.getFrontOffsetZ() * blocks);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos down() {
|
||||
return down(1);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos down(int blocks) {
|
||||
return offset(DOWN, blocks);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos north() {
|
||||
return north(1);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos north(int blocks) {
|
||||
return offset(NORTH, blocks);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos south() {
|
||||
return south(1);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos south(int blocks) {
|
||||
return offset(SOUTH, blocks);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos west() {
|
||||
return west(1);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos west(int blocks) {
|
||||
return offset(WEST, blocks);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos east() {
|
||||
return east(1);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos east(int blocks) {
|
||||
return offset(EAST, blocks);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos offset(@NonNull EnumFacing facing) {
|
||||
return offset(facing, 1);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos rotate(@NonNull Rotation rotation) {
|
||||
switch (rotation) {
|
||||
case NONE:
|
||||
default:
|
||||
return this;
|
||||
case CLOCKWISE_90:
|
||||
return new BlockPos(-this.getZ(), this.getY(), this.getX());
|
||||
case CLOCKWISE_180:
|
||||
return new BlockPos(-this.getX(), this.getY(), -this.getZ());
|
||||
case COUNTERCLOCKWISE_90:
|
||||
return new BlockPos(this.getZ(), this.getY(), -this.getX());
|
||||
case NONE:
|
||||
default:
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -393,14 +360,15 @@ public class BlockPos extends Vec3i {
|
||||
x * vec.getY() - y * vec.getX());
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos toImmutable() {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Setter(onMethod_ = @StableAPI.Expose)
|
||||
@Getter(onMethod_ = @StableAPI.Expose)
|
||||
@StableAPI(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
public static class MutableBlockPos extends BlockPos {
|
||||
/**
|
||||
* Mutable X Coordinate
|
||||
@@ -415,17 +383,14 @@ public class BlockPos extends Vec3i {
|
||||
*/
|
||||
protected int z;
|
||||
|
||||
@StableAPI.Expose
|
||||
public MutableBlockPos() {
|
||||
this(ORIGIN);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public MutableBlockPos(@NonNull BlockPos blockPos) {
|
||||
this(blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public MutableBlockPos(int x, int y, int z) {
|
||||
super(ORIGIN);
|
||||
this.x = x;
|
||||
@@ -454,7 +419,6 @@ public class BlockPos extends Vec3i {
|
||||
}
|
||||
|
||||
@Override
|
||||
@StableAPI.Expose
|
||||
public BlockPos toImmutable() {
|
||||
return new BlockPos(this);
|
||||
}
|
||||
@@ -463,12 +427,10 @@ public class BlockPos extends Vec3i {
|
||||
return this.setPos(entity.posX, entity.posY, entity.posZ);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos.MutableBlockPos setPos(double x, double y, double z) {
|
||||
return setPos(MathUtil.floor(x), MathUtil.floor(y), MathUtil.floor(z));
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos.MutableBlockPos setPos(int x, int y, int z) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
@@ -476,17 +438,14 @@ public class BlockPos extends Vec3i {
|
||||
return this;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos.MutableBlockPos setPos(@NonNull Vec3i vec) {
|
||||
return this.setPos(vec.getX(), vec.getY(), vec.getZ());
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos.MutableBlockPos move(@NonNull EnumFacing facing) {
|
||||
return this.move(facing, 1);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public BlockPos.MutableBlockPos move(@NonNull EnumFacing facing, int blocks) {
|
||||
return this.setPos(x + facing.getFrontOffsetX() * blocks,
|
||||
y + facing.getFrontOffsetY() * blocks,
|
||||
@@ -494,7 +453,9 @@ public class BlockPos extends Vec3i {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public static final class PooledMutableBlockPos extends BlockPos.MutableBlockPos {
|
||||
private static final List<BlockPos.PooledMutableBlockPos> POOL = new ArrayList<>();
|
||||
private boolean released;
|
||||
@@ -503,12 +464,10 @@ public class BlockPos extends Vec3i {
|
||||
super(x, y, z);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static BlockPos.PooledMutableBlockPos retain() {
|
||||
return retain(0, 0, 0);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static BlockPos.PooledMutableBlockPos retain(int x, int y, int z) {
|
||||
synchronized (POOL) {
|
||||
if (!POOL.isEmpty()) {
|
||||
@@ -523,17 +482,14 @@ public class BlockPos extends Vec3i {
|
||||
return new BlockPos.PooledMutableBlockPos(x, y, z);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static BlockPos.PooledMutableBlockPos retain(double x, double y, double z) {
|
||||
return retain(MathUtil.floor(x), MathUtil.floor(y), MathUtil.floor(z));
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static BlockPos.PooledMutableBlockPos retain(@NonNull Vec3i vec) {
|
||||
return retain(vec.getX(), vec.getY(), vec.getZ());
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public void release() {
|
||||
synchronized (POOL) {
|
||||
if (POOL.size() < 100) {
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.compat;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
@@ -37,17 +36,14 @@ import javax.annotation.concurrent.Immutable;
|
||||
@Immutable
|
||||
@EqualsAndHashCode
|
||||
@AllArgsConstructor
|
||||
@StableAPI(since = "0.6.0")
|
||||
public class ChunkPos {
|
||||
/**
|
||||
* The x position of the chunk.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public final int x;
|
||||
/**
|
||||
* The z position of the chunk.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public final int z;
|
||||
|
||||
/**
|
||||
@@ -55,7 +51,6 @@ public class ChunkPos {
|
||||
*
|
||||
* @param blockPos the block pos
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public ChunkPos(@NonNull BlockPos blockPos) {
|
||||
x = blockPos.getX() >> 4;
|
||||
z = blockPos.getZ() >> 4;
|
||||
@@ -69,7 +64,6 @@ public class ChunkPos {
|
||||
*
|
||||
* @return the unique chunk long
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static long asLong(int x, int z) {
|
||||
return (long) x & 0xFFFFFFFFL | ((long) z & 0xFFFFFFFFL) << 32;
|
||||
}
|
||||
@@ -81,7 +75,6 @@ public class ChunkPos {
|
||||
*
|
||||
* @return the distance sq
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public double getDistanceSq(@NonNull Entity entity) {
|
||||
val dX = ((x << 4) + 8) - entity.posX;
|
||||
val dY = ((z << 4) + 8) - entity.posZ;
|
||||
@@ -93,7 +86,6 @@ public class ChunkPos {
|
||||
*
|
||||
* @return the x start
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public int getXStart() {
|
||||
return x << 4;
|
||||
}
|
||||
@@ -103,7 +95,6 @@ public class ChunkPos {
|
||||
*
|
||||
* @return the z start
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public int getZStart() {
|
||||
return z << 4;
|
||||
}
|
||||
@@ -113,7 +104,6 @@ public class ChunkPos {
|
||||
*
|
||||
* @return the x end
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public int getXEnd() {
|
||||
return (x << 4) + 15;
|
||||
}
|
||||
@@ -123,7 +113,6 @@ public class ChunkPos {
|
||||
*
|
||||
* @return the z end
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public int getZEnd() {
|
||||
return (z << 4) + 15;
|
||||
}
|
||||
@@ -137,7 +126,6 @@ public class ChunkPos {
|
||||
*
|
||||
* @return the relative block position
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public BlockPos getBlock(int x, int y, int z) {
|
||||
return new BlockPos((this.x << 4) + x, y, (this.z << 4) + z);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.compat;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import lombok.NonNull;
|
||||
import lombok.val;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -39,9 +38,10 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* A functional equivalent to GuiLabel present in Minecraft 1.12.
|
||||
*
|
||||
* @since 0.8.0
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.8.0")
|
||||
public class GuiLabel extends Gui {
|
||||
private final List<String> lines = new ArrayList<>();
|
||||
private final FontRenderer fontRenderer;
|
||||
@@ -49,32 +49,26 @@ public class GuiLabel extends Gui {
|
||||
/**
|
||||
* The id of the label.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public int id;
|
||||
/**
|
||||
* The x position of the label.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public int x;
|
||||
/**
|
||||
* The y position of the label.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public int y;
|
||||
/**
|
||||
* The visibility of the label.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public boolean visible = true;
|
||||
/**
|
||||
* The label width.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
protected int width;
|
||||
/**
|
||||
* The label height.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
protected int height;
|
||||
private boolean centered = false;
|
||||
|
||||
@@ -89,7 +83,6 @@ public class GuiLabel extends Gui {
|
||||
* @param height the height
|
||||
* @param textColour the text colour
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public GuiLabel(@NonNull FontRenderer fontRenderer, int id, int x, int y, int width, int height, int textColour) {
|
||||
this.fontRenderer = fontRenderer;
|
||||
this.id = id;
|
||||
@@ -105,7 +98,6 @@ public class GuiLabel extends Gui {
|
||||
*
|
||||
* @param text string to add
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public void addLine(@NonNull String text) {
|
||||
lines.add(I18n.format(text));
|
||||
}
|
||||
@@ -115,7 +107,6 @@ public class GuiLabel extends Gui {
|
||||
*
|
||||
* @return the GuiLabel itself
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public GuiLabel setCentered() {
|
||||
centered = true;
|
||||
return this;
|
||||
@@ -129,7 +120,6 @@ public class GuiLabel extends Gui {
|
||||
* @param mouseX the mouse x
|
||||
* @param mouseY the mouse y
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public void drawLabel(@NonNull Minecraft minecraft, int mouseX, int mouseY) {
|
||||
if (!visible) {
|
||||
return;
|
||||
|
||||
@@ -21,26 +21,22 @@
|
||||
*/
|
||||
package com.falsepattern.lib.compat;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import lombok.NonNull;
|
||||
import lombok.val;
|
||||
|
||||
import net.minecraft.util.EnumFacing;
|
||||
|
||||
@StableAPI(since = "0.6.0")
|
||||
public enum Rotation {
|
||||
@StableAPI.Expose NONE,
|
||||
@StableAPI.Expose CLOCKWISE_90,
|
||||
@StableAPI.Expose CLOCKWISE_180,
|
||||
@StableAPI.Expose COUNTERCLOCKWISE_90;
|
||||
NONE,
|
||||
CLOCKWISE_90,
|
||||
CLOCKWISE_180,
|
||||
COUNTERCLOCKWISE_90;
|
||||
|
||||
@StableAPI.Expose
|
||||
public Rotation add(@NonNull Rotation rotation) {
|
||||
val values = Rotation.values();
|
||||
return values[(ordinal() + rotation.ordinal()) % values.length];
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public EnumFacing rotate(@NonNull EnumFacing facing) {
|
||||
if (facing == EnumFacing.UP || facing == EnumFacing.DOWN) {
|
||||
return facing;
|
||||
@@ -90,7 +86,6 @@ public enum Rotation {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public int rotate(int x, int z) {
|
||||
switch (this) {
|
||||
case CLOCKWISE_90:
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.compat;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.util.MathUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -38,19 +37,14 @@ import javax.annotation.concurrent.Immutable;
|
||||
@Immutable
|
||||
@EqualsAndHashCode
|
||||
@AllArgsConstructor
|
||||
@StableAPI(since = "0.6.0")
|
||||
public class Vec3i implements Comparable<Vec3i> {
|
||||
/**
|
||||
* A static zero vector
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static final Vec3i NULL_VECTOR = new Vec3i(0, 0, 0);
|
||||
|
||||
@StableAPI.Expose
|
||||
protected final int x;
|
||||
@StableAPI.Expose
|
||||
protected final int y;
|
||||
@StableAPI.Expose
|
||||
protected final int z;
|
||||
|
||||
/**
|
||||
@@ -60,7 +54,6 @@ public class Vec3i implements Comparable<Vec3i> {
|
||||
* @param y the y
|
||||
* @param z the z
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public Vec3i(double x, double y, double z) {
|
||||
this(MathUtil.floor(x), MathUtil.floor(y), MathUtil.floor(z));
|
||||
}
|
||||
@@ -77,7 +70,6 @@ public class Vec3i implements Comparable<Vec3i> {
|
||||
*
|
||||
* @return the new resulting vector
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public Vec3i crossProduct(@NonNull Vec3i vec) {
|
||||
return new Vec3i(y * vec.getZ() - z * vec.getY(),
|
||||
z * vec.getX() - x * vec.getZ(),
|
||||
@@ -93,7 +85,6 @@ public class Vec3i implements Comparable<Vec3i> {
|
||||
*
|
||||
* @return the distance
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public double getDistance(int x, int y, int z) {
|
||||
return Math.sqrt(distanceSq(x, y, z));
|
||||
}
|
||||
@@ -107,7 +98,6 @@ public class Vec3i implements Comparable<Vec3i> {
|
||||
*
|
||||
* @return the square distance
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public double distanceSq(int x, int y, int z) {
|
||||
val dX = this.x - x;
|
||||
val dY = this.y - y;
|
||||
@@ -122,7 +112,6 @@ public class Vec3i implements Comparable<Vec3i> {
|
||||
*
|
||||
* @return the square distance
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public double distanceSq(@NonNull Vec3i vec) {
|
||||
return distanceSq(vec.getX(), vec.getY(), vec.getZ());
|
||||
}
|
||||
@@ -136,7 +125,6 @@ public class Vec3i implements Comparable<Vec3i> {
|
||||
*
|
||||
* @return the square distance to center
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public double distanceSqToCenter(double x, double y, double z) {
|
||||
val dX = this.x + 0.5D - x;
|
||||
val dY = this.y + 0.5D - y;
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since 0.6.0
|
||||
*/
|
||||
package com.falsepattern.lib.compat;
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.config;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import org.intellij.lang.annotations.Language;
|
||||
|
||||
import java.lang.annotation.Documented;
|
||||
@@ -75,7 +74,6 @@ import java.util.function.BiConsumer;
|
||||
* <br>
|
||||
* {@link NoSync} - You MUST add this to fields that you don't want to be synchronized by {@link Synchronize}.
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@@ -85,19 +83,21 @@ public @interface Config {
|
||||
* If {@link #customPath()} is not set, this is used for the config file name (.minecraft/config/modid.cfg)
|
||||
* @see #customPath()
|
||||
*/
|
||||
@StableAPI.Expose String modid();
|
||||
String modid();
|
||||
|
||||
/**
|
||||
* Root element category, defaults to "general". MUST NOT be an empty string.
|
||||
*/
|
||||
@StableAPI.Expose String category() default "general";
|
||||
String category() default "general";
|
||||
|
||||
/**
|
||||
* Define category migrations here.
|
||||
* Used to rename config categories without losing data.
|
||||
* @see #pathMigrations()
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@StableAPI.Expose(since = "1.5.0") String[] categoryMigrations() default {};
|
||||
String[] categoryMigrations() default {};
|
||||
|
||||
/**
|
||||
* A custom configuration file path. Relative to the .minecraft/config folder.
|
||||
@@ -110,8 +110,10 @@ public @interface Config {
|
||||
* customPath = "mymod.config" -> .minecraft/config/mymod.config
|
||||
* <br>
|
||||
* @see #modid()
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@StableAPI.Expose(since = "1.5.0") String customPath() default "";
|
||||
String customPath() default "";
|
||||
|
||||
/**
|
||||
* Define file migration paths here.
|
||||
@@ -124,8 +126,10 @@ public @interface Config {
|
||||
* the category of this config.
|
||||
* @see #customPath()
|
||||
* @see #categoryMigrations()
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@StableAPI.Expose(since = "1.5.0") String[] pathMigrations() default {};
|
||||
String[] pathMigrations() default {};
|
||||
|
||||
// region Common
|
||||
|
||||
@@ -133,12 +137,11 @@ public @interface Config {
|
||||
* The description of the configuration or the category. Should be in the primary language of the mod.
|
||||
* @see LangKey
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||
@interface Comment {
|
||||
@StableAPI.Expose String[] value();
|
||||
String[] value();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -152,19 +155,17 @@ public @interface Config {
|
||||
* Also applies to categories, where it gets autogenerated from the modid and category (config.MODID.CATEGORY)
|
||||
* @see Comment
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||
@interface LangKey {
|
||||
@StableAPI.Expose String value() default "";
|
||||
String value() default "";
|
||||
}
|
||||
|
||||
/**
|
||||
* If you have extra fields in the config class used for anything else other than configuring, you must annotate
|
||||
* the using this so that the config engine doesn't pick them up.
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@@ -173,23 +174,23 @@ public @interface Config {
|
||||
/**
|
||||
* The name of this config property in the config file. If not specified, the field's name will be used instead.
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface Name {
|
||||
@StableAPI.Expose String value();
|
||||
String value();
|
||||
|
||||
/**
|
||||
* Use this to migrate from old config names. "" is resolved to the name of the field
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@StableAPI.Expose(since = "1.5.0") String[] migrations() default {};
|
||||
String[] migrations() default {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the specific configuration needs a minecraft restart to be applied.
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||
@@ -198,7 +199,6 @@ public @interface Config {
|
||||
/**
|
||||
* Whether the specific configuration needs a world/server rejoin to be applied.
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target({ElementType.FIELD, ElementType.TYPE})
|
||||
@@ -214,8 +214,9 @@ public @interface Config {
|
||||
* <p>
|
||||
* Note that synchronization ALWAYS happens FROM the server TO the client. The server should NEVER attempt to get
|
||||
* configuration values from a client. This is to avoid malicious clients manipulating the server configs.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.TYPE)
|
||||
@@ -223,8 +224,9 @@ public @interface Config {
|
||||
|
||||
/**
|
||||
* Use this to mark config fields you don't want to synchronize in a class marked with {@link Synchronize}.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@@ -238,12 +240,11 @@ public @interface Config {
|
||||
* The default value for a boolean field. Not having a default is deprecated since 0.10, and will be strongly
|
||||
* enforced in 0.11+!
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultBoolean {
|
||||
@StableAPI.Expose boolean value();
|
||||
boolean value();
|
||||
}
|
||||
|
||||
// endregion
|
||||
@@ -254,25 +255,23 @@ public @interface Config {
|
||||
* The default value for an int field.
|
||||
* @see RangeInt
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultInt {
|
||||
@StableAPI.Expose int value();
|
||||
int value();
|
||||
}
|
||||
|
||||
/**
|
||||
* The range of possible values an int config can have.
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface RangeInt {
|
||||
@StableAPI.Expose int min() default Integer.MIN_VALUE;
|
||||
int min() default Integer.MIN_VALUE;
|
||||
|
||||
@StableAPI.Expose int max() default Integer.MAX_VALUE;
|
||||
int max() default Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
// endregion
|
||||
@@ -282,26 +281,28 @@ public @interface Config {
|
||||
/**
|
||||
* The default value for a double field.
|
||||
* @see RangeDouble
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultDouble {
|
||||
@StableAPI.Expose double value();
|
||||
double value();
|
||||
}
|
||||
|
||||
/**
|
||||
* The range of possible values a double config can have.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface RangeDouble {
|
||||
@StableAPI.Expose double min() default -Double.MAX_VALUE;
|
||||
double min() default -Double.MAX_VALUE;
|
||||
|
||||
@StableAPI.Expose double max() default Double.MAX_VALUE;
|
||||
double max() default Double.MAX_VALUE;
|
||||
}
|
||||
|
||||
// endregion
|
||||
@@ -313,37 +314,36 @@ public @interface Config {
|
||||
* @see StringMaxLength
|
||||
* @see Pattern
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultString {
|
||||
@StableAPI.Expose String value();
|
||||
String value();
|
||||
}
|
||||
|
||||
/**
|
||||
* This annotation limits the maximum number of characters present in a string configuration.
|
||||
* <p>
|
||||
* When used with a string list, this limit will apply to each element individually, not to the size of the list as a whole.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface StringMaxLength {
|
||||
@StableAPI.Expose int value();
|
||||
int value();
|
||||
}
|
||||
|
||||
/**
|
||||
* A regex pattern for restricting the allowed strings.
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface Pattern {
|
||||
@Language("RegExp")
|
||||
@StableAPI.Expose String value();
|
||||
String value();
|
||||
}
|
||||
|
||||
// endregion
|
||||
@@ -353,12 +353,11 @@ public @interface Config {
|
||||
/**
|
||||
* The default value for an Enum field.
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultEnum {
|
||||
@StableAPI.Expose String value();
|
||||
String value();
|
||||
}
|
||||
|
||||
// endregion
|
||||
@@ -369,13 +368,14 @@ public @interface Config {
|
||||
* The default value for a boolean array field.
|
||||
* @see ListFixedLength
|
||||
* @see ListMaxLength
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultBooleanList {
|
||||
@StableAPI.Expose boolean[] value();
|
||||
boolean[] value();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -383,13 +383,14 @@ public @interface Config {
|
||||
* @see ListFixedLength
|
||||
* @see ListMaxLength
|
||||
* @see RangeInt
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultIntList {
|
||||
@StableAPI.Expose int[] value();
|
||||
int[] value();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -397,13 +398,14 @@ public @interface Config {
|
||||
* @see ListFixedLength
|
||||
* @see ListMaxLength
|
||||
* @see RangeDouble
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultDoubleList {
|
||||
@StableAPI.Expose double[] value();
|
||||
double[] value();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -413,20 +415,20 @@ public @interface Config {
|
||||
* @see StringMaxLength
|
||||
* @see Pattern
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface DefaultStringList {
|
||||
@StableAPI.Expose String[] value();
|
||||
String[] value();
|
||||
}
|
||||
|
||||
/**
|
||||
* If this annotation is present, the list in the config will be forced to have exactly the amount of elements as
|
||||
* the default value.
|
||||
* @see ListMaxLength
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@@ -435,13 +437,14 @@ public @interface Config {
|
||||
/**
|
||||
* This annotation limits the maximum number of elements present in an array configuration. Only effective if
|
||||
* {@link ListFixedLength} is NOT present.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
@Documented
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
@interface ListMaxLength {
|
||||
@StableAPI.Expose int value();
|
||||
int value();
|
||||
}
|
||||
|
||||
// endregion
|
||||
|
||||
@@ -21,25 +21,24 @@
|
||||
*/
|
||||
package com.falsepattern.lib.config;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
/**
|
||||
* A really basic wrapper for config to simplify handling them in external code.
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
public class ConfigException extends Exception {
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public ConfigException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public ConfigException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public ConfigException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.config;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.ReflectionUtil;
|
||||
import com.falsepattern.lib.internal.impl.config.ConfigurationManagerImpl;
|
||||
import lombok.AccessLevel;
|
||||
@@ -41,24 +40,28 @@ import java.util.function.BiConsumer;
|
||||
* Class for controlling the loading of configuration files.
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@StableAPI(since = "0.6.0")
|
||||
public class ConfigurationManager {
|
||||
|
||||
@StableAPI.Expose(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public static void initialize(Class<?>... configClasses) throws ConfigException {
|
||||
initialize((a, b) -> {}, configClasses);
|
||||
}
|
||||
|
||||
/**
|
||||
* You can use this method in the static initializer of a config class to self-load it without extra effort.
|
||||
*
|
||||
* @since 0.10.3
|
||||
*/
|
||||
@StableAPI.Expose(since = "0.10.3")
|
||||
@SneakyThrows
|
||||
public static void selfInit() {
|
||||
initialize(ReflectionUtil.getCallerClass());
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public static void initialize(BiConsumer<Class<?>, Field> validatorErrorCallback, Class<?>... configClasses)
|
||||
throws ConfigException {
|
||||
for (val clazz : configClasses) {
|
||||
@@ -69,12 +72,16 @@ public class ConfigurationManager {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public static boolean validate(boolean resetInvalid, Class<?>... configClasses) throws ConfigException {
|
||||
return validate((x, y) -> {}, resetInvalid, configClasses);
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public static boolean validate(BiConsumer<Class<?>, Field> validatorErrorCallback, boolean resetInvalid, Class<?>... configClasses)
|
||||
throws ConfigException {
|
||||
boolean valid = true;
|
||||
@@ -84,14 +91,18 @@ public class ConfigurationManager {
|
||||
return valid;
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public static void loadFromFile(Class<?>... configClasses) throws ConfigException {
|
||||
for (val clazz : configClasses) {
|
||||
ConfigurationManagerImpl.load(clazz);
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public static void saveToFile(boolean validateAndResetInvalid, Class<?>... configClasses) throws ConfigException {
|
||||
for (val clazz : configClasses) {
|
||||
if (validateAndResetInvalid) {
|
||||
@@ -109,7 +120,6 @@ public class ConfigurationManager {
|
||||
* @return The configuration elements.
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@StableAPI.Expose
|
||||
public static List<IConfigElement> getConfigElements(Class<?> configClass) throws ConfigException {
|
||||
return ConfigurationManagerImpl.getConfigElements(configClass);
|
||||
}
|
||||
@@ -120,9 +130,10 @@ public class ConfigurationManager {
|
||||
* @param configClasses The classes to process.
|
||||
*
|
||||
* @return The configuration elements.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@StableAPI.Expose(since = "0.10.0")
|
||||
public static List<IConfigElement> getConfigElementsMulti(Class<?>... configClasses) throws ConfigException {
|
||||
switch (configClasses.length) {
|
||||
case 0:
|
||||
@@ -139,10 +150,11 @@ public class ConfigurationManager {
|
||||
}
|
||||
/**
|
||||
* @return The configuration elements, structured with DummyCategoryElement groups per config class
|
||||
* @see #getConfigElementsMulti(Class[])
|
||||
* @see #getConfigElementsMulti(Class[])
|
||||
*
|
||||
* @since 1.5.0
|
||||
*/
|
||||
@SuppressWarnings("rawtypes")
|
||||
@StableAPI.Expose(since = "1.5.0")
|
||||
public static List<IConfigElement> getConfigElementsMultiStructured(Class<?>... configClasses) throws ConfigException {
|
||||
if (configClasses.length == 0) {
|
||||
return Collections.emptyList();
|
||||
|
||||
@@ -21,29 +21,33 @@
|
||||
*/
|
||||
package com.falsepattern.lib.config;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
|
||||
import net.minecraft.client.gui.GuiScreen;
|
||||
import cpw.mods.fml.client.config.GuiConfig;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
/**
|
||||
* @since 0.9.0
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.9.0")
|
||||
public class SimpleGuiConfig extends GuiConfig {
|
||||
@StableAPI.Expose
|
||||
public SimpleGuiConfig(GuiScreen parent, Class<?> configClass, String modID, String modName)
|
||||
throws ConfigException {
|
||||
this(parent, modID, modName, configClass);
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public SimpleGuiConfig(GuiScreen parent, String modID, String title, Class<?>... configClasses)
|
||||
throws ConfigException {
|
||||
this(parent, modID, title, null, configClasses);
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "1.5.0")
|
||||
|
||||
/**
|
||||
* @since 1.5.0
|
||||
*/
|
||||
public SimpleGuiConfig(GuiScreen parent, String modID, String title, String titleLine2, Class<?>... configClasses)
|
||||
throws ConfigException {
|
||||
super(parent,
|
||||
|
||||
@@ -21,8 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.config;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
|
||||
import net.minecraft.client.Minecraft;
|
||||
import cpw.mods.fml.client.IModGuiFactory;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -30,8 +28,10 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @since 0.9.0
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.9.0")
|
||||
public interface SimpleGuiFactory extends IModGuiFactory {
|
||||
@Override
|
||||
default void initialize(Minecraft minecraftInstance) {
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
*/
|
||||
package com.falsepattern.lib.config.event;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.EventUtil;
|
||||
import lombok.val;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -35,28 +35,26 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
* This is a client-only event, and is never triggered serverside!
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public class AllConfigSyncEvent extends Event {
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public AllConfigSyncEvent() {
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public static boolean postStart() {
|
||||
val event = new Start();
|
||||
return EventUtil.postOnCommonBus(event);
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public static void postEnd() {
|
||||
EventUtil.postOnCommonBus(new End());
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class Start extends AllConfigSyncEvent {
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public Start() {
|
||||
}
|
||||
|
||||
@@ -67,9 +65,8 @@ public class AllConfigSyncEvent extends Event {
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class End extends AllConfigSyncEvent {
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public End() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,9 +21,9 @@
|
||||
*/
|
||||
package com.falsepattern.lib.config.event;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.EventUtil;
|
||||
import lombok.val;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -35,37 +35,34 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
* This is a client-only event, and is never triggered serverside!
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public class ConfigSyncEvent extends Event {
|
||||
@StableAPI.Expose
|
||||
public final Class<?> configClass;
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public ConfigSyncEvent(Class<?> configClass) {
|
||||
this.configClass = configClass;
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public static boolean postStart(Class<?> configClass) {
|
||||
val event = new Start(configClass);
|
||||
return EventUtil.postOnCommonBus(event);
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public static void postEndSuccess(Class<?> configClass) {
|
||||
EventUtil.postOnCommonBus(new End(configClass, true, null));
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public static void postEndFailure(Class<?> configClass, Throwable error) {
|
||||
EventUtil.postOnCommonBus(new End(configClass, false, error));
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class Start extends ConfigSyncEvent {
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public Start(Class<?> configClass) {
|
||||
super(configClass);
|
||||
}
|
||||
@@ -77,15 +74,11 @@ public class ConfigSyncEvent extends Event {
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class End extends ConfigSyncEvent {
|
||||
@StableAPI.Expose
|
||||
public final boolean successful;
|
||||
|
||||
@StableAPI.Expose
|
||||
public final Throwable error;
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public End(Class<?> configClass, boolean successful, Throwable error) {
|
||||
super(configClass);
|
||||
this.successful = successful;
|
||||
|
||||
@@ -21,8 +21,8 @@
|
||||
*/
|
||||
package com.falsepattern.lib.config.event;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.EventUtil;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import net.minecraft.entity.player.EntityPlayerMP;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
@@ -36,39 +36,33 @@ import java.util.List;
|
||||
* different game sides. If you want to trigger this on the server, use {@link #postServer}, and if on the client, use
|
||||
* {@link #postClient}
|
||||
*/
|
||||
@StableAPI(since = "0.10.0")
|
||||
public class ConfigSyncRequestEvent extends Event {
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public ConfigSyncRequestEvent() {
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static void postClient() {
|
||||
EventUtil.postOnCommonBus(new Client());
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static void postServer(List<EntityPlayerMP> players) {
|
||||
EventUtil.postOnCommonBus(new Server(new ArrayList<>(players)));
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class Client extends ConfigSyncRequestEvent {
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public Client() {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class Server extends ConfigSyncRequestEvent {
|
||||
private final List<EntityPlayerMP> players;
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public Server(List<EntityPlayerMP> players) {
|
||||
this.players = players;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public List<EntityPlayerMP> getPlayers() {
|
||||
return Collections.unmodifiableList(players);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.config.event;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.config.Config;
|
||||
import com.falsepattern.lib.internal.EventUtil;
|
||||
import com.falsepattern.lib.internal.FPLog;
|
||||
@@ -30,6 +29,7 @@ import com.falsepattern.lib.toasts.GuiToast;
|
||||
import com.falsepattern.lib.toasts.SimpleToast;
|
||||
import com.falsepattern.lib.toasts.icon.ToastBG;
|
||||
import lombok.val;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import net.minecraft.util.EnumChatFormatting;
|
||||
import cpw.mods.fml.common.eventhandler.Event;
|
||||
@@ -38,20 +38,14 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public class ConfigValidationFailureEvent extends Event {
|
||||
@StableAPI.Expose
|
||||
public final String reason;
|
||||
@StableAPI.Expose
|
||||
public final Class<?> configClass;
|
||||
@StableAPI.Expose
|
||||
public final String fieldName;
|
||||
@StableAPI.Expose
|
||||
public final boolean listElement;
|
||||
@StableAPI.Expose
|
||||
public final int listIndex;
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
protected ConfigValidationFailureEvent(String reason, Class<?> configClass, String fieldName, boolean listElement, int listIndex) {
|
||||
this.reason = reason;
|
||||
this.configClass = configClass;
|
||||
@@ -60,7 +54,7 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
this.listIndex = listIndex;
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public static void postNumericRangeOutOfBounds(Field field, int listIndex, String value, String min, String max) {
|
||||
EventUtil.postOnCommonBus(new NumericRangeOutOfBounds(field.getDeclaringClass(),
|
||||
field.getName(),
|
||||
@@ -70,7 +64,7 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
max));
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public static void postSize(Field field, int requestedSize, boolean fixedSize, int maxSize, int defaultSize) {
|
||||
EventUtil.postOnCommonBus(new ListSizeOutOfBounds(field.getDeclaringClass(),
|
||||
field.getName(),
|
||||
@@ -80,7 +74,7 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
defaultSize));
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public static void postStringSizeOutOfBounds(Field field, int listIndex, String text, int maxSize) {
|
||||
EventUtil.postOnCommonBus(new StringSizeOutOfBounds(field.getDeclaringClass(),
|
||||
field.getName(),
|
||||
@@ -89,12 +83,12 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
maxSize));
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public static void fieldIsNull(Field field, int listIndex) {
|
||||
EventUtil.postOnCommonBus(new FieldIsNull(field.getDeclaringClass(), field.getName(), listIndex));
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public static void postStringPatternMismatch(Field field, int listIndex, String text, String pattern) {
|
||||
EventUtil.postOnCommonBus(new StringPatternMismatch(field.getDeclaringClass(),
|
||||
field.getName(),
|
||||
@@ -103,8 +97,8 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
pattern));
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI.Internal
|
||||
public void toast() {
|
||||
val ann = configClass.getAnnotation(Config.class);
|
||||
val toast = new SimpleToast(ToastBG.TOAST_DARK,
|
||||
@@ -118,11 +112,11 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
GuiToast.add(toast);
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
protected void customText(StringBuilder b) {
|
||||
}
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public void logWarn() {
|
||||
val errorString = new StringBuilder("Error validating configuration field!");
|
||||
errorString.append("\nReason: ").append(reason);
|
||||
@@ -136,16 +130,12 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class NumericRangeOutOfBounds extends ConfigValidationFailureEvent {
|
||||
@StableAPI.Expose
|
||||
public final String value;
|
||||
@StableAPI.Expose
|
||||
public final String min;
|
||||
@StableAPI.Expose
|
||||
public final String max;
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public NumericRangeOutOfBounds(Class<?> configClass, String fieldName, int listIndex, String value, String min, String max) {
|
||||
super("Number range out of bounds", configClass, fieldName, listIndex >= 0, listIndex);
|
||||
this.value = value;
|
||||
@@ -159,18 +149,13 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class ListSizeOutOfBounds extends ConfigValidationFailureEvent {
|
||||
@StableAPI.Expose
|
||||
public final int size;
|
||||
@StableAPI.Expose
|
||||
public final boolean fixedSize;
|
||||
@StableAPI.Expose
|
||||
public final int maxSize;
|
||||
@StableAPI.Expose
|
||||
public final int defaultSize;
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public ListSizeOutOfBounds(Class<?> configClass, String fieldName, int size, boolean fixedSize, int maxSize, int defaultSize) {
|
||||
super("Array size out of bounds", configClass, fieldName, false, -1);
|
||||
this.size = size;
|
||||
@@ -189,14 +174,11 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class StringSizeOutOfBounds extends ConfigValidationFailureEvent {
|
||||
@StableAPI.Expose
|
||||
public final String text;
|
||||
@StableAPI.Expose
|
||||
public final int maxSize;
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public StringSizeOutOfBounds(Class<?> configClass, String fieldName, int listIndex, String text, int maxSize) {
|
||||
super("String size out of bounds", configClass, fieldName, listIndex >= 0, listIndex);
|
||||
this.text = text;
|
||||
@@ -214,9 +196,8 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class FieldIsNull extends ConfigValidationFailureEvent {
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public FieldIsNull(Class<?> configClass, String fieldName, int listIndex) {
|
||||
super("Unexpected null", configClass, fieldName, listIndex >= 0, listIndex);
|
||||
}
|
||||
@@ -227,14 +208,11 @@ public class ConfigValidationFailureEvent extends Event {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static final class StringPatternMismatch extends ConfigValidationFailureEvent {
|
||||
@StableAPI.Expose
|
||||
public final String text;
|
||||
@StableAPI.Expose
|
||||
public final String pattern;
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
public StringPatternMismatch(Class<?> configClass, String fieldName, int listIndex, String text, String pattern) {
|
||||
super("String pattern mismatch", configClass, fieldName, listIndex >= 0, listIndex);
|
||||
this.text = text;
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
package com.falsepattern.lib.config.event;
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since 0.6.0
|
||||
*/
|
||||
package com.falsepattern.lib.config;
|
||||
@@ -21,18 +21,15 @@
|
||||
*/
|
||||
package com.falsepattern.lib.dependencies;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import lombok.NonNull;
|
||||
import lombok.val;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@StableAPI(since = "0.6.0")
|
||||
public class ComplexVersion extends Version {
|
||||
final Version[] versions;
|
||||
|
||||
@StableAPI.Expose
|
||||
public ComplexVersion(@NonNull Version mainVersion, Version... subVersions) {
|
||||
this.versions = new Version[subVersions.length + 1];
|
||||
this.versions[0] = mainVersion;
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.dependencies;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.impl.dependencies.DependencyLoaderImpl;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
@@ -31,19 +30,21 @@ import java.util.concurrent.CompletableFuture;
|
||||
* For regular external dependencies, see the DEPENDENCIES.MD files in the root of the resources for more information.
|
||||
* If you need more power than the one provided by the json format, you may use this class for granular loading instead.
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
public class DependencyLoader {
|
||||
@StableAPI.Expose
|
||||
public static void addMavenRepo(String url) {
|
||||
DependencyLoaderImpl.addMavenRepo(url);
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public static CompletableFuture<Void> loadLibrariesAsync(Library... libraries) {
|
||||
return DependencyLoaderImpl.loadLibrariesAsync(libraries);
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public static void loadLibraries(Library... libraries) {
|
||||
DependencyLoaderImpl.loadLibraries(libraries);
|
||||
}
|
||||
|
||||
@@ -22,34 +22,31 @@
|
||||
|
||||
package com.falsepattern.lib.dependencies;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import lombok.NonNull;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public class Library {
|
||||
@StableAPI.Expose
|
||||
@NonNull
|
||||
public final String loadingModId;
|
||||
@StableAPI.Expose
|
||||
@NonNull
|
||||
public final String groupId;
|
||||
@StableAPI.Expose
|
||||
@NonNull
|
||||
public final String artifactId;
|
||||
@StableAPI.Expose
|
||||
@NonNull
|
||||
public final Version minVersion;
|
||||
@StableAPI.Expose
|
||||
@Nullable
|
||||
public final Version maxVersion;
|
||||
@StableAPI.Expose
|
||||
@NonNull
|
||||
public final Version preferredVersion;
|
||||
@StableAPI.Expose
|
||||
@Nullable
|
||||
public final String regularSuffix;
|
||||
@StableAPI.Expose
|
||||
@Nullable
|
||||
public final String devSuffix;
|
||||
|
||||
@StableAPI.Expose
|
||||
public Library(@NonNull String loadingModId, @NonNull String groupId, @NonNull String artifactId, @NonNull Version minVersion, Version maxVersion, @NonNull Version preferredVersion, String regularSuffix, String devSuffix) {
|
||||
this.loadingModId = loadingModId;
|
||||
this.groupId = groupId;
|
||||
@@ -61,12 +58,13 @@ public class Library {
|
||||
this.devSuffix = devSuffix;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static LibraryBuilder builder() {
|
||||
return new LibraryBuilder();
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public static class LibraryBuilder {
|
||||
private String loadingModId;
|
||||
private String groupId;
|
||||
@@ -77,59 +75,50 @@ public class Library {
|
||||
private String regularSuffix;
|
||||
private String devSuffix;
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
LibraryBuilder() {
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public LibraryBuilder loadingModId(@NonNull String loadingModId) {
|
||||
this.loadingModId = loadingModId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public LibraryBuilder groupId(@NonNull String groupId) {
|
||||
this.groupId = groupId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public LibraryBuilder artifactId(@NonNull String artifactId) {
|
||||
this.artifactId = artifactId;
|
||||
return this;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public LibraryBuilder minVersion(@NonNull Version minVersion) {
|
||||
this.minVersion = minVersion;
|
||||
return this;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public LibraryBuilder maxVersion(Version maxVersion) {
|
||||
this.maxVersion = maxVersion;
|
||||
return this;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public LibraryBuilder preferredVersion(@NonNull Version preferredVersion) {
|
||||
this.preferredVersion = preferredVersion;
|
||||
return this;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public LibraryBuilder regularSuffix(String regularSuffix) {
|
||||
this.regularSuffix = regularSuffix;
|
||||
return this;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public LibraryBuilder devSuffix(String devSuffix) {
|
||||
this.devSuffix = devSuffix;
|
||||
return this;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public Library build() {
|
||||
return new Library(loadingModId,
|
||||
groupId,
|
||||
|
||||
@@ -21,27 +21,25 @@
|
||||
*/
|
||||
package com.falsepattern.lib.dependencies;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
import lombok.val;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@StableAPI(since = "0.6.0")
|
||||
public class SemanticVersion extends Version {
|
||||
@Getter(onMethod_ = @StableAPI.Expose)
|
||||
@Getter
|
||||
private final int majorVersion;
|
||||
@Getter(onMethod_ = @StableAPI.Expose)
|
||||
@Getter
|
||||
private final int minorVersion;
|
||||
@Getter(onMethod_ = @StableAPI.Expose)
|
||||
@Getter
|
||||
private final int patchVersion;
|
||||
@Getter(onMethod_ = @StableAPI.Expose)
|
||||
@Getter
|
||||
private final String preRelease;
|
||||
@Getter(onMethod_ = @StableAPI.Expose)
|
||||
@Getter
|
||||
private final String build;
|
||||
|
||||
@StableAPI.Expose
|
||||
public SemanticVersion(int majorVersion, int minorVersion, int patchVersion, String preRelease, String build) {
|
||||
this.majorVersion = majorVersion;
|
||||
this.minorVersion = minorVersion;
|
||||
@@ -52,27 +50,29 @@ public class SemanticVersion extends Version {
|
||||
this.build = "".equals(build) ? null : build;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public SemanticVersion(int majorVersion, int minorVersion, int patchVersion, String preRelease) {
|
||||
this(majorVersion, minorVersion, patchVersion, preRelease, null);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public SemanticVersion(int majorVersion, int minorVersion, int patchVersion) {
|
||||
this(majorVersion, minorVersion, patchVersion, null, null);
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public SemanticVersion(int majorVersion, int minorVersion) {
|
||||
this(majorVersion, minorVersion, -1, null, null);
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "0.10.0")
|
||||
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public SemanticVersion(int majorVersion) {
|
||||
this(majorVersion, -1, -1, null, null);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static SemanticVersionBuilder builder() {
|
||||
return new SemanticVersionBuilder();
|
||||
}
|
||||
@@ -119,7 +119,9 @@ public class SemanticVersion extends Version {
|
||||
// @formatter:on
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
public static class SemanticVersionBuilder {
|
||||
private int majorVersion;
|
||||
private int minorVersion = -1;
|
||||
@@ -127,41 +129,35 @@ public class SemanticVersion extends Version {
|
||||
private String preRelease;
|
||||
private String build;
|
||||
|
||||
@StableAPI.Internal
|
||||
@ApiStatus.Internal
|
||||
SemanticVersionBuilder() {
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public SemanticVersionBuilder majorVersion(int majorVersion) {
|
||||
this.majorVersion = majorVersion;
|
||||
return this;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public SemanticVersionBuilder minorVersion(int minorVersion) {
|
||||
this.minorVersion = minorVersion;
|
||||
return this;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public SemanticVersionBuilder patchVersion(int patchVersion) {
|
||||
this.patchVersion = patchVersion;
|
||||
return this;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public SemanticVersionBuilder preRelease(String preRelease) {
|
||||
this.preRelease = preRelease;
|
||||
return this;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public SemanticVersionBuilder build(String build) {
|
||||
this.build = build;
|
||||
return this;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public SemanticVersion build() {
|
||||
return new SemanticVersion(majorVersion, minorVersion, patchVersion, preRelease, build);
|
||||
}
|
||||
|
||||
@@ -21,9 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.dependencies;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
|
||||
@StableAPI(since = "0.6.0")
|
||||
public abstract class Version implements Comparable<Version> {
|
||||
protected Version() {
|
||||
}
|
||||
@@ -36,7 +33,6 @@ public abstract class Version implements Comparable<Version> {
|
||||
return equals((Version) obj);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public boolean equals(Version other) {
|
||||
return compareTo(other) == 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since 0.6.0
|
||||
*/
|
||||
package com.falsepattern.lib.dependencies;
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
package com.falsepattern.lib.internal.asm;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.asm.transformers.ConfigOrderTransformer;
|
||||
import com.falsepattern.lib.internal.asm.transformers.CrashReportImprover;
|
||||
import com.falsepattern.lib.internal.asm.transformers.MixinPluginTransformer;
|
||||
@@ -34,7 +33,6 @@ import lombok.experimental.Accessors;
|
||||
import java.util.Arrays;
|
||||
|
||||
@Accessors(fluent = true)
|
||||
@StableAPI(since = "__INTERNAL__")
|
||||
public class FPTransformer extends MergeableTurboTransformer {
|
||||
static {
|
||||
OptiFineTransformerHooksImpl.init();
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@ApiStatus.Internal
|
||||
package com.falsepattern.lib.internal.asm;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@ApiStatus.Internal
|
||||
package com.falsepattern.lib.internal.asm.transformers;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
package com.falsepattern.lib.internal.config;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.config.Config;
|
||||
import com.falsepattern.lib.config.ConfigurationManager;
|
||||
import com.falsepattern.lib.internal.Tags;
|
||||
@@ -60,8 +59,8 @@ public class ConfigEngineConfig {
|
||||
}
|
||||
|
||||
public enum LoggingLevel {
|
||||
@StableAPI.Expose(since = "__INTERNAL__") None,
|
||||
@StableAPI.Expose(since = "__INTERNAL__") Log,
|
||||
@StableAPI.Expose(since = "__INTERNAL__") LogAndToast
|
||||
None,
|
||||
Log,
|
||||
LogAndToast
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
package com.falsepattern.lib.internal.config;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.Tags;
|
||||
import com.falsepattern.lib.internal.core.LowLevelCallMultiplexer;
|
||||
import com.google.gson.GsonBuilder;
|
||||
@@ -43,11 +42,9 @@ import java.nio.file.Files;
|
||||
@Accessors(fluent = true)
|
||||
public class EarlyConfig {
|
||||
@Expose
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
private boolean enableLibraryDownloads;
|
||||
|
||||
@Expose
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
private boolean enableLetsEncryptRoot;
|
||||
|
||||
private static volatile EarlyConfig instance = null;
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.internal.config;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.config.Config;
|
||||
import com.falsepattern.lib.config.ConfigurationManager;
|
||||
import com.falsepattern.lib.internal.Tags;
|
||||
@@ -65,7 +64,7 @@ public class ToastConfig {
|
||||
}
|
||||
|
||||
public enum Side {
|
||||
@StableAPI.Expose(since = "__INTERNAL__") Left,
|
||||
@StableAPI.Expose(since = "__INTERNAL__") Right
|
||||
Left,
|
||||
Right
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@ApiStatus.Internal
|
||||
package com.falsepattern.lib.internal.config;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@ApiStatus.Internal
|
||||
package com.falsepattern.lib.internal.core;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@ApiStatus.Internal
|
||||
package com.falsepattern.lib.internal.impl.config.event;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@ApiStatus.Internal
|
||||
package com.falsepattern.lib.internal.impl.config.fields;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@ApiStatus.Internal
|
||||
package com.falsepattern.lib.internal.impl.config.net;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@ApiStatus.Internal
|
||||
package com.falsepattern.lib.internal.impl.config;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
package com.falsepattern.lib.internal.impl.dependencies;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.google.gson.annotations.Expose;
|
||||
import lombok.Data;
|
||||
import lombok.experimental.Accessors;
|
||||
@@ -34,23 +33,18 @@ import java.util.List;
|
||||
public class DepRoot {
|
||||
private String source;
|
||||
@Expose
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
private List<String> repositories;
|
||||
@Expose
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
private Dependencies dependencies;
|
||||
|
||||
@Data
|
||||
@Accessors(fluent = true)
|
||||
public static class Dependencies {
|
||||
@Expose
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
private SidedDependencies always;
|
||||
@Expose
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
private SidedDependencies obf;
|
||||
@Expose
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
private SidedDependencies dev;
|
||||
}
|
||||
|
||||
@@ -58,13 +52,10 @@ public class DepRoot {
|
||||
@Accessors(fluent = true)
|
||||
public static class SidedDependencies {
|
||||
@Expose
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
private List<String> common;
|
||||
@Expose
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
private List<String> client;
|
||||
@Expose
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
private List<String> server;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@ApiStatus.Internal
|
||||
package com.falsepattern.lib.internal.impl.dependencies;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@ApiStatus.Internal
|
||||
package com.falsepattern.lib.internal.impl.mixin;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@ApiStatus.Internal
|
||||
package com.falsepattern.lib.internal.impl.optifine;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@ApiStatus.Internal
|
||||
package com.falsepattern.lib.internal.impl;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@ApiStatus.Internal
|
||||
package com.falsepattern.lib.internal.impl.toast;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@ApiStatus.Internal
|
||||
package com.falsepattern.lib.internal.logging;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@ApiStatus.Internal
|
||||
package com.falsepattern.lib.internal;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@ApiStatus.Internal
|
||||
package com.falsepattern.lib.internal.proxy;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
@ApiStatus.Internal
|
||||
package com.falsepattern.lib.internal.render;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.mapping;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.FPLog;
|
||||
import com.falsepattern.lib.internal.asm.CoreLoadingPlugin;
|
||||
import com.falsepattern.lib.mapping.storage.Lookup;
|
||||
@@ -39,7 +38,6 @@ import org.objectweb.asm.tree.MethodInsnNode;
|
||||
import java.util.HashMap;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public class MappingManager {
|
||||
private static Lookup<UniversalClass> internalLookup;
|
||||
private static Lookup<UniversalClass> regularLookup;
|
||||
@@ -117,7 +115,6 @@ public class MappingManager {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static UniversalClass classForName(NameType nameType, MappingType mappingType, String className)
|
||||
throws ClassNotFoundException {
|
||||
initialize();
|
||||
@@ -142,7 +139,6 @@ public class MappingManager {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static boolean containsClass(NameType nameType, MappingType mappingType, String className) {
|
||||
initialize();
|
||||
switch (nameType) {
|
||||
@@ -155,7 +151,6 @@ public class MappingManager {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static UniversalField getField(FieldInsnNode instruction)
|
||||
throws ClassNotFoundException, NoSuchFieldException {
|
||||
initialize();
|
||||
@@ -186,7 +181,6 @@ public class MappingManager {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static UniversalMethod getMethod(MethodInsnNode instruction)
|
||||
throws ClassNotFoundException, NoSuchMethodException {
|
||||
initialize();
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
package com.falsepattern.lib.mapping;
|
||||
@@ -21,12 +21,12 @@
|
||||
*/
|
||||
package com.falsepattern.lib.mapping.storage;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.mapping.types.MappingType;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.NonNull;
|
||||
import lombok.experimental.Accessors;
|
||||
import lombok.val;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@@ -36,7 +36,6 @@ import java.util.Set;
|
||||
|
||||
@Accessors(fluent = true)
|
||||
@EqualsAndHashCode
|
||||
@StableAPI(since = "0.10.0")
|
||||
public class Lookup<T> {
|
||||
private final Set<T> values = new HashSet<>();
|
||||
private final Map<String, T> notch = new HashMap<>();
|
||||
@@ -53,12 +52,10 @@ public class Lookup<T> {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public boolean contains(T value) {
|
||||
return values.contains(value);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public boolean containsKey(MappingType mappingType, String key) {
|
||||
switch (mappingType) {
|
||||
case Notch:
|
||||
@@ -72,7 +69,6 @@ public class Lookup<T> {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public void unwrap(@NonNull MappedString mappedString, @NonNull T value) {
|
||||
if (contains(value)) {
|
||||
//Collision avoidance.
|
||||
@@ -87,7 +83,6 @@ public class Lookup<T> {
|
||||
mcp.put(mappedString.mcp, value);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public T get(MappingType mappingType, String key) throws LookupException {
|
||||
T result;
|
||||
switch (mappingType) {
|
||||
@@ -109,8 +104,8 @@ public class Lookup<T> {
|
||||
return result;
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public static class LookupException extends Exception {
|
||||
@ApiStatus.Internal
|
||||
public LookupException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.mapping.storage;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.mapping.types.MappingType;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -38,32 +37,23 @@ import java.util.function.Function;
|
||||
@EqualsAndHashCode
|
||||
@Getter
|
||||
@RequiredArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public class MappedString {
|
||||
@StableAPI.Expose
|
||||
public final String notch;
|
||||
|
||||
@StableAPI.Expose
|
||||
public final String srg;
|
||||
|
||||
@StableAPI.Expose
|
||||
public final String mcp;
|
||||
|
||||
@StableAPI.Expose
|
||||
public MappedString(String[] source, int offset, int stride, Function<String, String> remapper, Map<String, String> stringPool) {
|
||||
notch = stringPool.computeIfAbsent(remapper.apply(source[offset]), (str) -> str);
|
||||
srg = stringPool.computeIfAbsent(remapper.apply(source[offset + stride]), (str) -> str);
|
||||
mcp = stringPool.computeIfAbsent(remapper.apply(source[offset + stride * 2]), (str) -> str);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static MappedString fuse(MappedString a, MappedString b, String delimiter, Map<String, String> stringPool) {
|
||||
return new MappedString(stringPool.computeIfAbsent(a.notch + delimiter + b.notch, (str) -> str),
|
||||
stringPool.computeIfAbsent(a.srg + delimiter + b.srg, (str) -> str),
|
||||
stringPool.computeIfAbsent(a.mcp + delimiter + b.mcp, (str) -> str));
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public String get(MappingType type) {
|
||||
switch (type) {
|
||||
case Notch:
|
||||
|
||||
@@ -21,11 +21,8 @@
|
||||
*/
|
||||
package com.falsepattern.lib.mapping.types;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public enum MappingType {
|
||||
@StableAPI.Expose Notch,
|
||||
@StableAPI.Expose SRG,
|
||||
@StableAPI.Expose MCP
|
||||
Notch,
|
||||
SRG,
|
||||
MCP
|
||||
}
|
||||
@@ -21,10 +21,7 @@
|
||||
*/
|
||||
package com.falsepattern.lib.mapping.types;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
public enum NameType {
|
||||
@StableAPI.Expose Internal,
|
||||
@StableAPI.Expose Regular
|
||||
Internal,
|
||||
Regular
|
||||
}
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.mapping.types;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.asm.CoreLoadingPlugin;
|
||||
import com.falsepattern.lib.mapping.storage.Lookup;
|
||||
import com.falsepattern.lib.mapping.storage.MappedString;
|
||||
@@ -35,13 +34,12 @@ import java.util.Map;
|
||||
@Accessors(fluent = true)
|
||||
@ToString(onlyExplicitlyIncluded = true)
|
||||
@EqualsAndHashCode(onlyExplicitlyIncluded = true)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public class UniversalClass {
|
||||
@Getter(onMethod_ = @StableAPI.Expose)
|
||||
@Getter
|
||||
@ToString.Include
|
||||
@EqualsAndHashCode.Include
|
||||
public final MappedString internalName;
|
||||
@Getter(onMethod_ = @StableAPI.Expose)
|
||||
@Getter
|
||||
@ToString.Include
|
||||
@EqualsAndHashCode.Include
|
||||
public final MappedString regularName;
|
||||
@@ -53,7 +51,6 @@ public class UniversalClass {
|
||||
@Getter
|
||||
private MappingType realClassMapping = null;
|
||||
|
||||
@StableAPI.Expose
|
||||
public UniversalClass(String[] names, Map<String, String> stringPool) {
|
||||
internalName = new MappedString(names, 0, 1, (str) -> str, stringPool);
|
||||
regularName = new MappedString(names, 0, 1, (str) -> str.replace('/', '.'), stringPool);
|
||||
@@ -73,7 +70,6 @@ public class UniversalClass {
|
||||
methods.unwrap(method.fusedNameDescriptor, method);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public Class<?> asJavaClass() throws ClassNotFoundException {
|
||||
if (javaClassCache != null) {
|
||||
return javaClassCache;
|
||||
@@ -98,7 +94,6 @@ public class UniversalClass {
|
||||
return javaClassCache;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public String getName(NameType nameType, MappingType mappingType) {
|
||||
switch (nameType) {
|
||||
case Internal:
|
||||
@@ -110,12 +105,10 @@ public class UniversalClass {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public String getNameAsDescriptor(MappingType mappingType) {
|
||||
return "L" + getName(NameType.Internal, mappingType) + ";";
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public UniversalField getField(MappingType mappingType, String fieldName) throws NoSuchFieldException {
|
||||
try {
|
||||
return fields.get(mappingType, fieldName);
|
||||
@@ -124,7 +117,6 @@ public class UniversalClass {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public UniversalMethod getMethod(MappingType mappingType, String methodName, String methodDescriptor)
|
||||
throws NoSuchMethodException {
|
||||
try {
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.mapping.types;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.ReflectionUtil;
|
||||
import com.falsepattern.lib.mapping.storage.MappedString;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -39,14 +38,13 @@ import java.util.Map;
|
||||
@Accessors(fluent = true)
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
@StableAPI(since = "0.10.0")
|
||||
public class UniversalField {
|
||||
@Getter(onMethod_ = @StableAPI.Expose)
|
||||
@Getter
|
||||
@ToString.Exclude
|
||||
@EqualsAndHashCode.Exclude
|
||||
public final UniversalClass parent;
|
||||
|
||||
@Getter(onMethod_ = @StableAPI.Expose)
|
||||
@Getter
|
||||
public final MappedString name;
|
||||
|
||||
private Field javaFieldCache = null;
|
||||
@@ -57,17 +55,14 @@ public class UniversalField {
|
||||
parent.addField(this);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static void createAndAddToParent(@NonNull UniversalClass parent, String[] names, Map<String, String> stringPool) {
|
||||
new UniversalField(parent, names, stringPool);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public String getName(MappingType mappingType) {
|
||||
return name.get(mappingType);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public Field asJavaField() throws ClassNotFoundException, NoSuchFieldException {
|
||||
if (javaFieldCache != null) {
|
||||
return javaFieldCache;
|
||||
@@ -83,13 +78,11 @@ public class UniversalField {
|
||||
* you don't need to manually handle exceptions.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@StableAPI.Expose
|
||||
public <T> T get(Object instance) throws NoSuchFieldException, ClassNotFoundException, IllegalAccessException {
|
||||
val field = asJavaField();
|
||||
return (T) field.get(instance);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public FieldInsnNode asInstruction(int opcode, MappingType mapping, String descriptor) {
|
||||
return new FieldInsnNode(opcode, parent.getName(NameType.Internal, mapping), getName(mapping), descriptor);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.mapping.types;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.ReflectionUtil;
|
||||
import com.falsepattern.lib.mapping.storage.MappedString;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -41,20 +40,19 @@ import java.util.Map;
|
||||
@Accessors(fluent = true)
|
||||
@ToString
|
||||
@EqualsAndHashCode
|
||||
@StableAPI(since = "0.10.0")
|
||||
public class UniversalMethod {
|
||||
@Getter(onMethod_ = @StableAPI.Expose)
|
||||
@Getter
|
||||
@ToString.Exclude
|
||||
@EqualsAndHashCode.Exclude
|
||||
public final UniversalClass parent;
|
||||
|
||||
@Getter(onMethod_ = @StableAPI.Expose)
|
||||
@Getter
|
||||
public final MappedString name;
|
||||
|
||||
@Getter(onMethod_ = @StableAPI.Expose)
|
||||
@Getter
|
||||
public final MappedString descriptor;
|
||||
|
||||
@Getter(onMethod_ = @StableAPI.Expose)
|
||||
@Getter
|
||||
public final MappedString fusedNameDescriptor;
|
||||
|
||||
private Method javaMethodCache = null;
|
||||
@@ -67,7 +65,6 @@ public class UniversalMethod {
|
||||
parent.addMethod(this);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static void createAndAddToParent(@NonNull UniversalClass parent, String[] names, Map<String, String> stringPool) {
|
||||
new UniversalMethod(parent, names, stringPool);
|
||||
}
|
||||
@@ -135,17 +132,14 @@ public class UniversalMethod {
|
||||
return result.toArray(new Class[0]);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public String getName(MappingType mappingType) {
|
||||
return name.get(mappingType);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public String getDescriptor(MappingType mappingType) {
|
||||
return descriptor.get(mappingType);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public Method asJavaMethod() throws ClassNotFoundException, NoSuchMethodException {
|
||||
if (javaMethodCache != null) {
|
||||
return javaMethodCache;
|
||||
@@ -163,18 +157,15 @@ public class UniversalMethod {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
@SneakyThrows
|
||||
@StableAPI.Expose
|
||||
public <T> T invoke(Object instance, Object... arguments) {
|
||||
val m = asJavaMethod();
|
||||
return (T) m.invoke(instance, arguments);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public <T> T invokeStatic(Object... arguments) {
|
||||
return invoke(null, arguments);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public MethodInsnNode asInstruction(int opcode, MappingType mapping, boolean itf) {
|
||||
return new MethodInsnNode(opcode,
|
||||
parent.getName(NameType.Internal, mapping),
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
package com.falsepattern.lib.mapping.types;
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.mixin;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import lombok.val;
|
||||
|
||||
import cpw.mods.fml.relauncher.FMLLaunchHandler;
|
||||
@@ -30,16 +29,9 @@ import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
@StableAPI(since = "0.8.0")
|
||||
public interface IMixin {
|
||||
|
||||
@StableAPI.Expose
|
||||
String getMixin();
|
||||
|
||||
@StableAPI.Expose
|
||||
Side getSide();
|
||||
|
||||
@StableAPI.Expose
|
||||
Predicate<List<ITargetedMod>> getFilter();
|
||||
|
||||
default boolean shouldLoad(List<ITargetedMod> loadedMods) {
|
||||
@@ -49,36 +41,35 @@ public interface IMixin {
|
||||
|| side == Side.CLIENT && FMLLaunchHandler.side().isClient()) && getFilter().test(loadedMods);
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
enum Side {
|
||||
@StableAPI.Expose COMMON,
|
||||
@StableAPI.Expose CLIENT,
|
||||
@StableAPI.Expose SERVER
|
||||
COMMON,
|
||||
CLIENT,
|
||||
SERVER
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.0")
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
final class PredicateHelpers {
|
||||
@StableAPI.Expose
|
||||
public static Predicate<List<ITargetedMod>> never() {
|
||||
return (list) -> false;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static Predicate<List<ITargetedMod>> condition(Supplier<Boolean> condition) {
|
||||
return (list) -> condition.get();
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static Predicate<List<ITargetedMod>> always() {
|
||||
return (list) -> true;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static Predicate<List<ITargetedMod>> require(ITargetedMod mod) {
|
||||
return (list) -> list.contains(mod);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static Predicate<List<ITargetedMod>> avoid(ITargetedMod mod) {
|
||||
return (list) -> !list.contains(mod);
|
||||
}
|
||||
|
||||
@@ -21,12 +21,11 @@
|
||||
*/
|
||||
package com.falsepattern.lib.mixin;
|
||||
|
||||
import com.falsepattern.lib.DeprecationDetails;
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.util.FileUtil;
|
||||
import lombok.val;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.spongepowered.asm.lib.tree.ClassNode;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinConfigPlugin;
|
||||
import org.spongepowered.asm.mixin.extensibility.IMixinInfo;
|
||||
@@ -47,19 +46,14 @@ import java.util.stream.Collectors;
|
||||
|
||||
import static java.nio.file.Files.walk;
|
||||
|
||||
@StableAPI(since = "0.8.0")
|
||||
public interface IMixinPlugin extends IMixinConfigPlugin {
|
||||
@StableAPI.Expose
|
||||
Path MODS_DIRECTORY_PATH = FileUtil.getMinecraftHome().toPath().resolve("mods");
|
||||
|
||||
@StableAPI.Expose
|
||||
static Logger createLogger(String modName) {
|
||||
return LogManager.getLogger(modName + " Mixin Loader");
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@DeprecationDetails(deprecatedSince = "1.4.0")
|
||||
@StableAPI.Expose
|
||||
@Deprecated(since = "1.4.0")
|
||||
static File findJarOf(final ITargetedMod mod) {
|
||||
File result = null;
|
||||
try (val stream = walk(MODS_DIRECTORY_PATH)) {
|
||||
@@ -85,7 +79,9 @@ public interface IMixinPlugin extends IMixinConfigPlugin {
|
||||
return result;
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "1.4.0")
|
||||
/**
|
||||
* @since 1.4.0
|
||||
*/
|
||||
static Set<File> findJarsOf(IMixinPlugin self, final ITargetedMod mod) {
|
||||
if (!self.useNewFindJar()) {
|
||||
val jar = findJarOf(mod);
|
||||
@@ -111,46 +107,45 @@ public interface IMixinPlugin extends IMixinConfigPlugin {
|
||||
return results;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
Logger getLogger();
|
||||
|
||||
@StableAPI.Expose
|
||||
IMixin[] getMixinEnumValues();
|
||||
|
||||
@StableAPI.Expose
|
||||
ITargetedMod[] getTargetedModEnumValues();
|
||||
|
||||
@StableAPI.Expose(since = "1.4.0")
|
||||
/**
|
||||
* @since 1.4.0
|
||||
*/
|
||||
default boolean useNewFindJar() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
@ApiStatus.Internal
|
||||
default void onLoad(String mixinPackage) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
@ApiStatus.Internal
|
||||
default String getRefMapperConfig() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
@ApiStatus.Internal
|
||||
default boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
@ApiStatus.Internal
|
||||
default void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
@ApiStatus.Internal
|
||||
default List<String> getMixins() {
|
||||
val isDevelopmentEnvironment = (boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment");
|
||||
val targetedMods = getTargetedModEnumValues();
|
||||
@@ -185,7 +180,7 @@ public interface IMixinPlugin extends IMixinConfigPlugin {
|
||||
return mixins;
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
@ApiStatus.Internal
|
||||
default boolean loadJarOf(final ITargetedMod mod) {
|
||||
try {
|
||||
val jars = findJarsOf(this, mod);
|
||||
@@ -207,14 +202,14 @@ public interface IMixinPlugin extends IMixinConfigPlugin {
|
||||
return true;
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
@Override
|
||||
@ApiStatus.Internal
|
||||
default void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "__INTERNAL__")
|
||||
@Override
|
||||
@ApiStatus.Internal
|
||||
default void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
|
||||
|
||||
}
|
||||
|
||||
@@ -21,23 +21,17 @@
|
||||
*/
|
||||
package com.falsepattern.lib.mixin;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.google.common.io.Files;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
@StableAPI(since = "0.8.0")
|
||||
public interface ITargetedMod {
|
||||
|
||||
@StableAPI.Expose
|
||||
String getModName();
|
||||
|
||||
@StableAPI.Expose
|
||||
boolean isLoadInDevelopment();
|
||||
|
||||
@SuppressWarnings("UnstableApiUsage")
|
||||
@StableAPI.Expose
|
||||
default boolean isMatchingJar(Path path) {
|
||||
String pathString = path.toString();
|
||||
String nameLowerCase = Files.getNameWithoutExtension(pathString).toLowerCase();
|
||||
@@ -46,22 +40,17 @@ public interface ITargetedMod {
|
||||
return "jar".equals(fileExtension) && getCondition().test(nameLowerCase);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
Predicate<String> getCondition();
|
||||
|
||||
@StableAPI(since = "0.5.0")
|
||||
final class PredicateHelpers {
|
||||
@StableAPI.Expose
|
||||
public static Predicate<String> startsWith(String subString) {
|
||||
return (name) -> name.startsWith(subString.toLowerCase());
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static Predicate<String> contains(String subString) {
|
||||
return (name) -> name.contains(subString.toLowerCase());
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static Predicate<String> matches(String regex) {
|
||||
return (name) -> name.matches(regex);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.mixin;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.impl.mixin.UCPImpl;
|
||||
import lombok.AccessLevel;
|
||||
import lombok.NoArgsConstructor;
|
||||
@@ -32,11 +31,11 @@ import java.io.File;
|
||||
* Backport from spongemixins 1.3 for compat with the curseforge 1.2.0 version.
|
||||
* <p>
|
||||
* Also added Grimoire protection.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@NoArgsConstructor(access = AccessLevel.PRIVATE)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public final class MinecraftURLClassPath {
|
||||
@StableAPI.Expose
|
||||
public static void addJar(File pathToJar) throws Exception {
|
||||
UCPImpl.addJar(pathToJar);
|
||||
}
|
||||
|
||||
@@ -22,8 +22,8 @@
|
||||
|
||||
package com.falsepattern.lib.mixin;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import lombok.val;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.spongepowered.asm.launch.MixinBootstrap;
|
||||
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
@@ -31,9 +31,10 @@ import net.minecraft.launchwrapper.Launch;
|
||||
import java.io.IOException;
|
||||
import java.util.Optional;
|
||||
|
||||
@StableAPI(since = "0.10.2")
|
||||
/**
|
||||
* @since 0.10.2
|
||||
*/
|
||||
public final class MixinInfo {
|
||||
@StableAPI.Expose
|
||||
public static final MixinBootstrapperType mixinBootstrapper;
|
||||
|
||||
static {
|
||||
@@ -41,12 +42,10 @@ public final class MixinInfo {
|
||||
mixinBootstrapper = detect();
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static boolean isMixinsInstalled() {
|
||||
return mixinBootstrapper != MixinBootstrapperType.None;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static boolean isOfficialSpongeMixins() {
|
||||
return (mixinBootstrapper == MixinBootstrapperType.SpongeMixins) && getVerUnsafe().equals("0.7.11");
|
||||
}
|
||||
@@ -54,37 +53,36 @@ public final class MixinInfo {
|
||||
/**
|
||||
* The nh fork of spongemixins breaks some stuff since 1.5.0.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static boolean isTamperedSpongeMixins() {
|
||||
return (mixinBootstrapper == MixinBootstrapperType.SpongeMixins) && getVerUnsafe().equals("0.7.12");
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static boolean isGrimoire() {
|
||||
return mixinBootstrapper == MixinBootstrapperType.Grimoire;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static boolean isMixinBooterLegacy() {
|
||||
return mixinBootstrapper == MixinBootstrapperType.MixinBooterLegacy;
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "0.10.14")
|
||||
/**
|
||||
* @since 0.10.14
|
||||
*/
|
||||
public static boolean isGasStation() {
|
||||
return mixinBootstrapper == MixinBootstrapperType.GasStation;
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "0.10.15")
|
||||
/**
|
||||
* @since 0.10.15
|
||||
*/
|
||||
public static boolean isUniMixin() {
|
||||
return mixinBootstrapper == MixinBootstrapperType.UniMixin;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static MixinBootstrapperType bootstrapperType() {
|
||||
return mixinBootstrapper;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static Optional<String> mixinVersion() {
|
||||
return mixinBootstrapper != MixinBootstrapperType.None ? Optional.of(getVerUnsafe()) : Optional.empty();
|
||||
}
|
||||
@@ -93,6 +91,7 @@ public final class MixinInfo {
|
||||
return MixinBootstrap.VERSION;
|
||||
}
|
||||
|
||||
@ApiStatus.Internal
|
||||
public static boolean isClassPresentSafe(String clazz) {
|
||||
try {
|
||||
val bytes = Launch.classLoader.getClassBytes(clazz);
|
||||
@@ -130,14 +129,18 @@ public final class MixinInfo {
|
||||
return MixinBootstrapperType.Other;
|
||||
}
|
||||
|
||||
@StableAPI(since = "0.10.2")
|
||||
/**
|
||||
* @since 0.10.2
|
||||
*/
|
||||
public enum MixinBootstrapperType {
|
||||
@StableAPI.Expose None,
|
||||
@StableAPI.Expose(since = "0.10.9") GasStation,
|
||||
@StableAPI.Expose SpongeMixins,
|
||||
@StableAPI.Expose Grimoire,
|
||||
@StableAPI.Expose MixinBooterLegacy,
|
||||
@StableAPI.Expose Other,
|
||||
@StableAPI.Expose(since = "0.10.15") UniMixin
|
||||
None,
|
||||
/** @since 0.10.9 */
|
||||
GasStation,
|
||||
SpongeMixins,
|
||||
Grimoire,
|
||||
MixinBooterLegacy,
|
||||
Other,
|
||||
/** @since 0.10.15 */
|
||||
UniMixin
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
package com.falsepattern.lib.mixin;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -32,20 +31,20 @@ import java.util.List;
|
||||
/**
|
||||
* This is a class you can use to interact with MixinInfo before it gets classloaded.
|
||||
* (Originally placed here for future unimixins compat in case they change the class names)
|
||||
*
|
||||
* @since 0.10.15
|
||||
*/
|
||||
@StableAPI(since = "0.10.15")
|
||||
public class MixinInfoCompatCompanion {
|
||||
/**
|
||||
* A list of all mixin classes that are candidates for unimixins.
|
||||
* This is used to determine if a mixin plugin is unimixins. Once MixinInfo is classloaded, this list has no effect.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static final List<String> UNIMIXIN_CANDIDATES = new ArrayList<>(Arrays.asList(
|
||||
"io.github.legacymoddingmc.unimixins.compat.CompatCore",
|
||||
"io.github.legacymoddingmc.unimixins.devcompat.DevCompatCore",
|
||||
"io.github.legacymoddingmc.unimixins.all.AllCore",
|
||||
"io.github.legacymoddingmc.unimixins.mixin.MixinModule"));
|
||||
|
||||
@Getter(onMethod_ = @StableAPI.Expose)
|
||||
@Getter
|
||||
static boolean mixinInfoClassLoaded = false;
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since 0.8.0
|
||||
*/
|
||||
package com.falsepattern.lib.mixin;
|
||||
@@ -22,7 +22,6 @@
|
||||
|
||||
package com.falsepattern.lib.optifine;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.impl.optifine.OptiFineTransformerHooksImpl;
|
||||
|
||||
/**
|
||||
@@ -30,10 +29,10 @@ import com.falsepattern.lib.internal.impl.optifine.OptiFineTransformerHooksImpl;
|
||||
* If you have a mod that injects code that would otherwise conflict with OptiFine, and you have provably tested that
|
||||
* removing certain OptiFine patches from the jar does NOT break anything, you may use this class to disable them
|
||||
* without having to do jar file edits.
|
||||
*
|
||||
* @since 1.0.0
|
||||
*/
|
||||
@StableAPI(since = "1.0.0")
|
||||
public class OptiFineTransformerHooks {
|
||||
@StableAPI.Expose
|
||||
public static void disableOptiFinePatch(String patchName) {
|
||||
OptiFineTransformerHooksImpl.disableOptiFinePatch(patchName);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.text;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import lombok.NonNull;
|
||||
import lombok.val;
|
||||
|
||||
@@ -52,8 +51,9 @@ import java.util.function.Consumer;
|
||||
|
||||
/**
|
||||
* Universal escape sequence-based text rendering and chat messages.
|
||||
*
|
||||
* @since 0.6.0
|
||||
*/
|
||||
@StableAPI(since = "0.6.0")
|
||||
public final class FormattedText {
|
||||
private static final Map<Character, EnumChatFormatting> reverseMap = new HashMap<>();
|
||||
private static final Map<EnumChatFormatting, Color> colorMap = new HashMap<>();
|
||||
@@ -149,7 +149,6 @@ public final class FormattedText {
|
||||
*
|
||||
* @return The parsed text structure
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static FormattedText parse(String text) {
|
||||
EnumChatFormatting currentColorStyle = EnumChatFormatting.WHITE;
|
||||
val currentFancyStyle = new HashSet<EnumChatFormatting>();
|
||||
@@ -199,7 +198,6 @@ public final class FormattedText {
|
||||
return result;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public void addChatMessage(ICommandSender target) {
|
||||
addChatMessage(target::addChatMessage);
|
||||
}
|
||||
@@ -216,7 +214,6 @@ public final class FormattedText {
|
||||
*
|
||||
* @return The chat component.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public List<ChatComponentText> toChatText() {
|
||||
var thisComponent = toChatTextSingle();
|
||||
val result = new ArrayList<ChatComponentText>();
|
||||
@@ -264,33 +261,27 @@ public final class FormattedText {
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI.Expose
|
||||
public void addChatMessage(EntityOtherPlayerMP target) {
|
||||
addChatMessage(target::addChatMessage);
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI.Expose
|
||||
public void addChatMessage(EntityPlayerSP target) {
|
||||
addChatMessage(target::addChatMessage);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public void addChatMessage(CommandBlockLogic target) {
|
||||
addChatMessage(target::addChatMessage);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public void addChatMessage(EntityPlayerMP target) {
|
||||
addChatMessage(target::addChatMessage);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public void addChatMessage(RConConsoleSource target) {
|
||||
addChatMessage(target::addChatMessage);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public void addChatMessage(MinecraftServer target) {
|
||||
addChatMessage(target::addChatMessage);
|
||||
}
|
||||
@@ -303,7 +294,6 @@ public final class FormattedText {
|
||||
* @param y Top side
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI.Expose
|
||||
public void draw(FontRenderer renderer, int x, int y) {
|
||||
draw(renderer, x, y, false);
|
||||
}
|
||||
@@ -317,7 +307,6 @@ public final class FormattedText {
|
||||
* @param shadow Whether to have drop shadow under the text
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI.Expose
|
||||
public void draw(FontRenderer renderer, int x, int y, boolean shadow) {
|
||||
int startX = x;
|
||||
x = renderer.drawString(text, x, y, colorMap.get(colorStyle).getRGB(), shadow);
|
||||
@@ -342,7 +331,6 @@ public final class FormattedText {
|
||||
* @param y Top side
|
||||
*/
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI.Expose
|
||||
public void drawWithShadow(FontRenderer renderer, int x, int y) {
|
||||
draw(renderer, x, y, true);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.toasts;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.impl.toast.GuiToastImpl;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
@@ -30,20 +29,16 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public class GuiToast {
|
||||
@Nullable
|
||||
@StableAPI.Expose
|
||||
public static <T extends IToast> T getToast(Class<? extends T> toastClass, Object type) {
|
||||
return GuiToastImpl.getInstance().getToast(toastClass, type);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static void clear() {
|
||||
GuiToastImpl.getInstance().clear();
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static void add(IToast toastIn) {
|
||||
GuiToastImpl.getInstance().add(toastIn);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.toasts;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.Tags;
|
||||
import com.falsepattern.lib.internal.impl.toast.GuiToastImpl;
|
||||
|
||||
@@ -32,27 +31,20 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public interface IToast {
|
||||
@StableAPI.Expose
|
||||
Object NO_TOKEN = new Object();
|
||||
|
||||
@StableAPI.Expose
|
||||
Visibility draw(GuiToastImpl toastGui, long delta);
|
||||
|
||||
@StableAPI.Expose
|
||||
int width();
|
||||
|
||||
@StableAPI.Expose
|
||||
int height();
|
||||
|
||||
@StableAPI.Expose
|
||||
default Object getType() {
|
||||
return NO_TOKEN;
|
||||
}
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
enum Visibility {
|
||||
SHOW(new ResourceLocation(Tags.MODID, "ui.toast.in")),
|
||||
HIDE(new ResourceLocation(Tags.MODID, "ui.toast.out"));
|
||||
@@ -63,7 +55,6 @@ public interface IToast {
|
||||
this.sound = soundIn;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public void playSound(SoundHandler handler) {
|
||||
handler.playSound(PositionedSoundRecord.func_147674_a(this.sound, 1.0F));
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.toasts;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.impl.toast.GuiToastImpl;
|
||||
import com.falsepattern.lib.toasts.icon.ToastBG;
|
||||
import com.falsepattern.lib.toasts.icon.ToastIcon;
|
||||
@@ -38,7 +37,6 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public class SimpleToast implements IToast {
|
||||
private final ToastBG background;
|
||||
private final ToastIcon icon;
|
||||
@@ -51,7 +49,6 @@ public class SimpleToast implements IToast {
|
||||
private float displayedProgress;
|
||||
private float currentProgress;
|
||||
|
||||
@StableAPI.Expose
|
||||
public SimpleToast(@NonNull ToastBG background,
|
||||
@Nullable ToastIcon icon, IChatComponent titleComponent,
|
||||
@Nullable IChatComponent subtitleComponent, boolean drawProgressBar, long timeout) {
|
||||
@@ -117,12 +114,10 @@ public class SimpleToast implements IToast {
|
||||
return background.getIcon().getIconHeight();
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public void hide() {
|
||||
visibility = IToast.Visibility.HIDE;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public void setProgress(float progress) {
|
||||
this.currentProgress = progress;
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.toasts.icon;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.Tags;
|
||||
import lombok.NonNull;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
@@ -34,40 +33,30 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public class ToastBG extends ToastTexture {
|
||||
@StableAPI.Expose
|
||||
public static final ToastBG TOAST_DARK =
|
||||
new ToastBG(new ResourceLocation(Tags.MODID, "textures/gui/toast_dark.png"), 160, 32, 0xFFFFFFFF);
|
||||
@StableAPI.Expose
|
||||
public static final ToastBG TOAST_DARK_ROUNDED =
|
||||
new ToastBG(new ResourceLocation(Tags.MODID, "textures/gui/toast_dark_rounded.png"), 160, 32, 0xFFFFFFFF);
|
||||
@StableAPI.Expose
|
||||
public static final ToastBG TOAST_NARRATOR =
|
||||
new ToastBG(new ResourceLocation(Tags.MODID, "textures/gui/toast_narrator.png"), 160, 32, 0xFFAAAA00);
|
||||
@StableAPI.Expose
|
||||
public static final ToastBG TOAST_NARRATOR_ROUNDED =
|
||||
new ToastBG(new ResourceLocation(Tags.MODID, "textures/gui/toast_narrator_rounded.png"),
|
||||
160,
|
||||
32,
|
||||
0xFFAAAA00);
|
||||
@StableAPI.Expose
|
||||
public static final ToastBG TOAST_WHITE =
|
||||
new ToastBG(new ResourceLocation(Tags.MODID, "textures/gui/toast_white.png"), 160, 32, 0xFF500050);
|
||||
@StableAPI.Expose
|
||||
public static final ToastBG TOAST_WHITE_ROUNDED =
|
||||
new ToastBG(new ResourceLocation(Tags.MODID, "textures/gui/toast_white_rounded.png"), 160, 32, 0xFF500050);
|
||||
|
||||
@StableAPI.Expose
|
||||
public final int defaultTextColor;
|
||||
|
||||
@StableAPI.Expose
|
||||
public ToastBG(@NonNull ResourceLocation texture, int width, int height, int defaultTextColor) {
|
||||
super(texture, width, height);
|
||||
this.defaultTextColor = defaultTextColor;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public ToastBG(@NonNull ResourceLocation texture, @NonNull IIcon icon, int defaultTextColor) {
|
||||
super(texture, icon);
|
||||
this.defaultTextColor = defaultTextColor;
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.toasts.icon;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import lombok.NonNull;
|
||||
import org.lwjgl.opengl.GL11;
|
||||
|
||||
@@ -33,14 +32,11 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public class ToastIcon extends ToastTexture {
|
||||
@StableAPI.Expose
|
||||
public ToastIcon(@NonNull ResourceLocation texture, int width, int height) {
|
||||
super(texture, width, height);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public ToastIcon(@NonNull ResourceLocation texture, @NonNull IIcon icon) {
|
||||
super(texture, icon);
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.toasts.icon;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.util.RenderUtil;
|
||||
import lombok.Getter;
|
||||
import lombok.NonNull;
|
||||
@@ -33,19 +32,16 @@ import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
|
||||
@SideOnly(Side.CLIENT)
|
||||
@StableAPI(since = "0.10.0")
|
||||
public abstract class ToastTexture {
|
||||
@Getter(onMethod_ = @StableAPI.Expose)
|
||||
@Getter
|
||||
protected final IIcon icon;
|
||||
@Getter(onMethod_ = @StableAPI.Expose)
|
||||
@Getter
|
||||
protected final ResourceLocation texture;
|
||||
|
||||
@StableAPI.Expose
|
||||
public ToastTexture(@NonNull ResourceLocation texture, int width, int height) {
|
||||
this(texture, RenderUtil.getFullTextureIcon(texture.toString(), width, height));
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public ToastTexture(@NonNull ResourceLocation texture, @NonNull IIcon icon) {
|
||||
this.icon = icon;
|
||||
this.texture = texture;
|
||||
@@ -54,6 +50,5 @@ public abstract class ToastTexture {
|
||||
/**
|
||||
* Draws the icon at the specified position in the specified Gui
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public abstract void draw(Gui guiIn, int x, int y);
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
package com.falsepattern.lib.toasts.icon;
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
package com.falsepattern.lib.toasts;
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
package com.falsepattern.lib.turboasm;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.StableAPI.Expose;
|
||||
import org.jetbrains.annotations.Contract;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -36,42 +34,28 @@ import java.io.IOException;
|
||||
/**
|
||||
* Utilities for quickly processing class files without fully parsing them.
|
||||
*/
|
||||
@StableAPI(since = "__EXPERIMENTAL__")
|
||||
public final class ClassHeaderMetadata implements FastClassAccessor {
|
||||
|
||||
@Expose
|
||||
public final int minorVersion;
|
||||
@Expose
|
||||
public final int majorVersion;
|
||||
@Expose
|
||||
public final int constantPoolEntryCount;
|
||||
/** Byte offsets of where each constant pool entry starts (index of the tag byte), zero-indexed! */
|
||||
@Expose
|
||||
public final int @NotNull [] constantPoolEntryOffsets;
|
||||
/** Type of each parsed constant pool entry, zero-indexed! */
|
||||
@Expose
|
||||
public final ConstantPoolEntryTypes @NotNull [] constantPoolEntryTypes;
|
||||
|
||||
@Expose
|
||||
public final int constantPoolEndOffset;
|
||||
@Expose
|
||||
public final int accessFlags;
|
||||
@Expose
|
||||
public final int thisClassIndex;
|
||||
@Expose
|
||||
public final int superClassIndex;
|
||||
@Expose
|
||||
public final int interfacesCount;
|
||||
@Expose
|
||||
public final @NotNull String binaryThisName;
|
||||
@Expose
|
||||
public final @Nullable String binarySuperName;
|
||||
|
||||
/**
|
||||
* Attempts to parse a class header.
|
||||
* @param bytes The class bytes to parse.
|
||||
*/
|
||||
@Expose
|
||||
public ClassHeaderMetadata(byte @NotNull [] bytes) {
|
||||
if (!isValidClass(bytes)) {
|
||||
throw new IllegalArgumentException("Invalid class detected");
|
||||
@@ -143,7 +127,6 @@ public final class ClassHeaderMetadata implements FastClassAccessor {
|
||||
* @param off Offset to the 16-bit length field.
|
||||
* @return The decoded String.
|
||||
*/
|
||||
@Expose
|
||||
public static @NotNull String modifiedUtf8(byte @NotNull [] arr, int off) {
|
||||
try (ByteArrayInputStream bais = new ByteArrayInputStream(arr, off, arr.length - off);
|
||||
DataInputStream dis = new DataInputStream(bais)) {
|
||||
@@ -174,85 +157,57 @@ public final class ClassHeaderMetadata implements FastClassAccessor {
|
||||
* attribute_info attributes[attributes_count];
|
||||
* }
|
||||
*/
|
||||
@StableAPI(since = "__EXPERIMENTAL__")
|
||||
public static final class Offsets {
|
||||
private Offsets() {}
|
||||
/** The magic item supplies the magic number identifying the class file format; it has the value 0xCAFEBABE */
|
||||
@Expose
|
||||
public static final int magicU32 = 0;
|
||||
/** The values of the minor_version and major_version items are the minor and major version numbers of this class file. Together, a major and a minor version number determine the version of the class file format. If a class file has major version number M and minor version number m, we denote the version of its class file format as M.m */
|
||||
@Expose
|
||||
public static final int minorVersionU16 = magicU32 + 4;
|
||||
/** The values of the minor_version and major_version items are the minor and major version numbers of this class file. Together, a major and a minor version number determine the version of the class file format. If a class file has major version number M and minor version number m, we denote the version of its class file format as M.m */
|
||||
@Expose
|
||||
public static final int majorVersionU16 = minorVersionU16 + 2;
|
||||
/** The value of the constant_pool_count item is equal to the number of entries in the constant_pool table plus one. A constant_pool index is considered valid if it is greater than zero and less than constant_pool_count, with the exception for constants of type long and double noted in §4.4.5. */
|
||||
@Expose
|
||||
public static final int constantPoolCountU16 = majorVersionU16 + 2;
|
||||
/**
|
||||
* The constant_pool is a table of structures (§4.4) representing various string constants, class and interface names, field names, and other constants that are referred to within the ClassFile structure and its substructures. The format of each constant_pool table entry is indicated by its first "tag" byte.
|
||||
* <p>
|
||||
* The constant_pool table is indexed from 1 to constant_pool_count - 1.
|
||||
*/
|
||||
@Expose
|
||||
public static final int constantPoolStart = constantPoolCountU16 + 2;
|
||||
/**
|
||||
* The value of the access_flags item is a mask of flags used to denote access permissions to and properties of this class or interface. The interpretation of each flag, when set, is specified in Table 4.1-B.
|
||||
*/
|
||||
@Expose
|
||||
public static final int pastCpAccessFlagsU16 = 0;
|
||||
/**
|
||||
* The value of the this_class item must be a valid index into the constant_pool table. The constant_pool entry at that index must be a CONSTANT_Class_info structure (§4.4.1) representing the class or interface defined by this class file.
|
||||
*/
|
||||
@Expose
|
||||
public static final int pastCpThisClassU16 = pastCpAccessFlagsU16 + 2;
|
||||
/**
|
||||
* For a class, the value of the super_class item either must be zero or must be a valid index into the constant_pool table. If the value of the super_class item is nonzero, the constant_pool entry at that index must be a CONSTANT_Class_info structure representing the direct superclass of the class defined by this class file. Neither the direct superclass nor any of its superclasses may have the ACC_FINAL flag set in the access_flags item of its ClassFile structure. <p>
|
||||
* If the value of the super_class item is zero, then this class file must represent the class Object, the only class or interface without a direct superclass. <p>
|
||||
* For an interface, the value of the super_class item must always be a valid index into the constant_pool table. The constant_pool entry at that index must be a CONSTANT_Class_info structure representing the class Object.
|
||||
*/
|
||||
@Expose
|
||||
public static final int pastCpSuperClassU16 = pastCpThisClassU16 + 2;
|
||||
/** The value of the interfaces_count item gives the number of direct superinterfaces of this class or interface type */
|
||||
@Expose
|
||||
public static final int pastCpInterfacesCountU16 = pastCpSuperClassU16 + 2;
|
||||
}
|
||||
|
||||
@StableAPI(since = "__EXPERIMENTAL__")
|
||||
public enum ConstantPoolEntryTypes {
|
||||
@Expose
|
||||
Utf8(1, 45, -1),
|
||||
@Expose
|
||||
Integer(3, 45, 4),
|
||||
@Expose
|
||||
Float(4, 45, 4),
|
||||
@Expose
|
||||
Long(5, 45, 8),
|
||||
@Expose
|
||||
Double(6, 45, 8),
|
||||
@Expose
|
||||
Class(7, 49, 2),
|
||||
@Expose
|
||||
String(8, 45, 2),
|
||||
@Expose
|
||||
FieldRef(9, 45, 4),
|
||||
@Expose
|
||||
MethodRef(10, 45, 4),
|
||||
@Expose
|
||||
InterfaceMethodRef(11, 45, 4),
|
||||
@Expose
|
||||
NameAndType(12, 45, 4),
|
||||
@Expose
|
||||
MethodHandle(15, 51, 3),
|
||||
@Expose
|
||||
MethodType(16, 51, 2),
|
||||
@Expose
|
||||
Dynamic(17, 55, 4),
|
||||
@Expose
|
||||
InvokeDynamic(18, 51, 4),
|
||||
@Expose
|
||||
Module(19, 53, 2),
|
||||
@Expose
|
||||
Package(20, 53, 2),
|
||||
;
|
||||
private static final ConstantPoolEntryTypes[] lookup;
|
||||
@@ -267,10 +222,8 @@ public final class ClassHeaderMetadata implements FastClassAccessor {
|
||||
lookup = lut;
|
||||
}
|
||||
|
||||
@Expose
|
||||
public final int tag, minMajorVersion;
|
||||
/** Length in bytes of the entry (excluding the 1 byte tag), or -1 if length-encoded */
|
||||
@Expose
|
||||
public final int maybeByteLength;
|
||||
|
||||
ConstantPoolEntryTypes(int tag, int minMajorVersion, int maybeByteLength) {
|
||||
@@ -284,7 +237,6 @@ public final class ClassHeaderMetadata implements FastClassAccessor {
|
||||
* @param offset The offset where the entry starts
|
||||
* @return The total length of the entry, including the tag byte
|
||||
*/
|
||||
@Expose
|
||||
public int byteLength(final byte @NotNull [] classFile, final int offset) {
|
||||
if (this == ConstantPoolEntryTypes.Utf8) {
|
||||
return 3 + u16(classFile, offset + 1);
|
||||
@@ -295,7 +247,6 @@ public final class ClassHeaderMetadata implements FastClassAccessor {
|
||||
return 1 + maybeByteLength;
|
||||
}
|
||||
|
||||
@Expose
|
||||
public static @NotNull ConstantPoolEntryTypes parse(final byte @NotNull [] classFile, final int offset) {
|
||||
final int tag = u8(classFile, offset);
|
||||
final ConstantPoolEntryTypes type = tag >= lookup.length ? null : lookup[tag];
|
||||
@@ -312,7 +263,6 @@ public final class ClassHeaderMetadata implements FastClassAccessor {
|
||||
* @return If the class passes simple sanity checks.
|
||||
*/
|
||||
@Contract("null -> false")
|
||||
@Expose
|
||||
public static boolean isValidClass(byte @Nullable [] classBytes) {
|
||||
if (classBytes == null) {
|
||||
return false;
|
||||
@@ -329,7 +279,6 @@ public final class ClassHeaderMetadata implements FastClassAccessor {
|
||||
* @param classBytes Class data
|
||||
* @return The major version number of the class file. See {@link org.objectweb.asm.Opcodes#V1_8}
|
||||
*/
|
||||
@Expose
|
||||
public static int majorVersion(byte @NotNull [] classBytes) {
|
||||
return u16(classBytes, Offsets.majorVersionU16);
|
||||
}
|
||||
@@ -340,7 +289,6 @@ public final class ClassHeaderMetadata implements FastClassAccessor {
|
||||
* @param substring The short substring to search for.
|
||||
* @return If the substring was found somewhere in the long string.
|
||||
*/
|
||||
@Expose
|
||||
public static boolean hasSubstring(final byte @Nullable [] classBytes, final byte @NotNull [] substring) {
|
||||
if (classBytes == null) {
|
||||
return false;
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
package com.falsepattern.lib.turboasm;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.StableAPI.Expose;
|
||||
import org.intellij.lang.annotations.MagicConstant;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.objectweb.asm.ClassReader;
|
||||
@@ -31,7 +29,6 @@ import org.objectweb.asm.ClassWriter;
|
||||
import org.objectweb.asm.tree.ClassNode;
|
||||
|
||||
/** A simple handle to a mutable ClassNode and flags for ClassWriter. */
|
||||
@StableAPI(since = "__EXPERIMENTAL__")
|
||||
public final class ClassNodeHandle {
|
||||
private final byte @Nullable [] originalBytes;
|
||||
private final @Nullable ClassHeaderMetadata originalMetadata;
|
||||
@@ -42,13 +39,11 @@ public final class ClassNodeHandle {
|
||||
private int writerFlags = 0;
|
||||
|
||||
/** Parse the class data with no reader options (for fastest speed). */
|
||||
@Expose
|
||||
public ClassNodeHandle(byte @Nullable [] classData) {
|
||||
this(classData, 0);
|
||||
}
|
||||
|
||||
/** Parse the class data with custom reader options. */
|
||||
@Expose
|
||||
public ClassNodeHandle(
|
||||
byte @Nullable [] classData, @MagicConstant(flagsFromClass = ClassReader.class) int readerOptions) {
|
||||
@Nullable ClassHeaderMetadata originalMetadata;
|
||||
@@ -68,31 +63,26 @@ public final class ClassNodeHandle {
|
||||
}
|
||||
|
||||
/** Gets the original pre-transformer-phase bytes of the class. */
|
||||
@Expose
|
||||
public byte @Nullable [] getOriginalBytes() {
|
||||
return originalBytes;
|
||||
}
|
||||
|
||||
/** Gets the original pre-transformer-phase header metadata of the class, or null if invalid/not present. */
|
||||
@Expose
|
||||
public @Nullable ClassHeaderMetadata getOriginalMetadata() {
|
||||
return originalMetadata;
|
||||
}
|
||||
|
||||
/** Gets the fast class metadata accessor of the class, that can access the current state of various class attributes without (re)parsing. */
|
||||
@Expose
|
||||
public @Nullable FastClassAccessor getFastAccessor() {
|
||||
return accessor;
|
||||
}
|
||||
|
||||
/** @return If the class was not yet turned into a ClassNode object, and the original bytes still represent the class. */
|
||||
@Expose
|
||||
public boolean isOriginal() {
|
||||
return !initialized;
|
||||
}
|
||||
|
||||
/** If the class currently has any bytes or a node associated with it. */
|
||||
@Expose
|
||||
public boolean isPresent() {
|
||||
if (initialized) {
|
||||
return node != null;
|
||||
@@ -102,14 +92,12 @@ public final class ClassNodeHandle {
|
||||
}
|
||||
|
||||
/** Gets the parsed node of the currently processed class. This can cause full class parsing! */
|
||||
@Expose
|
||||
public @Nullable ClassNode getNode() {
|
||||
ensureInitialized();
|
||||
return node;
|
||||
}
|
||||
|
||||
/** Overwrites the parsed node of the currently processed class. */
|
||||
@Expose
|
||||
public void setNode(@Nullable ClassNode node) {
|
||||
initialized = true;
|
||||
this.node = node;
|
||||
@@ -121,7 +109,6 @@ public final class ClassNodeHandle {
|
||||
}
|
||||
|
||||
/** Computes the byte[] array of the transformed class. Returns the original bytes if {@link ClassNodeHandle#getNode()} was never called. */
|
||||
@Expose
|
||||
public byte @Nullable [] computeBytes() {
|
||||
if (!initialized) {
|
||||
return originalBytes;
|
||||
@@ -135,31 +122,26 @@ public final class ClassNodeHandle {
|
||||
}
|
||||
|
||||
/** Gets the ClassWriter flags for the current class. */
|
||||
@Expose
|
||||
public int getWriterFlags() {
|
||||
return writerFlags;
|
||||
}
|
||||
|
||||
/** Set the ClassWriter flags for the current class. */
|
||||
@Expose
|
||||
public void setWriterFlags(@MagicConstant(flagsFromClass = ClassWriter.class) int flags) {
|
||||
this.writerFlags = flags;
|
||||
}
|
||||
|
||||
/** Combine the currently set writer flags with the given flags using bitwise OR. */
|
||||
@Expose
|
||||
public void orWriterFlags(@MagicConstant(flagsFromClass = ClassWriter.class) int flags) {
|
||||
this.writerFlags |= flags;
|
||||
}
|
||||
|
||||
/** Set ClassWriter.COMPUTE_MAXS on the writer flags. */
|
||||
@Expose
|
||||
public void computeMaxs() {
|
||||
this.writerFlags |= ClassWriter.COMPUTE_MAXS;
|
||||
}
|
||||
|
||||
/** Set ClassWriter.COMPUTE_FRAMES on the writer flags. */
|
||||
@Expose
|
||||
public void computeFrames() {
|
||||
this.writerFlags |= ClassWriter.COMPUTE_FRAMES;
|
||||
}
|
||||
|
||||
@@ -22,8 +22,6 @@
|
||||
|
||||
package com.falsepattern.lib.turboasm;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.StableAPI.Expose;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.objectweb.asm.Opcodes;
|
||||
@@ -32,49 +30,36 @@ import org.objectweb.asm.tree.ClassNode;
|
||||
import java.lang.reflect.Modifier;
|
||||
|
||||
/** An accessor to metadata about a class that is quickly accessible without fully parsing one. */
|
||||
@StableAPI(since = "__EXPERIMENTAL__")
|
||||
public interface FastClassAccessor {
|
||||
/** Accessible from outside its package */
|
||||
@Expose
|
||||
boolean isPublic();
|
||||
/** No subclasses allowed */
|
||||
@Expose
|
||||
boolean isFinal();
|
||||
/** Is an interface instead of a class */
|
||||
@Expose
|
||||
boolean isInterface();
|
||||
/** Is an abstract class that should not be instantiated */
|
||||
@Expose
|
||||
boolean isAbstract();
|
||||
/** Is not present in source code (often used by obfuscated code too) */
|
||||
@Expose
|
||||
boolean isSynthetic();
|
||||
/** Is an annotation interface */
|
||||
@Expose
|
||||
boolean isAnnotation();
|
||||
/** Is an enum class */
|
||||
@Expose
|
||||
boolean isEnum();
|
||||
/** Binary (slash-separated packages) name of the class */
|
||||
@NotNull
|
||||
@Expose
|
||||
String binaryThisName();
|
||||
/** Binary (slash-separated packages) name of the super-class, null for the Object class */
|
||||
@Nullable
|
||||
@Expose
|
||||
String binarySuperName();
|
||||
|
||||
@Expose
|
||||
static OfLoaded ofLoaded(Class<?> loadedClass) {
|
||||
return new OfLoaded(loadedClass);
|
||||
}
|
||||
|
||||
@Expose
|
||||
static OfAsmNode ofAsmNode(ClassNode handle) {
|
||||
return new OfAsmNode(handle);
|
||||
}
|
||||
|
||||
@StableAPI(since = "__EXPERIMENTAL__")
|
||||
final class OfAsmNode implements FastClassAccessor {
|
||||
public final ClassNode handle;
|
||||
|
||||
@@ -128,7 +113,6 @@ public interface FastClassAccessor {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI(since = "__EXPERIMENTAL__")
|
||||
final class OfLoaded implements FastClassAccessor {
|
||||
public final Class<?> handle;
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.turboasm;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.asm.CoreLoadingPlugin;
|
||||
import lombok.val;
|
||||
|
||||
@@ -30,7 +29,6 @@ import net.minecraft.launchwrapper.IClassTransformer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@StableAPI(since = "__EXPERIMENTAL__")
|
||||
public class MergeableTurboTransformer implements IClassTransformer {
|
||||
private final List<TurboClassTransformer> transformers;
|
||||
|
||||
|
||||
@@ -26,9 +26,11 @@ import com.falsepattern.lib.internal.Tags;
|
||||
import lombok.val;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ApiStatus.Internal
|
||||
public class TransformerUtil {
|
||||
private static final boolean DEBUG_VERBOSE_TRANSFORMERS = Boolean.parseBoolean(System.getProperty(Tags.MODID + ".debug.verboseTransformers", "false"));
|
||||
private static final Logger LOG = LogManager.getLogger("ASM");
|
||||
|
||||
@@ -22,26 +22,21 @@
|
||||
|
||||
package com.falsepattern.lib.turboasm;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.StableAPI.Expose;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* A simple transformer that takes in class bytes and outputs different class bytes.
|
||||
* It should be thread-safe, and not change class names. It should also have a public no-arguments constructor.
|
||||
*/
|
||||
@StableAPI(since = "__EXPERIMENTAL__")
|
||||
public interface TurboClassTransformer {
|
||||
/**
|
||||
* @return The user-friendly owner name of this transformer. Usually a mod id.
|
||||
*/
|
||||
@Expose
|
||||
String owner();
|
||||
|
||||
/**
|
||||
* @return The user-friendly name of this transformer. Used in logs.
|
||||
*/
|
||||
@Expose
|
||||
String name();
|
||||
|
||||
/**
|
||||
@@ -50,7 +45,6 @@ public interface TurboClassTransformer {
|
||||
* @param classNode The handle to the class data and parsed metadata, try to avoid triggering the lazy ASM parse if possible for performance.
|
||||
* @return true if the class will be transformed by this class transformer.
|
||||
*/
|
||||
@Expose
|
||||
boolean shouldTransformClass(@NotNull String className, @NotNull ClassNodeHandle classNode);
|
||||
|
||||
/**
|
||||
@@ -60,6 +54,5 @@ public interface TurboClassTransformer {
|
||||
* @return True if the class has been modified in any way by this transformer. If all transformers return false,
|
||||
* then the ClassNode instance will not be re-serialized.
|
||||
*/
|
||||
@Expose
|
||||
boolean transformClass(@NotNull String className, @NotNull ClassNodeHandle classNode);
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* This file is part of FalsePatternLib.
|
||||
*
|
||||
* Copyright (C) 2022-2025 FalsePattern
|
||||
* All Rights Reserved
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included
|
||||
* in all copies or substantial portions of the Software.
|
||||
*
|
||||
* FalsePatternLib is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License as published by
|
||||
* the Free Software Foundation, only version 3 of the License.
|
||||
*
|
||||
* FalsePatternLib is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with FalsePatternLib. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
@ApiStatus.Experimental
|
||||
package com.falsepattern.lib.turboasm;
|
||||
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.util;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import net.minecraft.launchwrapper.Launch;
|
||||
@@ -30,15 +29,18 @@ import java.io.File;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
|
||||
/**
|
||||
* @since 0.8.2
|
||||
*/
|
||||
@UtilityClass
|
||||
@StableAPI(since = "0.8.2")
|
||||
public final class FileUtil {
|
||||
@StableAPI.Expose
|
||||
public static File getMinecraftHome() {
|
||||
return getMinecraftHomePath().toFile();
|
||||
}
|
||||
|
||||
@StableAPI.Expose(since = "1.0.0")
|
||||
/**
|
||||
* @since 1.0.0
|
||||
*/
|
||||
public static Path getMinecraftHomePath() {
|
||||
return Launch.minecraftHome == null ? Paths.get("").toAbsolutePath() : Launch.minecraftHome.toPath();
|
||||
}
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.util;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import lombok.NonNull;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import lombok.val;
|
||||
@@ -31,19 +30,18 @@ import cpw.mods.fml.common.registry.LanguageRegistry;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @since 0.8.0
|
||||
*/
|
||||
@UtilityClass
|
||||
@StableAPI(since = "0.8.0")
|
||||
public final class LangUtil {
|
||||
@StableAPI.Expose
|
||||
public static final String DEFAULT_LOCALE = "en_US";
|
||||
private static final ThreadLocal<HashMap<String, String>> tempMap = ThreadLocal.withInitial(HashMap::new);
|
||||
|
||||
@StableAPI.Expose
|
||||
public static void defaultLocalization(@NonNull Map<String, String> localeMap) {
|
||||
localeMap.forEach(LangUtil::defaultLocalization);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static void defaultLocalization(@NonNull String key, @NonNull String value) {
|
||||
if (!LanguageRegistry.instance().getStringLocalization(key, DEFAULT_LOCALE).isEmpty()) {
|
||||
return;
|
||||
|
||||
@@ -21,17 +21,17 @@
|
||||
*/
|
||||
package com.falsepattern.lib.util;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.compat.Vec3i;
|
||||
import lombok.experimental.UtilityClass;
|
||||
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@UtilityClass
|
||||
@StableAPI(since = "0.10.0")
|
||||
public final class MathUtil {
|
||||
@StableAPI.Expose
|
||||
public static final float SQRT_2 = sqrt(2.0F);
|
||||
/**
|
||||
* A table of sin values computed from 0 (inclusive) to 2*pi (exclusive), with steps of 2*PI / 65536.
|
||||
@@ -73,7 +73,6 @@ public final class MathUtil {
|
||||
/**
|
||||
* sin looked up in a table
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static float sin(float value) {
|
||||
return SIN_TABLE[(int) (value * 10430.378F) & 65535];
|
||||
}
|
||||
@@ -81,18 +80,14 @@ public final class MathUtil {
|
||||
/**
|
||||
* cos looked up in the sin table with the appropriate offset
|
||||
*/
|
||||
|
||||
@StableAPI.Expose
|
||||
public static float cos(float value) {
|
||||
return SIN_TABLE[(int) (value * 10430.378F + 16384.0F) & 65535];
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static float sqrt(float value) {
|
||||
return (float) Math.sqrt(value);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static float sqrt(double value) {
|
||||
return (float) Math.sqrt(value);
|
||||
}
|
||||
@@ -100,16 +95,14 @@ public final class MathUtil {
|
||||
/**
|
||||
* Returns the greatest integer less than or equal to the float argument
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static int floor(float value) {
|
||||
int i = (int) value;
|
||||
return value < (float) i ? i - 1 : i;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns par0 cast as an int, and no greater than Integer.MAX_VALUE-1024
|
||||
* returns value cast as an int, and no greater than Integer.MAX_VALUE-1024
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static int fastFloor(double value) {
|
||||
return (int) (value + 1024.0D) - 1024;
|
||||
}
|
||||
@@ -117,7 +110,6 @@ public final class MathUtil {
|
||||
/**
|
||||
* Returns the greatest integer less than or equal to the double argument
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static int floor(double value) {
|
||||
int i = (int) value;
|
||||
return value < (double) i ? i - 1 : i;
|
||||
@@ -126,18 +118,15 @@ public final class MathUtil {
|
||||
/**
|
||||
* Long version of floor()
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static long lfloor(double value) {
|
||||
long i = (long) value;
|
||||
return value < (double) i ? i - 1L : i;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static int absFloor(double value) {
|
||||
return (int) (value >= 0.0D ? value : -value + 1.0D);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static float abs(float value) {
|
||||
return value >= 0.0F ? value : -value;
|
||||
}
|
||||
@@ -145,18 +134,15 @@ public final class MathUtil {
|
||||
/**
|
||||
* Returns the unsigned value of an int.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static int abs(int value) {
|
||||
return value >= 0 ? value : -value;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static int ceil(float value) {
|
||||
int i = (int) value;
|
||||
return value > (float) i ? i + 1 : i;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static int ceil(double value) {
|
||||
int i = (int) value;
|
||||
return value > (double) i ? i + 1 : i;
|
||||
@@ -166,7 +152,6 @@ public final class MathUtil {
|
||||
* Returns the value of the first parameter, clamped to be within the lower and upper limits given by the second and
|
||||
* third parameters.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static int clamp(int num, int min, int max) {
|
||||
return num < min ? min : Math.min(num, max);
|
||||
}
|
||||
@@ -175,17 +160,14 @@ public final class MathUtil {
|
||||
* Returns the value of the first parameter, clamped to be within the lower and upper limits given by the second and
|
||||
* third parameters
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static float clamp(float num, float min, float max) {
|
||||
return num < min ? min : Math.min(num, max);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static double clamp(double num, double min, double max) {
|
||||
return num < min ? min : Math.min(num, max);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static double clampedLerp(double lowerBnd, double upperBnd, double slide) {
|
||||
if (slide < 0.0D) {
|
||||
return lowerBnd;
|
||||
@@ -197,7 +179,6 @@ public final class MathUtil {
|
||||
/**
|
||||
* Maximum of the absolute value of two numbers.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static double absMax(double a, double b) {
|
||||
if (a < 0.0D) {
|
||||
a = -a;
|
||||
@@ -213,27 +194,22 @@ public final class MathUtil {
|
||||
/**
|
||||
* Buckets an integer with specified bucket sizes.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static int intFloorDiv(int number, int bucket) {
|
||||
return number < 0 ? -((-number - 1) / bucket) - 1 : number / bucket;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static int getInt(Random random, int minimum, int maximum) {
|
||||
return minimum >= maximum ? minimum : random.nextInt(maximum - minimum + 1) + minimum;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static float nextFloat(Random random, float minimum, float maximum) {
|
||||
return minimum >= maximum ? minimum : random.nextFloat() * (maximum - minimum) + minimum;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static double nextDouble(Random random, double minimum, double maximum) {
|
||||
return minimum >= maximum ? minimum : random.nextDouble() * (maximum - minimum) + minimum;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static double average(long[] values) {
|
||||
long i = 0L;
|
||||
|
||||
@@ -244,22 +220,18 @@ public final class MathUtil {
|
||||
return (double) i / (double) values.length;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static boolean epsilonEquals(float a, float b) {
|
||||
return abs(b - a) < 1.0E-5F;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static int normalizeAngle(int a, int b) {
|
||||
return (a % b + b) % b;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static float positiveModulo(float numerator, float denominator) {
|
||||
return (numerator % denominator + denominator) % denominator;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static double positiveModulo(double numerator, double denominator) {
|
||||
return (numerator % denominator + denominator) % denominator;
|
||||
}
|
||||
@@ -267,7 +239,6 @@ public final class MathUtil {
|
||||
/**
|
||||
* the angle is reduced to an angle between -180 and +180 by mod, and a 360 check
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static float wrapDegrees(float value) {
|
||||
value = value % 360.0F;
|
||||
|
||||
@@ -285,7 +256,6 @@ public final class MathUtil {
|
||||
/**
|
||||
* the angle is reduced to an angle between -180 and +180 by mod, and a 360 check
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static double wrapDegrees(double value) {
|
||||
value = value % 360.0D;
|
||||
|
||||
@@ -303,7 +273,6 @@ public final class MathUtil {
|
||||
/**
|
||||
* Adjust the angle so that his value is in range [-180;180[
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static int wrapDegrees(int angle) {
|
||||
angle = angle % 360;
|
||||
|
||||
@@ -321,7 +290,6 @@ public final class MathUtil {
|
||||
/**
|
||||
* parses the string as integer or returns the second parameter if it fails
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static int getInt(String value, int defaultValue) {
|
||||
try {
|
||||
return Integer.parseInt(value);
|
||||
@@ -333,7 +301,6 @@ public final class MathUtil {
|
||||
/**
|
||||
* parses the string as integer or returns the second parameter if it fails. this value is capped to par2
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static int getInt(String value, int defaultValue, int max) {
|
||||
return Math.max(max, getInt(value, defaultValue));
|
||||
}
|
||||
@@ -341,7 +308,6 @@ public final class MathUtil {
|
||||
/**
|
||||
* parses the string as double or returns the second parameter if it fails.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static double getDouble(String value, double defaultValue) {
|
||||
try {
|
||||
return Double.parseDouble(value);
|
||||
@@ -350,7 +316,6 @@ public final class MathUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static double getDouble(String value, double defaultValue, double max) {
|
||||
return Math.max(max, getDouble(value, defaultValue));
|
||||
}
|
||||
@@ -358,7 +323,6 @@ public final class MathUtil {
|
||||
/**
|
||||
* Returns the input value rounded up to the next highest power of two.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static int smallestEncompassingPowerOfTwo(int value) {
|
||||
int i = value - 1;
|
||||
i = i | i >> 1;
|
||||
@@ -372,7 +336,6 @@ public final class MathUtil {
|
||||
/**
|
||||
* Is the given value a power of two? (1, 2, 4, 8, 16, ...)
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
private static boolean isPowerOfTwo(int value) {
|
||||
return value != 0 && (value & value - 1) == 0;
|
||||
}
|
||||
@@ -382,7 +345,6 @@ public final class MathUtil {
|
||||
* value. Optimized for cases where the input value is a power-of-two. If the input value is not a power-of-two,
|
||||
* then subtract 1 from the return value.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static int log2DeBruijn(int value) {
|
||||
value = isPowerOfTwo(value) ? value : smallestEncompassingPowerOfTwo(value);
|
||||
return MULTIPLY_DE_BRUIJN_BIT_POSITION[(int) ((long) value * 125613361L >> 27) & 31];
|
||||
@@ -392,7 +354,6 @@ public final class MathUtil {
|
||||
* Efficiently calculates the floor of the base-2 log of an integer value. This is effectively the index of the
|
||||
* highest bit that is set. For example, if the number in binary is 0...100101, this will return 5.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static int log2(int value) {
|
||||
return log2DeBruijn(value) - (isPowerOfTwo(value) ? 0 : 1);
|
||||
}
|
||||
@@ -403,7 +364,6 @@ public final class MathUtil {
|
||||
* For instance, {@code roundUp(1, 4)} returns 4; {@code roundUp(0, 4)} returns 0; and {@code roundUp(4, 4)} returns
|
||||
* 4.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static int roundUp(int number, int interval) {
|
||||
if (interval == 0) {
|
||||
return 0;
|
||||
@@ -419,7 +379,6 @@ public final class MathUtil {
|
||||
}
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static long getCoordinateRandom(int x, int y, int z) {
|
||||
long i = (x * 3129871L) ^ (long) z * 116129781L ^ (long) y;
|
||||
i = i * i * 42317861L + i * 11L;
|
||||
@@ -429,7 +388,6 @@ public final class MathUtil {
|
||||
/**
|
||||
* Makes an integer color from the given red, green, and blue float values
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static int rgb(float rIn, float gIn, float bIn) {
|
||||
return rgb(floor(rIn * 255.0F), floor(gIn * 255.0F), floor(bIn * 255.0F));
|
||||
}
|
||||
@@ -437,14 +395,12 @@ public final class MathUtil {
|
||||
/**
|
||||
* Makes a single int color with the given red, green, and blue values.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static int rgb(int rIn, int gIn, int bIn) {
|
||||
int lvt_3_1_ = (rIn << 8) + gIn;
|
||||
lvt_3_1_ = (lvt_3_1_ << 8) + bIn;
|
||||
return lvt_3_1_;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static int multiplyColor(int colorA, int colorB) {
|
||||
int rA = (colorA & 0xFF0000) >> 16;
|
||||
int rB = (colorB & 0xFF0000) >> 16;
|
||||
@@ -461,17 +417,14 @@ public final class MathUtil {
|
||||
/**
|
||||
* Gets the decimal portion of the given double. For instance, {@code frac(5.5)} returns {@code .5}.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static double frac(double number) {
|
||||
return number - Math.floor(number);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static long getPositionRandom(Vec3i pos) {
|
||||
return getCoordinateRandom(pos.getX(), pos.getY(), pos.getZ());
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static UUID getRandomUUID(Random rand) {
|
||||
long i = rand.nextLong() & -61441L | 16384L;
|
||||
long j = rand.nextLong() & 4611686018427387903L | Long.MIN_VALUE;
|
||||
@@ -481,17 +434,14 @@ public final class MathUtil {
|
||||
/**
|
||||
* Generates a random UUID using the shared random
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static UUID getRandomUUID() {
|
||||
return getRandomUUID(RANDOM);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static double pct(double a, double b, double c) {
|
||||
return (a - b) / (c - b);
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static double atan2(double y, double x) {
|
||||
double d0 = x * x + y * y;
|
||||
|
||||
@@ -551,7 +501,6 @@ public final class MathUtil {
|
||||
* Computes 1/sqrt(n) using <a href="https://en.wikipedia.org/wiki/Fast_inverse_square_root">the fast inverse square
|
||||
* root</a> with a constant of 0x5FE6EB50C7B537AA.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static double fastInvSqrt(double x) {
|
||||
double d0 = 0.5D * x;
|
||||
long i = Double.doubleToRawLongBits(x);
|
||||
@@ -561,7 +510,6 @@ public final class MathUtil {
|
||||
return x;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static int hsvToRGB(float hue, float saturation, float value) {
|
||||
int i = (int) (hue * 6.0F) % 6;
|
||||
float f = hue * 6.0F - (float) i;
|
||||
@@ -618,7 +566,6 @@ public final class MathUtil {
|
||||
return j << 16 | k << 8 | l;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
public static int hash(int x) {
|
||||
x = x ^ x >>> 16;
|
||||
x = x * -2048144789;
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.util;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.Tags;
|
||||
import com.falsepattern.lib.internal.render.ClampedIcon;
|
||||
import com.falsepattern.lib.internal.render.FullTextureIcon;
|
||||
@@ -41,9 +40,11 @@ import cpw.mods.fml.relauncher.SideOnly;
|
||||
import static cpw.mods.fml.relauncher.Side.CLIENT;
|
||||
import static net.minecraft.client.Minecraft.getMinecraft;
|
||||
|
||||
/**
|
||||
* @since 0.8.0
|
||||
*/
|
||||
@SideOnly(CLIENT)
|
||||
@UtilityClass
|
||||
@StableAPI(since = "0.8.0")
|
||||
public final class RenderUtil {
|
||||
private static final Timer MINECRAFT_TIMER = getMinecraftTimer();
|
||||
private static final ResourceLocation EMPTY_TEXTURE = new ResourceLocation(Tags.MODID, "textures/empty_texture.png");
|
||||
@@ -54,8 +55,9 @@ public final class RenderUtil {
|
||||
* This is useful for rendering things that are not part of the world mesh, but should be rendered as if they were.
|
||||
* <p>
|
||||
* It's good practice to make this call inside a {@link GL11#glPushMatrix() push}/{@link GL11#glPopMatrix() pop} matrix block.
|
||||
*
|
||||
* @since 0.12.0
|
||||
*/
|
||||
@StableAPI.Expose(since = "0.12.0")
|
||||
public static void setGLTranslationRelativeToPlayer() {
|
||||
val player = getMinecraft().thePlayer;
|
||||
val partialTick = partialTick();
|
||||
@@ -77,8 +79,9 @@ public final class RenderUtil {
|
||||
* @param height The icon height in pixels
|
||||
*
|
||||
* @return The full resolution texture icon.
|
||||
*
|
||||
* @since 0.10.0
|
||||
*/
|
||||
@StableAPI.Expose(since = "0.10.0")
|
||||
public static IIcon getFullTextureIcon(String iconName, int width, int height) {
|
||||
return new FullTextureIcon(iconName, width, height);
|
||||
}
|
||||
@@ -91,8 +94,9 @@ public final class RenderUtil {
|
||||
* This is helpful when using {@link RenderBlocks} but having different bounds.
|
||||
*
|
||||
* @param icon The icon to clamp
|
||||
*
|
||||
* @since 0.12.0
|
||||
*/
|
||||
@StableAPI.Expose(since = "0.12.0")
|
||||
public static IIcon wrapAsClampedIcon(IIcon icon) {
|
||||
return new ClampedIcon(icon);
|
||||
}
|
||||
@@ -104,8 +108,9 @@ public final class RenderUtil {
|
||||
* is sufficient to achieve the same effect.
|
||||
* <p>
|
||||
* However, when shaders are enabled, disabling textures using this method will have no effect. Therefore this method can be used as a workaround.
|
||||
*
|
||||
* @since 1.3.0
|
||||
*/
|
||||
@StableAPI.Expose(since = "1.3.0")
|
||||
public static void bindEmptyTexture() {
|
||||
getMinecraft().renderEngine.bindTexture(EMPTY_TEXTURE);
|
||||
}
|
||||
@@ -117,12 +122,10 @@ public final class RenderUtil {
|
||||
*
|
||||
* @return The current partial tick
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static float partialTick() {
|
||||
return MINECRAFT_TIMER.renderPartialTicks;
|
||||
}
|
||||
|
||||
@StableAPI.Expose
|
||||
@SneakyThrows
|
||||
private static Timer getMinecraftTimer() {
|
||||
val timerField = ReflectionHelper.findField(Minecraft.class, "timer", "field_71428_T");
|
||||
|
||||
@@ -21,7 +21,6 @@
|
||||
*/
|
||||
package com.falsepattern.lib.util;
|
||||
|
||||
import com.falsepattern.lib.StableAPI;
|
||||
import com.falsepattern.lib.internal.FPLog;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import lombok.val;
|
||||
@@ -36,9 +35,10 @@ import java.nio.charset.StandardCharsets;
|
||||
|
||||
/**
|
||||
* A utility class for reading resources in many ways.
|
||||
*
|
||||
* @since 0.6.0
|
||||
*/
|
||||
@UtilityClass
|
||||
@StableAPI(since = "0.6.0")
|
||||
public final class ResourceUtil {
|
||||
|
||||
/**
|
||||
@@ -52,7 +52,6 @@ public final class ResourceUtil {
|
||||
*
|
||||
* @throws IOException From {@link #readBytes(InputStream)}
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static String getResourceStringFromJar(String resourcePath, Class<?> referenceClass) throws IOException {
|
||||
return getResourceStringFromJar(resourcePath, referenceClass, StandardCharsets.UTF_8);
|
||||
}
|
||||
@@ -69,7 +68,6 @@ public final class ResourceUtil {
|
||||
*
|
||||
* @throws IOException From {@link #readBytes(InputStream)}
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static String getResourceStringFromJar(String resourcePath, Class<?> referenceClass, Charset charset)
|
||||
throws IOException {
|
||||
return new String(getResourceBytesFromJar(resourcePath, referenceClass), charset);
|
||||
@@ -85,7 +83,6 @@ public final class ResourceUtil {
|
||||
*
|
||||
* @throws IOException From {@link #readBytes(InputStream)}
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static byte[] getResourceBytesFromJar(String resourcePath, Class<?> referenceClass) throws IOException {
|
||||
return readBytesSafe(getResourceFromJar(resourcePath, referenceClass), resourcePath);
|
||||
}
|
||||
@@ -107,7 +104,6 @@ public final class ResourceUtil {
|
||||
*
|
||||
* @return The resource, or null if it was not found.
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static InputStream getResourceFromJar(String resourcePath, Class<?> referenceClass) {
|
||||
URL classFile = referenceClass.getResource('/' + referenceClass.getName().replace('.', '/') + ".class");
|
||||
lookup:
|
||||
@@ -145,7 +141,6 @@ public final class ResourceUtil {
|
||||
*
|
||||
* @throws IOException From {@link InputStream#read(byte[])}
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static byte[] readBytes(InputStream stream) throws IOException {
|
||||
val out = new ByteArrayOutputStream();
|
||||
val buf = new byte[4096];
|
||||
@@ -165,7 +160,6 @@ public final class ResourceUtil {
|
||||
*
|
||||
* @throws IOException From {@link #readBytes(InputStream)}
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static String getResourceString(String resourcePath) throws IOException {
|
||||
return getResourceString(resourcePath, StandardCharsets.UTF_8);
|
||||
}
|
||||
@@ -180,7 +174,6 @@ public final class ResourceUtil {
|
||||
*
|
||||
* @throws IOException From {@link #readBytes(InputStream)}
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static String getResourceString(String resourcePath, Charset charset) throws IOException {
|
||||
return new String(getResourceBytes(resourcePath), charset);
|
||||
}
|
||||
@@ -194,7 +187,6 @@ public final class ResourceUtil {
|
||||
*
|
||||
* @throws IOException From {@link #readBytes(InputStream)}
|
||||
*/
|
||||
@StableAPI.Expose
|
||||
public static byte[] getResourceBytes(String resourcePath) throws IOException {
|
||||
return readBytesSafe(ResourceUtil.class.getResourceAsStream(resourcePath), resourcePath);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user