Skip to content

Commit

Permalink
Update to MC 1.19
Browse files Browse the repository at this point in the history
  • Loading branch information
rubensworks committed Jun 22, 2022
1 parent 6642bce commit a1ce267
Show file tree
Hide file tree
Showing 12 changed files with 267 additions and 50 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ This mod uses [Project Lombok](http://projectlombok.org/) -- an annotation proce

### License
All code and images are licenced under the [MIT License](https://github.com/CyclopsMC/IntegratedREST/blob/master-1.8/LICENSE.txt)
This mod packages [netty-io-http](https://netty.io/) in order to serve an HTTP server.
17 changes: 17 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ plugins {
id 'com.matthewprenger.cursegradle' version '1.4.0'
id 'com.github.kt3k.coveralls' version '2.12.0'
id 'com.diffplug.spotless' version '5.14.3'
id 'com.github.johnrengelman.shadow' version '7.1.2'
id 'com.modrinth.minotaur' version '2.+'
}

Expand Down Expand Up @@ -61,6 +62,8 @@ sourceSets {
}

configurations {
shadow.setTransitive(true);

modLib
implementation.extendsFrom modLib
}
Expand Down Expand Up @@ -111,6 +114,9 @@ dependencies {

modLib "com.google.re2j:re2j:1.1"

modLib "io.netty:netty-codec-http:4.1.77.Final"
shadow "io.netty:netty-codec-http:4.1.77.Final"

// Project lombok
compileOnly 'org.projectlombok:lombok:1.18.22'
annotationProcessor 'org.projectlombok:lombok:1.18.22'
Expand Down Expand Up @@ -232,6 +238,17 @@ task javadocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
}

shadowJar {
configurations = [project.configurations.shadow]
classifier '' // Replace the default JAR
append 'META-INF/mods.toml'
relocate 'com.google.re2j', 'vendors.com.google.re2j' // Because Forge blocks all com.google.* class loading...
}

reobf {
shadowJar {} // Reobfuscate the shadowed JAR
}

artifacts {
archives deobfJar
archives sourcesJar
Expand Down
10 changes: 5 additions & 5 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
mod_version=1.1.5
minecraft_version=1.18.2
forge_version=40.0.54
cyclopscore_version=1.13.4-160
integrateddynamics_version=1.18.2-1.10.13-249
minecraft_version=1.19
forge_version=41.0.35
cyclopscore_version=1.15.0-208
integrateddynamics_version=1.19-1.11.3-312
release_type=release
fingerprint=bd0353b3e8a2810d60dd584e256e364bc3bedd44

commoncapabilities_version=1.18.2-2.8.2-54
commoncapabilities_version=1.19-2.8.2-63

# Workaround for Spotless bug
# https://github.com/diffplug/spotless/issues/834
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/org/cyclops/integratedrest/RegistryEntries.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,16 @@
*/
public class RegistryEntries {

@ObjectHolder("integratedrest:http")
@ObjectHolder(registryName = "item", value = "integratedrest:http")
public static final Item ITEM_BLOCK_HTTP = null;

@ObjectHolder("integratedrest:http")
@ObjectHolder(registryName = "block", value = "integratedrest:http")
public static final Block BLOCK_HTTP = null;

@ObjectHolder("integratedrest:http")
@ObjectHolder(registryName = "block_entity_type", value = "integratedrest:http")
public static final BlockEntityType<BlockEntityHttp> BLOCK_ENTITY_HTTP = null;

@ObjectHolder("integratedrest:http")
@ObjectHolder(registryName = "menu", value = "integratedrest:http")
public static final MenuType<ContainerHttp> CONTAINER_HTTP = null;

}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
import net.minecraft.nbt.CompoundTag;
import net.minecraft.nbt.Tag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.Player;
Expand Down Expand Up @@ -178,7 +177,7 @@ public AbstractContainerMenu createMenu(int id, Inventory playerInventory, Playe

@Override
public Component getDisplayName() {
return new TranslatableComponent("block.integratedrest.http");
return Component.translatable("block.integratedrest.http");
}

public static class HttpVariableAdapter extends VariableAdapter {
Expand Down Expand Up @@ -217,7 +216,7 @@ public IValueType getType() {
@Override
public IValue getValue() throws EvaluationException {
if (value == null) {
throw new EvaluationException(new TranslatableComponent("http.integratedrest.error.http_invalid", tile.getProxyId()));
throw new EvaluationException(Component.translatable("http.integratedrest.error.http_invalid", tile.getProxyId()));
}
return value;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.mojang.blaze3d.vertex.PoseStack;
import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TextComponent;
import net.minecraft.resources.ResourceLocation;
import net.minecraft.world.entity.player.Inventory;
import org.cyclops.cyclopscore.client.gui.component.input.WidgetArrowedListField;
Expand Down Expand Up @@ -65,7 +64,7 @@ public void init() {
List<IValueType> valueTypes = Lists.newArrayList(LogicProgrammerElementTypes.VALUETYPE.getValueTypes());
valueTypes.add(ValueTypes.CATEGORY_ANY);
valueTypeSelector = new WidgetArrowedListField<>(font,
leftPos + 38, topPos + 18, 105, 14, true, new TextComponent(""), true, valueTypes);
leftPos + 38, topPos + 18, 105, 14, true, Component.literal(""), true, valueTypes);
valueTypeSelector.setListener(() -> ValueNotifierHelpers.setValue(getMenu(), getMenu().getValueTypeId(), valueTypeSelector.getActiveElement().getUniqueName().toString()));
getMenu().getValueType().ifPresent(vt -> valueTypeSelector.setActiveElement(vt));
addWidget(valueTypeSelector);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,14 @@
import io.netty.handler.codec.http.HttpResponseStatus;
import net.minecraft.resources.ResourceLocation;
import net.minecraftforge.registries.IForgeRegistry;
import net.minecraftforge.registries.IForgeRegistryEntry;
import org.cyclops.integratedrest.api.http.request.IRequestHandler;
import org.cyclops.integratedrest.json.JsonUtil;

/**
* Abstract request handler for namespaced registry calls.
* @author rubensworks
*/
public abstract class RegistryNamespacedRequestHandler<T extends IForgeRegistryEntry<T>> implements IRequestHandler {
public abstract class RegistryNamespacedRequestHandler<T> implements IRequestHandler {

protected abstract IForgeRegistry<T> getRegistry();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import lombok.Data;
import lombok.EqualsAndHashCode;
import net.minecraft.client.renderer.block.model.BakedQuad;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.network.chat.Component;
import net.minecraft.network.chat.TranslatableComponent;
import net.minecraft.network.chat.MutableComponent;
import net.minecraft.util.RandomSource;
import net.minecraftforge.api.distmarker.Dist;
import net.minecraftforge.api.distmarker.OnlyIn;
import net.minecraftforge.client.model.data.IModelData;
Expand All @@ -17,7 +17,6 @@
import org.cyclops.integratedrest.client.model.HttpVariableModelProviders;

import java.util.List;
import java.util.Random;

/**
* Variable facade for variables determined by http blocks.
Expand All @@ -37,30 +36,30 @@ public HttpVariableFacade(int id, int proxyId) {

@Override
protected MutableComponent getProxyNotInNetworkError() {
return new TranslatableComponent("http.integratedrest.error.http_not_in_network", Integer.toString(getProxyId()));
return Component.translatable("http.integratedrest.error.http_not_in_network", Integer.toString(getProxyId()));
}

@Override
protected MutableComponent getProxyInvalidError() {
return new TranslatableComponent("http.integratedrest.error.http_invalid", Integer.toString(getProxyId()));
return Component.translatable("http.integratedrest.error.http_invalid", Integer.toString(getProxyId()));
}

@Override
protected MutableComponent getProxyInvalidTypeError(IPartNetwork network,
IValueType containingValueType,
IValueType actualType) {
return new TranslatableComponent("http.integratedrest.error.http_invalid_type",
new TranslatableComponent(containingValueType.getTranslationKey()),
new TranslatableComponent(actualType.getTranslationKey()));
return Component.translatable("http.integratedrest.error.http_invalid_type",
Component.translatable(containingValueType.getTranslationKey()),
Component.translatable(actualType.getTranslationKey()));
}

protected Component getProxyTooltip() {
return new TranslatableComponent("http.integratedrest.tooltip.delay_id", getProxyId());
return Component.translatable("http.integratedrest.tooltip.delay_id", getProxyId());
}

@OnlyIn(Dist.CLIENT)
@Override
public void addModelOverlay(IVariableModelBaked variableModelBaked, List<BakedQuad> quads, Random rand, IModelData modelData) {
public void addModelOverlay(IVariableModelBaked variableModelBaked, List<BakedQuad> quads, RandomSource rand, IModelData modelData) {
if(isValid()) {
quads.addAll(variableModelBaked.getSubModels(HttpVariableModelProviders.HTTP).getBakedModel().getQuads(null, null, rand));
}
Expand Down
27 changes: 14 additions & 13 deletions src/main/java/org/cyclops/integratedrest/json/JsonUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
import net.minecraftforge.common.capabilities.Capability;
import net.minecraftforge.common.util.LazyOptional;
import net.minecraftforge.forgespi.language.IModInfo;
import net.minecraftforge.registries.ForgeRegistries;
import org.cyclops.cyclopscore.datastructure.DimPos;
import org.cyclops.cyclopscore.helper.BlockEntityHelpers;
import org.cyclops.cyclopscore.helper.L10NHelpers;
Expand Down Expand Up @@ -96,7 +97,7 @@ public static void addNetworkElementInfo(JsonObject jsonObject, INetworkElement
DimPos pos = getNetworkElementPosition(networkElement);
if (pos != null) {
Block block = pos.getLevel(true).getBlockState(pos.getBlockPos()).getBlock();
jsonObject.addProperty("block", JsonUtil.absolutizePath("registry/block/" + JsonUtil.resourceLocationToPath(block.getRegistryName())));
jsonObject.addProperty("block", JsonUtil.absolutizePath("registry/block/" + JsonUtil.resourceLocationToPath(ForgeRegistries.BLOCKS.getKey(block))));
}

jsonObject.add("@type", types);
Expand Down Expand Up @@ -230,7 +231,7 @@ public static void addPartTypeInfo(JsonObject jsonObject, IPartType partType) {
types.add("WritePart");
}
jsonObject.add("@type", types);
jsonObject.addProperty("item", JsonUtil.absolutizePath("registry/item/" + JsonUtil.resourceLocationToPath(partType.getItem().getRegistryName())));
jsonObject.addProperty("item", JsonUtil.absolutizePath("registry/item/" + JsonUtil.resourceLocationToPath(ForgeRegistries.ITEMS.getKey(partType.getItem()))));
if (partType instanceof IPartTypeReader) {
JsonArray array = new JsonArray();
for (IAspect aspect : ((IPartTypeReader<?, ?>) partType).getReadAspects()) {
Expand Down Expand Up @@ -278,32 +279,32 @@ public static void addValueTypeInfo(JsonObject jsonObject, IValueType valueType)
}

public static void addItemInfo(JsonObject jsonObject, Item item) {
jsonObject.addProperty("@id", JsonUtil.absolutizePath("registry/item/" + JsonUtil.resourceLocationToPath(item.getRegistryName())));
jsonObject.addProperty("mod", JsonUtil.absolutizePath("registry/mod/" + item.getRegistryName().getNamespace()));
jsonObject.addProperty("@id", JsonUtil.absolutizePath("registry/item/" + JsonUtil.resourceLocationToPath(ForgeRegistries.ITEMS.getKey(item))));
jsonObject.addProperty("mod", JsonUtil.absolutizePath("registry/mod/" + ForgeRegistries.ITEMS.getKey(item).getNamespace()));
jsonObject.addProperty("unlocalizedName", item.getDescriptionId());
jsonObject.addProperty("resourceLocation", item.getRegistryName().toString());
jsonObject.addProperty("resourceLocation", ForgeRegistries.ITEMS.getKey(item).toString());
Block block = Block.byItem(item);
if (block != null && block != Blocks.AIR) {
jsonObject.addProperty("block", JsonUtil.absolutizePath("registry/block/" + JsonUtil.resourceLocationToPath(block.getRegistryName())));
jsonObject.addProperty("block", JsonUtil.absolutizePath("registry/block/" + JsonUtil.resourceLocationToPath(ForgeRegistries.BLOCKS.getKey(block))));
}
}

public static void addBlockInfo(JsonObject jsonObject, Block block) {
jsonObject.addProperty("@id", JsonUtil.absolutizePath("registry/block/" + JsonUtil.resourceLocationToPath(block.getRegistryName())));
jsonObject.addProperty("mod", JsonUtil.absolutizePath("registry/mod/" + block.getRegistryName().getNamespace()));
jsonObject.addProperty("@id", JsonUtil.absolutizePath("registry/block/" + JsonUtil.resourceLocationToPath(ForgeRegistries.BLOCKS.getKey(block))));
jsonObject.addProperty("mod", JsonUtil.absolutizePath("registry/mod/" + ForgeRegistries.BLOCKS.getKey(block).getNamespace()));
jsonObject.addProperty("unlocalizedName", block.getDescriptionId());
jsonObject.addProperty("resourceLocation", block.getRegistryName().toString());
jsonObject.addProperty("resourceLocation", ForgeRegistries.BLOCKS.getKey(block).toString());
Item item = Item.byBlock(block);
if (item != null && item != Items.AIR) {
jsonObject.addProperty("item", JsonUtil.absolutizePath("registry/item/" + JsonUtil.resourceLocationToPath(item.getRegistryName())));
jsonObject.addProperty("item", JsonUtil.absolutizePath("registry/item/" + JsonUtil.resourceLocationToPath(ForgeRegistries.ITEMS.getKey(item))));
}
}

public static void addFluidInfo(JsonObject jsonObject, Fluid fluid) {
jsonObject.addProperty("@id", JsonUtil.absolutizePath("registry/fluid/" + JsonUtil.resourceLocationToPath(fluid.getRegistryName())));
jsonObject.addProperty("resourceLocation", fluid.getRegistryName().toString());
jsonObject.addProperty("@id", JsonUtil.absolutizePath("registry/fluid/" + JsonUtil.resourceLocationToPath(ForgeRegistries.FLUIDS.getKey(fluid))));
jsonObject.addProperty("resourceLocation", ForgeRegistries.FLUIDS.getKey(fluid).toString());
if (fluid.defaultFluidState().createLegacyBlock() != null) {
jsonObject.addProperty("block", JsonUtil.absolutizePath("registry/block/" + JsonUtil.resourceLocationToPath(fluid.defaultFluidState().createLegacyBlock().getBlock().getRegistryName())));
jsonObject.addProperty("block", JsonUtil.absolutizePath("registry/block/" + JsonUtil.resourceLocationToPath(ForgeRegistries.BLOCKS.getKey(fluid.defaultFluidState().createLegacyBlock().getBlock()))));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,8 +165,8 @@ public ValueTypeNbt.ValueNbt handleUnchecked(JsonElement jsonElement) throws Ill
jsonObject.addProperty("@type", "ValueBlock");
if (value.getRawValue().isPresent()) {
BlockState blockState = value.getRawValue().get();
jsonObject.addProperty("block", JsonUtil.absolutizePath("registry/block/" + JsonUtil.resourceLocationToPath(blockState.getBlock().getRegistryName())));
jsonObject.addProperty("resourceLocation", blockState.getBlock().getRegistryName().toString());
jsonObject.addProperty("block", JsonUtil.absolutizePath("registry/block/" + JsonUtil.resourceLocationToPath(ForgeRegistries.BLOCKS.getKey(blockState.getBlock()))));
jsonObject.addProperty("resourceLocation", ForgeRegistries.BLOCKS.getKey(blockState.getBlock()).toString());
jsonObject.addProperty("state", BlockHelpers.serializeBlockState(blockState).toString());
JsonArray jsonProperties = new JsonArray();
for (Property<?> property : blockState.getProperties()) {
Expand Down Expand Up @@ -206,8 +206,8 @@ public ValueObjectTypeBlock.ValueBlock handleUnchecked(JsonElement jsonElement)
jsonObject.addProperty("@type", "ValueItem");
if (!value.getRawValue().isEmpty()) {
ItemStack itemStack = value.getRawValue();
jsonObject.addProperty("item", JsonUtil.absolutizePath("registry/item/" + JsonUtil.resourceLocationToPath(itemStack.getItem().getRegistryName())));
jsonObject.addProperty("resourceLocation", itemStack.getItem().getRegistryName().toString());
jsonObject.addProperty("item", JsonUtil.absolutizePath("registry/item/" + JsonUtil.resourceLocationToPath(ForgeRegistries.ITEMS.getKey(itemStack.getItem()))));
jsonObject.addProperty("resourceLocation", ForgeRegistries.ITEMS.getKey(itemStack.getItem()).toString());
jsonObject.addProperty("count", itemStack.getCount());
if (itemStack.hasTag()) {
jsonObject.add("nbt", new JsonParser().parse(itemStack.getTag().toString()));
Expand Down Expand Up @@ -286,8 +286,8 @@ public ValueObjectTypeEntity.ValueEntity handleUnchecked(JsonElement jsonElement
jsonObject.addProperty("@type", "ValueFluid");
if (!value.getRawValue().isEmpty()) {
FluidStack fluidStack = value.getRawValue();
jsonObject.addProperty("fluid", JsonUtil.absolutizePath("registry/fluid/" + fluidStack.getFluid().getRegistryName()));
jsonObject.addProperty("fluidName", fluidStack.getFluid().getRegistryName().toString());
jsonObject.addProperty("fluid", JsonUtil.absolutizePath("registry/fluid/" + ForgeRegistries.FLUIDS.getKey(fluidStack.getFluid())));
jsonObject.addProperty("fluidName", ForgeRegistries.FLUIDS.getKey(fluidStack.getFluid()).toString());
jsonObject.addProperty("count", fluidStack.getAmount());
if (fluidStack.hasTag()) {
jsonObject.add("nbt", new JsonParser().parse(fluidStack.getTag().toString()));
Expand Down
Loading

0 comments on commit a1ce267

Please sign in to comment.