From 922f89d14cbb3486763dc40580e8a89ff499b1f3 Mon Sep 17 00:00:00 2001 From: zontreck Date: Sat, 22 Feb 2025 23:38:42 -0700 Subject: [PATCH] Begin update process to 1.21.1 --- build.gradle | 16 ++++-- gradle.properties | 12 ++-- .../java/com/zontreck/AriasEssentials.java | 12 +++- .../zontreck/ariaslib/http/HTTPMethod.java | 5 +- .../zontreck/ariaslib/http/HTTPRequest.java | 7 +-- .../ariaslib/http/HTTPRequestBuilder.java | 57 +++++++++---------- .../zontreck/ariaslib/http/HTTPResponse.java | 7 +-- .../com/zontreck/items/CreativeModeTabs.java | 14 +++-- 8 files changed, 68 insertions(+), 62 deletions(-) diff --git a/build.gradle b/build.gradle index 5fcde0f..8a3c1e0 100644 --- a/build.gradle +++ b/build.gradle @@ -1,5 +1,5 @@ plugins { - id 'dev.architectury.loom' version '1.6-SNAPSHOT' + id 'dev.architectury.loom' version '1.7-SNAPSHOT' id 'maven-publish' } @@ -13,12 +13,16 @@ base { loom { silentMojangMappingsLicense() - forge { + neoforge { mixinConfig 'ariasessentials.mixins.json' } } repositories { + maven { + name = 'NeoForged' + url = 'https://maven.neoforged.net/releases' + } // Add repositories to retrieve artifacts from in here. // You should only use this when depending on other mods because // Loom adds the essential maven repositories to download Minecraft and libraries from automatically. @@ -45,7 +49,7 @@ repositories { dependencies { minecraft "net.minecraft:minecraft:$project.minecraft_version" mappings loom.officialMojangMappings() - forge "net.minecraftforge:forge:$project.forge_version" + neoForge "net.neoforged:neoforge:$project.neoforge_version" // compile against the JEI API but do not include it at runtime @@ -68,12 +72,12 @@ java { // If you remove this line, sources will not be generated. withSourcesJar() - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 + sourceCompatibility = JavaVersion.VERSION_21 + targetCompatibility = JavaVersion.VERSION_21 } tasks.withType(JavaCompile).configureEach { - it.options.release = 17 + it.options.release = 21 } // Configure Maven publishing. diff --git a/gradle.properties b/gradle.properties index 537f0b1..dc15e4a 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,15 +1,15 @@ # Done to increase the memory available to Gradle. -org.gradle.jvmargs=-Xmx1G -loom.platform = forge +org.gradle.jvmargs=-Xmx2G +org.gradle.parallel=true # Mod properties -mod_version = 1192.2.112124.2242 +mod_version = 1211.2.112124.2242 maven_group = com.zontreck archives_name = ariasessentials # Minecraft properties -minecraft_version = 1.19.2 +minecraft_version = 1.21.1 # Dependencies -forge_version = 1.19.2-43.4.0 -jei_version = 11.6.0.1024 \ No newline at end of file +neoforge_version = 21.1.84 +yarn_mappings_patch_version = 1.21+build.4 diff --git a/src/main/java/com/zontreck/AriasEssentials.java b/src/main/java/com/zontreck/AriasEssentials.java index b0b1cf3..45bb02c 100644 --- a/src/main/java/com/zontreck/AriasEssentials.java +++ b/src/main/java/com/zontreck/AriasEssentials.java @@ -13,7 +13,13 @@ import com.zontreck.entities.ModEntities; import com.zontreck.items.DeprecatedModItems; import com.zontreck.items.ModItems; import com.zontreck.libzontreck.config.ServerConfig; +import com.zontreck.libzontreck.util.SNbtIo; + import net.minecraft.client.renderer.entity.EntityRenderers; +import net.minecraft.data.structures.NbtToSnbt; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.nbt.NbtUtils; +import net.minecraft.nbt.StringTag; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.common.MinecraftForge; import net.minecraftforge.eventbus.api.IEventBus; @@ -26,6 +32,7 @@ import org.slf4j.ILoggerFactory; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.nio.file.Path; import java.time.Instant; import java.util.Random; import java.util.logging.LogManager; @@ -38,7 +45,8 @@ public final class AriasEssentials { public AriasEssentials() { // This code runs as soon as Minecraft is in a mod-load-ready state. - // However, some things (like registries and resources) may still be uninitialized. + // However, some things (like registries and resources) may still be + // uninitialized. // Proceed with mild caution. IEventBus bus = FMLJavaModLoadingContext.get().getModEventBus(); @@ -57,8 +65,6 @@ public final class AriasEssentials { DeprecatedModBlocks.register(bus); ModBlocks.register(bus); - - } @Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD, value = Dist.CLIENT) diff --git a/src/main/java/com/zontreck/ariaslib/http/HTTPMethod.java b/src/main/java/com/zontreck/ariaslib/http/HTTPMethod.java index 162477a..0841bef 100644 --- a/src/main/java/com/zontreck/ariaslib/http/HTTPMethod.java +++ b/src/main/java/com/zontreck/ariaslib/http/HTTPMethod.java @@ -1,7 +1,6 @@ -package dev.zontreck.ariaslib.http; +package com.zontreck.ariaslib.http; -public enum HTTPMethod -{ +public enum HTTPMethod { GET, POST, PUT, diff --git a/src/main/java/com/zontreck/ariaslib/http/HTTPRequest.java b/src/main/java/com/zontreck/ariaslib/http/HTTPRequest.java index 158d92a..e3fddab 100644 --- a/src/main/java/com/zontreck/ariaslib/http/HTTPRequest.java +++ b/src/main/java/com/zontreck/ariaslib/http/HTTPRequest.java @@ -1,7 +1,6 @@ -package dev.zontreck.ariaslib.http; +package com.zontreck.ariaslib.http; -public class HTTPRequest -{ +public class HTTPRequest { public String url; @@ -9,7 +8,7 @@ public class HTTPRequest public String body; public String contentType; - protected HTTPRequest(){ + protected HTTPRequest() { } } diff --git a/src/main/java/com/zontreck/ariaslib/http/HTTPRequestBuilder.java b/src/main/java/com/zontreck/ariaslib/http/HTTPRequestBuilder.java index 4e062d5..526b750 100644 --- a/src/main/java/com/zontreck/ariaslib/http/HTTPRequestBuilder.java +++ b/src/main/java/com/zontreck/ariaslib/http/HTTPRequestBuilder.java @@ -1,35 +1,32 @@ -package dev.zontreck.ariaslib.http; - +package com.zontreck.ariaslib.http; import java.io.*; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; -public class HTTPRequestBuilder -{ +public class HTTPRequestBuilder { private HttpURLConnection connection; private URL url; private HTTPRequest request = new HTTPRequest(); - public static HTTPRequestBuilder builder() - { + public static HTTPRequestBuilder builder() { return new HTTPRequestBuilder(); } - protected HTTPRequestBuilder() - { + protected HTTPRequestBuilder() { } /** * Sets the url in this request to the one supplied + * * @param url The url to connect to * @return Builder instance * @throws MalformedURLException If the URL supplied was invalid */ - public HTTPRequestBuilder withURL( String url) throws MalformedURLException { + public HTTPRequestBuilder withURL(String url) throws MalformedURLException { request.url = url; this.url = new URL(url); @@ -38,31 +35,31 @@ public class HTTPRequestBuilder /** * Sets the HTTP Request method + * * @param method The method you want to use * @see HTTPMethod * @return Builder instance */ - public HTTPRequestBuilder withMethod(HTTPMethod method) - { - switch(method) - { - case GET: - { + public HTTPRequestBuilder withMethod(HTTPMethod method) { + switch (method) { + case GET: { request.method = "GET"; break; } case POST: { request.method = "POST"; - if(request.contentType.isEmpty()) request.contentType = "application/x-www-form-urlencoded"; + if (request.contentType.isEmpty()) + request.contentType = "application/x-www-form-urlencoded"; break; } - case DELETE:{ + case DELETE: { request.method = "DELETE"; break; } - case PUT:{ + case PUT: { request.method = "PUT"; - if(request.contentType.isEmpty()) request.contentType = "application/x-www-form-urlencoded"; + if (request.contentType.isEmpty()) + request.contentType = "application/x-www-form-urlencoded"; break; } } @@ -71,35 +68,36 @@ public class HTTPRequestBuilder } /** - * Sets the request body. This may only be processed by the server when using POST or PUT, depending on the server's setup + * Sets the request body. This may only be processed by the server when using + * POST or PUT, depending on the server's setup + * * @param body The body to upload * @return Builder Instance */ - public HTTPRequestBuilder withBody(String body) - { + public HTTPRequestBuilder withBody(String body) { request.body = body; return this; } /** * Sets the content type header - * Default: application/x-www-form-urlencoded for POST/PUT, and null/not present for GET + * Default: application/x-www-form-urlencoded for POST/PUT, and null/not present + * for GET + * * @param type * @return */ - public HTTPRequestBuilder withContentType(String type) - { + public HTTPRequestBuilder withContentType(String type) { request.contentType = type; return this; } - public HTTPResponse build() - { + public HTTPResponse build() { try { connection = (HttpURLConnection) url.openConnection(); connection.setRequestMethod(request.method); byte[] array = request.body.getBytes("UTF-8"); - connection.setRequestProperty("Content-Length" , "" + array.length); + connection.setRequestProperty("Content-Length", "" + array.length); connection.setRequestProperty("Content-Type", request.contentType); connection.setDoInput(true); connection.setUseCaches(false); @@ -109,7 +107,6 @@ public class HTTPRequestBuilder dos.flush(); dos.close(); - // Get the response body InputStream inputStream = connection.getInputStream(); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream)); @@ -127,7 +124,7 @@ public class HTTPRequestBuilder return new HTTPResponse(connection.getContentType(), connection.getResponseCode(), responseBody, request); } catch (IOException e) { throw new RuntimeException(e); - }finally { + } finally { connection.disconnect(); } } diff --git a/src/main/java/com/zontreck/ariaslib/http/HTTPResponse.java b/src/main/java/com/zontreck/ariaslib/http/HTTPResponse.java index bd9bdfb..d7640b4 100644 --- a/src/main/java/com/zontreck/ariaslib/http/HTTPResponse.java +++ b/src/main/java/com/zontreck/ariaslib/http/HTTPResponse.java @@ -1,13 +1,12 @@ -package dev.zontreck.ariaslib.http; +package com.zontreck.ariaslib.http; -public class HTTPResponse -{ +public class HTTPResponse { private String ContentType; private int ResponseCode; private String ResponseBody; private HTTPRequest OriginalRequest; - protected HTTPResponse(String contentType, int code, String body, HTTPRequest request){ + protected HTTPResponse(String contentType, int code, String body, HTTPRequest request) { this.ContentType = contentType; this.ResponseCode = code; this.ResponseBody = body; diff --git a/src/main/java/com/zontreck/items/CreativeModeTabs.java b/src/main/java/com/zontreck/items/CreativeModeTabs.java index b7cca94..9fde9dd 100644 --- a/src/main/java/com/zontreck/items/CreativeModeTabs.java +++ b/src/main/java/com/zontreck/items/CreativeModeTabs.java @@ -1,14 +1,12 @@ package com.zontreck.items; +import java.util.ArrayList; +import java.util.List; +import java.util.function.Supplier; import com.zontreck.AriasEssentials; import com.zontreck.block.ModBlocks; -import net.minecraft.world.item.CreativeModeTab; -import net.minecraft.world.item.Item; -import net.minecraft.world.item.ItemStack; -import net.minecraftforge.api.distmarker.Dist; -import net.minecraftforge.fml.common.Mod; -import net.minecraftforge.registries.RegistryObject; + @Mod.EventBusSubscriber(modid = AriasEssentials.MOD_ID, value = Dist.CLIENT) public class CreativeModeTabs { @@ -19,9 +17,13 @@ public class CreativeModeTabs { } }; + public static final List> AE_TAB_ITEMS = new ArrayList>(); + + public static RegistryObject addToAETab(RegistryObject item) { + AE_TAB_ITEMS.add(item); return item; } }