mirror of
https://github.com/GTNewHorizons/Mantle.git
synced 2026-11-19 19:49:41 +00:00
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.
This commit is contained in:
1 parent
0044a11e0e
commit
94d297bf0b
9 files changed
+4
-500
No files matched your search
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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<ITextComponent> tooltip, ITooltipFlag flagIn) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
@@ -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<ResourceLocation> resourceLocations = new ArrayList<ResourceLocation>();
|
||||
|
||||
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";
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user