Allow json states to be plain strings, fix up error handling and gog build

This commit is contained in:
Vincent Lee committed 2020-03-28 20:42:19 -05:00
1 parent e0f272a358
commit 09b18e8ab9
5 files changed
+27 -7

No files matched your search

+4 -4
View File
@@ -27,14 +27,14 @@ def parseConfig(File config) {
ext.config = parseConfig(file('../build.properties'))
version = '1.1'
version = '1.2'
group = 'vazkii.botania' // http://maven.apache.org/guides/mini/guide-naming-conventions.html
archivesBaseName = 'gardenofglass'
sourceCompatibility = targetCompatibility = compileJava.sourceCompatibility = compileJava.targetCompatibility = '1.8' // Need this here so eclipse task generates correctly.
minecraft {
mappings channel: 'snapshot', version: "${config.mc_mappings}"
mappings channel: 'snapshot', version: "20200123-mixed-1.15.2"
// makeObfSourceJar = false // an Srg named sources jar is made by default. uncomment this to disable.
runs {
// No run configurations: Build this and run in a Botania workspace to debug
@@ -42,7 +42,7 @@ minecraft {
}
dependencies {
minecraft "net.minecraftforge:forge:${config.mc_version}-${config.forge_version}"
minecraft "net.minecraftforge:forge:1.15.2-31.1.24"
}
jar {
@@ -79,4 +79,4 @@ publishing {
url "file:///${project.projectDir}/mcmodsrepo"
}
}
}
}
Vendored Regular → Executable
View File
File mode changed.
@@ -30,9 +30,11 @@ import net.minecraft.util.NonNullList;
import net.minecraft.util.ResourceLocation;
import net.minecraft.world.World;
import net.minecraftforge.common.crafting.CraftingHelper;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.ForgeRegistryEntry;
import net.minecraftforge.registries.ObjectHolder;
import vazkii.botania.common.Botania;
import vazkii.botania.common.block.ModBlocks;
import vazkii.botania.common.crafting.ModRecipeTypes;
@@ -155,7 +157,19 @@ public class RecipeManaInfusion implements IRecipe<IInventory> {
String group = JSONUtils.getString(json, "group", "");
BlockState catalystState = null;
if (json.has("catalyst")) {
catalystState = StateIngredient.readBlockState(json.getAsJsonObject("catalyst"));
if (json.get("catalyst").isJsonPrimitive()) {
String s = JSONUtils.getString(json, "catalyst");
ResourceLocation catalystId = ResourceLocation.tryCreate(s);
if (catalystId == null) {
throw new IllegalArgumentException("Invalid catalyst ID: " + s);
}
if (!ForgeRegistries.BLOCKS.containsKey(catalystId)) {
throw new IllegalArgumentException("Unknown catalyst: " + s);
}
catalystState = ForgeRegistries.BLOCKS.getValue(catalystId).getDefaultState();
} else {
catalystState = StateIngredient.readBlockState(JSONUtils.getJsonObject(json, "catalyst"));
}
}
RecipeManaInfusion ret = new RecipeManaInfusion(id, output, ing, mana, group);
@@ -91,6 +91,7 @@ public class RecipePureDaisy implements IRecipe<IInventory> {
return time;
}
@Override
public ResourceLocation getId() {
return id;
}
@@ -130,8 +131,8 @@ public class RecipePureDaisy implements IRecipe<IInventory> {
@Nonnull
@Override
public RecipePureDaisy read(@Nonnull ResourceLocation id, JsonObject object) {
StateIngredient input = StateIngredient.deserialize(object.getAsJsonObject("input"));
BlockState output = StateIngredient.readBlockState(object.getAsJsonObject("output"));
StateIngredient input = StateIngredient.deserialize(JSONUtils.getJsonObject(object, "input"));
BlockState output = StateIngredient.readBlockState(JSONUtils.getJsonObject(object, "output"));
int time = JSONUtils.getInt(object, "time", DEFAULT_TIME);
return new RecipePureDaisy(id, input, output, time);
}
@@ -93,6 +93,11 @@ public abstract class StateIngredient implements Predicate<BlockState> {
CompoundNBT nbt = (CompoundNBT) new Dynamic<>(JsonOps.INSTANCE, object).convert(NBTDynamicOps.INSTANCE).getValue();
renameTag(nbt, "name", "Name");
renameTag(nbt, "properties", "Properties");
String name = nbt.getString("Name");
ResourceLocation id = ResourceLocation.tryCreate(name);
if (id == null || !ForgeRegistries.BLOCKS.containsKey(id)) {
throw new IllegalArgumentException("Invalid or unknown block ID: " + name);
}
return NBTUtil.readBlockState(nbt);
}