diff --git a/build.gradle b/build.gradle index 06f64bad..14f5dae9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,9 +1,13 @@ plugins { - id 'com.replaymod.preprocess' version '6989e16efc' - id 'fabric-loom' version '1.7-SNAPSHOT' apply false + id 'fabric-loom' version '1.9-SNAPSHOT' apply false + // https://github.com/ReplayMod/preprocessor + // https://github.com/Fallen-Breath/preprocessor + id 'com.replaymod.preprocess' version '9d21b334a7' } preprocess { + strictExtraMappings = false + //def mc1165 = createNode('1.16.5', 1_16_05, 'yarn') //def mc1171 = createNode('1.17.1', 1_17_01, 'yarn') //def mc1182 = createNode('1.18.2', 1_18_02, 'yarn') @@ -17,6 +21,8 @@ preprocess { def mc1206 = createNode('1.20.6', 1_20_06, 'yarn') def mc1210 = createNode('1.21.0', 1_21_00, 'yarn') def mc1211 = createNode('1.21.1', 1_21_01, 'yarn') + def mc1213 = createNode('1.21.3', 1_21_03, 'yarn') + def mc1214 = createNode('1.21.4', 1_21_04, 'yarn') // mapping difference map // base 1194 -> 1193 -> 1192 ->1190-> 118 -> 117 -> 116 @@ -26,6 +32,8 @@ preprocess { mc1206.link(mc1204, file('versions/mapping-1.20.6-1.20.4.txt')) mc1210.link(mc1206, file('versions/mapping-1.21.0-1.20.6.txt')) mc1211.link(mc1210, file('versions/mapping-1.21.1-1.21.0.txt')) + mc1213.link(mc1211, file('versions/mapping-1.21.3-1.21.1.txt')) + mc1214.link(mc1213, file('versions/mapping-1.21.4-1.21.3.txt')) //mc1194.link(mc1193, file('versions/mapping-1.19.4-1.19.3.txt')) //mc1193.link(mc1192, file('versions/mapping-1.19.3-1.19.2.txt')) //mc1192.link(mc1190, file('versions/mapping-1.19.2-1.19.0.txt')) @@ -42,19 +50,24 @@ preprocess { // gradlew :1.16.5:setCoreVersion -> set coremod version to 1.16.5 tasks.register('buildAndGather') { subprojects { - dependsOn project.name + ':build' + dependsOn project.tasks.named('build').get() } doFirst { - println 'Building and gathering all subprojects' - copy { - subprojects { - def libDir = project.projectDir.toPath().resolve('build/libs') - from(libDir) { + println 'Gathering builds' + def buildLibs = { + p -> p.buildDir.toPath().resolve('libs') + } + delete fileTree(buildLibs(rootProject)) { + include '*' + } + subprojects { + copy { + from(buildLibs(project)) { include '*.jar' - exclude '*-sources.jar', '*-dev.jar' + exclude '*-dev.jar', '*-sources.jar', '*-shadow.jar' } - into 'build/libs/' - duplicatesStrategy = DuplicatesStrategy.INCLUDE + into buildLibs(rootProject) + duplicatesStrategy DuplicatesStrategy.INCLUDE } } } diff --git a/common.gradle b/common.gradle index d03ac3f8..cb93286c 100644 --- a/common.gradle +++ b/common.gradle @@ -1,37 +1,11 @@ -// common.gradle is a file that called separately by each module. -plugins { - id 'fabric-loom' version '1.7-SNAPSHOT' - id 'com.replaymod.preprocess' version '6989e16efc' -} - -int mcVersion = 1 - -preprocess { - mcVersion = vars.get()["MC"] as Integer - tabIndentation = true -} - -if (mcVersion >= 12005) { - sourceCompatibility = JavaVersion.VERSION_21 - targetCompatibility = JavaVersion.VERSION_21 -} -else if (mcVersion >= 11800) { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 -} -else if (mcVersion >= 11700) { - sourceCompatibility = JavaVersion.VERSION_16 - targetCompatibility = JavaVersion.VERSION_16 -} -else { - sourceCompatibility = JavaVersion.VERSION_1_8 - targetCompatibility = JavaVersion.VERSION_1_8 -} +apply plugin: 'fabric-loom' +apply plugin: 'com.replaymod.preprocess' +int mcVersion = project.mcVersion -archivesBaseName = "${project.archives_base_name}-mc${project.minecraft_version}" -version = project.mod_version -group = project.maven_group +//preprocess { + //mcVersion = vars.get()["MC"] as Integer +//} repositories { mavenCentral() @@ -44,6 +18,12 @@ repositories { maven { url "https://pkgs.dev.azure.com/djtheredstoner/DevAuth/_packaging/public/maven/v1" } + //maven { url 'https://maven.fallenbreath.me/releases' } +} + +// https://github.com/FabricMC/fabric-loader/issues/783 +configurations { + modRuntimeOnly.exclude group: 'net.fabricmc', module: 'fabric-loader' } dependencies { @@ -84,51 +64,112 @@ dependencies { } //modImplementation "fi.dy.masa.litematica:litematica-fabric-${project.minecraft_version_out}:${project.litematica_version}" } - annotationProcessor "com.github.LlamaLad7:MixinExtras:0.1.1" + + // [FEATURE] MIXIN_AUDITOR + //modRuntimeOnly 'me.fallenbreath:mixin-auditor:0.1.0' + //include(modImplementation("me.fallenbreath:conditional-mixin-fabric:${project.conditionalmixin_version}")) + //include(annotationProcessor(implementation("io.github.llamalad7:mixinextras-fabric:${project.mixinextras_version}"))) } -processResources { - inputs.property "version", project.mod_version - // {$argument} exists in src/main/resources/fabric.mod.json, then it will be replaced with the value of the argument. - filesMatching("fabric.mod.json") { - def map = [ - "version": version, - "minecraft_dependency": project.minecraft_version_out - ] - expand map - } +String MIXIN_CONFIG_PATH = 'litematica-printer.mixins.json' +JavaVersion JAVA_COMPATIBILITY +if (mcVersion >= 12005) { + JAVA_COMPATIBILITY = JavaVersion.VERSION_21 +} else if (mcVersion >= 11800) { + JAVA_COMPATIBILITY = JavaVersion.VERSION_17 +} else if (mcVersion >= 11700) { + JAVA_COMPATIBILITY = JavaVersion.VERSION_16 +} else { + JAVA_COMPATIBILITY = JavaVersion.VERSION_1_8 } +JavaVersion MIXIN_COMPATIBILITY_LEVEL = JAVA_COMPATIBILITY -tasks.withType(JavaCompile).configureEach { - // ensure that the encoding is set to UTF-8, no matter what the system default is - // this fixes some edge cases with special characters not displaying correctly - // see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html - // If Javadoc is generated, this must be specified in that task too. - it.options.encoding = "UTF-8" - - if (mcVersion >= 12005) { - it.options.release = 21 +loom { + def commonVmArgs = ['-Dmixin.debug.export=true', '-Dmixin.debug.countInjections=true'] + runConfigs.configureEach { + // to make sure it generates all "Minecraft Client (:subproject_name)" applications + ideConfigGenerated = true + runDir '../../run' + vmArgs commonVmArgs } - else if (mcVersion >= 11800) { - it.options.release = 17 + // [FEATURE] MIXIN_AUDITOR + //runs { + //def auditVmArgs = [*commonVmArgs, '-DmixinAuditor.audit=true'] + //serverMixinAudit { + //server() + //vmArgs auditVmArgs + //ideConfigGenerated false + //} + //} +} + +String modVersionSuffix = '' +String artifactVersion = project.mod_version +String artifactVersionSuffix = '' +// detect github action environment variables +// https://docs.github.com/en/actions/learn-github-actions/environment-variables#default-environment-variables +if (System.getenv("BUILD_RELEASE") != "true") { + String buildNumber = System.getenv("BUILD_ID") + modVersionSuffix += buildNumber != null ? ('+build.' + buildNumber) : '-SNAPSHOT' + artifactVersionSuffix = '-SNAPSHOT' // A non-release artifact is always a SNAPSHOT artifact +} +String fullModVersion = project.mod_version + modVersionSuffix +String fullProjectVersion, fullArtifactVersion + +group = project.maven_group +if (System.getenv("JITPACK") == "true") { + // move mc version into archivesBaseName, so jitpack will be able to organize archives from multiple subprojects correctly + base.archivesName = project.archives_base_name + '-mc' + project.minecraft_version + fullProjectVersion = 'v' + project.mod_version + modVersionSuffix + fullArtifactVersion = artifactVersion + artifactVersionSuffix +} else { + base.archivesName = project.archives_base_name + fullProjectVersion = 'v' + project.mod_version + '-mc' + project.minecraft_version + modVersionSuffix + fullArtifactVersion = artifactVersion + '-mc' + project.minecraft_version + artifactVersionSuffix +} +version = fullProjectVersion + +processResources { + inputs.property "id", project.mod_id + inputs.property "name", project.mod_name + inputs.property "version", fullModVersion + inputs.property "minecraft_dependency", project.minecraft_dependency + + filesMatching("fabric.mod.json") { + def valueMap = [ + "id": project.mod_id, + "name": project.mod_name, + "version": fullModVersion, + "minecraft_dependency": project.minecraft_dependency, + ] + expand valueMap } - else if (mcVersion >= 11700) { - it.options.release = 16 + + filesMatching(MIXIN_CONFIG_PATH) { + filter { s -> s.replace('{{COMPATIBILITY_LEVEL}}', "JAVA_${MIXIN_COMPATIBILITY_LEVEL.ordinal() + 1}") } } - else { - it.options.release = 8 +} + +// ensure that the encoding is set to UTF-8, no matter what the system default is +// this fixes some edge cases with special characters not displaying correctly +// see http://yodaconditions.net/blog/fix-for-java-file-encoding-problems-with-gradle.html +tasks.withType(JavaCompile).configureEach { + options.encoding = "UTF-8" + options.compilerArgs << "-Xlint:deprecation" << "-Xlint:unchecked" + if (JAVA_COMPATIBILITY <= JavaVersion.VERSION_1_8) { + // suppressed "source/target value 8 is obsolete and will be removed in a future release" + options.compilerArgs << '-Xlint:-options' } } java { - // Loom will automatically attach sourcesJar to a RemapSourcesJar task and to the "build" task - // if it is present. - // If you remove this line, sources will not be generated. - withSourcesJar() + sourceCompatibility = JAVA_COMPATIBILITY + targetCompatibility = JAVA_COMPATIBILITY + //withSourcesJar() } jar { - from("LICENSE") { - rename { "${it}_${project.archivesBaseName}"} - } + from(rootProject.file('LICENSE')) { + rename { "${it}_${project.archives_base_name}" } + } } diff --git a/gradle.properties b/gradle.properties index e5735b68..2eff9be7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,10 +1,19 @@ -org.gradle.jvmargs=-Xmx6G -# This is base gradle.properties file for all projects in the workspace. -# This must not contain specific configuration for any project, such as minecraft version, etc. -# Fabric Properties - loader_version=0.15.11 +# Gradle Properties + org.gradle.jvmargs=-Xmx6G + +# Fabric Basic Properties + loader_version=0.16.9 # Mod Properties - mod_version = 7.2.1 + mod_id = litematica-printer + mod_name = Litematica Printer + mod_version = 7.2.2 maven_group = aria1th.extensions archives_base_name = litematica-printer + +# Global Dependencies + # https://github.com/Fallen-Breath/conditional-mixin + #conditionalmixin_version=0.6.3 + + # https://github.com/LlamaLad7/MixinExtras + mixinextras_version=0.3.6 diff --git a/gradle/wrapper/gradle-wrapper.jar b/gradle/wrapper/gradle-wrapper.jar index 2c352119..a4b76b95 100644 Binary files a/gradle/wrapper/gradle-wrapper.jar and b/gradle/wrapper/gradle-wrapper.jar differ diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 9355b415..e2847c82 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/jitpack.yml b/jitpack.yml new file mode 100644 index 00000000..df53b48a --- /dev/null +++ b/jitpack.yml @@ -0,0 +1,3 @@ +before_install: + - sdk install java 21.0.5-tem + - sdk use java 21.0.5-tem diff --git a/settings.gradle b/settings.gradle index 0f107813..31366e9a 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1,3 +1,5 @@ +import groovy.json.JsonSlurper + pluginManagement { repositories { maven { @@ -9,7 +11,8 @@ pluginManagement { url = "https://jitpack.io" } maven { - url "https://masa.dy.fi/maven" + name = 'Masa' + url = "https://masa.dy.fi/maven" } mavenCentral() gradlePluginPortal() @@ -19,31 +22,18 @@ pluginManagement { switch (requested.id.id) { case "com.replaymod.preprocess": { useModule("com.github.Fallen-Breath:preprocessor:${requested.version}") + break } } } } } -def versions = Arrays.asList( - //"1.16.5", - //"1.17.1", - //"1.18.2", - //"1.19.0", - //"1.19.2", - //"1.19.3", - "1.19.4", - "1.20.1", - "1.20.2", - "1.20.4", - "1.20.6", - "1.21.0", - "1.21.1" -) -for (String version : versions) { +def settings = new JsonSlurper().parseText(file('settings.json').text) +for (String version : settings.versions) { include(":$version") def proj = project(":$version") proj.projectDir = file("versions/$version") proj.buildFileName = "../../common.gradle" -} \ No newline at end of file +} diff --git a/settings.json b/settings.json new file mode 100644 index 00000000..e2a74870 --- /dev/null +++ b/settings.json @@ -0,0 +1,13 @@ +{ + "versions": [ + "1.19.4", + "1.20.1", + "1.20.2", + "1.20.4", + "1.20.6", + "1.21.0", + "1.21.1", + "1.21.3", + "1.21.4" + ] +} \ No newline at end of file diff --git a/src/main/java/io/github/eatmyvenom/litematicin/mixin/Litematica/WorldUtilsMixin.java b/src/main/java/io/github/eatmyvenom/litematicin/mixin/Litematica/WorldUtilsMixin.java index 0bc11ceb..ab6dc38c 100644 --- a/src/main/java/io/github/eatmyvenom/litematicin/mixin/Litematica/WorldUtilsMixin.java +++ b/src/main/java/io/github/eatmyvenom/litematicin/mixin/Litematica/WorldUtilsMixin.java @@ -50,7 +50,9 @@ private static void onDoEasyPlaceAction(MinecraftClient mc, CallbackInfoReturnab //in case of NPE, print log instead MessageHolder.sendMessageUncheckedUnique(mc.player, e.getMessage()); if (!hasSent && mc.player != null) { - //#if MC>=11900 + //#if MC>=12102 + //$$ mc.player.sendMessage(Text.of("Null pointer exception has occured, please upload log at https://github.com/aria1th/litematica-printer/issues"), false); + //#elseif MC>=11900 mc.player.sendMessage(Text.of("Null pointer exception has occured, please upload log at https://github.com/aria1th/litematica-printer/issues")); //#else //$$mc.player.sendMessage(new LiteralText("Null pointer exception has occured, please upload log at https://github.com/aria1th/litematica-printer/issues"), false); diff --git a/src/main/java/io/github/eatmyvenom/litematicin/mixin/quasiEssentialClient/ClientPlayerEntityMixin.java b/src/main/java/io/github/eatmyvenom/litematicin/mixin/quasiEssentialClient/ClientPlayerEntityMixin.java index 62066811..03c2ca53 100644 --- a/src/main/java/io/github/eatmyvenom/litematicin/mixin/quasiEssentialClient/ClientPlayerEntityMixin.java +++ b/src/main/java/io/github/eatmyvenom/litematicin/mixin/quasiEssentialClient/ClientPlayerEntityMixin.java @@ -48,7 +48,9 @@ private boolean canSendPacketNormally() { // if FakeAccurateBlockPlacement is active, then return false return !shouldModifyValues(); } - //#if MC>=11904 + + //#if MC>=12102 + //#elseif MC>=11904 @Redirect(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;)V", ordinal = 1), require = 0) //#else //$$@Redirect(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/Packet;)V", ordinal = 2), require = 0) @@ -63,11 +65,18 @@ private void onSendPacketVehicle(ClientPlayNetworkHandler clientPlayNetworkHandl this.getX(), this.hasVehicle()? -999.0D : this.getY(), this.getZ(), FakeAccurateBlockPlacement.fakeYaw, FakeAccurateBlockPlacement.fakePitch, + //#if MC>=12102 + //$$ this.isOnGround(), + //$$ false + //#else this.isOnGround() + //#endif )); } - //#if MC>=11904 + //#if MC>=12102 + //$$ @Redirect(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;)V", ordinal = 0), require = 0) + //#elseif MC>=11904 @Redirect(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;)V", ordinal = 2), require = 0) //#else //$$@Redirect(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/Packet;)V", ordinal = 3), require = 0) @@ -81,11 +90,18 @@ private void onSendPacketFull(ClientPlayNetworkHandler clientPlayNetworkHandler, this.getX(), this.hasVehicle()? -999.0D : this.getY(), this.getZ(), FakeAccurateBlockPlacement.fakeYaw, FakeAccurateBlockPlacement.fakePitch, + //#if MC>=12102 + //$$ this.isOnGround(), + //$$ false + //#else this.isOnGround() + //#endif )); } - //#if MC>=11904 + //#if MC>=12102 + //$$ @Redirect(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;)V", ordinal = 2), require = 0) + //#elseif MC>=11904 @Redirect(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/packet/Packet;)V", ordinal = 4), require = 0) //#else //$$@Redirect(method = "sendMovementPackets", at = @At(value = "INVOKE", target = "Lnet/minecraft/client/network/ClientPlayNetworkHandler;sendPacket(Lnet/minecraft/network/Packet;)V", ordinal = 5), require = 0) @@ -99,7 +115,12 @@ private void onSendPacketLookAndOnGround(ClientPlayNetworkHandler clientPlayNetw new PlayerMoveC2SPacket.LookAndOnGround( FakeAccurateBlockPlacement.fakeYaw, FakeAccurateBlockPlacement.fakePitch, + //#if MC>=12102 + //$$ this.isOnGround(), + //$$ false + //#else this.isOnGround() + //#endif ) ); } diff --git a/src/main/java/io/github/eatmyvenom/litematicin/utils/BedrockBreaker.java b/src/main/java/io/github/eatmyvenom/litematicin/utils/BedrockBreaker.java index 57681b05..f2e0159c 100644 --- a/src/main/java/io/github/eatmyvenom/litematicin/utils/BedrockBreaker.java +++ b/src/main/java/io/github/eatmyvenom/litematicin/utils/BedrockBreaker.java @@ -298,7 +298,11 @@ public static ActionResult interactBlock(MinecraftClient mc, BlockHitResult hitR //#else //$$ ActionResult result = mc.interactionManager.interactBlock(mc.player, mc.player.clientWorld, Hand.MAIN_HAND, hitResult); //#endif + //#if MC>=12102 + //$$ if (PRINTER_SHOULD_SWING_HAND.getBooleanValue() && result.isAccepted() && result.equals(ActionResult.SUCCESS)) { + //#else if (PRINTER_SHOULD_SWING_HAND.getBooleanValue() && result.isAccepted() && result.shouldSwingHand()) { + //#endif mc.player.swingHand(Hand.MAIN_HAND); } return result; @@ -339,6 +343,24 @@ public static void placeViaPacketReversed(MinecraftClient mc, BlockPos pos, Dire float OriginPitch = mc.player.getPitch(); float OriginYaw = mc.player.getYaw(); //#endif + //#if MC>=12102 + //$$ if (facing == Direction.DOWN) { + //$$ mc.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(OriginYaw, -90.0f, mc.player.isOnGround(), false)); + //$$ } else if (facing == Direction.UP) { + //$$ mc.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(OriginYaw, 90.0f, mc.player.isOnGround(), false)); + //$$ } else if (facing == Direction.EAST) { + //$$ mc.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(90.0f, OriginPitch, mc.player.isOnGround(), false)); + //$$ } else if (facing == Direction.WEST) { + //$$ mc.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(-90.0f, OriginPitch, mc.player.isOnGround(), false)); + //$$ } else if (facing == Direction.NORTH) { + //$$ mc.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(0.0f, OriginPitch, mc.player.isOnGround(), false)); + //$$ } else if (facing == Direction.SOUTH) { + //$$ mc.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(180.0f, OriginPitch, mc.player.isOnGround(), false)); + //$$ } + //$$ BlockHitResult hitResult = new BlockHitResult(hitPos, facing, npos, false); + //$$ handleTweakPlacementPacket(mc, hitResult); + //$$ mc.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(OriginYaw, OriginPitch, mc.player.isOnGround(), false)); + //#else if (facing == Direction.DOWN) { mc.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(OriginYaw, -90.0f, mc.player.isOnGround())); } else if (facing == Direction.UP) { @@ -355,6 +377,7 @@ public static void placeViaPacketReversed(MinecraftClient mc, BlockPos pos, Dire BlockHitResult hitResult = new BlockHitResult(hitPos, facing, npos, false); handleTweakPlacementPacket(mc, hitResult); mc.getNetworkHandler().sendPacket(new PlayerMoveC2SPacket.LookAndOnGround(OriginYaw, OriginPitch, mc.player.isOnGround())); + //#endif } public static void handleTweakPlacementPacket(MinecraftClient mc, BlockHitResult hitResult) { diff --git a/src/main/java/io/github/eatmyvenom/litematicin/utils/Breaker.java b/src/main/java/io/github/eatmyvenom/litematicin/utils/Breaker.java index 9b1128b3..6e862334 100644 --- a/src/main/java/io/github/eatmyvenom/litematicin/utils/Breaker.java +++ b/src/main/java/io/github/eatmyvenom/litematicin/utils/Breaker.java @@ -101,7 +101,11 @@ public static float getBlockBreakingSpeed(BlockState block, MinecraftClient mc, } float f = InventoryUtils.getInventory(mc.player).main.get(slotId).getMiningSpeedMultiplier(block); if (f > 1.0F) { - //#if MC >= 12100 + //#if MC>=12102 + //$$ ItemStack itemStack = mc.player.getInventory().getMainHandStack(); + //$$ Optional> optional = mc.world.getRegistryManager().getOptionalEntry(Enchantments.EFFICIENCY); + //$$ int i = optional.map(enchantmentReference -> EnchantmentHelper.getLevel(enchantmentReference, itemStack)).orElse(0); + //#elseif MC >= 12100 //$$ ItemStack itemStack = mc.player.getInventory().getMainHandStack(); //$$ Optional> optional = mc.world.getRegistryManager().get(RegistryKeys.ENCHANTMENT).getEntry(Enchantments.EFFICIENCY); //$$ int i = optional.map(enchantmentReference -> EnchantmentHelper.getLevel(enchantmentReference, itemStack)).orElse(0); diff --git a/src/main/java/io/github/eatmyvenom/litematicin/utils/FakeAccurateBlockPlacement.java b/src/main/java/io/github/eatmyvenom/litematicin/utils/FakeAccurateBlockPlacement.java index 7ae933c3..cba73aa1 100644 --- a/src/main/java/io/github/eatmyvenom/litematicin/utils/FakeAccurateBlockPlacement.java +++ b/src/main/java/io/github/eatmyvenom/litematicin/utils/FakeAccurateBlockPlacement.java @@ -185,7 +185,12 @@ public static void sendLookPacket(ClientPlayNetworkHandler networkHandler, Clien //#endif fakeYaw, fakePitch, + //#if MC>=12102 + //$$ playerEntity.isOnGround(), + //$$ false + //#else playerEntity.isOnGround() + //#endif ) ); //System.out.print(fakeYaw); diff --git a/src/main/java/io/github/eatmyvenom/litematicin/utils/InventoryUtils.java b/src/main/java/io/github/eatmyvenom/litematicin/utils/InventoryUtils.java index 2551a624..b659e896 100644 --- a/src/main/java/io/github/eatmyvenom/litematicin/utils/InventoryUtils.java +++ b/src/main/java/io/github/eatmyvenom/litematicin/utils/InventoryUtils.java @@ -158,7 +158,11 @@ public static boolean isCreative(ClientPlayerEntity player) { public static boolean isToolLikeItem(Item item) { // ToolItem or FlintAndSteelItem or ShearsItem + //#if MC>=12102 + //$$ return item instanceof MiningToolItem || item instanceof FlintAndSteelItem || item instanceof ShearsItem; + //#else return item instanceof ToolItem || item instanceof FlintAndSteelItem || item instanceof ShearsItem; + //#endif } public static void decrementCount(boolean isCreative) { @@ -297,7 +301,11 @@ public static boolean areItemsExactAllowNamed(ItemStack a, ItemStack b) { if (isToolLikeItem(a.getItem()) || isToolLikeItem(b.getItem())) { return a.getItem() == b.getItem(); } + //#if MC>=12102 + //$$ else if (a.getItem() instanceof MiningToolItem || b.getItem() instanceof MiningToolItem) { + //#else else if (a.getItem() instanceof ToolItem || b.getItem() instanceof ToolItem) { + //#endif return false; // safety } //#if MC >= 12006 @@ -339,7 +347,11 @@ public static boolean canSwap(ClientPlayerEntity player, Predicate pr Inventory inv = getInventory(player); for (int i = 0; i < inv.size(); i++) { ItemStack stack = inv.getStack(i); + //#if MC>=12102 + //$$ if (stack.getItem() instanceof MiningToolItem && predicate.test(stack)) { + //#else if (stack.getItem() instanceof ToolItem && predicate.test(stack)) { + //#endif return true; } } @@ -421,7 +433,11 @@ synchronized public static ItemStack findItem(MinecraftClient client, Predicate< Inventory inv = getInventory(player); for (int i = 0; i < inv.size(); i++) { ItemStack stack = inv.getStack(i); + //#if MC>=12102 + //$$ if (stack.getItem() instanceof MiningToolItem && predicate.test(stack)) { + //#else if (stack.getItem() instanceof ToolItem && predicate.test(stack)) { + //#endif return stack; } } @@ -435,7 +451,11 @@ synchronized public static boolean swapToItem(MinecraftClient client, Predicate< public static int getSlotWithStack(ClientPlayerEntity player, ItemStack stack) { PlayerInventory inv = getInventory(player); + //#if MC>=12102 + //$$ return stack.getItem() instanceof MiningToolItem || isToolLikeItem(stack.getItem()) ? getSlotWithItem(inv, stack) :getSlotWIthStackIgnoreNbt(getInventory(player), stack); + //#else return stack.getItem() instanceof ToolItem || isToolLikeItem(stack.getItem()) ? getSlotWithItem(inv, stack) :getSlotWIthStackIgnoreNbt(getInventory(player), stack); + //#endif } public static void printAllItems(PlayerInventory inv, ItemStack stack) { @@ -472,7 +492,11 @@ public static int getSlotWIthStackIgnoreNbt(PlayerInventory inv, ItemStack stack public static int getSlotWithStack(PlayerInventory inv, ItemStack stack) { int findingStack = getSlotWIthStackIgnoreNbt(inv, stack); + //#if MC>=12102 + //$$ return stack.getItem() instanceof MiningToolItem || isToolLikeItem(stack.getItem()) ? getSlotWithItem(inv, stack) :findingStack; + //#else return stack.getItem() instanceof ToolItem || isToolLikeItem(stack.getItem()) ? getSlotWithItem(inv, stack) :findingStack; + //#endif } @SuppressWarnings("ConstantConditions") diff --git a/src/main/java/io/github/eatmyvenom/litematicin/utils/MessageHolder.java b/src/main/java/io/github/eatmyvenom/litematicin/utils/MessageHolder.java index 6258d209..3fdc07d4 100644 --- a/src/main/java/io/github/eatmyvenom/litematicin/utils/MessageHolder.java +++ b/src/main/java/io/github/eatmyvenom/litematicin/utils/MessageHolder.java @@ -28,7 +28,9 @@ public static void sendPacketOrders(String string) { private static void send(String string) { final ClientPlayerEntity player = MinecraftClient.getInstance().player; - //#if MC>=11900 + //#if MC>=12102 + //$$ player.sendMessage(Text.of(string), false); + //#elseif MC>=11900 player.sendMessage(Text.of(string)); //#else //$$player.sendMessage(new LiteralText(string), false); diff --git a/src/main/java/io/github/eatmyvenom/litematicin/utils/Printer.java b/src/main/java/io/github/eatmyvenom/litematicin/utils/Printer.java index 105991bd..7057a474 100644 --- a/src/main/java/io/github/eatmyvenom/litematicin/utils/Printer.java +++ b/src/main/java/io/github/eatmyvenom/litematicin/utils/Printer.java @@ -123,7 +123,11 @@ public static boolean canPickBlock(MinecraftClient mc, BlockState preference, Bl if (!stack.isEmpty() && stack.getItem() != Items.AIR) { PlayerInventory inv = getInventory(mc.player); if (!isCreative(mc.player)) { + //#if MC>=12102 + //$$ if (stack.getItem() instanceof MiningToolItem || stack.getItem() instanceof FlintAndSteelItem) { + //#else if (stack.getItem() instanceof ToolItem || stack.getItem() instanceof FlintAndSteelItem) { + //#endif // manually search through inventories int slot = io.github.eatmyvenom.litematicin.utils.InventoryUtils.getSlotWithItem(inv, stack); if (slot == -1) { @@ -1457,7 +1461,11 @@ else if (stateSchematic.isOf(Blocks.FARMLAND) && PRINTER_PRINT_DIRT_VARIANTS.get * @return true if the block is blocking a beacon */ private static boolean isBlockingBeacon(BlockState stateSchematic, BlockPos pos, ClientWorld world) { + //#if MC>=12102 + //$$ if(stateSchematic.isTransparent()) { + //#else if(stateSchematic.isTransparent(world, pos)) { + //#endif return false; } int minY = world.getBottomY(); @@ -1501,7 +1509,11 @@ private static boolean checkObserverOutputs(MinecraftClient mc, World world, Blo return true; } // if block behind is powerable block in client world, we have to check recursively + //#if MC>=12102 + //$$ if(!behindStateClient.isTransparent()) { + //#else if (!behindStateClient.isTransparent(world, behindPos)) { + //#endif return false; } // if block behind-down is QCable, we have to check recursively diff --git a/src/main/resources/assets/modid/icon.png b/src/main/resources/assets/litematica-printer/icon.png similarity index 100% rename from src/main/resources/assets/modid/icon.png rename to src/main/resources/assets/litematica-printer/icon.png diff --git a/src/main/resources/assets/litematica-printer/lang/en_us.json b/src/main/resources/assets/litematica-printer/lang/en_us.json new file mode 100644 index 00000000..0e0dcd23 --- /dev/null +++ b/src/main/resources/assets/litematica-printer/lang/en_us.json @@ -0,0 +1,3 @@ +{ + +} \ No newline at end of file diff --git a/src/main/resources/fabric.mod.json b/src/main/resources/fabric.mod.json index a2c01310..c7120612 100644 --- a/src/main/resources/fabric.mod.json +++ b/src/main/resources/fabric.mod.json @@ -1,9 +1,9 @@ { "schemaVersion": 1, - "id": "litematica_printer", + "id": "${id}", "version": "${version}", - "name": "Litematica Printer", + "name": "${name}", "description": "Replaces EasyPlace with a printer to make building even easier.", "authors": [ "eatmyvenom, jensvh, aria1th" @@ -14,7 +14,7 @@ }, "license": "CC0-1.0", - "icon": "assets/modid/icon.png", + "icon": "assets/litematica-printer/icon.png", "environment": "*", "entrypoints": { "main": [ @@ -26,7 +26,7 @@ ], "depends": { - "fabricloader": ">=0.15.10", + "fabricloader": ">=0.16.7", "fabric": "*", "minecraft": "${minecraft_dependency}", "litematica": "*" diff --git a/src/main/resources/litematica-printer.mixins.json b/src/main/resources/litematica-printer.mixins.json index d7f2a697..9f2f2f63 100644 --- a/src/main/resources/litematica-printer.mixins.json +++ b/src/main/resources/litematica-printer.mixins.json @@ -2,7 +2,7 @@ "required": true, "minVersion": "0.8", "package": "io.github.eatmyvenom.litematicin.mixin", - "compatibilityLevel": "JAVA_8", + "compatibilityLevel": "{{COMPATIBILITY_LEVEL}}", "plugin": "io.github.eatmyvenom.litematicin.utils.MixinConfigPlugin", "client": [ "EssentialClient.FakeLookMixin", diff --git a/versions/1.19.4/gradle.properties b/versions/1.19.4/gradle.properties index 64292887..06a6eb0c 100644 --- a/versions/1.19.4/gradle.properties +++ b/versions/1.19.4/gradle.properties @@ -5,6 +5,13 @@ fabricapi_version=0.76.0+1.19.4 minecraft_version_out=1.19.4 +# Fabric Mod Metadata + minecraft_dependency=1.19.x + +# Build Information +# The target mc versions for the mod during mod publishing, separated with \n + game_versions=1.19\n1.19.1\n1.19.2\n1.19.3\n1.19.4 + # Mod Properties malilib_projectid=303119 malilib_fileid=4444338 diff --git a/versions/1.20.1/gradle.properties b/versions/1.20.1/gradle.properties index 1cfdc686..13c9d9b4 100644 --- a/versions/1.20.1/gradle.properties +++ b/versions/1.20.1/gradle.properties @@ -5,6 +5,13 @@ fabricapi_version=0.83.1+1.20.1 minecraft_version_out =1.20.x +# Fabric Mod Metadata + minecraft_dependency=>=1.20 <=1.20.1 + +# Build Information +# The target mc versions for the mod during mod publishing, separated with \n + game_versions=1.20\n1.20.1 + # Mod Properties malilib_projectid=303119 malilib_fileid=4593073 diff --git a/versions/1.20.2/gradle.properties b/versions/1.20.2/gradle.properties index 56f56c3b..5ea37831 100644 --- a/versions/1.20.2/gradle.properties +++ b/versions/1.20.2/gradle.properties @@ -5,6 +5,13 @@ fabricapi_version=0.90.0+1.20.2 minecraft_version_out =1.20.2 +# Fabric Mod Metadata + minecraft_dependency=1.20.2 + +# Build Information +# The target mc versions for the mod during mod publishing, separated with \n + game_versions=1.20.2 + # Mod Properties malilib_projectid=303119 malilib_fileid=4788432 diff --git a/versions/1.20.4/gradle.properties b/versions/1.20.4/gradle.properties index 105f47bc..68d2ba15 100644 --- a/versions/1.20.4/gradle.properties +++ b/versions/1.20.4/gradle.properties @@ -5,6 +5,13 @@ fabricapi_version=0.96.11+1.20.4 minecraft_version_out =1.20.4 +# Fabric Mod Metadata + minecraft_dependency=>=1.20.3 <=1.20.4 + +# Build Information +# The target mc versions for the mod during mod publishing, separated with \n + game_versions=1.20.3\n1.20.4 + # Mod Properties malilib_projectid=303119 malilib_fileid=4946328 diff --git a/versions/1.20.6/gradle.properties b/versions/1.20.6/gradle.properties index 1ac75af6..1a22994b 100644 --- a/versions/1.20.6/gradle.properties +++ b/versions/1.20.6/gradle.properties @@ -5,11 +5,18 @@ fabricapi_version=0.97.8+1.20.6 minecraft_version_out = 1.20.6 +# Fabric Mod Metadata + minecraft_dependency=>=1.20.5 <=1.20.6 + +# Build Information +# The target mc versions for the mod during mod publishing, separated with \n + game_versions=1.20.5\n1.20.6 + # Mod Properties # (Jitpack.io) https://github.com/sakura-ryoko/malilib malilib_projectid = "sakura-jitpack" - malilib_fileid = 795cbdd15c - # (Jitpack.io) https://github.com/sakura-ryoko/litematica + malilib_fileid = 1.20.6-0.19.1 +# (Jitpack.io) https://github.com/sakura-ryoko/litematica litematica_projectid = "sakura-jitpack" - litematica_fileid = 3b9d213f1b + litematica_fileid = 1.20.6-0.18.2 essentialclient_filename = essential-client-1.20.1-1.3.6.jar diff --git a/versions/1.21.0/gradle.properties b/versions/1.21.0/gradle.properties index a1dadabb..6218eeab 100644 --- a/versions/1.21.0/gradle.properties +++ b/versions/1.21.0/gradle.properties @@ -5,11 +5,18 @@ fabricapi_version=0.100.1+1.21 minecraft_version_out = 1.21 +# Fabric Mod Metadata + minecraft_dependency=1.21 + +# Build Information +# The target mc versions for the mod during mod publishing, separated with \n + game_versions=1.21 + # Mod Properties # (Jitpack.io) https://github.com/sakura-ryoko/malilib malilib_projectid = "sakura-jitpack" - malilib_fileid = 1.21-0.20.2 + malilib_fileid = 1.21-0.21.5-sakura.1 # (Jitpack.io) https://github.com/sakura-ryoko/litematica litematica_projectid = "sakura-jitpack" - litematica_fileid = 1.21-0.19.2 + litematica_fileid = 1.21-0.19.54-sakura.1 essentialclient_filename = essential-client-1.20.1-1.3.6.jar diff --git a/versions/1.21.1/gradle.properties b/versions/1.21.1/gradle.properties index 7aa092bb..1595746f 100644 --- a/versions/1.21.1/gradle.properties +++ b/versions/1.21.1/gradle.properties @@ -5,11 +5,18 @@ fabricapi_version=0.102.1+1.21.1 minecraft_version_out = 1.21.1 +# Fabric Mod Metadata + minecraft_dependency=1.21.1 + +# Build Information +# The target mc versions for the mod during mod publishing, separated with \n + game_versions=1.21.1 + # Mod Properties # (Jitpack.io) https://github.com/sakura-ryoko/malilib malilib_projectid = "sakura-jitpack" - malilib_fileid = 1.21-0.20.2 + malilib_fileid = 1.21-0.21.5-sakura.1 # (Jitpack.io) https://github.com/sakura-ryoko/litematica litematica_projectid = "sakura-jitpack" - litematica_fileid = 1.21-0.19.2 + litematica_fileid = 1.21-0.19.54-sakura.1 essentialclient_filename = essential-client-1.20.1-1.3.6.jar diff --git a/versions/1.21.3/gradle.properties b/versions/1.21.3/gradle.properties new file mode 100644 index 00000000..62eb8111 --- /dev/null +++ b/versions/1.21.3/gradle.properties @@ -0,0 +1,22 @@ +# Fabric Properties + # check these on https://fabricmc.net/use + minecraft_version=1.21.3 + yarn_mappings=1.21.3+build.2 + fabricapi_version=0.106.1+1.21.3 + minecraft_version_out = 1.21.3 + +# Fabric Mod Metadata + minecraft_dependency=>=1.21.2 <=1.21.3 + +# Build Information +# The target mc versions for the mod during mod publishing, separated with \n + game_versions=1.21.2\n1.21.3 + +# Mod Properties + # (Jitpack.io) https://github.com/sakura-ryoko/malilib + malilib_projectid = "sakura-jitpack" + malilib_fileid = 1.21.3-0.22.3-sakura.1 + # (Jitpack.io) https://github.com/sakura-ryoko/litematica + litematica_projectid = "sakura-jitpack" + litematica_fileid = 1.21.3-0.20.2-sakura.1 + essentialclient_filename = essential-client-1.20.1-1.3.6.jar diff --git a/versions/1.21.4/gradle.properties b/versions/1.21.4/gradle.properties new file mode 100644 index 00000000..4b38a77a --- /dev/null +++ b/versions/1.21.4/gradle.properties @@ -0,0 +1,22 @@ +# Fabric Properties + # check these on https://fabricmc.net/use + minecraft_version=1.21.4 + yarn_mappings=1.21.4+build.1 + fabricapi_version=0.110.5+1.21.4 + minecraft_version_out = 1.21.4 + +# Fabric Mod Metadata + minecraft_dependency=1.21.4 + +# Build Information +# The target mc versions for the mod during mod publishing, separated with \n + game_versions=1.21.4 + +# Mod Properties + # (Jitpack.io) https://github.com/sakura-ryoko/malilib + malilib_projectid = "sakura-jitpack" + malilib_fileid = 1.21.4-0.23.0-sakura.1 + # (Jitpack.io) https://github.com/sakura-ryoko/litematica + litematica_projectid = "sakura-jitpack" + litematica_fileid = 1.21.4-0.21.0-sakura.1 + essentialclient_filename = essential-client-1.20.1-1.3.6.jar diff --git a/versions/mapping-1.21.3-1.21.1.txt b/versions/mapping-1.21.3-1.21.1.txt new file mode 100644 index 00000000..e69de29b diff --git a/versions/mapping-1.21.4-1.21.3.txt b/versions/mapping-1.21.4-1.21.3.txt new file mode 100644 index 00000000..e69de29b