Tags
This commit is contained in:
@@ -13,9 +13,7 @@ import net.minecraft.client.util.SpriteIdentifier;
|
||||
import net.minecraft.client.util.math.MatrixStack;
|
||||
|
||||
import net.minecraft.client.render.item.ItemRenderer;
|
||||
import net.minecraft.item.Item;
|
||||
import net.minecraft.tag.ItemTags;
|
||||
import net.minecraft.tag.Tag;
|
||||
import net.minecraft.item.BlockItem;
|
||||
import net.minecraft.util.math.Quaternion;
|
||||
import net.minecraft.client.render.RenderLayer;
|
||||
import net.minecraft.client.render.block.entity.BlockEntityRenderer;
|
||||
@@ -189,8 +187,6 @@ public final class InscriberTESR extends BlockEntityRenderer<InscriberBlockEntit
|
||||
vb.next();
|
||||
}
|
||||
|
||||
private static final Identifier TAG_STORAGE_BLOCKS = new Identifier("forge:storage_blocks");
|
||||
|
||||
private void renderItem(MatrixStack ms, final ItemStack stack, final float o, VertexConsumerProvider buffers,
|
||||
int combinedLight, int combinedOverlay) {
|
||||
if (!stack.isEmpty()) {
|
||||
@@ -204,8 +200,8 @@ public final class InscriberTESR extends BlockEntityRenderer<InscriberBlockEntit
|
||||
ItemRenderer itemRenderer = MinecraftClient.getInstance().getItemRenderer();
|
||||
|
||||
// heuristic to scale items down much further than blocks
|
||||
Tag<Item> storageBlockTag = ItemTags.getContainer().get(TAG_STORAGE_BLOCKS);
|
||||
if (storageBlockTag == null || !stack.getItem().isIn(storageBlockTag)) {
|
||||
boolean renderAsCube = (stack.getItem() instanceof BlockItem);
|
||||
if (!renderAsCube) {
|
||||
ms.scale(0.5f, 0.5f, 0.5f);
|
||||
}
|
||||
|
||||
|
||||
@@ -61,11 +61,11 @@ import appeng.util.Platform;
|
||||
public class RestrictedInputSlot extends AppEngSlot {
|
||||
|
||||
private static final List<Identifier> METAL_INGOT_TAGS = ImmutableList.of(
|
||||
new Identifier("forge:ingots/copper"), new Identifier("forge:ingots/tin"),
|
||||
new Identifier("forge:ingots/iron"), new Identifier("forge:ingots/gold"),
|
||||
new Identifier("forge:ingots/lead"), new Identifier("forge:ingots/bronze"),
|
||||
new Identifier("forge:ingots/brass"), new Identifier("forge:ingots/nickel"),
|
||||
new Identifier("forge:ingots/aluminium"));
|
||||
new Identifier("c:copper_ingots"), new Identifier("c:tin_ingots"),
|
||||
new Identifier("c:iron_ingots"), new Identifier("c:gold_ingots"),
|
||||
new Identifier("c:lead_ingots"), new Identifier("c:bronze_ingots"),
|
||||
new Identifier("c:brass_ingots"), new Identifier("c:nickel_ingots"),
|
||||
new Identifier("c:aluminium_ingots"));
|
||||
|
||||
private final PlacableItemType which;
|
||||
private final PlayerInventory p;
|
||||
|
||||
@@ -41,7 +41,7 @@ public final class Api implements IAppEngApi {
|
||||
private final ApiDefinitions definitions;
|
||||
private final IClientHelper client;
|
||||
|
||||
Api() {
|
||||
public Api() {
|
||||
this.storageHelper = new ApiStorage();
|
||||
this.networkHelper = new ApiGrid();
|
||||
this.registryContainer = new RegistryContainer();
|
||||
|
||||
@@ -28,6 +28,7 @@ import appeng.core.sync.network.NetworkHandler;
|
||||
import appeng.core.sync.network.TargetPoint;
|
||||
import appeng.fluids.container.*;
|
||||
import appeng.fluids.registries.BasicFluidCellGuiHandler;
|
||||
import appeng.forge.data.AE2DataGenerators;
|
||||
import appeng.hooks.ToolItemHook;
|
||||
import appeng.items.tools.NetworkToolItem;
|
||||
import appeng.me.cache.*;
|
||||
@@ -99,6 +100,11 @@ public abstract class AppEngBase implements AppEng {
|
||||
|
||||
setupInternalRegistries();
|
||||
|
||||
if (System.getProperty("appeng2.generatedataendexit", "false").equals("true")) {
|
||||
AE2DataGenerators.dump();
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void setupInternalRegistries() {
|
||||
|
||||
@@ -10,7 +10,7 @@ import java.nio.file.Files;
|
||||
|
||||
public class ConfigFileManager {
|
||||
|
||||
private static Gson GSON = new GsonBuilder()
|
||||
private static final Gson GSON = new GsonBuilder()
|
||||
.setPrettyPrinting()
|
||||
.setLenient()
|
||||
.create();
|
||||
|
||||
@@ -40,77 +40,77 @@ public class MatterCannonAmmoRegistry implements IMatterCannonAmmoRegistry {
|
||||
private final Map<Item, Double> itemDamageModifiers = new IdentityHashMap<>();
|
||||
|
||||
public MatterCannonAmmoRegistry() {
|
||||
this.addTagWeight("forge:nuggets/meatraw", 32);
|
||||
this.addTagWeight("forge:nuggets/meatcooked", 32);
|
||||
this.addTagWeight("forge:nuggets/meat", 32);
|
||||
this.addTagWeight("forge:nuggets/chicken", 32);
|
||||
this.addTagWeight("forge:nuggets/beef", 32);
|
||||
this.addTagWeight("forge:nuggets/sheep", 32);
|
||||
this.addTagWeight("forge:nuggets/fish", 32);
|
||||
this.addTagWeight("c:raw_meat_nuggets", 32);
|
||||
this.addTagWeight("c:cooked_meat_nuggets", 32);
|
||||
this.addTagWeight("c:meat_nuggets", 32);
|
||||
this.addTagWeight("c:chicken_nuggets", 32);
|
||||
this.addTagWeight("c:beef_nuggets", 32);
|
||||
this.addTagWeight("c:sheep_nuggets", 32);
|
||||
this.addTagWeight("c:fish_nuggets", 32);
|
||||
|
||||
// real world...
|
||||
this.addTagWeight("forge:nuggets/lithium", 6.941);
|
||||
this.addTagWeight("forge:nuggets/beryllium", 9.0122);
|
||||
this.addTagWeight("forge:nuggets/boron", 10.811);
|
||||
this.addTagWeight("forge:nuggets/carbon", 12.0107);
|
||||
this.addTagWeight("forge:nuggets/coal", 12.0107);
|
||||
this.addTagWeight("forge:nuggets/charcoal", 12.0107);
|
||||
this.addTagWeight("forge:nuggets/sodium", 22.9897);
|
||||
this.addTagWeight("forge:nuggets/magnesium", 24.305);
|
||||
this.addTagWeight("forge:nuggets/aluminum", 26.9815);
|
||||
this.addTagWeight("forge:nuggets/silicon", 28.0855);
|
||||
this.addTagWeight("forge:nuggets/phosphorus", 30.9738);
|
||||
this.addTagWeight("forge:nuggets/sulfur", 32.065);
|
||||
this.addTagWeight("forge:nuggets/potassium", 39.0983);
|
||||
this.addTagWeight("forge:nuggets/calcium", 40.078);
|
||||
this.addTagWeight("forge:nuggets/scandium", 44.9559);
|
||||
this.addTagWeight("forge:nuggets/titanium", 47.867);
|
||||
this.addTagWeight("forge:nuggets/vanadium", 50.9415);
|
||||
this.addTagWeight("forge:nuggets/manganese", 54.938);
|
||||
this.addTagWeight("forge:nuggets/iron", 55.845);
|
||||
this.addTagWeight("forge:nuggets/gold", 196.96655);
|
||||
this.addTagWeight("forge:nuggets/nickel", 58.6934);
|
||||
this.addTagWeight("forge:nuggets/cobalt", 58.9332);
|
||||
this.addTagWeight("forge:nuggets/copper", 63.546);
|
||||
this.addTagWeight("forge:nuggets/zinc", 65.39);
|
||||
this.addTagWeight("forge:nuggets/gallium", 69.723);
|
||||
this.addTagWeight("forge:nuggets/germanium", 72.64);
|
||||
this.addTagWeight("forge:nuggets/bromine", 79.904);
|
||||
this.addTagWeight("forge:nuggets/krypton", 83.8);
|
||||
this.addTagWeight("forge:nuggets/rubidium", 85.4678);
|
||||
this.addTagWeight("forge:nuggets/strontium", 87.62);
|
||||
this.addTagWeight("forge:nuggets/yttrium", 88.9059);
|
||||
this.addTagWeight("forge:nuggets/zirconium", 91.224);
|
||||
this.addTagWeight("forge:nuggets/niobium", 92.9064);
|
||||
this.addTagWeight("forge:nuggets/technetium", 98);
|
||||
this.addTagWeight("forge:nuggets/ruthenium", 101.07);
|
||||
this.addTagWeight("forge:nuggets/rhodium", 102.9055);
|
||||
this.addTagWeight("forge:nuggets/palladium", 106.42);
|
||||
this.addTagWeight("forge:nuggets/silver", 107.8682);
|
||||
this.addTagWeight("forge:nuggets/cadmium", 112.411);
|
||||
this.addTagWeight("forge:nuggets/indium", 114.818);
|
||||
this.addTagWeight("forge:nuggets/tin", 118.71);
|
||||
this.addTagWeight("forge:nuggets/antimony", 121.76);
|
||||
this.addTagWeight("forge:nuggets/iodine", 126.9045);
|
||||
this.addTagWeight("forge:nuggets/tellurium", 127.6);
|
||||
this.addTagWeight("forge:nuggets/xenon", 131.293);
|
||||
this.addTagWeight("forge:nuggets/cesium", 132.9055);
|
||||
this.addTagWeight("forge:nuggets/barium", 137.327);
|
||||
this.addTagWeight("forge:nuggets/lanthanum", 138.9055);
|
||||
this.addTagWeight("forge:nuggets/cerium", 140.116);
|
||||
this.addTagWeight("forge:nuggets/tantalum", 180.9479);
|
||||
this.addTagWeight("forge:nuggets/tungsten", 183.84);
|
||||
this.addTagWeight("forge:nuggets/osmium", 190.23);
|
||||
this.addTagWeight("forge:nuggets/iridium", 192.217);
|
||||
this.addTagWeight("forge:nuggets/platinum", 195.078);
|
||||
this.addTagWeight("forge:nuggets/lead", 207.2);
|
||||
this.addTagWeight("forge:nuggets/bismuth", 208.9804);
|
||||
this.addTagWeight("forge:nuggets/uranium", 238.0289);
|
||||
this.addTagWeight("forge:nuggets/plutonium", 244);
|
||||
this.addTagWeight("c:lithium_nuggets", 6.941);
|
||||
this.addTagWeight("c:beryllium_nuggets", 9.0122);
|
||||
this.addTagWeight("c:boron_nuggets", 10.811);
|
||||
this.addTagWeight("c:carbon_nuggets", 12.0107);
|
||||
this.addTagWeight("c:coal_nuggets", 12.0107);
|
||||
this.addTagWeight("c:charcoal_nuggets", 12.0107);
|
||||
this.addTagWeight("c:sodium_nuggets", 22.9897);
|
||||
this.addTagWeight("c:magnesium_nuggets", 24.305);
|
||||
this.addTagWeight("c:aluminum_nuggets", 26.9815);
|
||||
this.addTagWeight("c:silicon_nuggets", 28.0855);
|
||||
this.addTagWeight("c:phosphorus_nuggets", 30.9738);
|
||||
this.addTagWeight("c:sulfur_nuggets", 32.065);
|
||||
this.addTagWeight("c:potassium_nuggets", 39.0983);
|
||||
this.addTagWeight("c:calcium_nuggets", 40.078);
|
||||
this.addTagWeight("c:scandium_nuggets", 44.9559);
|
||||
this.addTagWeight("c:titanium_nuggets", 47.867);
|
||||
this.addTagWeight("c:vanadium_nuggets", 50.9415);
|
||||
this.addTagWeight("c:manganese_nuggets", 54.938);
|
||||
this.addTagWeight("c:iron_nuggets", 55.845);
|
||||
this.addTagWeight("c:gold_nuggets", 196.96655);
|
||||
this.addTagWeight("c:nickel_nuggets", 58.6934);
|
||||
this.addTagWeight("c:cobalt_nuggets", 58.9332);
|
||||
this.addTagWeight("c:copper_nuggets", 63.546);
|
||||
this.addTagWeight("c:zinc_nuggets", 65.39);
|
||||
this.addTagWeight("c:gallium_nuggets", 69.723);
|
||||
this.addTagWeight("c:germanium_nuggets", 72.64);
|
||||
this.addTagWeight("c:bromine_nuggets", 79.904);
|
||||
this.addTagWeight("c:krypton_nuggets", 83.8);
|
||||
this.addTagWeight("c:rubidium_nuggets", 85.4678);
|
||||
this.addTagWeight("c:strontium_nuggets", 87.62);
|
||||
this.addTagWeight("c:yttrium_nuggets", 88.9059);
|
||||
this.addTagWeight("c:zirconium_nuggets", 91.224);
|
||||
this.addTagWeight("c:niobium_nuggets", 92.9064);
|
||||
this.addTagWeight("c:technetium_nuggets", 98);
|
||||
this.addTagWeight("c:ruthenium_nuggets", 101.07);
|
||||
this.addTagWeight("c:rhodium_nuggets", 102.9055);
|
||||
this.addTagWeight("c:palladium_nuggets", 106.42);
|
||||
this.addTagWeight("c:silver_nuggets", 107.8682);
|
||||
this.addTagWeight("c:cadmium_nuggets", 112.411);
|
||||
this.addTagWeight("c:indium_nuggets", 114.818);
|
||||
this.addTagWeight("c:tin_nuggets", 118.71);
|
||||
this.addTagWeight("c:antimony_nuggets", 121.76);
|
||||
this.addTagWeight("c:iodine_nuggets", 126.9045);
|
||||
this.addTagWeight("c:tellurium_nuggets", 127.6);
|
||||
this.addTagWeight("c:xenon_nuggets", 131.293);
|
||||
this.addTagWeight("c:cesium_nuggets", 132.9055);
|
||||
this.addTagWeight("c:barium_nuggets", 137.327);
|
||||
this.addTagWeight("c:lanthanum_nuggets", 138.9055);
|
||||
this.addTagWeight("c:cerium_nuggets", 140.116);
|
||||
this.addTagWeight("c:tantalum_nuggets", 180.9479);
|
||||
this.addTagWeight("c:tungsten_nuggets", 183.84);
|
||||
this.addTagWeight("c:osmium_nuggets", 190.23);
|
||||
this.addTagWeight("c:iridium_nuggets", 192.217);
|
||||
this.addTagWeight("c:platinum_nuggets", 195.078);
|
||||
this.addTagWeight("c:lead_nuggets", 207.2);
|
||||
this.addTagWeight("c:bismuth_nuggets", 208.9804);
|
||||
this.addTagWeight("c:uranium_nuggets", 238.0289);
|
||||
this.addTagWeight("c:plutonium_nuggets", 244);
|
||||
|
||||
// TE stuff...
|
||||
this.addTagWeight("forge:nuggets/invar", (58.6934 + 55.845 + 55.845) / 3.0);
|
||||
this.addTagWeight("forge:nuggets/electrum", (107.8682 + 196.96655) / 2.0);
|
||||
this.addTagWeight("c:invar_nuggets", (58.6934 + 55.845 + 55.845) / 3.0);
|
||||
this.addTagWeight("c:electrum_nuggets", (107.8682 + 196.96655) / 2.0);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package appeng.forge.data;
|
||||
|
||||
import appeng.forge.data.providers.loot.BlockDropProvider;
|
||||
import appeng.forge.data.providers.recipes.SlabStairRecipes;
|
||||
import appeng.forge.data.providers.tags.ConventionTagProvider;
|
||||
import net.minecraft.data.DataGenerator;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Collections;
|
||||
|
||||
public class AE2DataGenerators {
|
||||
|
||||
public static void dump() {
|
||||
Path output = Paths.get("../src/generated/resources");
|
||||
|
||||
DataGenerator generator = new DataGenerator(output, Collections.emptyList());
|
||||
generator.install(new BlockDropProvider(output));
|
||||
generator.install(new SlabStairRecipes(output));
|
||||
generator.install(new ConventionTagProvider(output));
|
||||
try {
|
||||
generator.run();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package appeng.forge.data.providers;
|
||||
|
||||
import net.minecraft.data.DataProvider;
|
||||
|
||||
import appeng.api.AEApi;
|
||||
import appeng.api.definitions.IBlocks;
|
||||
import appeng.api.definitions.IItems;
|
||||
import appeng.api.definitions.IMaterials;
|
||||
|
||||
public interface IAE2DataProvider extends DataProvider {
|
||||
IBlocks BLOCKS = AEApi.instance().definitions().blocks();
|
||||
IItems ITEMS = AEApi.instance().definitions().items();
|
||||
IMaterials MATERIALS = AEApi.instance().definitions().materials();
|
||||
}
|
||||
@@ -0,0 +1,100 @@
|
||||
package appeng.forge.data.providers.loot;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Map;
|
||||
import java.util.function.Function;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonElement;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.data.DataCache;
|
||||
import net.minecraft.data.DataProvider;
|
||||
import net.minecraft.data.server.BlockLootTableGenerator;
|
||||
import net.minecraft.enchantment.Enchantments;
|
||||
import net.minecraft.loot.*;
|
||||
import net.minecraft.loot.condition.SurvivesExplosionLootCondition;
|
||||
import net.minecraft.loot.context.LootContextTypes;
|
||||
import net.minecraft.loot.entry.ItemEntry;
|
||||
import net.minecraft.loot.entry.LeafEntry;
|
||||
import net.minecraft.loot.function.ApplyBonusLootFunction;
|
||||
import net.minecraft.loot.function.SetCountLootFunction;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import appeng.forge.data.providers.IAE2DataProvider;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
import net.minecraft.util.registry.RegistryKey;
|
||||
|
||||
public class BlockDropProvider extends BlockLootTableGenerator implements IAE2DataProvider {
|
||||
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
|
||||
private final Path outputFolder;
|
||||
|
||||
private Map<Block, Function<Block, LootTable.Builder>> overrides = ImmutableMap.<Block, Function<Block, LootTable.Builder>>builder()
|
||||
.put(BLOCKS.matrixFrame().block(), $ -> LootTable.builder())
|
||||
.put(BLOCKS.quartzOre().block(),
|
||||
b -> dropsWithSilkTouch(BLOCKS.quartzOre().block(),
|
||||
applyExplosionDecay(BLOCKS.quartzOre().block(),
|
||||
ItemEntry.builder(MATERIALS.certusQuartzCrystal().item())
|
||||
.apply(SetCountLootFunction.builder(UniformLootTableRange.between(1.0F, 2.0F)))
|
||||
.apply(ApplyBonusLootFunction.uniformBonusCount(Enchantments.FORTUNE)))))
|
||||
.put(BLOCKS.quartzOreCharged().block(),
|
||||
b -> dropsWithSilkTouch(BLOCKS.quartzOreCharged().block(),
|
||||
applyExplosionDecay(BLOCKS.quartzOreCharged().block(),
|
||||
ItemEntry.builder(MATERIALS.certusQuartzCrystalCharged().item())
|
||||
.apply(SetCountLootFunction.builder(UniformLootTableRange.between(1.0F, 2.0F)))
|
||||
.apply(ApplyBonusLootFunction.uniformBonusCount(Enchantments.FORTUNE)))))
|
||||
.build();
|
||||
|
||||
public BlockDropProvider(Path outputFolder) {
|
||||
this.outputFolder = outputFolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(DataCache cache) throws IOException {
|
||||
for (Map.Entry<RegistryKey<Block>, Block> entry : Registry.BLOCK.getEntries()) {
|
||||
LootTable.Builder builder;
|
||||
Identifier id = entry.getKey().getValue();
|
||||
if (id.getNamespace().equals(AppEng.MOD_ID)) {
|
||||
builder = overrides.getOrDefault(entry.getValue(), this::defaultBuilder).apply(entry.getValue());
|
||||
|
||||
DataProvider.writeToPath(GSON, cache, toJson(builder), getPath(outputFolder, id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private LootTable.Builder defaultBuilder(Block block) {
|
||||
LeafEntry.Builder<?> entry = ItemEntry.builder(block);
|
||||
LootPool.Builder pool = LootPool.builder().rolls(ConstantLootTableRange.create(1)).with(entry)
|
||||
.conditionally(SurvivesExplosionLootCondition.builder());
|
||||
|
||||
return LootTable.builder().pool(pool);
|
||||
}
|
||||
|
||||
private Path getPath(Path root, Identifier id) {
|
||||
return root.resolve("data/" + id.getNamespace() + "/loot_tables/blocks/" + id.getPath() + ".json");
|
||||
}
|
||||
|
||||
public JsonElement toJson(LootTable.Builder builder) {
|
||||
return LootManager.toJson(finishBuilding(builder));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
public LootTable finishBuilding(LootTable.Builder builder) {
|
||||
return builder.type(LootContextTypes.BLOCK).build();
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
@Override
|
||||
public String getName() {
|
||||
return AppEng.MOD_NAME + " Block Drops";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package appeng.forge.data.providers.recipes;
|
||||
|
||||
import appeng.api.definitions.IBlockDefinition;
|
||||
import appeng.core.AppEng;
|
||||
import appeng.forge.data.providers.IAE2DataProvider;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.data.DataCache;
|
||||
import net.minecraft.data.server.recipe.RecipeJsonProvider;
|
||||
import net.minecraft.data.server.recipe.ShapedRecipeJsonFactory;
|
||||
import net.minecraft.data.server.recipe.SingleItemRecipeJsonFactory;
|
||||
import net.minecraft.recipe.Ingredient;
|
||||
import net.minecraft.util.Identifier;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import static net.minecraft.data.server.RecipesProvider.conditionsFromItem;
|
||||
import static net.minecraft.data.server.RecipesProvider.saveRecipe;
|
||||
import static net.minecraft.data.server.RecipesProvider.saveRecipeAdvancement;
|
||||
|
||||
public class SlabStairRecipes implements IAE2DataProvider {
|
||||
|
||||
IBlockDefinition[][] blocks = {{BLOCKS.skyStoneBlock(), BLOCKS.skyStoneSlab(), BLOCKS.skyStoneStairs()},
|
||||
{BLOCKS.smoothSkyStoneBlock(), BLOCKS.smoothSkyStoneSlab(), BLOCKS.smoothSkyStoneStairs()},
|
||||
{BLOCKS.skyStoneBrick(), BLOCKS.skyStoneBrickSlab(), BLOCKS.skyStoneBrickStairs()},
|
||||
{BLOCKS.skyStoneSmallBrick(), BLOCKS.skyStoneSmallBrickSlab(), BLOCKS.skyStoneSmallBrickStairs()},
|
||||
{BLOCKS.fluixBlock(), BLOCKS.fluixSlab(), BLOCKS.fluixStairs()},
|
||||
{BLOCKS.quartzBlock(), BLOCKS.quartzSlab(), BLOCKS.quartzStairs()},
|
||||
{BLOCKS.chiseledQuartzBlock(), BLOCKS.chiseledQuartzSlab(), BLOCKS.chiseledQuartzStairs()},
|
||||
{BLOCKS.quartzPillar(), BLOCKS.quartzPillarSlab(), BLOCKS.quartzPillarStairs()},};
|
||||
|
||||
private final Path outputPath;
|
||||
|
||||
private final Consumer<RecipeJsonProvider> consumer;
|
||||
|
||||
private DataCache cache;
|
||||
|
||||
public SlabStairRecipes(Path outputPath) {
|
||||
this.outputPath = outputPath;
|
||||
this.consumer = this::provideRecipe;
|
||||
}
|
||||
|
||||
public void run(DataCache cache) {
|
||||
this.cache = cache;
|
||||
for (IBlockDefinition[] block : blocks) {
|
||||
slabRecipe(block[0], block[1]);
|
||||
stairRecipe(block[0], block[2]);
|
||||
}
|
||||
}
|
||||
|
||||
private void slabRecipe(IBlockDefinition block, IBlockDefinition slabs) {
|
||||
Block inputBlock = block.block();
|
||||
Block outputBlock = slabs.block();
|
||||
|
||||
ShapedRecipeJsonFactory.create(slabs.block(), 6).pattern("###").input('#', inputBlock)
|
||||
.criterion(criterionName(block), conditionsFromItem(inputBlock))
|
||||
.offerTo(consumer, new Identifier(AppEng.MOD_ID, "shaped/slabs/" + block.identifier()));
|
||||
|
||||
SingleItemRecipeJsonFactory.create(Ingredient.ofItems(inputBlock), outputBlock, 2)
|
||||
.create(criterionName(block), conditionsFromItem(inputBlock))
|
||||
.offerTo(consumer, new Identifier(AppEng.MOD_ID, "block_cutter/slabs/" + slabs.identifier()));
|
||||
}
|
||||
|
||||
private void stairRecipe(IBlockDefinition block, IBlockDefinition stairs) {
|
||||
Block inputBlock = block.block();
|
||||
Block outputBlock = stairs.block();
|
||||
|
||||
ShapedRecipeJsonFactory.create(outputBlock, 4).pattern("# ").pattern("## ").pattern("###")
|
||||
.input('#', inputBlock).criterion(criterionName(block), conditionsFromItem(inputBlock))
|
||||
.offerTo(consumer, new Identifier(AppEng.MOD_ID, "shaped/stairs/" + block.identifier()));
|
||||
|
||||
SingleItemRecipeJsonFactory.create(Ingredient.ofItems(inputBlock), outputBlock)
|
||||
.create(criterionName(block), conditionsFromItem(inputBlock))
|
||||
.offerTo(consumer, new Identifier(AppEng.MOD_ID, "block_cutter/stairs/" + stairs.identifier()));
|
||||
|
||||
}
|
||||
|
||||
private void provideRecipe(RecipeJsonProvider recipeJsonProvider) {
|
||||
saveRecipe(cache, recipeJsonProvider.toJson(), outputPath.resolve("data/" + recipeJsonProvider.getRecipeId().getNamespace() + "/recipes/" + recipeJsonProvider.getRecipeId().getPath() + ".json"));
|
||||
JsonObject jsonObject = recipeJsonProvider.toAdvancementJson();
|
||||
if (jsonObject != null) {
|
||||
saveRecipeAdvancement(cache, jsonObject, outputPath.resolve("data/" + recipeJsonProvider.getRecipeId().getNamespace() + "/advancements/" + recipeJsonProvider.getAdvancementId().getPath() + ".json"));
|
||||
}
|
||||
}
|
||||
|
||||
private String criterionName(IBlockDefinition block) {
|
||||
return String.format("has_%s", block.identifier());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return AppEng.MOD_NAME + " Slabs and Stairs";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package appeng.forge.data.providers.tags;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import net.minecraft.block.Blocks;
|
||||
import net.minecraft.item.Items;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
|
||||
public class ConventionTagProvider extends TagProvider {
|
||||
|
||||
public ConventionTagProvider(Path outputPath) {
|
||||
super(outputPath);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void generate() throws IOException {
|
||||
// Dyes
|
||||
addItemTag("white_dyes", Items.WHITE_DYE);
|
||||
addItemTag("orange_dyes", Items.ORANGE_DYE);
|
||||
addItemTag("magenta_dyes", Items.MAGENTA_DYE);
|
||||
addItemTag("light_blue_dyes", Items.LIGHT_BLUE_DYE);
|
||||
addItemTag("yellow_dyes", Items.YELLOW_DYE);
|
||||
addItemTag("lime_dyes", Items.LIME_DYE);
|
||||
addItemTag("pink_dyes", Items.PINK_DYE);
|
||||
addItemTag("gray_dyes", Items.GRAY_DYE);
|
||||
addItemTag("light_gray_dyes", Items.LIGHT_GRAY_DYE);
|
||||
addItemTag("cyan_dyes", Items.CYAN_DYE);
|
||||
addItemTag("purple_dyes", Items.PURPLE_DYE);
|
||||
addItemTag("blue_dyes", Items.BLUE_DYE);
|
||||
addItemTag("brown_dyes", Items.BROWN_DYE);
|
||||
addItemTag("green_dyes", Items.GREEN_DYE);
|
||||
addItemTag("red_dyes", Items.RED_DYE);
|
||||
addItemTag("black_dyes", Items.BLACK_DYE);
|
||||
|
||||
addItemTag("iron_ingots", Items.IRON_INGOT);
|
||||
addItemTag("iron_ores", Items.IRON_ORE);
|
||||
addItemTag("gold_ingots", Items.GOLD_INGOT);
|
||||
addItemTag("gold_ores", Items.GOLD_ORE);
|
||||
addItemTag("glowstone_dusts", Items.GLOWSTONE_DUST);
|
||||
addItemTag("wooden_rods", Items.STICK);
|
||||
addItemTag("nether_quartz_ores", Items.NETHER_QUARTZ_ORE);
|
||||
addItemTag("nether_quartz_crystals", Items.QUARTZ);
|
||||
addItemTag("sand_blocks", Items.SAND, Items.RED_SAND);
|
||||
addItemTag("diamonds", Items.DIAMOND);
|
||||
addItemTag("wooden_chests", Items.CHEST, Items.TRAPPED_CHEST);
|
||||
addItemTag("wheat_crops", Items.WHEAT);
|
||||
addItemTag("redstone_dusts", Items.REDSTONE);
|
||||
addItemTag("ender_pearls", Items.ENDER_PEARL);
|
||||
addItemTag("terracotta_blocks", Items.TERRACOTTA,
|
||||
Items.WHITE_TERRACOTTA,
|
||||
Items.ORANGE_TERRACOTTA,
|
||||
Items.MAGENTA_TERRACOTTA,
|
||||
Items.LIGHT_BLUE_TERRACOTTA,
|
||||
Items.YELLOW_TERRACOTTA,
|
||||
Items.LIME_TERRACOTTA,
|
||||
Items.PINK_TERRACOTTA,
|
||||
Items.GRAY_TERRACOTTA,
|
||||
Items.LIGHT_GRAY_TERRACOTTA,
|
||||
Items.CYAN_TERRACOTTA,
|
||||
Items.PURPLE_TERRACOTTA,
|
||||
Items.BLUE_TERRACOTTA,
|
||||
Items.BROWN_TERRACOTTA,
|
||||
Items.GREEN_TERRACOTTA,
|
||||
Items.RED_TERRACOTTA,
|
||||
Items.BLACK_TERRACOTTA
|
||||
);
|
||||
addItemTag("glass_blocks", Items.GLASS,
|
||||
Items.WHITE_STAINED_GLASS,
|
||||
Items.ORANGE_STAINED_GLASS,
|
||||
Items.MAGENTA_STAINED_GLASS,
|
||||
Items.LIGHT_BLUE_STAINED_GLASS,
|
||||
Items.YELLOW_STAINED_GLASS,
|
||||
Items.LIME_STAINED_GLASS,
|
||||
Items.PINK_STAINED_GLASS,
|
||||
Items.GRAY_STAINED_GLASS,
|
||||
Items.LIGHT_GRAY_STAINED_GLASS,
|
||||
Items.CYAN_STAINED_GLASS,
|
||||
Items.PURPLE_STAINED_GLASS,
|
||||
Items.BLUE_STAINED_GLASS,
|
||||
Items.BROWN_STAINED_GLASS,
|
||||
Items.GREEN_STAINED_GLASS,
|
||||
Items.RED_STAINED_GLASS,
|
||||
Items.BLACK_STAINED_GLASS
|
||||
);
|
||||
|
||||
addBlockTag("glass_blocks", Blocks.GLASS,
|
||||
Blocks.WHITE_STAINED_GLASS,
|
||||
Blocks.ORANGE_STAINED_GLASS,
|
||||
Blocks.MAGENTA_STAINED_GLASS,
|
||||
Blocks.LIGHT_BLUE_STAINED_GLASS,
|
||||
Blocks.YELLOW_STAINED_GLASS,
|
||||
Blocks.LIME_STAINED_GLASS,
|
||||
Blocks.PINK_STAINED_GLASS,
|
||||
Blocks.GRAY_STAINED_GLASS,
|
||||
Blocks.LIGHT_GRAY_STAINED_GLASS,
|
||||
Blocks.CYAN_STAINED_GLASS,
|
||||
Blocks.PURPLE_STAINED_GLASS,
|
||||
Blocks.BLUE_STAINED_GLASS,
|
||||
Blocks.BROWN_STAINED_GLASS,
|
||||
Blocks.GREEN_STAINED_GLASS,
|
||||
Blocks.RED_STAINED_GLASS,
|
||||
Blocks.BLACK_STAINED_GLASS
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return AppEng.MOD_NAME + " Convention Tags";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package appeng.forge.data.providers.tags;
|
||||
|
||||
import appeng.core.AppEng;
|
||||
import appeng.forge.data.providers.IAE2DataProvider;
|
||||
import com.google.gson.Gson;
|
||||
import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.data.DataCache;
|
||||
import net.minecraft.data.DataProvider;
|
||||
import net.minecraft.item.ItemConvertible;
|
||||
import net.minecraft.item.Items;
|
||||
import net.minecraft.util.Identifier;
|
||||
import net.minecraft.util.registry.Registry;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class TagProvider implements IAE2DataProvider {
|
||||
|
||||
private static final Gson GSON = new GsonBuilder().setPrettyPrinting().create();
|
||||
protected static final String CONVENTION_NAMESPACE = "c";
|
||||
protected static final String TYPE_ITEMS = "items";
|
||||
protected static final String TYPE_BLOCKS = "blocks";
|
||||
|
||||
private final Path outputPath;
|
||||
|
||||
private DataCache cache;
|
||||
|
||||
protected TagProvider(Path outputPath) {
|
||||
this.outputPath = outputPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(DataCache cache) throws IOException {
|
||||
this.cache = cache;
|
||||
try {
|
||||
generate();
|
||||
} finally {
|
||||
this.cache = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract void generate() throws IOException;
|
||||
|
||||
protected void addItemTag(String name, ItemConvertible... items) throws IOException {
|
||||
List<String> itemIds = Arrays.stream(items)
|
||||
.map(ItemConvertible::asItem)
|
||||
.map(Registry.ITEM::getId)
|
||||
.map(Identifier::toString)
|
||||
.collect(Collectors.toList());
|
||||
writeTagFile(CONVENTION_NAMESPACE, TYPE_ITEMS, name, itemIds);
|
||||
}
|
||||
|
||||
protected void addBlockTag(String name, Block... blocks) throws IOException {
|
||||
List<String> itemIds = Arrays.stream(blocks)
|
||||
.map(Registry.BLOCK::getId)
|
||||
.map(Identifier::toString)
|
||||
.collect(Collectors.toList());
|
||||
writeTagFile(CONVENTION_NAMESPACE, TYPE_BLOCKS, name, itemIds);
|
||||
}
|
||||
|
||||
protected void writeTagFile(String namespace, String tagType, String tagName, List<String> entries) throws IOException {
|
||||
JsonObject rootObj = new JsonObject();
|
||||
JsonArray valuesArr = new JsonArray();
|
||||
for (String entry : entries) {
|
||||
valuesArr.add(entry);
|
||||
}
|
||||
rootObj.add("values", valuesArr);
|
||||
|
||||
Path path = outputPath.resolve("data/" + namespace + "/tags/" + tagType + "/" + tagName + ".json");
|
||||
DataProvider.writeToPath(GSON, this.cache, rootObj, path);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return AppEng.MOD_NAME + " Convention Tags";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -81,22 +81,22 @@ public class ColorApplicatorItem extends AEBasePoweredItem
|
||||
implements IStorageCell<IAEItemStack>, IBlockTool, IMouseWheelItem {
|
||||
|
||||
private static final Map<Identifier, AEColor> TAG_TO_COLOR = ImmutableMap.<Identifier, AEColor>builder()
|
||||
.put(new Identifier("forge:dyes/black"), AEColor.BLACK)
|
||||
.put(new Identifier("forge:dyes/blue"), AEColor.BLUE)
|
||||
.put(new Identifier("forge:dyes/brown"), AEColor.BROWN)
|
||||
.put(new Identifier("forge:dyes/cyan"), AEColor.CYAN)
|
||||
.put(new Identifier("forge:dyes/gray"), AEColor.GRAY)
|
||||
.put(new Identifier("forge:dyes/green"), AEColor.GREEN)
|
||||
.put(new Identifier("forge:dyes/light_blue"), AEColor.LIGHT_BLUE)
|
||||
.put(new Identifier("forge:dyes/light_gray"), AEColor.LIGHT_GRAY)
|
||||
.put(new Identifier("forge:dyes/lime"), AEColor.LIME)
|
||||
.put(new Identifier("forge:dyes/magenta"), AEColor.MAGENTA)
|
||||
.put(new Identifier("forge:dyes/orange"), AEColor.ORANGE)
|
||||
.put(new Identifier("forge:dyes/pink"), AEColor.PINK)
|
||||
.put(new Identifier("forge:dyes/purple"), AEColor.PURPLE)
|
||||
.put(new Identifier("forge:dyes/red"), AEColor.RED)
|
||||
.put(new Identifier("forge:dyes/white"), AEColor.WHITE)
|
||||
.put(new Identifier("forge:dyes/yellow"), AEColor.YELLOW).build();
|
||||
.put(new Identifier("c:black_dyes"), AEColor.BLACK)
|
||||
.put(new Identifier("c:blue_dyes"), AEColor.BLUE)
|
||||
.put(new Identifier("c:brown_dyes"), AEColor.BROWN)
|
||||
.put(new Identifier("c:cyan_dyes"), AEColor.CYAN)
|
||||
.put(new Identifier("c:gray_dyes"), AEColor.GRAY)
|
||||
.put(new Identifier("c:green_dyes"), AEColor.GREEN)
|
||||
.put(new Identifier("c:light_blue_dyes"), AEColor.LIGHT_BLUE)
|
||||
.put(new Identifier("c:light_gray_dyes"), AEColor.LIGHT_GRAY)
|
||||
.put(new Identifier("c:lime_dyes"), AEColor.LIME)
|
||||
.put(new Identifier("c:magenta_dyes"), AEColor.MAGENTA)
|
||||
.put(new Identifier("c:orange_dyes"), AEColor.ORANGE)
|
||||
.put(new Identifier("c:pink_dyes"), AEColor.PINK)
|
||||
.put(new Identifier("c:purple_dyes"), AEColor.PURPLE)
|
||||
.put(new Identifier("c:red_dyes"), AEColor.RED)
|
||||
.put(new Identifier("c:white_dyes"), AEColor.WHITE)
|
||||
.put(new Identifier("c:yellow_dyes"), AEColor.YELLOW).build();
|
||||
|
||||
private static final String TAG_COLOR = "color";
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ public class MeteoriteStructureStart extends StructureStart<DefaultFeatureConfig
|
||||
|
||||
private final Tag<Block> sandTag = BlockTags.getContainer().getOrCreate(new Identifier("minecraft:sand"));
|
||||
private final Tag<Block> terracottaTag = BlockTags.getContainer()
|
||||
.getOrCreate(new Identifier("forge:terracotta"));
|
||||
.getOrCreate(new Identifier("c:terracotta_blocks"));
|
||||
|
||||
public MeteoriteStructureStart(StructureFeature<DefaultFeatureConfig> feature, int chunkX, int chunkZ, BlockBox box, int references, long seed) {
|
||||
super(feature, chunkX, chunkZ, box, references, seed);
|
||||
|
||||
Reference in New Issue
Block a user