Begin update process to 1.21.1
This commit is contained in:
parent
1c63a59566
commit
922f89d14c
8 changed files with 68 additions and 62 deletions
|
@ -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)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package dev.zontreck.ariaslib.http;
|
||||
package com.zontreck.ariaslib.http;
|
||||
|
||||
public enum HTTPMethod
|
||||
{
|
||||
public enum HTTPMethod {
|
||||
GET,
|
||||
POST,
|
||||
PUT,
|
||||
|
|
|
@ -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() {
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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<Supplier<? extends ItemLike>> AE_TAB_ITEMS = new ArrayList<Supplier<? extends ItemLike>>();
|
||||
|
||||
|
||||
|
||||
public static <T extends Item> RegistryObject<T> addToAETab(RegistryObject<T> item)
|
||||
{
|
||||
AE_TAB_ITEMS.add(item);
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue