From 94d297bf0b9f89a2c1b9ce976ada939baaba32f1 Mon Sep 17 00:00:00 2001 From: alexbegt Date: Thu, 14 Nov 2019 20:53:11 -0500 Subject: [PATCH] Upgrade to the latest forge, mappings (Mappings contain new names for some functions) and remove our Model, Language, BlockState and Drop generator since forge now has all these. --- gradle.properties | 6 +- .../block/ExampleGeneratedJsonBlock.java | 38 ----- .../mantle/common/IGeneratedJson.java | 14 -- .../slimeknights/mantle/item/EdibleItem.java | 18 +-- .../mantle/item/GeneratedItem.java | 27 ---- .../util/BlankBlockDropJsonGenerator.java | 77 --------- .../mantle/util/BlockStateJsonGenerator.java | 84 ---------- .../mantle/util/LanguageJsonGenerator.java | 93 ----------- .../mantle/util/ModelJsonGenerator.java | 147 ------------------ 9 files changed, 4 insertions(+), 500 deletions(-) delete mode 100644 src/main/java/slimeknights/mantle/block/ExampleGeneratedJsonBlock.java delete mode 100644 src/main/java/slimeknights/mantle/common/IGeneratedJson.java delete mode 100644 src/main/java/slimeknights/mantle/item/GeneratedItem.java delete mode 100644 src/main/java/slimeknights/mantle/util/BlankBlockDropJsonGenerator.java delete mode 100644 src/main/java/slimeknights/mantle/util/BlockStateJsonGenerator.java delete mode 100644 src/main/java/slimeknights/mantle/util/LanguageJsonGenerator.java delete mode 100644 src/main/java/slimeknights/mantle/util/ModelJsonGenerator.java diff --git a/gradle.properties b/gradle.properties index 9eaefd0..6b2a734 100644 --- a/gradle.properties +++ b/gradle.properties @@ -10,11 +10,11 @@ minecraft_version=1.14.4 minecraft_version_toml=14 # Forge Version Information -forge_version=28.1.24 +forge_version=28.1.90 forge_version_toml=28 # Mappings Information -mappings_version=20190912-1.14.3 +mappings_version=20191114-1.14.3 -jei_version=6.0.0.11 +jei_version=6.0.0.25 configurate_version=3.3 diff --git a/src/main/java/slimeknights/mantle/block/ExampleGeneratedJsonBlock.java b/src/main/java/slimeknights/mantle/block/ExampleGeneratedJsonBlock.java deleted file mode 100644 index 0f7fc96..0000000 --- a/src/main/java/slimeknights/mantle/block/ExampleGeneratedJsonBlock.java +++ /dev/null @@ -1,38 +0,0 @@ -package slimeknights.mantle.block; - -import com.google.gson.JsonObject; -import net.minecraft.block.Block; -import slimeknights.mantle.common.IGeneratedJson; - -public class ExampleGeneratedJsonBlock extends Block implements IGeneratedJson { - - public ExampleGeneratedJsonBlock(Properties p_i48440_1_) { - super(p_i48440_1_); - } - - @Override - public String getParentToUse() { - return "block/cube_all"; - } - - @Override - public JsonObject getTexturesToUse() { - JsonObject textures = new JsonObject(); - - textures.addProperty("all", this.getRegistryName().getNamespace() + ":block/" + this.getRegistryName().getPath()); - - return textures; - } - - @Override - public JsonObject getVariants() { - JsonObject variants = new JsonObject(); - JsonObject variant = new JsonObject(); - - variant.addProperty("model", this.getRegistryName().getNamespace() + ":block/" + this.getRegistryName().getPath()); - variants.add("", variant); - - return variants; - } - -} diff --git a/src/main/java/slimeknights/mantle/common/IGeneratedJson.java b/src/main/java/slimeknights/mantle/common/IGeneratedJson.java deleted file mode 100644 index 8a82882..0000000 --- a/src/main/java/slimeknights/mantle/common/IGeneratedJson.java +++ /dev/null @@ -1,14 +0,0 @@ -package slimeknights.mantle.common; - -import com.google.gson.JsonObject; - -public interface IGeneratedJson { - - String getParentToUse(); - - JsonObject getTexturesToUse(); - - default JsonObject getVariants() { - return null; - } -} diff --git a/src/main/java/slimeknights/mantle/item/EdibleItem.java b/src/main/java/slimeknights/mantle/item/EdibleItem.java index 9d7671c..a515b2c 100644 --- a/src/main/java/slimeknights/mantle/item/EdibleItem.java +++ b/src/main/java/slimeknights/mantle/item/EdibleItem.java @@ -1,6 +1,5 @@ package slimeknights.mantle.item; -import com.google.gson.JsonObject; import net.minecraft.client.resources.I18n; import net.minecraft.client.util.ITooltipFlag; import net.minecraft.item.Food; @@ -15,12 +14,11 @@ import net.minecraft.world.World; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import org.apache.commons.lang3.tuple.Pair; -import slimeknights.mantle.common.IGeneratedJson; import javax.annotation.Nullable; import java.util.List; -public class EdibleItem extends Item implements IGeneratedJson { +public class EdibleItem extends Item { private boolean displayEffectsTooltip; // set to false to not display effects of food in tooltip @@ -33,20 +31,6 @@ public class EdibleItem extends Item implements IGeneratedJson { this.displayEffectsTooltip = displayEffectsTooltip; } - @Override - public String getParentToUse() { - return "item/generated"; - } - - @Override - public JsonObject getTexturesToUse() { - JsonObject textures = new JsonObject(); - - textures.addProperty("layer0", this.getRegistryName().getNamespace() + ":item/" + this.getRegistryName().getPath() + " CHANGEME"); - - return textures; - } - @Override @OnlyIn(Dist.CLIENT) public void addInformation(ItemStack stack, @Nullable World worldIn, List tooltip, ITooltipFlag flagIn) { diff --git a/src/main/java/slimeknights/mantle/item/GeneratedItem.java b/src/main/java/slimeknights/mantle/item/GeneratedItem.java deleted file mode 100644 index 3253f81..0000000 --- a/src/main/java/slimeknights/mantle/item/GeneratedItem.java +++ /dev/null @@ -1,27 +0,0 @@ -package slimeknights.mantle.item; - -import com.google.gson.JsonObject; -import net.minecraft.item.Item; -import net.minecraft.item.ItemGroup; -import slimeknights.mantle.common.IGeneratedJson; - -public class GeneratedItem extends TooltipItem implements IGeneratedJson { - - public GeneratedItem(ItemGroup itemGroup) { - super(new Properties().group(itemGroup)); - } - - @Override - public String getParentToUse() { - return "item/generated"; - } - - @Override - public JsonObject getTexturesToUse() { - JsonObject textures = new JsonObject(); - - textures.addProperty("layer0", this.getRegistryName().getNamespace() + ":item/" + this.getRegistryName().getPath() + " CHANGEME"); - - return textures; - } -} \ No newline at end of file diff --git a/src/main/java/slimeknights/mantle/util/BlankBlockDropJsonGenerator.java b/src/main/java/slimeknights/mantle/util/BlankBlockDropJsonGenerator.java deleted file mode 100644 index e8cd693..0000000 --- a/src/main/java/slimeknights/mantle/util/BlankBlockDropJsonGenerator.java +++ /dev/null @@ -1,77 +0,0 @@ -package slimeknights.mantle.util; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import net.minecraft.block.Block; -import net.minecraft.data.DataGenerator; -import net.minecraft.data.DirectoryCache; -import net.minecraft.data.IDataProvider; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.registry.Registry; -import org.apache.commons.io.IOUtils; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; - -public class BlankBlockDropJsonGenerator implements IDataProvider { - - private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().create(); - private final DataGenerator generator; - private final String modId; - - public BlankBlockDropJsonGenerator(DataGenerator generatorIn, String modId) { - this.generator = generatorIn; - this.modId = modId; - } - - @Override - public void act(DirectoryCache cache) throws IOException { - JsonObject blockState = new JsonObject(); - int generatedEntries = 0; - JsonObject blockstateCache = new JsonObject(); - - Path cacheP = this.generator.getOutputFolder().resolve("cache/" + this.modId + "/loot_tables/blocks/blocks.json"); - - if (Files.exists(cacheP)) { - String jsonTxt = IOUtils.toString(cacheP.toUri(), "UTF-8"); - blockstateCache = new JsonParser().parse(jsonTxt).getAsJsonObject(); - } - - for (Block block : Registry.BLOCK) { - blockState = new JsonObject(); - ResourceLocation resourcelocation = Registry.BLOCK.getKey(block); - - if (!resourcelocation.getNamespace().equals(this.modId)) { - continue; - } - - if (blockstateCache.has(resourcelocation.toString())) { - continue; - } - blockState.addProperty("REPLACEME", "TRUE"); - - blockstateCache.addProperty(resourcelocation.toString(), "UNUSED"); - generatedEntries++; - - Path path = this.generator.getOutputFolder().resolve("assets/" + this.modId + "/loot_tables/blocks/" + resourcelocation.getPath() + ".json"); - IDataProvider.save(GSON, cache, blockState, path); - } - - if (generatedEntries != 0) { - IDataProvider.save(GSON, cache, blockstateCache, cacheP); - } - - cache.func_218456_c(cacheP); - } - - /** - * Gets a name for this provider, to use in logging. - */ - @Override - public String getName() { - return "Blank Block Drops Generator"; - } -} diff --git a/src/main/java/slimeknights/mantle/util/BlockStateJsonGenerator.java b/src/main/java/slimeknights/mantle/util/BlockStateJsonGenerator.java deleted file mode 100644 index cfe2aa7..0000000 --- a/src/main/java/slimeknights/mantle/util/BlockStateJsonGenerator.java +++ /dev/null @@ -1,84 +0,0 @@ -package slimeknights.mantle.util; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import net.minecraft.block.Block; -import net.minecraft.data.DataGenerator; -import net.minecraft.data.DirectoryCache; -import net.minecraft.data.IDataProvider; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.registry.Registry; -import org.apache.commons.io.IOUtils; -import slimeknights.mantle.common.IGeneratedJson; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; - -public class BlockStateJsonGenerator implements IDataProvider { - - private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().create(); - private final DataGenerator generator; - private final String modId; - - public BlockStateJsonGenerator(DataGenerator generatorIn, String modId) { - this.generator = generatorIn; - this.modId = modId; - } - - @Override - public void act(DirectoryCache cache) throws IOException { - JsonObject blockState = new JsonObject(); - int generatedEntries = 0; - JsonObject blockstateCache = new JsonObject(); - - Path cacheP = this.generator.getOutputFolder().resolve("cache/" + this.modId + "/blockstates/blockstates.json"); - - if (Files.exists(cacheP)) { - String jsonTxt = IOUtils.toString(cacheP.toUri(), "UTF-8"); - blockstateCache = new JsonParser().parse(jsonTxt).getAsJsonObject(); - } - - for (Block block : Registry.BLOCK) { - blockState = new JsonObject(); - ResourceLocation resourcelocation = Registry.BLOCK.getKey(block); - - if (!resourcelocation.getNamespace().equals(this.modId)) { - continue; - } - - if (!(block instanceof IGeneratedJson)) { - continue; - } - if (blockstateCache.has(resourcelocation.toString())) { - continue; - } - - IGeneratedJson block1 = (IGeneratedJson) block; - - blockState.add("variants", block1.getVariants()); - - blockstateCache.addProperty(resourcelocation.toString(), "UNUSED"); - generatedEntries++; - - Path path = this.generator.getOutputFolder().resolve("assets/" + this.modId + "/blockstates/" + resourcelocation.getPath() + ".json"); - IDataProvider.save(GSON, cache, blockState, path); - } - - if (generatedEntries != 0) { - IDataProvider.save(GSON, cache, blockstateCache, cacheP); - } - - cache.func_218456_c(cacheP); - } - - /** - * Gets a name for this provider, to use in logging. - */ - @Override - public String getName() { - return "Blockstate Generator"; - } -} diff --git a/src/main/java/slimeknights/mantle/util/LanguageJsonGenerator.java b/src/main/java/slimeknights/mantle/util/LanguageJsonGenerator.java deleted file mode 100644 index d2606f7..0000000 --- a/src/main/java/slimeknights/mantle/util/LanguageJsonGenerator.java +++ /dev/null @@ -1,93 +0,0 @@ -package slimeknights.mantle.util; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import net.minecraft.block.Block; -import net.minecraft.data.DataGenerator; -import net.minecraft.data.DirectoryCache; -import net.minecraft.data.IDataProvider; -import net.minecraft.item.Item; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.registry.Registry; -import org.apache.commons.io.IOUtils; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; - -public class LanguageJsonGenerator implements IDataProvider { - - private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().create(); - private final DataGenerator generator; - private final String modId; - - public LanguageJsonGenerator(DataGenerator generatorIn, String modId) { - this.generator = generatorIn; - this.modId = modId; - } - - @Override - public void act(DirectoryCache cache) throws IOException { - JsonObject names = new JsonObject(); - int generatedEntries = 0; - JsonObject langCache = new JsonObject(); - - Path cacheP = this.generator.getOutputFolder().resolve("cache/" + this.modId + "/lang/en_us.json"); - - if (Files.exists(cacheP)) { - String jsonTxt = IOUtils.toString(cacheP.toUri(), "UTF-8"); - langCache = new JsonParser().parse(jsonTxt).getAsJsonObject(); - } - - for (Block block : Registry.BLOCK) { - ResourceLocation resourcelocation = Registry.BLOCK.getKey(block); - - if (!resourcelocation.getNamespace().equals(this.modId)) { - continue; - } - - if (langCache.has(block.getTranslationKey())) { - continue; - } - - names.addProperty(block.getTranslationKey(), "RENAME"); - langCache.addProperty(block.getTranslationKey(), "RENAME"); - generatedEntries++; - } - - for (Item item : Registry.ITEM) { - ResourceLocation resourcelocation = Registry.ITEM.getKey(item); - - if (!resourcelocation.getNamespace().equals(this.modId)) { - continue; - } - - if (langCache.has(item.getTranslationKey())) { - continue; - } - - names.addProperty(item.getTranslationKey(), "RENAME"); - langCache.addProperty(item.getTranslationKey(), "RENAME"); - generatedEntries++; - } - - Path path = this.generator.getOutputFolder().resolve("assets/" + this.modId + "/lang/en_us.json"); - IDataProvider.save(GSON, cache, names, path); - - if (generatedEntries != 0) { - IDataProvider.save(GSON, cache, langCache, cacheP); - } - - cache.func_218456_c(cacheP); - } - - /** - * Gets a name for this provider, to use in logging. - */ - @Override - public String getName() { - return "Language Generator"; - } -} diff --git a/src/main/java/slimeknights/mantle/util/ModelJsonGenerator.java b/src/main/java/slimeknights/mantle/util/ModelJsonGenerator.java deleted file mode 100644 index 239f218..0000000 --- a/src/main/java/slimeknights/mantle/util/ModelJsonGenerator.java +++ /dev/null @@ -1,147 +0,0 @@ -package slimeknights.mantle.util; - -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import com.google.gson.JsonObject; -import com.google.gson.JsonParser; -import net.minecraft.block.Block; -import net.minecraft.data.DataGenerator; -import net.minecraft.data.DirectoryCache; -import net.minecraft.data.IDataProvider; -import net.minecraft.item.Item; -import net.minecraft.util.ResourceLocation; -import net.minecraft.util.registry.Registry; -import org.apache.commons.io.IOUtils; -import slimeknights.mantle.common.IGeneratedJson; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.ArrayList; -import java.util.List; - -public class ModelJsonGenerator implements IDataProvider { - - private static final Gson GSON = (new GsonBuilder()).setPrettyPrinting().create(); - private final DataGenerator generator; - private final String modId; - - public ModelJsonGenerator(DataGenerator generatorIn, String modId) { - this.generator = generatorIn; - this.modId = modId; - } - - @Override - public void act(DirectoryCache cache) throws IOException { - JsonObject blockObject = new JsonObject(); - JsonObject itemObject = new JsonObject(); - - List resourceLocations = new ArrayList(); - - int generatedBlockEntries = 0; - int generatedItemEntries = 0; - JsonObject blockModelCache = new JsonObject(); - JsonObject itemModelCache = new JsonObject(); - - Path blockCachePath = this.generator.getOutputFolder().resolve("cache/" + this.modId + "/models/block/models.json"); - - if (Files.exists(blockCachePath)) { - String jsonTxt = IOUtils.toString(blockCachePath.toUri(), "UTF-8"); - blockModelCache = new JsonParser().parse(jsonTxt).getAsJsonObject(); - } - - for (Block block : Registry.BLOCK) { - blockObject = new JsonObject(); - ResourceLocation resourcelocation = Registry.BLOCK.getKey(block); - - if (!resourcelocation.getNamespace().equals(this.modId)) { - continue; - } - if (!(block instanceof IGeneratedJson)) { - continue; - } - if (blockModelCache.has(resourcelocation.toString())) { - continue; - } - - IGeneratedJson block1 = (IGeneratedJson) block; - - resourceLocations.add(resourcelocation); - - blockObject.addProperty("parent", block1.getParentToUse()); - - blockObject.add("textures", block1.getTexturesToUse()); - - blockModelCache.addProperty(resourcelocation.toString(), "UNUSED"); - generatedBlockEntries++; - - Path path = this.generator.getOutputFolder().resolve("assets/" + this.modId + "/models/block/" + resourcelocation.getPath() + ".json"); - IDataProvider.save(GSON, cache, blockObject, path); - } - - Path itemCachePath = this.generator.getOutputFolder().resolve("cache/" + this.modId + "/models/item/models.json"); - - if (Files.exists(itemCachePath)) { - String jsonTxt = IOUtils.toString(itemCachePath.toUri(), "UTF-8"); - itemModelCache = new JsonParser().parse(jsonTxt).getAsJsonObject(); - } - - for (Item item : Registry.ITEM) { - itemObject = new JsonObject(); - ResourceLocation resourcelocation = Registry.ITEM.getKey(item); - - if (!resourcelocation.getNamespace().equals(this.modId)) { - continue; - } - if (itemModelCache.has(resourcelocation.toString())) { - continue; - } - - if (resourceLocations.contains(resourcelocation)) { - itemObject.addProperty("parent", resourcelocation.getNamespace() + ":block/" + resourcelocation.getPath()); - - itemModelCache.addProperty(resourcelocation.toString(), "UNUSED"); - generatedItemEntries++; - - Path path = this.generator.getOutputFolder().resolve("assets/" + this.modId + "/models/item/" + resourcelocation.getPath() + ".json"); - IDataProvider.save(GSON, cache, itemObject, path); - } - else { - if (!(item instanceof IGeneratedJson)) { - continue; - } - - IGeneratedJson item1 = (IGeneratedJson) item; - - itemObject.addProperty("parent", item1.getParentToUse()); - - itemObject.add("textures", item1.getTexturesToUse()); - - itemModelCache.addProperty(resourcelocation.toString(), "UNUSED"); - generatedItemEntries++; - - Path path = this.generator.getOutputFolder().resolve("assets/" + this.modId + "/models/item/" + resourcelocation.getPath() + ".json"); - IDataProvider.save(GSON, cache, itemObject, path); - } - } - - if (generatedBlockEntries != 0) { - IDataProvider.save(GSON, cache, blockModelCache, blockCachePath); - } - - if (generatedItemEntries != 0) { - IDataProvider.save(GSON, cache, itemModelCache, itemCachePath); - } - - cache.func_218456_c(blockCachePath); - cache.func_218456_c(itemCachePath); - } - - /** - * Gets a name for this provider, to use in logging. - */ - @Override - public String getName() { - return "Model Generator"; - } -}