From 9e75c2cf05c6cbf3f8c43cb61465d9b4c2a1072c Mon Sep 17 00:00:00 2001 From: LatvianModder Date: Tue, 11 Jan 2022 18:39:54 +0200 Subject: [PATCH] Updated to 1.18 --- .github/workflows/build-release.yml | 35 +++ build.gradle | 206 ++++++++---------- gradle.properties | 20 +- gradle/wrapper/gradle-wrapper.properties | 5 +- settings.gradle | 9 + .../StructureExpansion.java | 10 + .../commands/CommandClean.java | 72 +++--- .../commands/StructureCommand.java | 24 -- .../CUpdateStructureBlockPacketMixin.java | 133 ----------- ...rverboundSetStructureBlockPacketMixin.java | 61 ++++++ ...in.java => StructureBlockEntityMixin.java} | 8 +- .../mixin/StructureBlockRendererMixin.java | 14 ++ .../StructureBlockTileEntityRenderMixin.java | 18 -- .../resources/META-INF/accesstransformer.cfg | 1 - src/main/resources/META-INF/mods.toml | 48 ++-- .../assets/structureexpansion/lang/en_us.json | 2 - src/main/resources/pack.mcmeta | 2 +- .../resources/structureexpansion.mixins.json | 29 ++- 18 files changed, 305 insertions(+), 392 deletions(-) create mode 100644 .github/workflows/build-release.yml create mode 100644 settings.gradle delete mode 100644 src/main/java/com/sunekaer/mods/structureexpansion/commands/StructureCommand.java delete mode 100644 src/main/java/com/sunekaer/mods/structureexpansion/mixin/CUpdateStructureBlockPacketMixin.java create mode 100644 src/main/java/com/sunekaer/mods/structureexpansion/mixin/ServerboundSetStructureBlockPacketMixin.java rename src/main/java/com/sunekaer/mods/structureexpansion/mixin/{StructureBlockTileEntityMixin.java => StructureBlockEntityMixin.java} (67%) create mode 100644 src/main/java/com/sunekaer/mods/structureexpansion/mixin/StructureBlockRendererMixin.java delete mode 100644 src/main/java/com/sunekaer/mods/structureexpansion/mixin/StructureBlockTileEntityRenderMixin.java delete mode 100644 src/main/resources/META-INF/accesstransformer.cfg delete mode 100644 src/main/resources/assets/structureexpansion/lang/en_us.json diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml new file mode 100644 index 0000000..03704e2 --- /dev/null +++ b/.github/workflows/build-release.yml @@ -0,0 +1,35 @@ +name: Build & Release + +on: + push: + tags: + - 'v*' + +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/cache@v2 + with: + path: | + ~/.gradle/caches + ~/.gradle/wrapper + key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} + restore-keys: | + ${{ runner.os }}-gradle- + - uses: actions/checkout@v2 + with: + fetch-depth: 30 # Gets the last 30 commits so the changelog might work + - name: Set up JDK + uses: actions/setup-java@v1 + with: + java-version: 17 + - name: Build & release to curseforge + env: + GIT_COMMIT: ${{ github.event.after }} + GIT_PREVIOUS_COMMIT: ${{ github.event.before }} + NANITE_DEPLOY: ${{ secrets.NANITE_DEPLOY }} + CURSE_DEPLOY: ${{ secrets.CURSE_DEPLOY }} + run: | + chmod +x ./gradlew + ./gradlew build publish curseforge --stacktrace --no-daemon \ No newline at end of file diff --git a/build.gradle b/build.gradle index 220ed23..7afbed9 100644 --- a/build.gradle +++ b/build.gradle @@ -1,143 +1,113 @@ -buildscript { - repositories { - jcenter() - maven { url = 'https://files.minecraftforge.net/maven' } - maven { url "https://plugins.gradle.org/m2/" } - maven { url "https://repo.spongepowered.org/repository/maven-public/" } - mavenCentral() - } - dependencies { - classpath group: 'net.minecraftforge.gradle', name: 'ForgeGradle', version: '3.+', changing: true - classpath 'gradle.plugin.com.matthewprenger:CurseGradle:1.1.0' - classpath 'com.wynprice.cursemaven:CurseMaven:1.2.+' - classpath 'org.spongepowered:mixingradle:0.7-SNAPSHOT' - } +plugins { + id "dev.architectury.loom" version "0.10.0-SNAPSHOT" + id 'maven-publish' + id "com.matthewprenger.cursegradle" version "1.4.0" } -apply plugin: 'net.minecraftforge.gradle' -apply plugin: 'eclipse' -apply plugin: 'com.matthewprenger.cursegradle' -apply plugin: 'maven' -apply plugin: 'com.wynprice.cursemaven' -apply plugin: 'org.spongepowered.mixin' -apply from: 'https://raw.githubusercontent.com/MinecraftModDevelopment/Gradle-Collection/master/generic/markdown-git-changelog.gradle' +apply from: 'https://files.latmod.com/public/markdown-git-changelog.gradle' +sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = 17 def ENV = System.getenv() -version = ENV.BUILD_NUMBER ? "${project_version}.${ENV.BUILD_NUMBER}" : "${project_version}.custom" -group = 'com.sunekaer.mods' -archivesBaseName = 'StructureExpansion' - -sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' - -minecraft { - mappings channel: 'snapshot', version: "${mcp_mappings}" - accessTransformer = file('src/main/resources/META-INF/accesstransformer.cfg') - runs { - client { - workingDirectory project.file('run') - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' - property 'forge.logging.console.level', 'debug' - args '--mixin.config', 'structureexpansion.mixins.json' - mods { - structureexpansion { - source sourceSets.main - } - } - } - - server { - workingDirectory project.file('run') - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' - property 'forge.logging.console.level', 'debug' - args '--mixin.config', 'structureexpansion.mixins.json' - mods { - structureexpansion { - source sourceSets.main - } - } - } - data { - workingDirectory project.file('run') - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' - property 'forge.logging.console.level', 'debug' - args '--mod', 'structureexpansion', '--all', '--output', file('src/generated/resources/') - args '--mixin.config', 'structureexpansion.mixins.json' - mods { - structureexpansion { - source sourceSets.main - } - } - } - } +version = "${mod_version}-build.${ENV.GITHUB_RUN_NUMBER ?: 9999}" +archivesBaseName = project.archives_base_name +group = project.maven_group + +loom { + silentMojangMappingsLicense() + + forge { + mixinConfigs = [ + 'structureexpansion.mixins.json' + ] + + dataGen { + mod project.mod_id + } + + launches { + data { + arg "--existing", file("src/main/resources").absolutePath + } + } + } } repositories { - mavenLocal() - maven { url "https://maven.latmod.com/" } - maven { url "https://dvs1.progwml6.com/files/maven/"} } dependencies { - minecraft "net.minecraftforge:forge:${minecraft_version}-${forge_version}" -} + minecraft "com.mojang:minecraft:${project.minecraft_version}" + mappings minecraft.officialMojangMappings() -mixin { - add sourceSets.main, "structureexpansion.refmap.json" + forge "net.minecraftforge:forge:${project.minecraft_version}-${project.forge_version}" } -jar { - manifest { - attributes([ - "MixinConfigs": "structureexpansion.mixins.json", - "Specification-Title": "structureexpansion", - "Specification-Vendor": "Sunekaer", - "Specification-Version": "1", // We are version 1 of ourselves - "Implementation-Title": project.name, - "Implementation-Version": "${version}", - "Implementation-Vendor" :"Sunekaer", - "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") - ]) - } -} +processResources { + inputs.property "version", project.version -def reobfFile = file("$buildDir/reobfJar/output.jar") -def reobfArtifact = artifacts.add('default', reobfFile) { - type 'jar' - builtBy 'reobfJar' + filesMatching("META-INF/mods.toml") { + expand "version": project.version + } } -task deobfJar(type: Jar) { - from sourceSets.main.output - classifier 'deobf' +compileJava { + options.encoding = "UTF-8" } -build.dependsOn deobfJar +java { + withSourcesJar() +} -artifacts { - archives deobfJar +jar { + from("LICENSE") { + rename { "${it}_${project.archivesBaseName}" } + } + + manifest { + attributes([ + "Specification-Title" : project.mod_id, + "Specification-Vendor" : project.mod_author, + "Specification-Version" : "1", + "Implementation-Title" : project.name, + "Implementation-Version" : version, + "Implementation-Vendor" : project.mod_author, + "Implementation-Timestamp": new Date().format("yyyy-MM-dd'T'HH:mm:ssZ") + ]) + } } -if (ENV.LOCAL_MAVEN) { - uploadArchives { - repositories { - mavenDeployer { - repository(url: "file://${ENV.LOCAL_MAVEN}") - } - } - } +publishing { + publications { + mavenForge(MavenPublication) { + artifactId = rootProject.archivesBaseName + from components.java + } + } + + repositories { + if (ENV.NANITE_DEPLOY) { + maven { + url "https://maven.nanite.dev/" + credentials { + username = "nanite" + password = "${ENV.NANITE_DEPLOY}" + } + } + } + } } -if (ENV.WTBW_CF_KEY) { - curseforge { - apiKey = ENV.WTBW_CF_KEY - project { - id = "398430" - releaseType = "release" - addGameVersion "1.16.5" - changelog = getGitChangelog - changelogType = 'markdown' - addArtifact(deobfJar) - } - } +if (ENV.CURSE_DEPLOY) { + curseforge { + apiKey = ENV.CURSE_DEPLOY + project { + id = project.curseforge_id + releaseType = project.curseforge_type + addGameVersion "1.18.1" + mainArtifact(remapJar.archivePath) + changelog = getGitChangelog + changelogType = 'markdown' + } + } } \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 309dc37..acc6e75 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,9 +1,11 @@ -# Sets default memory used for gradle commands. Can be overridden by user or command line properties. -# This is required to provide enough memory for the Minecraft decompilation process. -org.gradle.jvmargs=-Xmx3G -org.gradle.daemon=false - -project_version=1.16.5-1.0 -mcp_mappings=20210309-1.16.5 -minecraft_version=1.16.5 -forge_version=36.1.0 \ No newline at end of file +org.gradle.jvmargs=-Xmx1G +loom.platform=forge +mod_id=structure-expansion +archives_base_name=structure-expansion +maven_group=com.sunekaer.mods +minecraft_version=1.18.1 +mod_version=1801.1.0 +mod_author=LatvianModder +forge_version=39.0.10 +curseforge_id=398430 +curseforge_type=release diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 85ba130..b72c1af 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,5 @@ -#Mon Jul 27 23:20:33 CEST 2020 -distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.3-all.zip distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -zipStorePath=wrapper/dists zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.2-bin.zip \ No newline at end of file diff --git a/settings.gradle b/settings.gradle new file mode 100644 index 0000000..a93d69f --- /dev/null +++ b/settings.gradle @@ -0,0 +1,9 @@ +pluginManagement { + repositories { + maven { url "https://maven.creeperhost.net/" } + maven { url "https://maven.shedaniel.me/" } + gradlePluginPortal() + } +} + +rootProject.name = 'Structure-Expansion' \ No newline at end of file diff --git a/src/main/java/com/sunekaer/mods/structureexpansion/StructureExpansion.java b/src/main/java/com/sunekaer/mods/structureexpansion/StructureExpansion.java index dbacf1e..345a340 100644 --- a/src/main/java/com/sunekaer/mods/structureexpansion/StructureExpansion.java +++ b/src/main/java/com/sunekaer/mods/structureexpansion/StructureExpansion.java @@ -1,10 +1,20 @@ package com.sunekaer.mods.structureexpansion; +import com.sunekaer.mods.structureexpansion.commands.CommandClean; +import net.minecraft.commands.Commands; +import net.minecraftforge.event.RegisterCommandsEvent; +import net.minecraftforge.eventbus.api.SubscribeEvent; import net.minecraftforge.fml.common.Mod; @Mod("structureexpansion") +@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.FORGE) public class StructureExpansion { public static final int NEW_LIMIT = 512; public static final int NEW_LIMIT_POS = NEW_LIMIT - 1; public static final int NEW_LIMIT_NEG = -NEW_LIMIT_POS; + + @SubscribeEvent + public static void registerCommands(RegisterCommandsEvent event) { + event.getDispatcher().register(Commands.literal("structure").then(CommandClean.register())); + } } diff --git a/src/main/java/com/sunekaer/mods/structureexpansion/commands/CommandClean.java b/src/main/java/com/sunekaer/mods/structureexpansion/commands/CommandClean.java index 1c1b817..7d20702 100644 --- a/src/main/java/com/sunekaer/mods/structureexpansion/commands/CommandClean.java +++ b/src/main/java/com/sunekaer/mods/structureexpansion/commands/CommandClean.java @@ -2,46 +2,38 @@ import com.mojang.brigadier.arguments.StringArgumentType; import com.mojang.brigadier.builder.ArgumentBuilder; -import net.minecraft.block.Blocks; -import net.minecraft.command.CommandSource; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.text.TranslationTextComponent; -import net.minecraft.world.gen.feature.template.Template; -import net.minecraft.world.gen.feature.template.TemplateManager; -import net.minecraft.world.server.ServerWorld; - -import static net.minecraft.command.Commands.argument; -import static net.minecraft.command.Commands.literal; - +import net.minecraft.commands.CommandSourceStack; +import net.minecraft.commands.Commands; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureManager; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate; public class CommandClean { - public static ArgumentBuilder register() { - return literal("clean") - .requires(cs -> cs.hasPermissionLevel(2)) - .then(argument("structure_file", StringArgumentType.string()) - .executes(ctx -> cleanStruc( - ctx.getSource(), - StringArgumentType.getString(ctx, "structure_file") - ) - ) - ); - } - - private static int cleanStruc(CommandSource source, String file) { - - ServerWorld worldServer = source.getWorld(); - TemplateManager templateManager = worldServer.getStructureTemplateManager(); - ResourceLocation name = new ResourceLocation(file); - Template template = templateManager.getTemplate(name); - - template.blocks.forEach(e -> { - int preSize = e.func_237157_a_().size(); - e.func_237157_a_().removeIf(a -> a.state.getBlock() == Blocks.AIR); - int removed = preSize - e.func_237157_a_().size(); - source.sendFeedback(new TranslationTextComponent("Removed " + removed + " air blocks"), true); - }); - templateManager.writeToFile(name); - - return 1; - } + public static ArgumentBuilder register() { + return Commands.literal("clean") + .requires(cs -> cs.hasPermission(2)) + .then(Commands.argument("structure_file", StringArgumentType.string()) + .executes(ctx -> cleanStruc(ctx.getSource(), StringArgumentType.getString(ctx, "structure_file"))) + ); + } + + private static int cleanStruc(CommandSourceStack source, String file) { + ServerLevel worldServer = source.getLevel(); + StructureManager templateManager = worldServer.getStructureManager(); + ResourceLocation name = new ResourceLocation(file); + StructureTemplate template = templateManager.getOrCreate(name); + + /* + template.blocks.forEach(e -> { + int preSize = e.func_237157_a_().size(); + e.func_237157_a_().removeIf(a -> a.state.getBlock() == Blocks.AIR); + int removed = preSize - e.func_237157_a_().size(); + source.sendSuccess(new TranslatableComponent("Removed " + removed + " air blocks"), true); + }); + */ + + templateManager.save(name); + return 1; + } } diff --git a/src/main/java/com/sunekaer/mods/structureexpansion/commands/StructureCommand.java b/src/main/java/com/sunekaer/mods/structureexpansion/commands/StructureCommand.java deleted file mode 100644 index 38068cd..0000000 --- a/src/main/java/com/sunekaer/mods/structureexpansion/commands/StructureCommand.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.sunekaer.mods.structureexpansion.commands; - -import com.mojang.brigadier.CommandDispatcher; -import net.minecraft.command.CommandSource; -import net.minecraft.command.Commands; -import net.minecraftforge.event.RegisterCommandsEvent; -import net.minecraftforge.eventbus.api.SubscribeEvent; -import net.minecraftforge.fml.common.Mod; - -@Mod.EventBusSubscriber(modid = "structureexpansion", bus = Mod.EventBusSubscriber.Bus.FORGE) -public class StructureCommand { - @SubscribeEvent - public static void registerCommands(RegisterCommandsEvent event) - { - new StructureCommand(event.getDispatcher()); - } - - public StructureCommand(CommandDispatcher dispatcher) { - dispatcher.register( - Commands.literal("structure") - .then(CommandClean.register()) - ); - } -} diff --git a/src/main/java/com/sunekaer/mods/structureexpansion/mixin/CUpdateStructureBlockPacketMixin.java b/src/main/java/com/sunekaer/mods/structureexpansion/mixin/CUpdateStructureBlockPacketMixin.java deleted file mode 100644 index 03b2f0c..0000000 --- a/src/main/java/com/sunekaer/mods/structureexpansion/mixin/CUpdateStructureBlockPacketMixin.java +++ /dev/null @@ -1,133 +0,0 @@ -package com.sunekaer.mods.structureexpansion.mixin; - -import com.sunekaer.mods.structureexpansion.StructureExpansion; -import net.minecraft.network.PacketBuffer; -import net.minecraft.network.play.client.CUpdateStructureBlockPacket; -import net.minecraft.state.properties.StructureMode; -import net.minecraft.tileentity.StructureBlockTileEntity; -import net.minecraft.util.Mirror; -import net.minecraft.util.Rotation; -import net.minecraft.util.math.BlockPos; -import net.minecraft.util.math.MathHelper; -import org.spongepowered.asm.mixin.Mixin; -import org.spongepowered.asm.mixin.Overwrite; -import org.spongepowered.asm.mixin.Shadow; - -import java.io.IOException; - -@Mixin(CUpdateStructureBlockPacket.class) -public abstract class CUpdateStructureBlockPacketMixin { - @Shadow - private BlockPos pos; - - @Shadow - private StructureBlockTileEntity.UpdateCommand updateCommand; - - @Shadow - private StructureMode mode; - - @Shadow - private String name; - - @Shadow - private BlockPos position; - - @Shadow - private BlockPos size; - - @Shadow - private Mirror mirror; - - @Shadow - private Rotation rotation; - - @Shadow - private String metaData; - - @Shadow - private boolean ignoreEntities; - - @Shadow - private boolean showAir; - - @Shadow - private boolean showBoundingBox; - - @Shadow - private float integrity; - - @Shadow - private long seed; - - /** - * @author LatvianModder - * @reason to fix 48 block limit - */ - @Overwrite - public void readPacketData(PacketBuffer buf) throws IOException { - pos = buf.readBlockPos(); - updateCommand = buf.readEnumValue(StructureBlockTileEntity.UpdateCommand.class); - mode = buf.readEnumValue(StructureMode.class); - name = buf.readString(32767); - - position = new BlockPos( - MathHelper.clamp(buf.readVarInt(), StructureExpansion.NEW_LIMIT_NEG, StructureExpansion.NEW_LIMIT_POS), - MathHelper.clamp(buf.readVarInt(), StructureExpansion.NEW_LIMIT_NEG, StructureExpansion.NEW_LIMIT_POS), - MathHelper.clamp(buf.readVarInt(), StructureExpansion.NEW_LIMIT_NEG, StructureExpansion.NEW_LIMIT_POS) - ); - - size = new BlockPos( - MathHelper.clamp(buf.readVarInt(), 0, StructureExpansion.NEW_LIMIT_POS), - MathHelper.clamp(buf.readVarInt(), 0, StructureExpansion.NEW_LIMIT_POS), - MathHelper.clamp(buf.readVarInt(), 0, StructureExpansion.NEW_LIMIT_POS) - ); - - mirror = buf.readEnumValue(Mirror.class); - rotation = buf.readEnumValue(Rotation.class); - metaData = buf.readString(12); - integrity = MathHelper.clamp(buf.readFloat(), 0.0F, 1.0F); - seed = buf.readVarLong(); - int k = buf.readVarInt(); - ignoreEntities = (k & 1) != 0; - showAir = (k & 2) != 0; - showBoundingBox = (k & 4) != 0; - } - - /** - * @author LatvianModder - * @reason to fix 48 block limit - */ - @Overwrite - public void writePacketData(PacketBuffer buf) { - buf.writeBlockPos(pos); - buf.writeEnumValue(updateCommand); - buf.writeEnumValue(mode); - buf.writeString(name); - buf.writeVarInt(position.getX()); - buf.writeVarInt(position.getY()); - buf.writeVarInt(position.getZ()); - buf.writeVarInt(size.getX()); - buf.writeVarInt(size.getY()); - buf.writeVarInt(size.getZ()); - buf.writeEnumValue(mirror); - buf.writeEnumValue(rotation); - buf.writeString(metaData); - buf.writeFloat(integrity); - buf.writeVarLong(seed); - - int i = 0; - if (ignoreEntities) { - i |= 1; - } - - if (showAir) { - i |= 2; - } - - if (showBoundingBox) { - i |= 4; - } - - buf.writeVarInt(i); - } -} diff --git a/src/main/java/com/sunekaer/mods/structureexpansion/mixin/ServerboundSetStructureBlockPacketMixin.java b/src/main/java/com/sunekaer/mods/structureexpansion/mixin/ServerboundSetStructureBlockPacketMixin.java new file mode 100644 index 0000000..11fb880 --- /dev/null +++ b/src/main/java/com/sunekaer/mods/structureexpansion/mixin/ServerboundSetStructureBlockPacketMixin.java @@ -0,0 +1,61 @@ +package com.sunekaer.mods.structureexpansion.mixin; + +import com.sunekaer.mods.structureexpansion.StructureExpansion; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Vec3i; +import net.minecraft.network.FriendlyByteBuf; +import net.minecraft.network.protocol.game.ServerboundSetStructureBlockPacket; +import net.minecraft.util.Mth; +import org.spongepowered.asm.mixin.Final; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Mutable; +import org.spongepowered.asm.mixin.Shadow; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Inject; +import org.spongepowered.asm.mixin.injection.callback.CallbackInfo; + +@Mixin(ServerboundSetStructureBlockPacket.class) +public abstract class ServerboundSetStructureBlockPacketMixin { + @Shadow + @Final + @Mutable + private BlockPos offset; + + @Shadow + @Final + @Mutable + private Vec3i size; + + /** + * @author LatvianModder + * @reason to fix 48 block limit + */ + @Inject(method = "(Lnet/minecraft/network/FriendlyByteBuf;)V", at = @At("RETURN")) + public void readSE(FriendlyByteBuf buf, CallbackInfo ci) { + offset = new BlockPos( + Mth.clamp(buf.readVarInt(), StructureExpansion.NEW_LIMIT_NEG, StructureExpansion.NEW_LIMIT_POS), + Mth.clamp(buf.readVarInt(), StructureExpansion.NEW_LIMIT_NEG, StructureExpansion.NEW_LIMIT_POS), + Mth.clamp(buf.readVarInt(), StructureExpansion.NEW_LIMIT_NEG, StructureExpansion.NEW_LIMIT_POS) + ); + + size = new BlockPos( + Mth.clamp(buf.readVarInt(), 0, StructureExpansion.NEW_LIMIT_POS), + Mth.clamp(buf.readVarInt(), 0, StructureExpansion.NEW_LIMIT_POS), + Mth.clamp(buf.readVarInt(), 0, StructureExpansion.NEW_LIMIT_POS) + ); + } + + /** + * @author LatvianModder + * @reason to fix 48 block limit + */ + @Inject(method = "write", at = @At("RETURN")) + public void writeSE(FriendlyByteBuf buf, CallbackInfo ci) { + buf.writeVarInt(offset.getX()); + buf.writeVarInt(offset.getY()); + buf.writeVarInt(offset.getZ()); + buf.writeVarInt(size.getX()); + buf.writeVarInt(size.getY()); + buf.writeVarInt(size.getZ()); + } +} diff --git a/src/main/java/com/sunekaer/mods/structureexpansion/mixin/StructureBlockTileEntityMixin.java b/src/main/java/com/sunekaer/mods/structureexpansion/mixin/StructureBlockEntityMixin.java similarity index 67% rename from src/main/java/com/sunekaer/mods/structureexpansion/mixin/StructureBlockTileEntityMixin.java rename to src/main/java/com/sunekaer/mods/structureexpansion/mixin/StructureBlockEntityMixin.java index 4bbb4c2..2ed4256 100644 --- a/src/main/java/com/sunekaer/mods/structureexpansion/mixin/StructureBlockTileEntityMixin.java +++ b/src/main/java/com/sunekaer/mods/structureexpansion/mixin/StructureBlockEntityMixin.java @@ -1,14 +1,14 @@ package com.sunekaer.mods.structureexpansion.mixin; import com.sunekaer.mods.structureexpansion.StructureExpansion; -import net.minecraft.tileentity.StructureBlockTileEntity; +import net.minecraft.world.level.block.entity.StructureBlockEntity; import org.spongepowered.asm.mixin.Mixin; import org.spongepowered.asm.mixin.injection.Constant; import org.spongepowered.asm.mixin.injection.ModifyConstant; -@Mixin(StructureBlockTileEntity.class) -public abstract class StructureBlockTileEntityMixin { - @ModifyConstant(method = "read", constant = {@Constant(intValue = 48), @Constant(intValue = -48)}) +@Mixin(StructureBlockEntity.class) +public abstract class StructureBlockEntityMixin { + @ModifyConstant(method = "load", constant = {@Constant(intValue = 48), @Constant(intValue = -48)}) private int getMaxSizePos(int value) { return value > 0 ? StructureExpansion.NEW_LIMIT_POS : StructureExpansion.NEW_LIMIT_NEG; } diff --git a/src/main/java/com/sunekaer/mods/structureexpansion/mixin/StructureBlockRendererMixin.java b/src/main/java/com/sunekaer/mods/structureexpansion/mixin/StructureBlockRendererMixin.java new file mode 100644 index 0000000..9bd16c2 --- /dev/null +++ b/src/main/java/com/sunekaer/mods/structureexpansion/mixin/StructureBlockRendererMixin.java @@ -0,0 +1,14 @@ +package com.sunekaer.mods.structureexpansion.mixin; + +import com.sunekaer.mods.structureexpansion.StructureExpansion; +import net.minecraft.client.renderer.blockentity.StructureBlockRenderer; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.Overwrite; + +@Mixin(StructureBlockRenderer.class) +public abstract class StructureBlockRendererMixin { + @Overwrite + public int getViewDistance() { + return StructureExpansion.NEW_LIMIT; + } +} diff --git a/src/main/java/com/sunekaer/mods/structureexpansion/mixin/StructureBlockTileEntityRenderMixin.java b/src/main/java/com/sunekaer/mods/structureexpansion/mixin/StructureBlockTileEntityRenderMixin.java deleted file mode 100644 index 60a8e41..0000000 --- a/src/main/java/com/sunekaer/mods/structureexpansion/mixin/StructureBlockTileEntityRenderMixin.java +++ /dev/null @@ -1,18 +0,0 @@ -package com.sunekaer.mods.structureexpansion.mixin; - -import net.minecraft.tileentity.StructureBlockTileEntity; -import net.minecraft.tileentity.TileEntity; -import net.minecraft.tileentity.TileEntityType; -import org.spongepowered.asm.mixin.Mixin; - -@Mixin(StructureBlockTileEntity.class) -public abstract class StructureBlockTileEntityRenderMixin extends TileEntity { - public StructureBlockTileEntityRenderMixin(TileEntityType tileEntityType_1) { - super(tileEntityType_1); - } - - @Override - public double getMaxRenderDistanceSquared() { - return 32767D; - } -} diff --git a/src/main/resources/META-INF/accesstransformer.cfg b/src/main/resources/META-INF/accesstransformer.cfg deleted file mode 100644 index 90ddb9e..0000000 --- a/src/main/resources/META-INF/accesstransformer.cfg +++ /dev/null @@ -1 +0,0 @@ -public net.minecraft.world.gen.feature.template.Template field_204769_a # blocks \ No newline at end of file diff --git a/src/main/resources/META-INF/mods.toml b/src/main/resources/META-INF/mods.toml index 8749413..a03d3f1 100644 --- a/src/main/resources/META-INF/mods.toml +++ b/src/main/resources/META-INF/mods.toml @@ -1,29 +1,29 @@ -modLoader="javafml" -loaderVersion="[34,)" -issueTrackerURL="https://github.com/Sunekaer/Structure-Expansion/issues" -license="MIT License" -[[mods]] -modId="structureexpansion" -version="${file.jarVersion}" -displayName="Structure Expansion" -displayURL="https://www.curseforge.com/minecraft/mc-mods/structure-expansion" -logoFile="logo.png" -authors="Sunekaer" -description=''' +modLoader = "javafml" +loaderVersion = "[39,)" +issueTrackerURL = "https://github.com/nanite/Structure-Expansion/issues" +license = "MIT License" +[[mods]] +modId = "structureexpansion" +version = "${version}" +displayName = "Structure Expansion" +displayURL = "https://www.curseforge.com/minecraft/mc-mods/structure-expansion" +logoFile = "logo.png" +authors = "Sunekaer, LatvianModder" +description = ''' Small mod that Increases the size limit of the vanilla structure blocks Increases the size limit of the structure block from 48x48x48 to 127x127x127 ''' -[[dependencies.structureexpansion]] #optional - modId="forge" - mandatory=true - versionRange="[34.0.0,)" - ordering="NONE" - side="BOTH" -# Here's another dependency [[dependencies.structureexpansion]] - modId="minecraft" - mandatory=true - versionRange="[1.16.3]" - ordering="NONE" - side="BOTH" +modId = "forge" +mandatory = true +versionRange = "[39,)" +ordering = "NONE" +side = "BOTH" + +[[dependencies.structureexpansion]] +modId = "minecraft" +mandatory = true +versionRange = "[1.18,)" +ordering = "NONE" +side = "BOTH" diff --git a/src/main/resources/assets/structureexpansion/lang/en_us.json b/src/main/resources/assets/structureexpansion/lang/en_us.json deleted file mode 100644 index 7a73a41..0000000 --- a/src/main/resources/assets/structureexpansion/lang/en_us.json +++ /dev/null @@ -1,2 +0,0 @@ -{ -} \ No newline at end of file diff --git a/src/main/resources/pack.mcmeta b/src/main/resources/pack.mcmeta index a570779..7cf4126 100644 --- a/src/main/resources/pack.mcmeta +++ b/src/main/resources/pack.mcmeta @@ -1,6 +1,6 @@ { "pack": { "description": "Structure Expansion resources", - "pack_format": 5 + "pack_format": 7 } } diff --git a/src/main/resources/structureexpansion.mixins.json b/src/main/resources/structureexpansion.mixins.json index b46d2ab..dccf55d 100644 --- a/src/main/resources/structureexpansion.mixins.json +++ b/src/main/resources/structureexpansion.mixins.json @@ -1,17 +1,16 @@ { - "required": true, - "package": "com.sunekaer.mods.structureexpansion.mixin", - "compatibilityLevel": "JAVA_8", - "refmap": "structureexpansion.refmap.json", - "mixins": [ - "CUpdateStructureBlockPacketMixin", - "StructureBlockTileEntityMixin" - ], - "client": [ - "StructureBlockTileEntityRenderMixin" - ], - "injectors": { - "defaultRequire": 1 - }, - "minVersion": "0.8" + "required": true, + "package": "com.sunekaer.mods.structureexpansion.mixin", + "compatibilityLevel": "JAVA_17", + "mixins": [ + "ServerboundSetStructureBlockPacketMixin", + "StructureBlockEntityMixin" + ], + "client": [ + "StructureBlockRendererMixin" + ], + "injectors": { + "defaultRequire": 1 + }, + "minVersion": "0.8" } \ No newline at end of file