diff --git a/build.gradle b/build.gradle index 2183dc7..67bf772 100644 --- a/build.gradle +++ b/build.gradle @@ -1,4 +1,15 @@ -import groovy.json.* +buildscript { + repositories { + mavenCentral() + } + dependencies { + classpath 'de.marhali:json5-java:2.0.0' + } +} + +// TODO Move methods with j5tj in buildSrc and use kotlin lang +import de.marhali.json5.Json5 +import de.marhali.json5.Json5Element plugins { id("fabric-loom") version "1.8-SNAPSHOT" @@ -193,6 +204,7 @@ stonecutter { swap("mod_version", "\"${prop("mod_version")}\";") swap("mod_id", "\"${prop("mod_id")}\";") swap("mod_name", "\"${prop("mod_name")}\";") + stonecutter.const("geckolib", prop("dep.geckolib") != "unknown") } tasks.withType(JavaCompile).configureEach { @@ -226,13 +238,12 @@ tasks.named("processResources") { return } - def parser = new JsonSlurper() - parser.type = JsonParserType.LAX - def obj = parser.parseText(json5Text) - def json = JsonOutput.toJson(obj) + Json5 json5 = Json5.builder(options -> options.allowInvalidSurrogate().build()); + Json5Element obj = json5.parse(json5Text) + String json = json5.serialize(obj) - def jsonPath = parent.resolve(substringBeforeLast(name, ".") + ".json").toString() - def jsonFile = new File(jsonPath) + String jsonPath = parent.resolve(substringBeforeLast(name, ".") + ".json").toString() + File jsonFile = new File(jsonPath) jsonFile.parentFile.mkdirs() jsonFile.write(json) @@ -413,16 +424,16 @@ publishMods { } if (requiresDepends.first() != "none") { - requires(requiresDepends) + requires = requiresDepends } if (optionalDepends.first() != "none") { - optional(optionalDepends) + optional = optionalDepends } if (incompatibleDepends.first() != "none") { - incompatible(incompatibleDepends) + incompatible = incompatibleDepends } if (embedsDepends.first() != "none") { - embeds(embedsDepends) + embeds = embedsDepends } } @@ -440,16 +451,16 @@ publishMods { } if (requiresDepends.first() != "none") { - requires(requiresDepends) + requires = requiresDepends } if (optionalDepends.first() != "none") { - optional(optionalDepends) + optional = optionalDepends } if (incompatibleDepends.first() != "none") { - incompatible(incompatibleDepends) + incompatible = incompatibleDepends } if (embedsDepends.first() != "none") { - embeds(embedsDepends) + embeds = embedsDepends } } } @@ -507,7 +518,7 @@ UUID getUUID(Object uuid) { return null } -// Cannot be static! +@SuppressWarnings('GrMethodMayBeStatic') // Method cannot be static int getJavaVersionAsInteger(String minecraftVersion) { return stonecutter.compare("1.20.5", minecraftVersion) == 1 ? stonecutter.compare("1.18", minecraftVersion) == 1 ? @@ -532,7 +543,7 @@ Properties getPersonalProperties() { for (line in personalPropertiesFile.readLines()) { def key = "absolute_path_to_sponge_mixin" if (line.startsWith(key)) { - def substring = line.substring(key.length()+1) + def substring = line.substring(key.length() + 1) if (!substring.isEmpty()) { personalProperties.setProperty(key, substring) } @@ -546,7 +557,7 @@ Properties getPersonalProperties() { MultiVersion getCurrentMultiVersion(String minecraftVersion) { def versions = prop("publication_versions").toString().split(" ") for (version in versions) { - def split = version.substring(0, version.length()-1).split("\\[") + def split = version.substring(0, version.length() - 1).split("\\[") def project = split[0] if (project == minecraftVersion) { def supportedVersionsString = split[1] @@ -599,7 +610,7 @@ class MultiVersion { bMax = maxVersion.length() } def maxMain = maxVersion.substring(0, bMax) - def maxMinor = maxVersion.substring(bMax+1, maxVersion.length()) + def maxMinor = maxVersion.substring(bMax + 1, maxVersion.length()) if (minMain == maxMain) { return "${minVersion}-${maxMinor}" } diff --git a/gradle.properties b/gradle.properties index f13149e..a3901a5 100644 --- a/gradle.properties +++ b/gradle.properties @@ -22,7 +22,7 @@ lombok_version = 1.18.32 # Multi-Versions Properties # Verified version: 1.20 1.20.1 1.20.2 1.20.3 1.20.4 1.20.5 1.20.6 1.21 -multi_versions = 1.16.5 1.17 1.17.1 1.18 1.18.1 1.18.2 1.19 1.19.1 1.19.2 1.19.3 1.19.4 1.20 1.20.1 1.20.2 1.20.3 1.20.4 1.20.5 1.20.6 1.21 1.21.1 1.21.2 1.21.3 +multi_versions = 1.16.5 1.17 1.17.1 1.18 1.18.1 1.18.2 1.19 1.19.1 1.19.2 1.19.3 1.19.4 1.20 1.20.1 1.20.2 1.20.3 1.20.4 1.20.5 1.20.6 1.21 1.21.1 1.21.2 1.21.3 1.21.4 # Build Dependencies build.yarn = [VERSIONED] diff --git a/settings.gradle b/settings.gradle index 8aee434..e8b672f 100644 --- a/settings.gradle +++ b/settings.gradle @@ -22,7 +22,7 @@ pluginManagement { } plugins { - id "dev.kikugie.stonecutter" version "0.4.4" + id "dev.kikugie.stonecutter" version "0.5-beta.5" } def multiVersions = getMultiVersions() diff --git a/src/main/java/net/lopymine/patpat/PatLogger.java b/src/main/java/net/lopymine/patpat/PatLogger.java index c2b588c..933d4cd 100644 --- a/src/main/java/net/lopymine/patpat/PatLogger.java +++ b/src/main/java/net/lopymine/patpat/PatLogger.java @@ -2,45 +2,27 @@ //? >=1.17 { import org.slf4j.*; -//?} + //?} else { +/*import org.apache.logging.log4j.*; +*///?} public class PatLogger { - //? >=1.17 { private final Logger logger; - //?} else { - /*private final String name; - *///?} - public PatLogger(String name){ - //? >=1.17 { - logger = LoggerFactory.getLogger(name); - //?} else { - /*this.name = name; - *///?} + public PatLogger(String name) { + logger = /*? if >=1.17 {*/LoggerFactory/*?} else {*//*LogManager*//*?}*/.getLogger(name); } public void info(String text, Object... args) { - //? >=1.17 { logger.info(text, args); - //?} else { - /*System.out.println("[%s/INFO] ".formatted(name) + text.replace("{}", "%s").formatted(args)); - *///?} } public void warn(String text, Object... args) { - //? >=1.17 { logger.warn(text, args); - //?} else { - /*System.out.println("[%s/WARN] ".formatted(name) + text.replace("{}", "%s").formatted(args)); - *///?} } public void error(String text, Object... args) { - //? >=1.17 { logger.error(text, args); - //?} else { - /*System.out.println("[%s/ERROR] ".formatted(name) + text.replace("{}", "%s").formatted(args)); - *///?} } } \ No newline at end of file diff --git a/src/main/java/net/lopymine/patpat/PatPat.java b/src/main/java/net/lopymine/patpat/PatPat.java index d634d78..3023715 100644 --- a/src/main/java/net/lopymine/patpat/PatPat.java +++ b/src/main/java/net/lopymine/patpat/PatPat.java @@ -16,12 +16,12 @@ public class PatPat implements ModInitializer { public static final PatLogger LOGGER = new PatLogger(MOD_NAME); @Getter - private static PatPatServerConfig config = PatPatServerConfig.getInstance(); + private static PatPatServerConfig config; @Override public void onInitialize() { - PatPat.config = PatPatServerConfig.getInstance(); PatPatConfigManager.onInitialize(); + PatPat.config = PatPatServerConfig.getInstance(); PatPatServerCommandManager.register(); PatPatServerPacketManager.register(); PatPat.LOGGER.info("PatPat Initialized"); diff --git a/src/main/java/net/lopymine/patpat/argument/ListModeArgumentType.java b/src/main/java/net/lopymine/patpat/argument/ListModeArgumentType.java index 6ae7873..396dca1 100644 --- a/src/main/java/net/lopymine/patpat/argument/ListModeArgumentType.java +++ b/src/main/java/net/lopymine/patpat/argument/ListModeArgumentType.java @@ -35,7 +35,7 @@ public static ListMode getListMode(CommandContext context, String id) { public ListMode parse(StringReader reader) throws CommandSyntaxException { String modeId = reader.readUnquotedString(); if (PatPatClient.getConfig().isDebugLogEnabled()) { - PatPatClient.info("Parsed modeId from ListModeArgumentType: {}", modeId); + PatPatClient.LOGGER.info("Parsed modeId from ListModeArgumentType: {}", modeId); } ListMode listMode = ListMode.getById(modeId); if (listMode == null) { @@ -46,11 +46,11 @@ public ListMode parse(StringReader reader) throws CommandSyntaxException { @Override public CompletableFuture listSuggestions(CommandContext context, SuggestionsBuilder builder) { - return CommandSource.suggestMatching(Arrays.stream(ListMode.values()).flatMap((listMode) -> Stream.of(listMode.name())).toList(), builder); + return CommandSource.suggestMatching(Arrays.stream(ListMode.values()).flatMap(listMode -> Stream.of(listMode.name())).toList(), builder); } @Override public Collection getExamples() { - return Arrays.stream(ListMode.values()).flatMap((listMode) -> Stream.of(listMode.name())).toList(); + return Arrays.stream(ListMode.values()).flatMap(listMode -> Stream.of(listMode.name())).toList(); } } diff --git a/src/main/java/net/lopymine/patpat/argument/PlayerInfoArgumentType.java b/src/main/java/net/lopymine/patpat/argument/PlayerInfoArgumentType.java index 4ca8591..64fbe77 100644 --- a/src/main/java/net/lopymine/patpat/argument/PlayerInfoArgumentType.java +++ b/src/main/java/net/lopymine/patpat/argument/PlayerInfoArgumentType.java @@ -41,7 +41,7 @@ public PlayerInfo parse(@NotNull StringReader reader) throws CommandSyntaxExcept String s = reader.readUnquotedString(); if (PatPatClient.getConfig().isDebugLogEnabled()) { - PatPatClient.info("Parsed PlayerInfo from PlayerInfoArgumentType: {}",s); + PatPatClient.LOGGER.info("Parsed PlayerInfo from PlayerInfoArgumentType: {}",s); } ClientPlayNetworkHandler networkHandler = MinecraftClient.getInstance().getNetworkHandler(); diff --git a/src/main/java/net/lopymine/patpat/client/PatPatClient.java b/src/main/java/net/lopymine/patpat/client/PatPatClient.java index 77c8531..d8da6f3 100644 --- a/src/main/java/net/lopymine/patpat/client/PatPatClient.java +++ b/src/main/java/net/lopymine/patpat/client/PatPatClient.java @@ -2,47 +2,20 @@ import lombok.*; -//? >=1.17 -import org.slf4j.*; - import net.fabricmc.api.ClientModInitializer; +import net.lopymine.patpat.PatLogger; import net.lopymine.patpat.compat.LoadedMods; import net.lopymine.patpat.config.client.PatPatClientConfig; import net.lopymine.patpat.manager.client.*; public class PatPatClient implements ClientModInitializer { - //? >=1.17 - public static final Logger LOGGER = LoggerFactory.getLogger("PatPat/Client"); + public static final PatLogger LOGGER = new PatLogger("PatPat/Client"); @Getter @Setter private static PatPatClientConfig config; - public static void info(String text, Object... args) { - //? >=1.17 { - LOGGER.info(text, args); - //?} else { - /*System.out.println("[PatPat/Client/INFO] " + text.replace("{}", "%s").formatted(args)); - *///?} - } - - public static void warn(String text, Object... args) { - //? >=1.17 { - LOGGER.warn(text, args); - //?} else { - /*System.out.println("[PatPat/Client/WARN] " + text.replace("{}", "%s").formatted(args)); - *///?} - } - - public static void error(String text, Object... args) { - //? >=1.17 { - LOGGER.error(text, args); - //?} else { - /*System.out.println("[PatPat/Client/ERROR] " + text.replace("{}", "%s").formatted(args)); - *///?} - } - @Override public void onInitializeClient() { PatPatClient.config = PatPatClientConfig.getInstance(); @@ -52,6 +25,6 @@ public void onInitializeClient() { PatPatClientReloadListener.register(); LoadedMods.onInitialize(); - info("PatPat Client Initialized"); + LOGGER.info("PatPat Client Initialized"); } } diff --git a/src/main/java/net/lopymine/patpat/compat/LoadedMods.java b/src/main/java/net/lopymine/patpat/compat/LoadedMods.java index e3fe94d..18b1d71 100644 --- a/src/main/java/net/lopymine/patpat/compat/LoadedMods.java +++ b/src/main/java/net/lopymine/patpat/compat/LoadedMods.java @@ -13,7 +13,7 @@ public static void onInitialize() { private static void sendDebugLog(boolean modLoaded, String modId) { if (PatPatClient.getConfig().isDebugLogEnabled()) { - PatPatClient.info("{} Loaded: {}", modId, modLoaded); + PatPatClient.LOGGER.info("{} Loaded: {}", modId, modLoaded); } } } diff --git a/src/main/java/net/lopymine/patpat/compat/geckolib/GeckoLibCompatPlugin.java b/src/main/java/net/lopymine/patpat/compat/geckolib/GeckoLibCompatPlugin.java index 9cc6c27..19295ef 100644 --- a/src/main/java/net/lopymine/patpat/compat/geckolib/GeckoLibCompatPlugin.java +++ b/src/main/java/net/lopymine/patpat/compat/geckolib/GeckoLibCompatPlugin.java @@ -6,7 +6,10 @@ public class GeckoLibCompatPlugin extends CompatPlugin { @Override protected String getCompatModId() { + //? <= 1.19.3 { + /*return "geckolib3"; + *///?} else { return "geckolib"; + //?} } - } diff --git a/src/main/java/net/lopymine/patpat/compat/replaymod/ReplayModCompat.java b/src/main/java/net/lopymine/patpat/compat/replaymod/ReplayModCompat.java index 1117386..1e3b4c0 100644 --- a/src/main/java/net/lopymine/patpat/compat/replaymod/ReplayModCompat.java +++ b/src/main/java/net/lopymine/patpat/compat/replaymod/ReplayModCompat.java @@ -16,7 +16,7 @@ public class ReplayModCompat { public static void onPat(UUID pattedEntity, UUID whoPatted) { if (PatPatClient.getConfig().isDebugLogEnabled()) { - PatPatClient.info("Sending dummy packet for Replay Mod. [Patted: {} and Who: {}]", pattedEntity, whoPatted); + PatPatClient.LOGGER.info("Sending dummy packet for Replay Mod. [Patted: {} and Who: {}]", pattedEntity, whoPatted); } if (LoadedMods.REPLAY_MOD_LOADED) { PatEntityForReplayModS2CPacket packet = new PatEntityForReplayModS2CPacket(pattedEntity, whoPatted); @@ -30,7 +30,7 @@ public static void onPat(UUID pattedEntity, UUID whoPatted) { return; } if (PatPatClient.getConfig().isDebugLogEnabled()) { - PatPatClient.info("Replay Mod not Installed!"); + PatPatClient.LOGGER.info("Replay Mod not Installed!"); } } } diff --git a/src/main/java/net/lopymine/patpat/compat/replaymod/ReplayModManager.java b/src/main/java/net/lopymine/patpat/compat/replaymod/ReplayModManager.java index 5b162af..7bd5c8e 100644 --- a/src/main/java/net/lopymine/patpat/compat/replaymod/ReplayModManager.java +++ b/src/main/java/net/lopymine/patpat/compat/replaymod/ReplayModManager.java @@ -23,7 +23,7 @@ public static void sendDummyPacket(Packet packet) { //? !(=1.20.5) { if (com.replaymod.recording.ReplayModRecording.instance.getConnectionEventHandler() != null) { if (PatPatClient.getConfig().isDebugLogEnabled()) { - PatPatClient.info("Sent dummy packet for Replay Mod"); + PatPatClient.LOGGER.info("Sent dummy packet for Replay Mod"); } com.replaymod.recording.packet.PacketListener packetListener = com.replaymod.recording.ReplayModRecording.instance.getConnectionEventHandler().getPacketListener(); if (packetListener != null) { diff --git a/src/main/java/net/lopymine/patpat/config/client/PatPatClientConfig.java b/src/main/java/net/lopymine/patpat/config/client/PatPatClientConfig.java index 090889c..bcb68bc 100644 --- a/src/main/java/net/lopymine/patpat/config/client/PatPatClientConfig.java +++ b/src/main/java/net/lopymine/patpat/config/client/PatPatClientConfig.java @@ -89,10 +89,10 @@ public static PatPatClientConfig getInstance() { private static @NotNull PatPatClientConfig create() { PatPatClientConfig config = new PatPatClientConfig(); try (FileWriter writer = new FileWriter(CONFIG_FILE, StandardCharsets.UTF_8)) { - String json = GSON.toJson(CODEC.encode(config, JsonOps.INSTANCE, JsonOps.INSTANCE.empty())/*? if >=1.20.5 {*/.getOrThrow());/*?} else*//*.getOrThrow(false, PatPatClient::error));*/ + String json = GSON.toJson(CODEC.encode(config, JsonOps.INSTANCE, JsonOps.INSTANCE.empty())/*? if >=1.20.5 {*/.getOrThrow());/*?} else*//*.getOrThrow(false, PatPatClient.LOGGER::error));*/ writer.write(json); } catch (Exception e) { - PatPatClient.error("Failed to create config", e); + PatPatClient.LOGGER.error("Failed to create config", e); } return config; } @@ -103,9 +103,9 @@ private static PatPatClientConfig read() { } try (FileReader reader = new FileReader(CONFIG_FILE, StandardCharsets.UTF_8)) { - return CODEC.decode(JsonOps.INSTANCE, /*? <=1.17.1 {*//*new JsonParser().parse(reader)*//*?} else {*/JsonParser.parseReader(reader)/*?}*/)/*? if >=1.20.5 {*/.getOrThrow()/*?} else {*//*.getOrThrow(false, PatPatClient::error)*//*?}*/.getFirst(); + return CODEC.decode(JsonOps.INSTANCE, /*? <=1.17.1 {*//*new JsonParser().parse(reader)*//*?} else {*/JsonParser.parseReader(reader)/*?}*/)/*? if >=1.20.5 {*/.getOrThrow()/*?} else {*//*.getOrThrow(false, PatPatClient.LOGGER::error)*//*?}*/.getFirst(); } catch (Exception e) { - PatPatClient.error("Failed to read config", e); + PatPatClient.LOGGER.error("Failed to read config", e); } return PatPatClientConfig.create(); } @@ -114,16 +114,16 @@ public void save() { PatPatClient.setConfig(this); CompletableFuture.runAsync(() -> { if (PatPatClient.getConfig().isDebugLogEnabled()) { - PatPatClient.info("Saving PatPat Client Config..."); + PatPatClient.LOGGER.info("Saving PatPat Client Config..."); } try (FileWriter writer = new FileWriter(CONFIG_FILE, StandardCharsets.UTF_8)) { - String json = GSON.toJson(CODEC.encode(this, JsonOps.INSTANCE, JsonOps.INSTANCE.empty())/*? if >=1.20.5 {*/.getOrThrow());/*?} else*//*.getOrThrow(false, PatPatClient::error));*/ + String json = GSON.toJson(CODEC.encode(this, JsonOps.INSTANCE, JsonOps.INSTANCE.empty())/*? if >=1.20.5 {*/.getOrThrow());/*?} else*//*.getOrThrow(false, PatPatClient.LOGGER::error));*/ writer.write(json); } catch (Exception e) { - PatPatClient.error("Failed to save config", e); + PatPatClient.LOGGER.error("Failed to save config", e); } if (PatPatClient.getConfig().isDebugLogEnabled()) { - PatPatClient.info("Saved PatPat Client Config"); + PatPatClient.LOGGER.info("Saved PatPat Client Config"); } }); } diff --git a/src/main/java/net/lopymine/patpat/config/resourcepack/CustomAnimationConfig.java b/src/main/java/net/lopymine/patpat/config/resourcepack/CustomAnimationConfig.java index a4e9f32..1f12a11 100644 --- a/src/main/java/net/lopymine/patpat/config/resourcepack/CustomAnimationConfig.java +++ b/src/main/java/net/lopymine/patpat/config/resourcepack/CustomAnimationConfig.java @@ -53,8 +53,8 @@ public boolean canUseFor(@NotNull String entityTypeId, @Nullable String entityNa } for (EntityConfig entityConfig : this.entities) { if (PatPatClient.getConfig().isDebugLogEnabled()) { - PatPatClient.info("Comparing Entity Config: " + entityConfig.toString()); - PatPatClient.info("with {}, {}, {}, {}", entityTypeId, entityName, entityUuid, whoPatted.toString()); + PatPatClient.LOGGER.info("Comparing Entity Config: " + entityConfig.toString()); + PatPatClient.LOGGER.info("with {}, {}, {}, {}", entityTypeId, entityName, entityUuid, whoPatted.toString()); } if (entityConfig.is(entityTypeId, entityName, entityUuid) && (entityConfig.getEntitiesFrom() == null || entityConfig.getEntitiesFrom().contains(whoPatted))) { return !this.blacklist; diff --git a/src/main/java/net/lopymine/patpat/config/resourcepack/PlayerConfig.java b/src/main/java/net/lopymine/patpat/config/resourcepack/PlayerConfig.java index c52e5c8..38bf222 100644 --- a/src/main/java/net/lopymine/patpat/config/resourcepack/PlayerConfig.java +++ b/src/main/java/net/lopymine/patpat/config/resourcepack/PlayerConfig.java @@ -47,7 +47,7 @@ public boolean equals(Object o) { boolean b = that.name == null || Objects.equals(this.name, that.name); boolean b1 = that.uuid == null || Objects.equals(this.uuid, that.uuid); if (PatPatClient.getConfig().isDebugLogEnabled()) { - PatPatClient.info("Comparing PlayerConfigs: [{} and {}] [{} and {}] - {}",this.name, that.name, this.uuid, that.uuid, b && b1); + PatPatClient.LOGGER.info("Comparing PlayerConfigs: [{} and {}] [{} and {}] - {}",this.name, that.name, this.uuid, that.uuid, b && b1); } return b && b1; } diff --git a/src/main/java/net/lopymine/patpat/config/resourcepack/Version.java b/src/main/java/net/lopymine/patpat/config/resourcepack/Version.java index 5a6f362..e81f4e9 100644 --- a/src/main/java/net/lopymine/patpat/config/resourcepack/Version.java +++ b/src/main/java/net/lopymine/patpat/config/resourcepack/Version.java @@ -9,7 +9,8 @@ public record Version(int major, int minor, int patch) { public static final Codec CODEC = Codec.STRING.xmap(Version::of, Version::toString); - public static final Version DEFAULT = Version.of(PatPat.MOD_VERSION); + public static final Version SUPPORT_VERSION = Version.of(PatPat.MOD_VERSION); + public static final Version MIN_SUPPORT_VERSION = Version.of("1.0.0"); public static Version of(@NotNull String version) { String[] numbers = version.split("\\."); diff --git a/src/main/java/net/lopymine/patpat/extension/EntityExtension.java b/src/main/java/net/lopymine/patpat/extension/EntityExtension.java index bda59cf..4c173f4 100644 --- a/src/main/java/net/lopymine/patpat/extension/EntityExtension.java +++ b/src/main/java/net/lopymine/patpat/extension/EntityExtension.java @@ -19,7 +19,7 @@ public static String getTypeId(Entity entity) { public static String getId(EntityType entityType) { Identifier id = VersionedThings.ENTITY_TYPE.getId(entityType); if (id == null) { - PatPatClient.warn("Failed to find entity type {}", entityType.getName()); + PatPatClient.LOGGER.warn("Failed to find entity type {}", entityType.getName()); return "null"; } return id.toString(); diff --git a/src/main/java/net/lopymine/patpat/manager/client/PatPatClientManager.java b/src/main/java/net/lopymine/patpat/manager/client/PatPatClientManager.java index 520b2bb..2f52df6 100644 --- a/src/main/java/net/lopymine/patpat/manager/client/PatPatClientManager.java +++ b/src/main/java/net/lopymine/patpat/manager/client/PatPatClientManager.java @@ -36,7 +36,7 @@ public static void removePatEntity(@NotNull PatEntity patEntity) { public static PatEntity pat(@NotNull LivingEntity entity, @NotNull PlayerConfig whoPatted) { if (PatPatClient.getConfig().isDebugLogEnabled()) { - PatPatClient.info("{} patted {}", whoPatted.getName(), entity.getName()); + PatPatClient.LOGGER.info("{} patted {}", whoPatted.getName(), entity.getName()); } UUID uuid = entity.getUuid(); PatEntity patEntity = PAT_ENTITIES.get(uuid); diff --git a/src/main/java/net/lopymine/patpat/manager/client/PatPatClientPacketManager.java b/src/main/java/net/lopymine/patpat/manager/client/PatPatClientPacketManager.java index 19ec7b4..db43615 100644 --- a/src/main/java/net/lopymine/patpat/manager/client/PatPatClientPacketManager.java +++ b/src/main/java/net/lopymine/patpat/manager/client/PatPatClientPacketManager.java @@ -41,7 +41,7 @@ public static void register() { private static void handlePatting(UUID whoPattedUuid, UUID pattedEntityUuid, boolean replayModPacket) { if (PatPatClient.getConfig().isDebugLogEnabled()) { - PatPatClient.info("Received packet from server, {} patted {}, replayModPacket: {}", whoPattedUuid, pattedEntityUuid, replayModPacket); + PatPatClient.LOGGER.info("Received packet from server, {} patted {}, replayModPacket: {}", whoPattedUuid, pattedEntityUuid, replayModPacket); } ClientWorld clientWorld = MinecraftClient.getInstance().world; diff --git a/src/main/java/net/lopymine/patpat/manager/client/PatPatClientResourcePackManager.java b/src/main/java/net/lopymine/patpat/manager/client/PatPatClientResourcePackManager.java index cb3b42f..91eda08 100644 --- a/src/main/java/net/lopymine/patpat/manager/client/PatPatClientResourcePackManager.java +++ b/src/main/java/net/lopymine/patpat/manager/client/PatPatClientResourcePackManager.java @@ -37,31 +37,33 @@ public static void parseConfig(String packName, Identifier identifier, Supplier< try (InputStream inputStream = inputStreamInputSupplier.get(); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) { JsonElement json = /*? <=1.17.1 {*//*new JsonParser().parse(reader)*//*?} else {*/JsonParser.parseReader(reader)/*?}*/; if (!json.isJsonObject()) { - PatPatClient.warn("ResourcePack '{}', file '{}' is not a json object, skip", packName, path); + PatPatClient.LOGGER.warn("ResourcePack '{}', file '{}' is not a json object, skip", packName, path); return; } JsonObject jsonObject = json.getAsJsonObject(); JsonElement jsonElement = jsonObject.get("version"); if (jsonElement == null) { - PatPatClient.warn("ResourcePack '{}', file '{}' failed to verify version because it's missing, skip", packName, path); + PatPatClient.LOGGER.warn("ResourcePack '{}', file '{}' failed to verify version because it's missing, skip", packName, path); return; } String string = jsonElement.getAsString(); Version configVersion = Version.of(string); - if (configVersion.isLessThan(Version.DEFAULT)) { + if (configVersion.isMoreThan(Version.SUPPORT_VERSION)) { + PatPatClient.LOGGER.warn("ResourcePack '{}', file '{}' has unsupported new version[{} < {}], there may be errors!", packName, path, Version.SUPPORT_VERSION, configVersion); + } else if (configVersion.isLessThan(Version.MIN_SUPPORT_VERSION)) { boolean shouldSkip = config.isSkipOldAnimationsEnabled(); - PatPatClient.warn("ResourcePack '{}', file '{}' has old version[{} > {}], {}!", packName, path, Version.DEFAULT, configVersion, (shouldSkip ? "skip" : "there may be errors")); + PatPatClient.LOGGER.warn("ResourcePack '{}', file '{}' has unsupported old version[{} > {}], {}!", packName, path, Version.MIN_SUPPORT_VERSION, configVersion, (shouldSkip ? "skip" : "there may be errors")); if (shouldSkip) { return; } } - CustomAnimationConfig animationConfig = CustomAnimationConfig.CODEC.decode(JsonOps.INSTANCE, json)/*? if >=1.20.5 {*/.getOrThrow()/*?} else {*//*.getOrThrow(false, PatPatClient::error)*//*?}*/.getFirst(); + CustomAnimationConfig animationConfig = CustomAnimationConfig.CODEC.decode(JsonOps.INSTANCE, json)/*? if >=1.20.5 {*/.getOrThrow()/*?} else {*//*.getOrThrow(false, PatPatClient.LOGGER::error)*//*?}*/.getFirst(); animationConfig.setConfigPath("%s/%s".formatted(packName, path)); configs.add(animationConfig); } catch (Exception e) { - PatPatClient.warn(String.format("ResourcePack '%s', file '%s' failed to parse, skip", packName, path), e); + PatPatClient.LOGGER.warn(String.format("ResourcePack '%s', file '%s' failed to parse, skip", packName, path), e); } } @@ -77,27 +79,27 @@ public void reload(List reloadPacks, ResourceManager manager) { String resourcePackName = /*? >=1.20.5 {*/ pack.getId(); /*?} else {*//*pack.getName();*//*?}*/ List animationConfigs = new ArrayList<>(); - PatPatClient.info("Registering {} resource pack", resourcePackName); + PatPatClient.LOGGER.info("Registering {} resource pack", resourcePackName); //? >=1.19.3 { pack.findResources(ResourceType.CLIENT_RESOURCES, PatPat.MOD_ID, "textures", (id, input) -> { try (InputStream inputStream = input.get()) { parseConfig(resourcePackName, id, () -> inputStream, animationConfigs, config); } catch (Exception e) { - PatPatClient.error("Failed to read custom animation at {} from {}", id.toString(), resourcePackName); + PatPatClient.LOGGER.error("Failed to read custom animation at {} from {}", id.toString(), resourcePackName); } });//?} else { - /*Collection customAnimationIds = pack.findResources(ResourceType.CLIENT_RESOURCES, PatPat.MOD_ID, "textures",/^? <=1.18.2 {^/0,/^?}^/ (identifier) -> { + /*Collection customAnimationIds = pack.findResources(ResourceType.CLIENT_RESOURCES, PatPat.MOD_ID, "textures",/^? <=1.18.2 {^//^0,^//^?}^/ (identifier) -> { //? >=1.19 { - /^return identifier.getPath().endsWith(".json") || identifier.getPath().endsWith(".json5"); - ^///?} else { - return identifier.endsWith(".json") || identifier.endsWith(".json5"); - //?} + return identifier.getPath().endsWith(".json") || identifier.getPath().endsWith(".json5"); + //?} else { + /^return identifier.endsWith(".json") || identifier.endsWith(".json5"); + ^///?} }); for (Identifier customAnimationId : customAnimationIds) { - try (InputStream inputStream = /^? >=1.19 {^//^manager.open(customAnimationId)^//^?} else {^/manager.getResource(customAnimationId).getInputStream()/^?}^/) { + try (InputStream inputStream = /^? >=1.19 {^/manager.open(customAnimationId)/^?} else {^//^manager.getResource(customAnimationId).getInputStream()^//^?}^/) { PatPatClientResourcePackManager.parseConfig(resourcePackName, customAnimationId, () -> inputStream, animationConfigs, config); } catch (Exception e) { - PatPatClient.error("Failed to read custom animation at {} from {}", customAnimationId.toString(), resourcePackName); + PatPatClient.LOGGER.error("Failed to read custom animation at {} from {}", customAnimationId.toString(), resourcePackName); } } *///?} diff --git a/src/main/java/net/lopymine/patpat/mixin/geckolib/GeoEntityRendererMixin.java b/src/main/java/net/lopymine/patpat/mixin/geckolib/GeoEntityRendererMixin.java index e228b9b..92bd548 100644 --- a/src/main/java/net/lopymine/patpat/mixin/geckolib/GeoEntityRendererMixin.java +++ b/src/main/java/net/lopymine/patpat/mixin/geckolib/GeoEntityRendererMixin.java @@ -1,7 +1,7 @@ package net.lopymine.patpat.mixin.geckolib; -//? !(=1.17 || =1.18 || =1.18.1 || =1.19 || =1.21.2) { -import net.minecraft.client.render.VertexConsumerProvider; +//? geckolib { +/*import net.minecraft.client.render.VertexConsumerProvider; import net.minecraft.client.util.math.MatrixStack; import net.minecraft.entity.*; import org.spongepowered.asm.mixin.*; @@ -10,10 +10,10 @@ import net.lopymine.patpat.renderer.PatAnimationRenderer; //? =1.16.5 { -/*import software.bernie.geckolib3.renderer.geo.GeoEntityRenderer; -*///?} elif >=1.17.1 && <=1.19.2 { -/*import software.bernie.geckolib3.renderers.geo.GeoEntityRenderer; -*///?} else { +/^import software.bernie.geckolib3.renderer.geo.GeoEntityRenderer; +^///?} elif >=1.17.1 && <=1.19.2 { +/^import software.bernie.geckolib3.renderers.geo.GeoEntityRenderer; +^///?} else { import software.bernie.geckolib.renderer.GeoEntityRenderer; //?} @@ -25,19 +25,22 @@ @Mixin(GeoEntityRenderer.class) public abstract class GeoEntityRendererMixin { - //? <1.21.2 { - /*@Inject(at=@At(value = "HEAD"), method = "render") - private void render(Entity entity, float entityYaw, float partialTick, MatrixStack matrixStack, VertexConsumerProvider bufferSource, int packedLight, CallbackInfo ci) { - *///?} else { - @Inject(at = @At(value = "HEAD"), method = "render") + @Inject(at=@At(value = "HEAD"), method = "render") + //? if <=1.16.5 { + /^private void render(LivingEntity livingEntity, float entityYaw, float partialTicks, MatrixStack matrixStack, VertexConsumerProvider bufferIn, int packedLightIn, CallbackInfo ci){ + ^///?} elif <1.21.2 { + /^private void render(Entity entity, float entityYaw, float partialTicks, MatrixStack matrixStack, VertexConsumerProvider bufferIn, int packedLightIn) { + ^///?} else { + private void render(EntityRenderState entityRenderState, MatrixStack matrixStack, VertexConsumerProvider bufferSource, int packedLight, CallbackInfo ci) { Entity entity = ((EntityRenderStateWithParent) entityRenderState).patPat$getEntity(); //?} + //? if >1.16.5 { if (!(entity instanceof LivingEntity livingEntity)) { return; } + //?} PatAnimationRenderer.scaleEntityIfPatted(livingEntity, matrixStack); } } - -//?} +*///?} diff --git a/src/main/java/net/lopymine/patpat/modmenu/screen/NoConfigLibrariesScreen.java b/src/main/java/net/lopymine/patpat/modmenu/screen/NoConfigLibrariesScreen.java index e69f1cc..5f9ad9c 100644 --- a/src/main/java/net/lopymine/patpat/modmenu/screen/NoConfigLibrariesScreen.java +++ b/src/main/java/net/lopymine/patpat/modmenu/screen/NoConfigLibrariesScreen.java @@ -59,7 +59,7 @@ private static void onConfirm(boolean bl) { } Util.getOperatingSystem().open(link); } catch (URISyntaxException e) { - PatPatClient.error("Can't open {} Modrinth page: ", (bl ? "YACL" : "Cloth Config API"), e); + PatPatClient.LOGGER.error("Can't open {} Modrinth page: ", (bl ? "YACL" : "Cloth Config API"), e); } } } diff --git a/src/main/resources/assets/patpat/textures/easter/egg.json b/src/main/resources/assets/patpat/textures/easter/egg.json index 987b372..d9e773c 100644 --- a/src/main/resources/assets/patpat/textures/easter/egg.json +++ b/src/main/resources/assets/patpat/textures/easter/egg.json @@ -1,5 +1,5 @@ { - "version": "1.0.0", + "version": "1.0.1", "priority": 1, "animation": { "texture": "patpat:textures/default/patpat.png", diff --git a/src/main/resources/aws/1.21.4.accesswidener b/src/main/resources/aws/1.21.4.accesswidener new file mode 100644 index 0000000..0a83788 --- /dev/null +++ b/src/main/resources/aws/1.21.4.accesswidener @@ -0,0 +1,2 @@ +accessWidener v2 named +# 1.21.4 AW diff --git a/src/main/resources/example/example_custom_animation_config.json5 b/src/main/resources/example/example_custom_animation_config.json5 index f038472..3a7f5c2 100644 --- a/src/main/resources/example/example_custom_animation_config.json5 +++ b/src/main/resources/example/example_custom_animation_config.json5 @@ -2,7 +2,7 @@ // The comment above is important FOR MOD DEVELOPERS! // See https://github.com/LopyMine/Mossy?tab=readme-ov-file#about-json5-files { - "version": "1.0.0", + "version": "1.0.1", "priority": 1, // Optional, default 0 diff --git a/src/main/resources/patpat-geckolib.mixins.json5 b/src/main/resources/patpat-geckolib.mixins.json5 index b4a7f24..0941bb1 100644 --- a/src/main/resources/patpat-geckolib.mixins.json5 +++ b/src/main/resources/patpat-geckolib.mixins.json5 @@ -7,7 +7,9 @@ "mixins": [ ], "client": [ - "GeoEntityRendererMixin", + //? geckolib { + /*"GeoEntityRendererMixin", + *///?} ], "injectors": { "defaultRequire": 1 diff --git a/stonecutter.gradle b/stonecutter.gradle index 41e9987..6ffe99b 100644 --- a/stonecutter.gradle +++ b/stonecutter.gradle @@ -1,7 +1,7 @@ plugins { id "dev.kikugie.stonecutter" } -stonecutter.active "1.21.3" /* [SC] DO NOT EDIT */ +stonecutter.active "1.21.4" /* [SC] DO NOT EDIT */ stonecutter.registerChiseled tasks.register("chiseledBuildAndCollectAll", stonecutter.chiseled) { setGroup("project") diff --git a/versions/1.21.4/gradle.properties b/versions/1.21.4/gradle.properties new file mode 100644 index 0000000..fd2d614 --- /dev/null +++ b/versions/1.21.4/gradle.properties @@ -0,0 +1,17 @@ +# Versioned Properties + +# Fabric Properties, check https://fabricmc.net/develop/ +build.yarn=1.21.4+build.1 +build.fabric_api=0.110.5+1.21.4 + +# Additional Dependencies Properties +# cloth-config, check https://modrinth.com/mod/cloth-config/versions?g=1.21.4 +dep.cloth-config=16.0.141+fabric +# modmenu, check https://modrinth.com/mod/modmenu/versions?g=1.21.4 +dep.modmenu=13.0.0-beta.1 +# yacl, check https://modrinth.com/mod/yacl/versions?g=1.21.4 +dep.yacl=3.6.1+1.21.2-fabric +# replaymod, check https://modrinth.com/mod/replaymod/versions?g=1.21.4 +dep.replaymod=1.21.2-2.6.20 +# geckolib, check https://modrinth.com/mod/geckolib/versions?g=1.21.4 +dep.geckolib=unknown