4 Commits
Author SHA1 Message Date
FalsePattern 643e0e2881 update buildscript and gradle 2025-06-25 02:34:07 +02:00
FalsePattern 090d58f18f remove fplib dep 2025-06-25 02:32:44 +02:00
FalsePattern 31060c07c5 replace fplib StableAPI with jetbrains annotations 2025-06-25 02:30:11 +02:00
FalsePattern a9081e049b shadow in fplib mixin helper 2025-06-25 02:25:49 +02:00
25 changed files with 704 additions and 75 deletions

No files matched your search

+1 -10
View File
@@ -1,5 +1,5 @@
plugins {
id("com.falsepattern.fpgradle-mc") version("0.17.1")
id("com.falsepattern.fpgradle-mc") version("0.18.0")
}
group = "com.falsepattern"
@@ -37,27 +37,18 @@ minecraft_fp {
}
curseforge {
projectId = "844484"
dependencies {
required("fplib")
}
}
modrinth {
projectId = "y0vBUOla"
dependencies {
required("fplib")
}
}
}
}
repositories {
cursemavenEX()
exclusive(maven("mavenpattern", "https://mvn.falsepattern.com/releases/"), "com.falsepattern")
}
dependencies {
apiSplit("com.falsepattern:falsepatternlib-mc1.7.10:1.5.9")
//LookingGlass 0.2.0.01
compileOnly(deobfCurse("lookingglass-230541:2321557"))
}
+1 -1
View File
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14.2-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
@@ -22,7 +22,7 @@
package com.falsepattern.chunk.api;
import com.falsepattern.lib.StableAPI;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import net.minecraft.world.chunk.NibbleArray;
@@ -33,11 +33,13 @@ import java.util.Arrays;
* This is an API class covered by the additional permissions in the license.
* <p>
* Miscellaneous utilities for in-place array transfer (where possible).
* @version 0.5.0
* @since 0.5.0
*/
@StableAPI(since = "0.5.0")
@ApiStatus.NonExtendable
@SuppressWarnings("DuplicatedCode")
public class ArrayUtil {
@StableAPI.Expose
@Contract(value = "null, _ -> null;" +
"!null, null -> new;",
mutates = "param2")
@@ -52,7 +54,6 @@ public class ArrayUtil {
return dst;
}
@StableAPI.Expose
@Contract(value = "null, _ -> null;" +
"!null, null -> new;",
mutates = "param2")
@@ -67,7 +68,6 @@ public class ArrayUtil {
return dst;
}
@StableAPI.Expose
@Contract(value = "null, _ -> null;" +
"!null, null -> new;",
mutates = "param2")
@@ -82,7 +82,6 @@ public class ArrayUtil {
return dst;
}
@StableAPI.Expose
@Contract(value = "null, _ -> null;" +
"!null, null -> new;",
mutates = "param2")
@@ -97,7 +96,6 @@ public class ArrayUtil {
return dst;
}
@StableAPI.Expose
@Contract(value = "null, _ -> null;" +
"!null, null -> new;",
mutates = "param2")
@@ -112,7 +110,6 @@ public class ArrayUtil {
return dst;
}
@StableAPI.Expose
@Contract(value = "null, _ -> null;" +
"!null, null -> new;",
mutates = "param2")
@@ -127,7 +124,6 @@ public class ArrayUtil {
return dst;
}
@StableAPI.Expose
@Contract(value = "null, _ -> null;" +
"!null, null -> new;",
mutates = "param2")
@@ -142,7 +138,6 @@ public class ArrayUtil {
return dst;
}
@StableAPI.Expose
@Contract(value = "null, _ -> null;" +
"!null, null -> new;",
mutates = "param2")
@@ -157,7 +152,6 @@ public class ArrayUtil {
return dst;
}
@StableAPI.Expose
@Contract(value = "null, _ -> null;" +
"!null, null -> new;",
mutates = "param2")
@@ -172,7 +166,6 @@ public class ArrayUtil {
return dst;
}
@StableAPI.Expose
@Contract(value = "null, _ -> null;" +
"!null, null -> new;",
mutates = "param2")
@@ -22,7 +22,6 @@
package com.falsepattern.chunk.api;
import com.falsepattern.lib.StableAPI;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
@@ -51,20 +50,17 @@ import java.nio.ByteBuffer;
* @see DataRegistry
* @since 0.5.0
*/
@StableAPI(since = "0.5.0")
public interface DataManager {
/**
* @return The domain of this manager. Usually the modid of the mod that owns this manager.
*/
@StableAPI.Expose
@Contract(pure = true)
String domain();
/**
* @return The id of this manager. Usually the name of the manager. Unique per domain.
*/
@StableAPI.Expose
@Contract(pure = true)
String id();
@@ -72,10 +68,8 @@ public interface DataManager {
* Implement this interface if you want to synchronize your data with the client.
*
* @author FalsePattern
* @version 0.5.0
* @since 0.5.0
*/
@StableAPI(since = "0.5.0")
interface PacketDataManager extends DataManager {
/**
* @return The maximum amount of bytes your data can take up in a packet.
@@ -83,7 +77,6 @@ public interface DataManager {
* @implSpec This is used to determine the size of the packet compression/decompression buffer.
* Only called ONCE, during registration!
*/
@StableAPI.Expose
@Contract(pure = true)
int maxPacketSize();
@@ -93,7 +86,6 @@ public interface DataManager {
* @param chunk The chunk to serialize.
*/
@Contract(mutates = "param4")
@StableAPI.Expose
void writeToBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer buffer);
/**
@@ -103,7 +95,6 @@ public interface DataManager {
* @param buffer The packet buffer to read from.
*/
@Contract(mutates = "param1,param4")
@StableAPI.Expose
void readFromBuffer(Chunk chunk, int subChunkMask, boolean forceUpdate, ByteBuffer buffer);
}
@@ -115,28 +106,23 @@ public interface DataManager {
* @version 0.6.0
* @since 0.6.0
*/
@StableAPI(since = "0.6.0")
interface BlockPacketDataManager extends DataManager {
@Contract(mutates = "param1")
@StableAPI.Expose
void writeBlockToPacket(Chunk chunk, int x, int y, int z, S23PacketBlockChange packet);
@Contract(mutates = "param1,param5")
@StableAPI.Expose
void readBlockFromPacket(Chunk chunk, int x, int y, int z, S23PacketBlockChange packet);
/**
* Serializes your block data into a buffer.
*/
@Contract(mutates = "param2")
@StableAPI.Expose
void writeBlockPacketToBuffer(S23PacketBlockChange packet, PacketBuffer buffer) throws IOException;
/**
* Deserializes your block data from a buffer.
*/
@Contract(mutates = "param1,param2")
@StableAPI.Expose
void readBlockPacketFromBuffer(S23PacketBlockChange packet, PacketBuffer buffer) throws IOException;
}
@@ -148,12 +134,10 @@ public interface DataManager {
* @version 0.5.0
* @since 0.5.0
*/
@StableAPI(since = "0.5.0")
interface StorageDataManager extends DataManager {
/**
* @return The current version of the data manager
*/
@StableAPI.Expose
@Contract(pure = true)
@NotNull String version();
@@ -161,7 +145,6 @@ public interface DataManager {
* @return The message to show to users when a world is opened with this mod for the first time.
* Return null to show no message, and treat the manager as fully compatible with vanilla.
*/
@StableAPI.Expose
@Contract(pure = true)
@Nullable String newInstallDescription();
@@ -169,7 +152,6 @@ public interface DataManager {
* @return The message to show to users when this manager is removed, AND they try to load the world (stored in the
* world's NBT during previous saves)
*/
@StableAPI.Expose
@Contract(pure = true)
@NotNull String uninstallMessage();
@@ -179,7 +161,6 @@ public interface DataManager {
* @return A warning message to show to the user when upgrading.\
* If null, the manager is treated as fully compatible with the old version, and no warning is shown.
*/
@StableAPI.Expose
@Contract(pure = true)
@Nullable String versionChangeMessage(String priorVersion);
}
@@ -191,7 +172,6 @@ public interface DataManager {
* @version 0.5.0
* @since 0.5.0
*/
@StableAPI(since = "0.5.0")
interface ChunkDataManager extends StorageDataManager {
/**
* If false, the given nbt compound will be a freshly created object that gets inserted into the actual
@@ -201,7 +181,6 @@ public interface DataManager {
*
* @implNote This is used internally for reimplementing the vanilla logic. Only change this if you know what you're doing.
*/
@StableAPI.Expose
@Contract(pure = true)
default boolean chunkPrivilegedAccess() {
return false;
@@ -211,7 +190,6 @@ public interface DataManager {
* Serializes your data into an NBT tag. This is used when saving the chunk to disk.
*/
@Contract(mutates = "param2")
@StableAPI.Expose
void writeChunkToNBT(Chunk chunk, NBTTagCompound nbt);
@@ -222,7 +200,6 @@ public interface DataManager {
* In this case, you should initialize the data to a sane default.
*/
@Contract(mutates = "param1")
@StableAPI.Expose
void readChunkFromNBT(Chunk chunk, NBTTagCompound nbt);
/**
@@ -232,7 +209,6 @@ public interface DataManager {
* @param to The chunk to copy data to.
*/
@Contract(mutates = "param2")
@StableAPI.Expose
void cloneChunk(Chunk from, Chunk to);
}
@@ -244,7 +220,6 @@ public interface DataManager {
* @version 0.5.0
* @since 0.5.0
*/
@StableAPI(since = "0.5.0")
interface SubChunkDataManager extends StorageDataManager {
/**
* If false, the given nbt compound will be a freshly created object that gets inserted into the actual
@@ -254,7 +229,6 @@ public interface DataManager {
*
* @implNote This is used internally for reimplementing the vanilla logic. Only change this if you know what you're doing.
*/
@StableAPI.Expose
@Contract(pure = true)
default boolean subChunkPrivilegedAccess() {
return false;
@@ -264,7 +238,6 @@ public interface DataManager {
* Serializes your data into an NBT tag. This is used when saving the chunk to disk.
*/
@Contract(mutates = "param3")
@StableAPI.Expose
void writeSubChunkToNBT(Chunk chunk, ExtendedBlockStorage subChunk, NBTTagCompound nbt);
/**
@@ -274,7 +247,6 @@ public interface DataManager {
* In this case, you should initialize the data to a sane default.
*/
@Contract(mutates = "param2")
@StableAPI.Expose
void readSubChunkFromNBT(Chunk chunk, ExtendedBlockStorage subChunk, NBTTagCompound nbt);
/**
@@ -285,7 +257,6 @@ public interface DataManager {
* @param to The subChunk to copy data to.
*/
@Contract(mutates = "param3")
@StableAPI.Expose
void cloneSubChunk(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to);
}
}
@@ -23,7 +23,7 @@
package com.falsepattern.chunk.api;
import com.falsepattern.chunk.internal.DataRegistryImpl;
import com.falsepattern.lib.StableAPI;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.Unmodifiable;
@@ -42,7 +42,7 @@ import java.util.Set;
* @see DataManager
* @since 0.5.0
*/
@StableAPI(since = "0.5.0")
@ApiStatus.NonExtendable
public class DataRegistry {
/**
* Registers a ChunkDataManager. Only do this during the init phase.
@@ -52,7 +52,6 @@ public class DataRegistry {
* @throws IllegalStateException If the registration stage is over.
* @throws IllegalArgumentException If the manager has a duplicate id.
*/
@StableAPI.Expose
public static void registerDataManager(DataManager manager) throws IllegalStateException, IllegalArgumentException {
DataRegistryImpl.registerDataManager(manager);
}
@@ -64,7 +63,6 @@ public class DataRegistry {
*
* @throws IllegalStateException If the disable stage is over.
*/
@StableAPI.Expose
public static void disableDataManager(String domain, String id) throws IllegalStateException {
DataRegistryImpl.disableDataManager(domain, id);
}
@@ -74,7 +72,6 @@ public class DataRegistry {
* The id of a manager is its domain and id separated by a colon. (domain:id)
*/
@Contract(pure = true)
@StableAPI.Expose
public static @Unmodifiable Set<String> getRegisteredManagers() {
return DataRegistryImpl.getRegisteredManagers();
}
@@ -87,7 +84,6 @@ public class DataRegistry {
* @param to The chunk to write the data to
*/
@Contract(mutates = "param2")
@StableAPI.Expose(since = "0.5.0")
public static void cloneChunk(Chunk from, Chunk to) {
DataRegistryImpl.cloneChunk(from, to);
}
@@ -100,7 +96,6 @@ public class DataRegistry {
* @param to The subChunk to write the data to
*/
@Contract(mutates = "param3")
@StableAPI.Expose(since = "0.5.0")
public static void cloneSubChunk(Chunk fromChunk, ExtendedBlockStorage from, ExtendedBlockStorage to) {
DataRegistryImpl.cloneSubChunk(fromChunk, from, to);
}
@@ -21,12 +21,10 @@
*/
/**
* This is an API package covered by the additional permissions in the license.
* <p>
* This package contains the classes that you will use to interact with the ChunkAPI library.
*
* @author FalsePattern
* @version 0.5.0
* @version 0.6.0
* @since 0.5.0
*/
package com.falsepattern.chunk.api;
package com.falsepattern.chunk.api;
@@ -36,8 +36,7 @@ import cpw.mods.fml.common.event.FMLInitializationEvent;
@Mod(modid = Tags.MOD_ID,
version = Tags.MOD_VERSION,
name = Tags.MOD_NAME,
acceptedMinecraftVersions = "[1.7.10]",
dependencies = "required-after:falsepatternlib@[1.5.9,);")
acceptedMinecraftVersions = "[1.7.10]")
public class ChunkAPI {
@Mod.EventHandler
@@ -0,0 +1,26 @@
/*
* ChunkAPI
*
* Copyright (C) 2023-2025 FalsePattern, The MEGA Team, LegacyModdingMC contributors
* All Rights Reserved
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* This program 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.
*
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*/
@ApiStatus.Internal
package com.falsepattern.chunk.internal.core;
import org.jetbrains.annotations.ApiStatus;
@@ -0,0 +1,26 @@
/*
* ChunkAPI
*
* Copyright (C) 2023-2025 FalsePattern, The MEGA Team, LegacyModdingMC contributors
* All Rights Reserved
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* This program 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.
*
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*/
@ApiStatus.Internal
package com.falsepattern.chunk.internal.impl;
import org.jetbrains.annotations.ApiStatus;
@@ -0,0 +1,26 @@
/*
* ChunkAPI
*
* Copyright (C) 2023-2025 FalsePattern, The MEGA Team, LegacyModdingMC contributors
* All Rights Reserved
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* This program 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.
*
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*/
@ApiStatus.Internal
package com.falsepattern.chunk.internal.mixin.helpers;
import org.jetbrains.annotations.ApiStatus;
@@ -22,16 +22,16 @@
package com.falsepattern.chunk.internal.mixin.plugin;
import com.falsepattern.lib.mixin.IMixin;
import com.falsepattern.lib.mixin.ITargetedMod;
import com.falsepattern.chunk.internal.mixin.plugin.fplib.IMixin;
import com.falsepattern.chunk.internal.mixin.plugin.fplib.ITargetedMod;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import java.util.List;
import java.util.function.Predicate;
import static com.falsepattern.lib.mixin.IMixin.PredicateHelpers.always;
import static com.falsepattern.lib.mixin.IMixin.PredicateHelpers.require;
import static com.falsepattern.chunk.internal.mixin.plugin.fplib.IMixin.PredicateHelpers.always;
import static com.falsepattern.chunk.internal.mixin.plugin.fplib.IMixin.PredicateHelpers.require;
@RequiredArgsConstructor
public enum Mixin implements IMixin {
@@ -23,9 +23,9 @@
package com.falsepattern.chunk.internal.mixin.plugin;
import com.falsepattern.chunk.internal.Tags;
import com.falsepattern.lib.mixin.IMixin;
import com.falsepattern.lib.mixin.IMixinPlugin;
import com.falsepattern.lib.mixin.ITargetedMod;
import com.falsepattern.chunk.internal.mixin.plugin.fplib.IMixin;
import com.falsepattern.chunk.internal.mixin.plugin.fplib.IMixinPlugin;
import com.falsepattern.chunk.internal.mixin.plugin.fplib.ITargetedMod;
import lombok.Getter;
import org.apache.logging.log4j.Logger;
@@ -22,13 +22,13 @@
package com.falsepattern.chunk.internal.mixin.plugin;
import com.falsepattern.lib.mixin.ITargetedMod;
import com.falsepattern.chunk.internal.mixin.plugin.fplib.ITargetedMod;
import lombok.Getter;
import lombok.RequiredArgsConstructor;
import java.util.function.Predicate;
import static com.falsepattern.lib.mixin.ITargetedMod.PredicateHelpers.contains;
import static com.falsepattern.chunk.internal.mixin.plugin.fplib.ITargetedMod.PredicateHelpers.contains;
@RequiredArgsConstructor
public enum TargetedMod implements ITargetedMod {
@@ -0,0 +1,47 @@
/*
* 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/>.
*/
package com.falsepattern.chunk.internal.mixin.plugin.fplib;
import lombok.experimental.UtilityClass;
import net.minecraft.launchwrapper.Launch;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
/**
* @since 0.8.2
*/
@UtilityClass
public final class FileUtil {
public static File getMinecraftHome() {
return getMinecraftHomePath().toFile();
}
/**
* @since 1.0.0
*/
public static Path getMinecraftHomePath() {
return Launch.minecraftHome == null ? Paths.get("").toAbsolutePath() : Launch.minecraftHome.toPath();
}
}
@@ -0,0 +1,77 @@
/*
* 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/>.
*/
package com.falsepattern.chunk.internal.mixin.plugin.fplib;
import lombok.val;
import cpw.mods.fml.relauncher.FMLLaunchHandler;
import java.util.List;
import java.util.function.Predicate;
import java.util.function.Supplier;
public interface IMixin {
String getMixin();
Side getSide();
Predicate<List<ITargetedMod>> getFilter();
default boolean shouldLoad(List<ITargetedMod> loadedMods) {
val side = getSide();
return (side == Side.COMMON
|| side == Side.SERVER && FMLLaunchHandler.side().isServer()
|| side == Side.CLIENT && FMLLaunchHandler.side().isClient()) && getFilter().test(loadedMods);
}
/**
* @since 0.10.0
*/
enum Side {
COMMON,
CLIENT,
SERVER
}
/**
* @since 0.10.0
*/
final class PredicateHelpers {
public static Predicate<List<ITargetedMod>> never() {
return (list) -> false;
}
public static Predicate<List<ITargetedMod>> condition(Supplier<Boolean> condition) {
return (list) -> condition.get();
}
public static Predicate<List<ITargetedMod>> always() {
return (list) -> true;
}
public static Predicate<List<ITargetedMod>> require(ITargetedMod mod) {
return (list) -> list.contains(mod);
}
public static Predicate<List<ITargetedMod>> avoid(ITargetedMod mod) {
return (list) -> !list.contains(mod);
}
}
}
@@ -0,0 +1,218 @@
/*
* 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/>.
*/
package com.falsepattern.chunk.internal.mixin.plugin.fplib;
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;
import net.minecraft.launchwrapper.Launch;
import java.io.File;
import java.net.URL;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;
import java.util.stream.Collectors;
import static java.nio.file.Files.walk;
public interface IMixinPlugin extends IMixinConfigPlugin {
Path MODS_DIRECTORY_PATH = FileUtil.getMinecraftHome().toPath().resolve("mods");
static Logger createLogger(String modName) {
return LogManager.getLogger(modName + " Mixin Loader");
}
/**
* @deprecated since 1.4.0
*/
@Deprecated
static File findJarOf(final ITargetedMod mod) {
File result = null;
try (val stream = walk(MODS_DIRECTORY_PATH)) {
result = stream.filter(mod::isMatchingJar).map(Path::toFile).findFirst().orElse(null);
} catch (Exception e) {
e.printStackTrace();
}
if (result == null) {
File found = null;
for (URL url : Launch.classLoader.getURLs()) {
try {
val file = new File(url.toURI());
Path path = file.toPath();
if (mod.isMatchingJar(path)) {
found = file;
break;
}
} catch (Exception ignored) {
}
}
result = found;
}
return result;
}
/**
* @since 1.4.0
*/
static Set<File> findJarsOf(IMixinPlugin self, final ITargetedMod mod) {
if (!self.useNewFindJar()) {
val jar = findJarOf(mod);
return jar == null ? Collections.emptySet() : Collections.singleton(jar);
}
val results = new HashSet<File>();
try (val stream = walk(MODS_DIRECTORY_PATH)) {
results.addAll(stream.filter(mod::isMatchingJar).map(Path::toFile).collect(Collectors.toSet()));
} catch (Exception e) {
e.printStackTrace();
}
for (URL url : Launch.classLoader.getURLs()) {
try {
val file = new File(url.toURI());
Path path = file.toPath();
if (mod.isMatchingJar(path)) {
results.add(file);
break;
}
} catch (Exception ignored) {
}
}
return results;
}
Logger getLogger();
IMixin[] getMixinEnumValues();
ITargetedMod[] getTargetedModEnumValues();
/**
* @since 1.4.0
*/
default boolean useNewFindJar() {
return false;
}
@Override
@ApiStatus.Internal
default void onLoad(String mixinPackage) {
}
@Override
@ApiStatus.Internal
default String getRefMapperConfig() {
return null;
}
@Override
@ApiStatus.Internal
default boolean shouldApplyMixin(String targetClassName, String mixinClassName) {
return true;
}
@Override
@ApiStatus.Internal
default void acceptTargets(Set<String> myTargets, Set<String> otherTargets) {
}
@Override
@ApiStatus.Internal
default List<String> getMixins() {
val isDevelopmentEnvironment = (boolean) Launch.blackboard.get("fml.deobfuscatedEnvironment");
val targetedMods = getTargetedModEnumValues();
val loadedMods = Arrays.stream(targetedMods)
//Java 21 compat
.filter(new Predicate<ITargetedMod>() {
@Override
public boolean test(ITargetedMod mod) {
boolean loadJar = IMixinPlugin.this.loadJarOf(mod);
return (mod.isLoadInDevelopment() && isDevelopmentEnvironment)
|| loadJar;
}
})
.collect(Collectors.toList());
for (val mod : targetedMods) {
if (loadedMods.contains(mod)) {
getLogger().info("Found " + mod.getModName() + "! Integrating now...");
} else {
getLogger().info("Could not find " + mod.getModName() + "! Skipping integration....");
}
}
List<String> mixins = new ArrayList<>();
for (val mixin : getMixinEnumValues()) {
if (mixin.shouldLoad(loadedMods)) {
String mixinClass = mixin.getSide().name().toLowerCase() + "." + mixin.getMixin();
mixins.add(mixinClass);
getLogger().info("Loading mixin: " + mixinClass);
}
}
return mixins;
}
@ApiStatus.Internal
default boolean loadJarOf(final ITargetedMod mod) {
try {
val jars = findJarsOf(this, mod);
if (jars.isEmpty()) {
getLogger().info("Jar not found for {}", mod);
return false;
}
for (val jar: jars) {
getLogger().info("Attempting to add {} to the URL Class Path", jar);
try {
MinecraftURLClassPath.addJar(jar);
} catch (Throwable e) {
e.printStackTrace();
}
}
} catch (Throwable e) {
e.printStackTrace();
}
return true;
}
@Override
@ApiStatus.Internal
default void preApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
}
@Override
@ApiStatus.Internal
default void postApply(String targetClassName, ClassNode targetClass, String mixinClassName, IMixinInfo mixinInfo) {
}
}
@@ -0,0 +1,59 @@
/*
* 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/>.
*/
package com.falsepattern.chunk.internal.mixin.plugin.fplib;
import com.google.common.io.Files;
import java.nio.file.Path;
import java.util.function.Predicate;
public interface ITargetedMod {
String getModName();
boolean isLoadInDevelopment();
@SuppressWarnings("UnstableApiUsage")
default boolean isMatchingJar(Path path) {
String pathString = path.toString();
String nameLowerCase = Files.getNameWithoutExtension(pathString).toLowerCase();
String fileExtension = Files.getFileExtension(pathString);
return "jar".equals(fileExtension) && getCondition().test(nameLowerCase);
}
Predicate<String> getCondition();
final class PredicateHelpers {
public static Predicate<String> startsWith(String subString) {
return (name) -> name.startsWith(subString.toLowerCase());
}
public static Predicate<String> contains(String subString) {
return (name) -> name.contains(subString.toLowerCase());
}
public static Predicate<String> matches(String regex) {
return (name) -> name.matches(regex);
}
}
}
@@ -0,0 +1,19 @@
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.
This program 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.
This program 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 General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
@@ -0,0 +1,41 @@
/*
* 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/>.
*/
package com.falsepattern.chunk.internal.mixin.plugin.fplib;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
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)
public final class MinecraftURLClassPath {
public static void addJar(File pathToJar) throws Exception {
UCPImpl.addJar(pathToJar);
}
}
@@ -0,0 +1 @@
Shadowed from FalsePatternLib 1.7.0
@@ -0,0 +1,61 @@
/*
* 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/>.
*/
package com.falsepattern.chunk.internal.mixin.plugin.fplib;
import lombok.val;
import net.minecraft.launchwrapper.Launch;
import net.minecraft.launchwrapper.LaunchClassLoader;
import java.io.File;
import java.io.IOException;
public final class UCPImpl {
private static final boolean GRIMOIRE;
static {
boolean grimoire = false;
String[] knownGrimoireClassNames =
new String[]{"io.github.crucible.grimoire.Grimoire", "io.github.crucible.grimoire.common.GrimoireCore"};
for (val className : knownGrimoireClassNames) {
try {
if (Launch.classLoader.getClassBytes(className) != null) {
grimoire = true;
break;
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
GRIMOIRE = grimoire;
}
public static void addJar(File pathToJar) throws Exception {
if (!GRIMOIRE) {
final LaunchClassLoader loader = Launch.classLoader;
loader.addURL(pathToJar.toURI().toURL());
// Act as-if we only added the mod to ucp
loader.getSources().remove(loader.getSources().size() - 1);
}
}
}
@@ -0,0 +1,26 @@
/*
* ChunkAPI
*
* Copyright (C) 2023-2025 FalsePattern, The MEGA Team, LegacyModdingMC contributors
* All Rights Reserved
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* This program 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.
*
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*/
@ApiStatus.Internal
package com.falsepattern.chunk.internal.mixin.plugin.fplib;
import org.jetbrains.annotations.ApiStatus;
@@ -0,0 +1,26 @@
/*
* ChunkAPI
*
* Copyright (C) 2023-2025 FalsePattern, The MEGA Team, LegacyModdingMC contributors
* All Rights Reserved
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* This program 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.
*
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*/
@ApiStatus.Internal
package com.falsepattern.chunk.internal.mixin.plugin;
import org.jetbrains.annotations.ApiStatus;
@@ -23,4 +23,7 @@
/**
* This package contains the internal classes of the ChunkAPI library. Do not use these classes directly.
*/
package com.falsepattern.chunk.internal;
@ApiStatus.Internal
package com.falsepattern.chunk.internal;
import org.jetbrains.annotations.ApiStatus;
@@ -0,0 +1,26 @@
/*
* ChunkAPI
*
* Copyright (C) 2023-2025 FalsePattern, The MEGA Team, LegacyModdingMC contributors
* All Rights Reserved
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* This program 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.
*
* This program 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 this program. If not, see <https://www.gnu.org/licenses/>.
*/
@ApiStatus.Internal
package com.falsepattern.chunk.internal.vanilla;
import org.jetbrains.annotations.ApiStatus;