Skip to content

Commit

Permalink
feat: add tag for all block
Browse files Browse the repository at this point in the history
Signed-off-by: AlasDiablo <[email protected]>
  • Loading branch information
AlasDiablo committed Jun 19, 2021
1 parent 722db43 commit 967d002
Show file tree
Hide file tree
Showing 4 changed files with 140 additions and 61 deletions.
Original file line number Diff line number Diff line change
@@ -1,20 +1,61 @@
package fr.alasdiablo.janoeo.foundation.data;

import static fr.alasdiablo.janoeo.foundation.init.FoundationBlocks.*;
import static fr.alasdiablo.janoeo.foundation.init.FoundationTags.Blocks.*;

import fr.alasdiablo.janoeo.foundation.Registries;
import net.minecraft.data.BlockTagsProvider;
import net.minecraft.data.DataGenerator;
import net.minecraftforge.common.Tags;
import net.minecraftforge.common.data.ExistingFileHelper;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

@SuppressWarnings("unchecked")
public class FoundationBlockTagsProvider extends BlockTagsProvider {
public FoundationBlockTagsProvider(DataGenerator generatorIn, @Nullable ExistingFileHelper existingFileHelper) {
super(generatorIn, Registries.MOD_ID, existingFileHelper);
}

@Override
protected void registerTags() {
this.getOrCreateBuilder(Tags.Blocks.ORES).addTags(
ORES_ALUMINIUM,
ORES_ALUMINUM,
ORES_LEAD,
ORES_NICKEL,
ORES_SILVER,
ORES_TIN,
ORES_URANIUM,
ORES_TINY
);
this.getOrCreateBuilder(ORES_ALUMINIUM).addItemEntry(BAUXITE_ORE);
this.getOrCreateBuilder(ORES_ALUMINUM).addTags(ORES_ALUMINIUM); // Reference to DUSTS_ALUMINIUM
this.getOrCreateBuilder(ORES_LEAD).addItemEntry(LEAD_ORE);
this.getOrCreateBuilder(ORES_NICKEL).addItemEntry(NICKEL_ORE);
this.getOrCreateBuilder(ORES_SILVER).addItemEntry(SILVER_ORE);
this.getOrCreateBuilder(ORES_TIN).addItemEntry(TIN_ORE);
this.getOrCreateBuilder(ORES_URANIUM).addItemEntry(URANIUM_ORE);

this.getOrCreateBuilder(ORES_TINY).addTags(
ORES_TINY_COAL,
ORES_TINY_COPPER,
ORES_TINY_DIAMOND,
ORES_TINY_EMERALD,
ORES_TINY_GOLD,
ORES_TINY_IRON,
ORES_TINY_LAPIS,
ORES_TINY_REDSTONE
);
this.getOrCreateBuilder(ORES_TINY_COAL).addItemEntry(TINY_COAL_ORE);
this.getOrCreateBuilder(ORES_TINY_COPPER).addItemEntry(TINY_COPPER_ORE);
this.getOrCreateBuilder(ORES_TINY_DIAMOND).addItemEntry(TINY_DIAMOND_ORE);
this.getOrCreateBuilder(ORES_TINY_EMERALD).addItemEntry(TINY_EMERALD_ORE);
this.getOrCreateBuilder(ORES_TINY_GOLD).addItemEntry(TINY_GOLD_ORE);
this.getOrCreateBuilder(ORES_TINY_IRON).addItemEntry(TINY_IRON_ORE);
this.getOrCreateBuilder(ORES_TINY_LAPIS).addItemEntry(TINY_LAPIS_ORE);
this.getOrCreateBuilder(ORES_TINY_REDSTONE).addItemEntry(TINY_REDSTONE_ORE);
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static fr.alasdiablo.janoeo.foundation.init.FoundationItems.*;
import static fr.alasdiablo.janoeo.foundation.init.FoundationTags.Items.*;

import fr.alasdiablo.janoeo.foundation.init.FoundationTags;
import mcp.MethodsReturnNonnullByDefault;
import net.minecraft.data.BlockTagsProvider;
import net.minecraft.data.DataGenerator;
Expand All @@ -24,7 +25,28 @@ public FoundationItemTagsProvider(DataGenerator dataGenerator, BlockTagsProvider

@Override
protected void registerTags() {
getOrCreateBuilder(Tags.Items.DUSTS).addTags(
this.copy(FoundationTags.Blocks.ORES_TINY_COAL, ORES_TINY_COAL);
this.copy(FoundationTags.Blocks.ORES_TINY_COPPER, ORES_TINY_COPPER);
this.copy(FoundationTags.Blocks.ORES_TINY_DIAMOND, ORES_TINY_DIAMOND);
this.copy(FoundationTags.Blocks.ORES_TINY_EMERALD, ORES_TINY_EMERALD);
this.copy(FoundationTags.Blocks.ORES_TINY_GOLD, ORES_TINY_GOLD);
this.copy(FoundationTags.Blocks.ORES_TINY_IRON, ORES_TINY_IRON);
this.copy(FoundationTags.Blocks.ORES_TINY_LAPIS, ORES_TINY_LAPIS);
this.copy(FoundationTags.Blocks.ORES_TINY_REDSTONE, ORES_TINY_REDSTONE);

this.copy(FoundationTags.Blocks.ORES_ALUMINIUM, ORES_ALUMINIUM);
this.copy(FoundationTags.Blocks.ORES_ALUMINUM, ORES_ALUMINUM);
this.copy(FoundationTags.Blocks.ORES_LEAD, ORES_LEAD);
this.copy(FoundationTags.Blocks.ORES_NICKEL, ORES_NICKEL);
this.copy(FoundationTags.Blocks.ORES_SILVER, ORES_SILVER);
this.copy(FoundationTags.Blocks.ORES_TIN, ORES_TIN);
this.copy(FoundationTags.Blocks.ORES_URANIUM, ORES_URANIUM);

this.copy(FoundationTags.Blocks.ORES_TINY, ORES_TINY);
this.copy(Tags.Blocks.ORES, Tags.Items.ORES);


this.getOrCreateBuilder(Tags.Items.DUSTS).addTags(
DUSTS_ALUMINIUM,
DUSTS_ALUMINUM,
DUSTS_AMETHYST,
Expand All @@ -41,23 +63,23 @@ protected void registerTags() {
DUSTS_TIN,
DUSTS_URANIUM
);
getOrCreateBuilder(DUSTS_ALUMINIUM).addItemEntry(ALUMINIUM_DUST);
getOrCreateBuilder(DUSTS_ALUMINUM).addTags(DUSTS_ALUMINIUM); // Reference to DUSTS_ALUMINIUM
getOrCreateBuilder(DUSTS_AMETHYST).addItemEntry(AMETHYST_DUST);
getOrCreateBuilder(DUSTS_COAL).addItemEntry(COAL_DUST);
getOrCreateBuilder(DUSTS_COPPER).addItemEntry(COPPER_DUST);
getOrCreateBuilder(DUSTS_DIAMOND).addItemEntry(DIAMOND_DUST);
getOrCreateBuilder(DUSTS_GOLD).addItemEntry(GOLD_DUST);
getOrCreateBuilder(DUSTS_EMERALD).addItemEntry(EMERALD_DUST);
getOrCreateBuilder(DUSTS_IRON).addItemEntry(IRON_DUST);
getOrCreateBuilder(DUSTS_LAPIS).addItemEntry(LAPIS_DUST);
getOrCreateBuilder(DUSTS_LEAD).addItemEntry(LEAD_DUST);
getOrCreateBuilder(DUSTS_NICKEL).addItemEntry(NICKEL_DUST);
getOrCreateBuilder(DUSTS_SILVER).addItemEntry(SILVER_DUST);
getOrCreateBuilder(DUSTS_TIN).addItemEntry(TIN_DUST);
getOrCreateBuilder(DUSTS_URANIUM).addItemEntry(URANIUM_DUST);
this.getOrCreateBuilder(DUSTS_ALUMINIUM).addItemEntry(ALUMINIUM_DUST);
this.getOrCreateBuilder(DUSTS_ALUMINUM).addTags(DUSTS_ALUMINIUM); // Reference to DUSTS_ALUMINIUM
this.getOrCreateBuilder(DUSTS_AMETHYST).addItemEntry(AMETHYST_DUST);
this.getOrCreateBuilder(DUSTS_COAL).addItemEntry(COAL_DUST);
this.getOrCreateBuilder(DUSTS_COPPER).addItemEntry(COPPER_DUST);
this.getOrCreateBuilder(DUSTS_DIAMOND).addItemEntry(DIAMOND_DUST);
this.getOrCreateBuilder(DUSTS_GOLD).addItemEntry(GOLD_DUST);
this.getOrCreateBuilder(DUSTS_EMERALD).addItemEntry(EMERALD_DUST);
this.getOrCreateBuilder(DUSTS_IRON).addItemEntry(IRON_DUST);
this.getOrCreateBuilder(DUSTS_LAPIS).addItemEntry(LAPIS_DUST);
this.getOrCreateBuilder(DUSTS_LEAD).addItemEntry(LEAD_DUST);
this.getOrCreateBuilder(DUSTS_NICKEL).addItemEntry(NICKEL_DUST);
this.getOrCreateBuilder(DUSTS_SILVER).addItemEntry(SILVER_DUST);
this.getOrCreateBuilder(DUSTS_TIN).addItemEntry(TIN_DUST);
this.getOrCreateBuilder(DUSTS_URANIUM).addItemEntry(URANIUM_DUST);

getOrCreateBuilder(Tags.Items.NUGGETS).addTags(
this.getOrCreateBuilder(Tags.Items.NUGGETS).addTags(
NUGGETS_ALUMINIUM,
NUGGETS_ALUMINUM,
NUGGETS_COAL,
Expand All @@ -72,21 +94,21 @@ protected void registerTags() {
NUGGETS_TIN,
NUGGETS_URANIUM
);
getOrCreateBuilder(NUGGETS_ALUMINIUM).addItemEntry(ALUMINIUM_NUGGET);
getOrCreateBuilder(NUGGETS_ALUMINUM).addTags(NUGGETS_ALUMINIUM); // Reference to NUGGETS_ALUMINIUM
getOrCreateBuilder(NUGGETS_COAL).addItemEntry(COAL_NUGGET);
getOrCreateBuilder(NUGGETS_COPPER).addItemEntry(COPPER_NUGGET);
getOrCreateBuilder(NUGGETS_DIAMOND).addItemEntry(DIAMOND_NUGGET);
getOrCreateBuilder(NUGGETS_EMERALD).addItemEntry(EMERALD_NUGGET);
getOrCreateBuilder(NUGGETS_LAPIS).addItemEntry(LAPIS_NUGGET);
getOrCreateBuilder(NUGGETS_LEAD).addItemEntry(LEAD_NUGGET);
getOrCreateBuilder(NUGGETS_NICKEL).addItemEntry(NICKEL_NUGGET);
getOrCreateBuilder(NUGGETS_REDSTONE).addItemEntry(REDSTONE_NUGGET);
getOrCreateBuilder(NUGGETS_SILVER).addItemEntry(SILVER_NUGGET);
getOrCreateBuilder(NUGGETS_TIN).addItemEntry(TIN_NUGGET);
getOrCreateBuilder(NUGGETS_URANIUM).addItemEntry(URANIUM_NUGGET);
this.getOrCreateBuilder(NUGGETS_ALUMINIUM).addItemEntry(ALUMINIUM_NUGGET);
this.getOrCreateBuilder(NUGGETS_ALUMINUM).addTags(NUGGETS_ALUMINIUM); // Reference to NUGGETS_ALUMINIUM
this.getOrCreateBuilder(NUGGETS_COAL).addItemEntry(COAL_NUGGET);
this.getOrCreateBuilder(NUGGETS_COPPER).addItemEntry(COPPER_NUGGET);
this.getOrCreateBuilder(NUGGETS_DIAMOND).addItemEntry(DIAMOND_NUGGET);
this.getOrCreateBuilder(NUGGETS_EMERALD).addItemEntry(EMERALD_NUGGET);
this.getOrCreateBuilder(NUGGETS_LAPIS).addItemEntry(LAPIS_NUGGET);
this.getOrCreateBuilder(NUGGETS_LEAD).addItemEntry(LEAD_NUGGET);
this.getOrCreateBuilder(NUGGETS_NICKEL).addItemEntry(NICKEL_NUGGET);
this.getOrCreateBuilder(NUGGETS_REDSTONE).addItemEntry(REDSTONE_NUGGET);
this.getOrCreateBuilder(NUGGETS_SILVER).addItemEntry(SILVER_NUGGET);
this.getOrCreateBuilder(NUGGETS_TIN).addItemEntry(TIN_NUGGET);
this.getOrCreateBuilder(NUGGETS_URANIUM).addItemEntry(URANIUM_NUGGET);

getOrCreateBuilder(Tags.Items.INGOTS).addTags(
this.getOrCreateBuilder(Tags.Items.INGOTS).addTags(
INGOTS_ALUMINIUM,
INGOTS_ALUMINUM,
INGOTS_LEAD,
Expand All @@ -95,15 +117,15 @@ protected void registerTags() {
INGOTS_TIN,
INGOTS_URANIUM
);
getOrCreateBuilder(INGOTS_ALUMINIUM).addItemEntry(ALUMINIUM_INGOT);
getOrCreateBuilder(INGOTS_ALUMINUM).addTags(INGOTS_ALUMINIUM); // Reference to INGOTS_ALUMINIUM
getOrCreateBuilder(INGOTS_LEAD).addItemEntry(LEAD_INGOT);
getOrCreateBuilder(INGOTS_NICKEL).addItemEntry(NICKEL_INGOT);
getOrCreateBuilder(INGOTS_SILVER).addItemEntry(SILVER_INGOT);
getOrCreateBuilder(INGOTS_TIN).addItemEntry(TIN_INGOT);
getOrCreateBuilder(INGOTS_URANIUM).addItemEntry(URANIUM_INGOT);
this.getOrCreateBuilder(INGOTS_ALUMINIUM).addItemEntry(ALUMINIUM_INGOT);
this.getOrCreateBuilder(INGOTS_ALUMINUM).addTags(INGOTS_ALUMINIUM); // Reference to INGOTS_ALUMINIUM
this.getOrCreateBuilder(INGOTS_LEAD).addItemEntry(LEAD_INGOT);
this.getOrCreateBuilder(INGOTS_NICKEL).addItemEntry(NICKEL_INGOT);
this.getOrCreateBuilder(INGOTS_SILVER).addItemEntry(SILVER_INGOT);
this.getOrCreateBuilder(INGOTS_TIN).addItemEntry(TIN_INGOT);
this.getOrCreateBuilder(INGOTS_URANIUM).addItemEntry(URANIUM_INGOT);

getOrCreateBuilder(RAWS).addTags(
this.getOrCreateBuilder(RAWS).addTags(
RAWS_ALUMINIUM,
RAWS_ALUMINUM,
RAWS_LEAD,
Expand All @@ -112,13 +134,13 @@ protected void registerTags() {
RAWS_TIN,
RAWS_URANIUM
);
getOrCreateBuilder(RAWS_ALUMINIUM).addItemEntry(RAW_ALUMINIUM);
getOrCreateBuilder(RAWS_ALUMINUM).addTags(RAWS_ALUMINIUM); // Reference to INGOTS_ALUMINIUM
getOrCreateBuilder(RAWS_LEAD).addItemEntry(RAW_LEAD);
getOrCreateBuilder(RAWS_NICKEL).addItemEntry(RAW_NICKEL);
getOrCreateBuilder(RAWS_SILVER).addItemEntry(RAW_SILVER);
getOrCreateBuilder(RAWS_TIN).addItemEntry(RAW_TIN);
getOrCreateBuilder(RAWS_URANIUM).addItemEntry(RAW_URANIUM);
this.getOrCreateBuilder(RAWS_ALUMINIUM).addItemEntry(RAW_ALUMINIUM);
this.getOrCreateBuilder(RAWS_ALUMINUM).addTags(RAWS_ALUMINIUM); // Reference to INGOTS_ALUMINIUM
this.getOrCreateBuilder(RAWS_LEAD).addItemEntry(RAW_LEAD);
this.getOrCreateBuilder(RAWS_NICKEL).addItemEntry(RAW_NICKEL);
this.getOrCreateBuilder(RAWS_SILVER).addItemEntry(RAW_SILVER);
this.getOrCreateBuilder(RAWS_TIN).addItemEntry(RAW_TIN);
this.getOrCreateBuilder(RAWS_URANIUM).addItemEntry(RAW_URANIUM);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@
import net.minecraft.block.Block;
import net.minecraft.item.Item;
import net.minecraft.tags.BlockTags;
import net.minecraft.tags.ITag;
import net.minecraft.tags.ItemTags;
import net.minecraft.util.ResourceLocation;
import net.minecraftforge.common.Tags;

public class FoundationTags {

public static class Blocks {
public static final Tags.IOptionalNamedTag<Block> ORES = tag("ores");
public static final Tags.IOptionalNamedTag<Block> ORES_ALUMINIUM = tag("ores/aluminium"); // UK also FR btw (haha)
public static final Tags.IOptionalNamedTag<Block> ORES_ALUMINUM = tag("ores/aluminum"); // US // because we can found both…
public static final Tags.IOptionalNamedTag<Block> ORES_LEAD = tag("ores/lead");
Expand All @@ -20,12 +18,40 @@ public static class Blocks {
public static final Tags.IOptionalNamedTag<Block> ORES_TIN = tag("ores/tin");
public static final Tags.IOptionalNamedTag<Block> ORES_URANIUM = tag("ores/uranium");

public static final Tags.IOptionalNamedTag<Block> ORES_TINY = tag("ores/tiny");
public static final Tags.IOptionalNamedTag<Block> ORES_TINY_COAL = tag("ores/tiny/coal");
public static final Tags.IOptionalNamedTag<Block> ORES_TINY_COPPER = tag("ores/tiny/copper");
public static final Tags.IOptionalNamedTag<Block> ORES_TINY_DIAMOND = tag("ores/tiny/diamond");
public static final Tags.IOptionalNamedTag<Block> ORES_TINY_EMERALD = tag("ores/tiny/emerald");
public static final Tags.IOptionalNamedTag<Block> ORES_TINY_GOLD = tag("ores/tiny/gold");
public static final Tags.IOptionalNamedTag<Block> ORES_TINY_IRON = tag("ores/tiny/iron");
public static final Tags.IOptionalNamedTag<Block> ORES_TINY_LAPIS = tag("ores/tiny/lapis");
public static final Tags.IOptionalNamedTag<Block> ORES_TINY_REDSTONE = tag("ores/tiny/redstone");

private static Tags.IOptionalNamedTag<Block> tag(String name) {
return BlockTags.createOptional(new ResourceLocation("forge", name));
}
}

public static class Items {
public static final Tags.IOptionalNamedTag<Item> ORES_ALUMINIUM = tag("ores/aluminium"); // UK also FR btw (haha)
public static final Tags.IOptionalNamedTag<Item> ORES_ALUMINUM = tag("ores/aluminum"); // US // because we can found both…
public static final Tags.IOptionalNamedTag<Item> ORES_LEAD = tag("ores/lead");
public static final Tags.IOptionalNamedTag<Item> ORES_NICKEL = tag("ores/nickel");
public static final Tags.IOptionalNamedTag<Item> ORES_SILVER = tag("ores/silver");
public static final Tags.IOptionalNamedTag<Item> ORES_TIN = tag("ores/tin");
public static final Tags.IOptionalNamedTag<Item> ORES_URANIUM = tag("ores/uranium");

public static final Tags.IOptionalNamedTag<Item> ORES_TINY = tag("ores/tiny");
public static final Tags.IOptionalNamedTag<Item> ORES_TINY_COAL = tag("ores/tiny/coal");
public static final Tags.IOptionalNamedTag<Item> ORES_TINY_COPPER = tag("ores/tiny/copper");
public static final Tags.IOptionalNamedTag<Item> ORES_TINY_DIAMOND = tag("ores/tiny/diamond");
public static final Tags.IOptionalNamedTag<Item> ORES_TINY_EMERALD = tag("ores/tiny/emerald");
public static final Tags.IOptionalNamedTag<Item> ORES_TINY_GOLD = tag("ores/tiny/gold");
public static final Tags.IOptionalNamedTag<Item> ORES_TINY_IRON = tag("ores/tiny/iron");
public static final Tags.IOptionalNamedTag<Item> ORES_TINY_LAPIS = tag("ores/tiny/lapis");
public static final Tags.IOptionalNamedTag<Item> ORES_TINY_REDSTONE = tag("ores/tiny/redstone");

public static final Tags.IOptionalNamedTag<Item> DUSTS_ALUMINIUM = tag("dusts/aluminium"); // UK also FR btw (haha)
public static final Tags.IOptionalNamedTag<Item> DUSTS_ALUMINUM = tag("dusts/aluminum"); // US // because we can found both…
public static final Tags.IOptionalNamedTag<Item> DUSTS_AMETHYST = tag("dusts/amethyst");
Expand Down Expand Up @@ -65,8 +91,7 @@ public static class Items {
public static final Tags.IOptionalNamedTag<Item> INGOTS_TIN = tag("ingots/tin");
public static final Tags.IOptionalNamedTag<Item> INGOTS_URANIUM = tag("ingots/uranium");

// TEMP
public static final Tags.IOptionalNamedTag<Item> RAWS = tag("raws");
public static final Tags.IOptionalNamedTag<Item> RAWS = tag("raws"); // To change or not in 1.17
public static final Tags.IOptionalNamedTag<Item> RAWS_ALUMINIUM = tag("raws/aluminium"); // UK also FR btw (haha)
public static final Tags.IOptionalNamedTag<Item> RAWS_ALUMINUM = tag("raws/aluminum"); // US // because we can found both…
public static final Tags.IOptionalNamedTag<Item> RAWS_LEAD = tag("raws/lead");
Expand All @@ -75,15 +100,6 @@ public static class Items {
public static final Tags.IOptionalNamedTag<Item> RAWS_TIN = tag("raws/tin");
public static final Tags.IOptionalNamedTag<Item> RAWS_URANIUM = tag("raws/uranium");

public static final Tags.IOptionalNamedTag<Item> ORES = tag("ores");
public static final Tags.IOptionalNamedTag<Item> ORES_ALUMINIUM = tag("ores/aluminium"); // UK also FR btw (haha)
public static final Tags.IOptionalNamedTag<Item> ORES_ALUMINUM = tag("ores/aluminum"); // US // because we can found both…
public static final Tags.IOptionalNamedTag<Item> ORES_LEAD = tag("ores/lead");
public static final Tags.IOptionalNamedTag<Item> ORES_NICKEL = tag("ores/nickel");
public static final Tags.IOptionalNamedTag<Item> ORES_SILVER = tag("ores/silver");
public static final Tags.IOptionalNamedTag<Item> ORES_TIN = tag("ores/tin");
public static final Tags.IOptionalNamedTag<Item> ORES_URANIUM = tag("ores/uranium");

private static Tags.IOptionalNamedTag<Item> tag(String name) {
return ItemTags.createOptional(new ResourceLocation("forge", name));
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/META-INF/mods.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
modLoader="javafml"
loaderVersion="[36,)"
license="LGPL-3.0"
issueTrackerURL="https://github.com/AlasDiablo/JANOEO/issues"
license = "LGPL-3.0"
issueTrackerURL = "https://github.com/Janoeo/Foundation/issues"

[[mods]]
modId="janoeo_foundation"
Expand Down

0 comments on commit 967d002

Please sign in to comment.