mirror of
https://github.com/Creators-of-Create/Create.git
synced 2024-11-13 14:04:20 +01:00
added datagen for ItemTags to AllBlocks and AllItems
This commit is contained in:
parent
1da43f8ffc
commit
46d54a597c
@ -155,7 +155,7 @@ public enum AllBlocks {
|
|||||||
ROPE_PULLEY(new PulleyBlock()),
|
ROPE_PULLEY(new PulleyBlock()),
|
||||||
ROPE(new PulleyBlock.RopeBlock()),
|
ROPE(new PulleyBlock.RopeBlock()),
|
||||||
PULLEY_MAGNET(new PulleyBlock.MagnetBlock()),
|
PULLEY_MAGNET(new PulleyBlock.MagnetBlock()),
|
||||||
CART_ASSEMBLER(new TaggedBlock<>(new CartAssemblerBlock()).withVanillaTags(ITaggable.TagType.BLOCK, "rails")),
|
CART_ASSEMBLER(new TaggedBlock(new CartAssemblerBlock()).withVanillaTags(ITaggable.TagType.BLOCK, "rails")),
|
||||||
MINECART_ANCHOR(new MinecartAnchorBlock()),
|
MINECART_ANCHOR(new MinecartAnchorBlock()),
|
||||||
TRANSLATION_CHASSIS(new LinearChassisBlock()),
|
TRANSLATION_CHASSIS(new LinearChassisBlock()),
|
||||||
TRANSLATION_CHASSIS_SECONDARY(new LinearChassisBlock()),
|
TRANSLATION_CHASSIS_SECONDARY(new LinearChassisBlock()),
|
||||||
@ -205,10 +205,10 @@ public enum AllBlocks {
|
|||||||
SYMMETRY_CROSSPLANE(new CrossPlaneSymmetryBlock()),
|
SYMMETRY_CROSSPLANE(new CrossPlaneSymmetryBlock()),
|
||||||
SYMMETRY_TRIPLEPLANE(new TriplePlaneSymmetryBlock()),
|
SYMMETRY_TRIPLEPLANE(new TriplePlaneSymmetryBlock()),
|
||||||
WINDOW_IN_A_BLOCK(new WindowInABlockBlock()),
|
WINDOW_IN_A_BLOCK(new WindowInABlockBlock()),
|
||||||
COCOA_LOG(new TaggedBlock<>(new CocoaLogBlock()).withVanillaTags(ITaggable.TagType.BLOCK, "jungle_logs")),
|
COCOA_LOG(new TaggedBlock(new CocoaLogBlock()).withVanillaTags(ITaggable.TagType.BLOCK, "jungle_logs")),
|
||||||
|
|
||||||
__PALETTES__(),
|
__PALETTES__(),
|
||||||
TILED_GLASS(new TaggedBlock<>(new GlassBlock(Properties.from(Blocks.GLASS))).withVanillaTags(ITaggable.TagType.BLOCK, "impermeable").withForgeTags("glass")),
|
TILED_GLASS(new TaggedBlock(new GlassBlock(Properties.from(Blocks.GLASS))).withVanillaTags(ITaggable.TagType.BLOCK, "impermeable").withForgeTags("glass")),
|
||||||
FRAMED_GLASS(new CTGlassBlock(AllCTs.FRAMED_GLASS, false)),
|
FRAMED_GLASS(new CTGlassBlock(AllCTs.FRAMED_GLASS, false)),
|
||||||
HORIZONTAL_FRAMED_GLASS(new HorizontalCTGlassBlock(AllCTs.HORIZONTAL_FRAMED_GLASS, AllCTs.FRAMED_GLASS, false)),
|
HORIZONTAL_FRAMED_GLASS(new HorizontalCTGlassBlock(AllCTs.HORIZONTAL_FRAMED_GLASS, AllCTs.FRAMED_GLASS, false)),
|
||||||
VERTICAL_FRAMED_GLASS(new VerticalCTGlassBlock(AllCTs.VERTICAL_FRAMED_GLASS, false)),
|
VERTICAL_FRAMED_GLASS(new VerticalCTGlassBlock(AllCTs.VERTICAL_FRAMED_GLASS, false)),
|
||||||
@ -221,7 +221,7 @@ public enum AllBlocks {
|
|||||||
ACACIA_GLASS(new CTWindowBlock(AllCTs.ACACIA_GLASS, false)),
|
ACACIA_GLASS(new CTWindowBlock(AllCTs.ACACIA_GLASS, false)),
|
||||||
IRON_GLASS(new CTWindowBlock(AllCTs.IRON_GLASS, false)),
|
IRON_GLASS(new CTWindowBlock(AllCTs.IRON_GLASS, false)),
|
||||||
|
|
||||||
TILED_GLASS_PANE(new TaggedBlock<>(new GlassPaneBlock(Properties.from(Blocks.GLASS))).withForgeTags("glass_panes")),
|
TILED_GLASS_PANE(new TaggedBlock(new GlassPaneBlock(Properties.from(Blocks.GLASS))).withForgeTags("glass_panes")),
|
||||||
FRAMED_GLASS_PANE(new CTGlassPaneBlock(FRAMED_GLASS.get())),
|
FRAMED_GLASS_PANE(new CTGlassPaneBlock(FRAMED_GLASS.get())),
|
||||||
HORIZONTAL_FRAMED_GLASS_PANE(new CTGlassPaneBlock(HORIZONTAL_FRAMED_GLASS.get())),
|
HORIZONTAL_FRAMED_GLASS_PANE(new CTGlassPaneBlock(HORIZONTAL_FRAMED_GLASS.get())),
|
||||||
VERTICAL_FRAMED_GLASS_PANE(new CTGlassPaneBlock(VERTICAL_FRAMED_GLASS.get())),
|
VERTICAL_FRAMED_GLASS_PANE(new CTGlassPaneBlock(VERTICAL_FRAMED_GLASS.get())),
|
||||||
@ -241,8 +241,8 @@ public enum AllBlocks {
|
|||||||
ANDESITE_LAYERS(
|
ANDESITE_LAYERS(
|
||||||
new LayeredCTBlock(Properties.from(Blocks.ANDESITE), AllCTs.ANDESITE_LAYERS, AllCTs.POLISHED_ANDESITE)),
|
new LayeredCTBlock(Properties.from(Blocks.ANDESITE), AllCTs.ANDESITE_LAYERS, AllCTs.POLISHED_ANDESITE)),
|
||||||
|
|
||||||
GABBRO(new TaggedBlock<>(new Block(Properties.from(Blocks.GRANITE))).withForgeTags("stone"), ComesWith.STAIRS, ComesWith.SLAB, ComesWith.WALL),
|
GABBRO(new TaggedBlock(new Block(Properties.from(Blocks.GRANITE))).withForgeTags("stone"), ComesWith.STAIRS, ComesWith.SLAB, ComesWith.WALL),
|
||||||
POLISHED_GABBRO(new TaggedBlock<>(new Block(Properties.from(GABBRO.get()))).withForgeTags("stone")),
|
POLISHED_GABBRO(new TaggedBlock(new Block(Properties.from(GABBRO.get()))).withForgeTags("stone")),
|
||||||
GABBRO_BRICKS(new Block(Properties.from(GABBRO.get())), ComesWith.STAIRS, ComesWith.WALL),
|
GABBRO_BRICKS(new Block(Properties.from(GABBRO.get())), ComesWith.STAIRS, ComesWith.WALL),
|
||||||
PAVED_GABBRO_BRICKS(new Block(Properties.from(GABBRO.get())), ComesWith.SLAB),
|
PAVED_GABBRO_BRICKS(new Block(Properties.from(GABBRO.get())), ComesWith.SLAB),
|
||||||
INDENTED_GABBRO(new Block(Properties.from(GABBRO.get())), ComesWith.SLAB),
|
INDENTED_GABBRO(new Block(Properties.from(GABBRO.get())), ComesWith.SLAB),
|
||||||
@ -250,31 +250,31 @@ public enum AllBlocks {
|
|||||||
MOSSY_GABBRO_BRICKS(new Block(Properties.from(GABBRO.get()))),
|
MOSSY_GABBRO_BRICKS(new Block(Properties.from(GABBRO.get()))),
|
||||||
GABBRO_LAYERS(new LayeredCTBlock(Properties.from(GABBRO.get()), AllCTs.GABBRO_LAYERS, AllCTs.POLISHED_GABBRO)),
|
GABBRO_LAYERS(new LayeredCTBlock(Properties.from(GABBRO.get()), AllCTs.GABBRO_LAYERS, AllCTs.POLISHED_GABBRO)),
|
||||||
|
|
||||||
DOLOMITE(new TaggedBlock<>(new Block(Properties.from(Blocks.QUARTZ_BLOCK))).withForgeTags("stone"), ComesWith.STAIRS, ComesWith.SLAB, ComesWith.WALL),
|
DOLOMITE(new TaggedBlock(new Block(Properties.from(Blocks.QUARTZ_BLOCK))).withForgeTags("stone"), ComesWith.STAIRS, ComesWith.SLAB, ComesWith.WALL),
|
||||||
DOLOMITE_BRICKS(new Block(Properties.from(DOLOMITE.get()))),
|
DOLOMITE_BRICKS(new Block(Properties.from(DOLOMITE.get()))),
|
||||||
POLISHED_DOLOMITE(new TaggedBlock<>(new Block(Properties.from(DOLOMITE.get()))).withForgeTags("stone")),
|
POLISHED_DOLOMITE(new TaggedBlock(new Block(Properties.from(DOLOMITE.get()))).withForgeTags("stone")),
|
||||||
DOLOMITE_PILLAR(new RotatedPillarBlock(Properties.from(DOLOMITE.get()))),
|
DOLOMITE_PILLAR(new RotatedPillarBlock(Properties.from(DOLOMITE.get()))),
|
||||||
DOLOMITE_LAYERS(
|
DOLOMITE_LAYERS(
|
||||||
new LayeredCTBlock(Properties.from(DOLOMITE.get()), AllCTs.DOLOMITE_LAYERS, AllCTs.POLISHED_DOLOMITE)),
|
new LayeredCTBlock(Properties.from(DOLOMITE.get()), AllCTs.DOLOMITE_LAYERS, AllCTs.POLISHED_DOLOMITE)),
|
||||||
|
|
||||||
LIMESAND(new FallingBlock(Properties.from(Blocks.SAND))),
|
LIMESAND(new FallingBlock(Properties.from(Blocks.SAND))),
|
||||||
LIMESTONE(new TaggedBlock<>(new Block(Properties.from(Blocks.SANDSTONE))).withForgeTags("stone"), ComesWith.STAIRS, ComesWith.SLAB, ComesWith.WALL),
|
LIMESTONE(new TaggedBlock(new Block(Properties.from(Blocks.SANDSTONE))).withForgeTags("stone"), ComesWith.STAIRS, ComesWith.SLAB, ComesWith.WALL),
|
||||||
LIMESTONE_BRICKS(new Block(Properties.from(LIMESTONE.get())), ComesWith.STAIRS, ComesWith.SLAB, ComesWith.WALL),
|
LIMESTONE_BRICKS(new Block(Properties.from(LIMESTONE.get())), ComesWith.STAIRS, ComesWith.SLAB, ComesWith.WALL),
|
||||||
POLISHED_LIMESTONE(new TaggedBlock<>(new Block(Properties.from(LIMESTONE.get()))).withForgeTags("stone"), ComesWith.SLAB),
|
POLISHED_LIMESTONE(new TaggedBlock(new Block(Properties.from(LIMESTONE.get()))).withForgeTags("stone"), ComesWith.SLAB),
|
||||||
LIMESTONE_PILLAR(new RotatedPillarBlock(Properties.from(LIMESTONE.get()))),
|
LIMESTONE_PILLAR(new RotatedPillarBlock(Properties.from(LIMESTONE.get()))),
|
||||||
LIMESTONE_LAYERS(
|
LIMESTONE_LAYERS(
|
||||||
new LayeredCTBlock(Properties.from(LIMESTONE.get()), AllCTs.LIMESTONE_LAYERS, AllCTs.POLISHED_LIMESTONE)),
|
new LayeredCTBlock(Properties.from(LIMESTONE.get()), AllCTs.LIMESTONE_LAYERS, AllCTs.POLISHED_LIMESTONE)),
|
||||||
WEATHERED_LIMESTONE(new TaggedBlock<>(new Block(Properties.from(Blocks.ANDESITE))).withForgeTags("stone"), ComesWith.STAIRS, ComesWith.SLAB, ComesWith.WALL),
|
WEATHERED_LIMESTONE(new TaggedBlock(new Block(Properties.from(Blocks.ANDESITE))).withForgeTags("stone"), ComesWith.STAIRS, ComesWith.SLAB, ComesWith.WALL),
|
||||||
WEATHERED_LIMESTONE_BRICKS(new Block(Properties.from(WEATHERED_LIMESTONE.get())), ComesWith.STAIRS, ComesWith.SLAB,
|
WEATHERED_LIMESTONE_BRICKS(new Block(Properties.from(WEATHERED_LIMESTONE.get())), ComesWith.STAIRS, ComesWith.SLAB,
|
||||||
ComesWith.WALL),
|
ComesWith.WALL),
|
||||||
POLISHED_WEATHERED_LIMESTONE(new TaggedBlock<>(new Block(Properties.from(WEATHERED_LIMESTONE.get()))).withForgeTags("stone"), ComesWith.SLAB),
|
POLISHED_WEATHERED_LIMESTONE(new TaggedBlock(new Block(Properties.from(WEATHERED_LIMESTONE.get()))).withForgeTags("stone"), ComesWith.SLAB),
|
||||||
WEATHERED_LIMESTONE_PILLAR(new RotatedPillarBlock(Properties.from(WEATHERED_LIMESTONE.get()))),
|
WEATHERED_LIMESTONE_PILLAR(new RotatedPillarBlock(Properties.from(WEATHERED_LIMESTONE.get()))),
|
||||||
WEATHERED_LIMESTONE_LAYERS(new LayeredCTBlock(Properties.from(WEATHERED_LIMESTONE.get()),
|
WEATHERED_LIMESTONE_LAYERS(new LayeredCTBlock(Properties.from(WEATHERED_LIMESTONE.get()),
|
||||||
AllCTs.WEATHERED_LIMESTONE_LAYERS, AllCTs.POLISHED_WEATHERED_LIMESTONE)),
|
AllCTs.WEATHERED_LIMESTONE_LAYERS, AllCTs.POLISHED_WEATHERED_LIMESTONE)),
|
||||||
|
|
||||||
NATURAL_SCORIA(new ScoriaBlock()),
|
NATURAL_SCORIA(new ScoriaBlock()),
|
||||||
SCORIA(new TaggedBlock<>(new Block(Properties.from(Blocks.ANDESITE))).withForgeTags("stone"), ComesWith.STAIRS, ComesWith.SLAB, ComesWith.WALL),
|
SCORIA(new TaggedBlock(new Block(Properties.from(Blocks.ANDESITE))).withForgeTags("stone"), ComesWith.STAIRS, ComesWith.SLAB, ComesWith.WALL),
|
||||||
POLISHED_SCORIA(new TaggedBlock<>(new Block(Properties.from(SCORIA.get()))).withForgeTags("stone"), ComesWith.SLAB),
|
POLISHED_SCORIA(new TaggedBlock(new Block(Properties.from(SCORIA.get()))).withForgeTags("stone"), ComesWith.SLAB),
|
||||||
SCORIA_BRICKS(new Block(Properties.from(SCORIA.get()))),
|
SCORIA_BRICKS(new Block(Properties.from(SCORIA.get()))),
|
||||||
SCORIA_LAYERS(new LayeredCTBlock(Properties.from(SCORIA.get()), AllCTs.SCORIA_LAYERS, AllCTs.POLISHED_SCORIA)),
|
SCORIA_LAYERS(new LayeredCTBlock(Properties.from(SCORIA.get()), AllCTs.SCORIA_LAYERS, AllCTs.POLISHED_SCORIA)),
|
||||||
SCORIA_PILLAR(new RotatedPillarBlock(Properties.from(SCORIA.get()))),
|
SCORIA_PILLAR(new RotatedPillarBlock(Properties.from(SCORIA.get()))),
|
||||||
@ -285,37 +285,37 @@ public enum AllBlocks {
|
|||||||
DARK_SCORIA_BRICKS(new Block(Properties.from(DARK_SCORIA.get())), ComesWith.STAIRS, ComesWith.SLAB, ComesWith.WALL),
|
DARK_SCORIA_BRICKS(new Block(Properties.from(DARK_SCORIA.get())), ComesWith.STAIRS, ComesWith.SLAB, ComesWith.WALL),
|
||||||
|
|
||||||
__MATERIALS__(),
|
__MATERIALS__(),
|
||||||
COPPER_ORE(new TaggedBlock<>(new OxidizingBlock(Properties.from(Blocks.IRON_ORE), 1)).withForgeTags("ores/copper")),
|
COPPER_ORE(new TaggedBlock(new OxidizingBlock(Properties.from(Blocks.IRON_ORE), 1)).withForgeTags("ores/copper")),
|
||||||
ZINC_ORE(new TaggedBlock<>(new Block(Properties.from(Blocks.GOLD_ORE).harvestLevel(2).harvestTool(ToolType.PICKAXE))).withForgeTags("ores/zinc")),
|
ZINC_ORE(new TaggedBlock(new Block(Properties.from(Blocks.GOLD_ORE).harvestLevel(2).harvestTool(ToolType.PICKAXE))).withForgeTags("ores/zinc")),
|
||||||
COPPER_BLOCK(new TaggedBlock<>(new OxidizingBlock(Properties.from(Blocks.IRON_BLOCK), 1 / 32f)).withForgeTags("storage_blocks/copper")),
|
COPPER_BLOCK(new TaggedBlock(new OxidizingBlock(Properties.from(Blocks.IRON_BLOCK), 1 / 32f)).withForgeTags("storage_blocks/copper")),
|
||||||
COPPER_SHINGLES(new OxidizingBlock(Properties.from(Blocks.IRON_BLOCK), 1 / 32f)),
|
COPPER_SHINGLES(new OxidizingBlock(Properties.from(Blocks.IRON_BLOCK), 1 / 32f)),
|
||||||
ZINC_BLOCK(new TaggedBlock<>(new Block(Properties.from(Blocks.IRON_BLOCK))).withForgeTags("storage_blocks/zinc")),
|
ZINC_BLOCK(new TaggedBlock(new Block(Properties.from(Blocks.IRON_BLOCK))).withForgeTags("storage_blocks/zinc")),
|
||||||
BRASS_BLOCK(new TaggedBlock<>(new Block(Properties.from(Blocks.IRON_BLOCK))).withForgeTags("storage_blocks/brass")),
|
BRASS_BLOCK(new TaggedBlock(new Block(Properties.from(Blocks.IRON_BLOCK))).withForgeTags("storage_blocks/brass")),
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private enum ComesWith {
|
private enum ComesWith {
|
||||||
WALL, FENCE, FENCE_GATE, SLAB, STAIRS;
|
WALL, FENCE, FENCE_GATE, SLAB, STAIRS
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class CategoryTracker {
|
private static class CategoryTracker {
|
||||||
static IModule currentModule;
|
static IModule currentModule;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TaggedBlock<? extends Block> taggedBlock;
|
private TaggedBlock taggedBlock;
|
||||||
public TaggedBlock<?>[] alsoRegistered;
|
public TaggedBlock[] alsoRegistered;
|
||||||
public IModule module;
|
public IModule module;
|
||||||
|
|
||||||
AllBlocks() {
|
AllBlocks() {
|
||||||
CategoryTracker.currentModule = () -> Lang.asId(name()).replaceAll("__", "");
|
CategoryTracker.currentModule = () -> Lang.asId(name()).replaceAll("__", "");
|
||||||
taggedBlock = new TaggedBlock<>(null);
|
taggedBlock = new TaggedBlock(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
AllBlocks(Block block, ComesWith... comesWith) {
|
AllBlocks(Block block, ComesWith... comesWith) {
|
||||||
this(new TaggedBlock<>(block), comesWith);
|
this(new TaggedBlock(block), comesWith);
|
||||||
}
|
}
|
||||||
|
|
||||||
AllBlocks(TaggedBlock<? extends Block> taggedBlockIn, ComesWith... comesWith){
|
AllBlocks(TaggedBlock taggedBlockIn, ComesWith... comesWith){
|
||||||
this.taggedBlock = taggedBlockIn;
|
this.taggedBlock = taggedBlockIn;
|
||||||
this.taggedBlock.getBlock().setRegistryName(Create.ID, Lang.asId(name()));
|
this.taggedBlock.getBlock().setRegistryName(Create.ID, Lang.asId(name()));
|
||||||
this.module = CategoryTracker.currentModule;
|
this.module = CategoryTracker.currentModule;
|
||||||
@ -334,7 +334,7 @@ public enum AllBlocks {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
registry.register(block.get());
|
registry.register(block.get());
|
||||||
for (TaggedBlock<?> extra : block.alsoRegistered)
|
for (TaggedBlock extra : block.alsoRegistered)
|
||||||
registry.register(extra.block);
|
registry.register(extra.block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -348,13 +348,13 @@ public enum AllBlocks {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
registerAsItem(registry, def);
|
registerAsItem(registry, def);
|
||||||
for (TaggedBlock<?> extra : block.alsoRegistered)
|
for (TaggedBlock extra : block.alsoRegistered)
|
||||||
registerAsItem(registry, extra.block);
|
registerAsItem(registry, extra.block);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void registerAsItem(IForgeRegistry<Item> registry, Block blockIn) {
|
private static void registerAsItem(IForgeRegistry<Item> registry, Block blockIn) {
|
||||||
BlockItem blockItem = null;
|
BlockItem blockItem;
|
||||||
Item.Properties standardItemProperties = AllItems.includeInItemGroup();
|
Item.Properties standardItemProperties = AllItems.includeInItemGroup();
|
||||||
|
|
||||||
if (blockIn instanceof IHaveCustomBlockItem)
|
if (blockIn instanceof IHaveCustomBlockItem)
|
||||||
@ -381,25 +381,25 @@ public enum AllBlocks {
|
|||||||
return state.getBlock() == get();
|
return state.getBlock() == get();
|
||||||
}
|
}
|
||||||
|
|
||||||
private TaggedBlock<? extends Block> makeRelatedBlock(Block block, ComesWith feature) {
|
private TaggedBlock makeRelatedBlock(Block block, ComesWith feature) {
|
||||||
Properties properties = Properties.from(block);
|
Properties properties = Properties.from(block);
|
||||||
TaggedBlock<? extends Block> featured = null;
|
TaggedBlock featured;
|
||||||
|
|
||||||
switch (feature) {
|
switch (feature) {
|
||||||
case FENCE:
|
case FENCE:
|
||||||
featured = new TaggedBlock<>(new FenceBlock(properties)).withVanillaTags(ITaggable.TagType.BLOCK, "fences");
|
featured = new TaggedBlock(new FenceBlock(properties)).withVanillaTags(ITaggable.TagType.BLOCK, "fences");
|
||||||
break;
|
break;
|
||||||
case SLAB:
|
case SLAB:
|
||||||
featured = new TaggedBlock<>(new SlabBlock(properties)).withVanillaTags(ITaggable.TagType.BLOCK, "slabs");
|
featured = new TaggedBlock(new SlabBlock(properties)).withVanillaTags(ITaggable.TagType.BLOCK, "slabs");
|
||||||
break;
|
break;
|
||||||
case STAIRS:
|
case STAIRS:
|
||||||
featured = new TaggedBlock<>(new ProperStairsBlock(block)).withVanillaTags(ITaggable.TagType.BLOCK, "stairs");
|
featured = new TaggedBlock(new ProperStairsBlock(block)).withVanillaTags(ITaggable.TagType.BLOCK, "stairs");
|
||||||
break;
|
break;
|
||||||
case WALL:
|
case WALL:
|
||||||
featured = new TaggedBlock<>(new WallBlock(properties)).withVanillaTags(ITaggable.TagType.BLOCK, "walls");
|
featured = new TaggedBlock(new WallBlock(properties)).withVanillaTags(ITaggable.TagType.BLOCK, "walls");
|
||||||
break;
|
break;
|
||||||
case FENCE_GATE:
|
case FENCE_GATE:
|
||||||
featured = new TaggedBlock<>(new FenceGateBlock(properties));
|
featured = new TaggedBlock(new FenceGateBlock(properties));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
@ -419,18 +419,18 @@ public enum AllBlocks {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class TaggedBlock<T extends Block> implements ITaggable<TaggedBlock<T>> {
|
public static class TaggedBlock implements ITaggable<TaggedBlock> {
|
||||||
//A wrapper around Block that allows for tags to be included. needed for datagen
|
//A wrapper around Block that allows for tags to be included. needed for datagen
|
||||||
|
|
||||||
private Set<ResourceLocation> tagSetBlock = new HashSet<>();
|
private Set<ResourceLocation> tagSetBlock = new HashSet<>();
|
||||||
private Set<ResourceLocation> tagSetBlockItem = new HashSet<>();
|
private Set<ResourceLocation> tagSetBlockItem = new HashSet<>();
|
||||||
private T block;
|
private Block block;
|
||||||
|
|
||||||
public TaggedBlock(T blockIn){
|
public TaggedBlock(Block blockIn){
|
||||||
block = blockIn;
|
block = blockIn;
|
||||||
}
|
}
|
||||||
|
|
||||||
public T getBlock() {
|
public Block getBlock() {
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -5,11 +5,14 @@ import static com.simibubi.create.foundation.item.AllToolTypes.HOE;
|
|||||||
import static com.simibubi.create.foundation.item.AllToolTypes.PICKAXE;
|
import static com.simibubi.create.foundation.item.AllToolTypes.PICKAXE;
|
||||||
import static com.simibubi.create.foundation.item.AllToolTypes.SHOVEL;
|
import static com.simibubi.create.foundation.item.AllToolTypes.SHOVEL;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
import com.simibubi.create.foundation.item.IHaveCustomItemModel;
|
import com.simibubi.create.foundation.item.IHaveCustomItemModel;
|
||||||
import com.simibubi.create.foundation.item.IItemWithColorHandler;
|
import com.simibubi.create.foundation.item.IItemWithColorHandler;
|
||||||
import com.simibubi.create.foundation.utility.Lang;
|
import com.simibubi.create.foundation.utility.Lang;
|
||||||
|
import com.simibubi.create.foundation.utility.data.ITaggable;
|
||||||
import com.simibubi.create.modules.IModule;
|
import com.simibubi.create.modules.IModule;
|
||||||
import com.simibubi.create.modules.contraptions.GogglesItem;
|
import com.simibubi.create.modules.contraptions.GogglesItem;
|
||||||
import com.simibubi.create.modules.contraptions.WrenchItem;
|
import com.simibubi.create.modules.contraptions.WrenchItem;
|
||||||
@ -39,6 +42,7 @@ import net.minecraft.item.Item;
|
|||||||
import net.minecraft.item.Item.Properties;
|
import net.minecraft.item.Item.Properties;
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.item.Rarity;
|
import net.minecraft.item.Rarity;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
import net.minecraft.item.SwordItem;
|
import net.minecraft.item.SwordItem;
|
||||||
import net.minecraftforge.api.distmarker.Dist;
|
import net.minecraftforge.api.distmarker.Dist;
|
||||||
import net.minecraftforge.api.distmarker.OnlyIn;
|
import net.minecraftforge.api.distmarker.OnlyIn;
|
||||||
@ -51,14 +55,14 @@ import net.minecraftforge.registries.IForgeRegistry;
|
|||||||
public enum AllItems {
|
public enum AllItems {
|
||||||
|
|
||||||
__MATERIALS__(module()),
|
__MATERIALS__(module()),
|
||||||
COPPER_NUGGET,
|
COPPER_NUGGET(new TaggedItem().withForgeTags("nuggets/copper")),
|
||||||
ZINC_NUGGET,
|
ZINC_NUGGET(new TaggedItem().withForgeTags("nuggets/zinc")),
|
||||||
BRASS_NUGGET,
|
BRASS_NUGGET(new TaggedItem().withForgeTags("nuggets/brass")),
|
||||||
IRON_SHEET,
|
IRON_SHEET(new TaggedItem().withForgeTags("plates/iron")),
|
||||||
GOLD_SHEET,
|
GOLD_SHEET(new TaggedItem().withForgeTags("plates/gold")),
|
||||||
COPPER_SHEET,
|
COPPER_SHEET(new TaggedItem().withForgeTags("plates/copper")),
|
||||||
BRASS_SHEET,
|
BRASS_SHEET(new TaggedItem().withForgeTags("plates/brass")),
|
||||||
LAPIS_PLATE,
|
LAPIS_PLATE(new TaggedItem().withForgeTags("plates/lapis")),
|
||||||
|
|
||||||
CRUSHED_IRON,
|
CRUSHED_IRON,
|
||||||
CRUSHED_GOLD,
|
CRUSHED_GOLD,
|
||||||
@ -67,9 +71,9 @@ public enum AllItems {
|
|||||||
CRUSHED_BRASS,
|
CRUSHED_BRASS,
|
||||||
|
|
||||||
ANDESITE_ALLOY,
|
ANDESITE_ALLOY,
|
||||||
COPPER_INGOT,
|
COPPER_INGOT(new TaggedItem().withForgeTags("ingots/copper")),
|
||||||
ZINC_INGOT,
|
ZINC_INGOT(new TaggedItem().withForgeTags("ingots/zinc")),
|
||||||
BRASS_INGOT,
|
BRASS_INGOT(new TaggedItem().withForgeTags("ingots/brass")),
|
||||||
|
|
||||||
SAND_PAPER(SandPaperItem::new),
|
SAND_PAPER(SandPaperItem::new),
|
||||||
RED_SAND_PAPER(SandPaperItem::new),
|
RED_SAND_PAPER(SandPaperItem::new),
|
||||||
@ -135,28 +139,32 @@ public enum AllItems {
|
|||||||
|
|
||||||
public IModule module;
|
public IModule module;
|
||||||
private Function<Properties, Properties> specialProperties;
|
private Function<Properties, Properties> specialProperties;
|
||||||
private Function<Properties, Item> itemSupplier;
|
private TaggedItem taggedItem;
|
||||||
private Item item;
|
private Item item;
|
||||||
|
|
||||||
private AllItems(int moduleMarker) {
|
AllItems(int moduleMarker) {
|
||||||
CategoryTracker.currentModule = new IModule() {
|
CategoryTracker.currentModule = () -> Lang.asId(name()).replaceAll("__", "");
|
||||||
@Override
|
taggedItem = new TaggedItem(null);
|
||||||
public String getModuleName() {
|
|
||||||
return Lang.asId(name()).replaceAll("__", "");
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private AllItems() {
|
AllItems(Function<Properties, Item> itemSupplier) {
|
||||||
this(Item::new);
|
this(new TaggedItem(itemSupplier), Function.identity());
|
||||||
}
|
}
|
||||||
|
|
||||||
private AllItems(Function<Properties, Item> itemSupplier) {
|
AllItems(Function<Properties, Item> itemSupplier, Function<Properties, Properties> specialProperties) {
|
||||||
this(itemSupplier, Function.identity());
|
this(new TaggedItem(itemSupplier), specialProperties);
|
||||||
}
|
}
|
||||||
|
|
||||||
private AllItems(Function<Properties, Item> itemSupplier, Function<Properties, Properties> specialProperties) {
|
AllItems() {
|
||||||
this.itemSupplier = itemSupplier;
|
this(new TaggedItem(Item::new));
|
||||||
|
}
|
||||||
|
|
||||||
|
AllItems(TaggedItem taggedItemIn) {
|
||||||
|
this(taggedItemIn, Function.identity());
|
||||||
|
}
|
||||||
|
|
||||||
|
AllItems(TaggedItem taggedItemIn, Function<Properties, Properties> specialProperties) {
|
||||||
|
this.taggedItem = taggedItemIn;
|
||||||
this.module = CategoryTracker.currentModule;
|
this.module = CategoryTracker.currentModule;
|
||||||
this.specialProperties = specialProperties;
|
this.specialProperties = specialProperties;
|
||||||
}
|
}
|
||||||
@ -185,11 +193,11 @@ public enum AllItems {
|
|||||||
IForgeRegistry<Item> registry = event.getRegistry();
|
IForgeRegistry<Item> registry = event.getRegistry();
|
||||||
|
|
||||||
for (AllItems entry : values()) {
|
for (AllItems entry : values()) {
|
||||||
if (entry.itemSupplier == null)
|
if (entry.taggedItem == null || entry.taggedItem.getItemSupplier() == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
entry.item = entry.itemSupplier.apply(new Properties());
|
entry.item = entry.taggedItem.getItemSupplier().apply(new Properties());
|
||||||
entry.item = entry.itemSupplier.apply(entry.specialProperties.apply(defaultProperties(entry)));
|
entry.item = entry.taggedItem.getItemSupplier().apply(entry.specialProperties.apply(defaultProperties(entry)));
|
||||||
entry.item.setRegistryName(Create.ID, Lang.asId(entry.name()));
|
entry.item.setRegistryName(Create.ID, Lang.asId(entry.name()));
|
||||||
registry.register(entry.item);
|
registry.register(entry.item);
|
||||||
}
|
}
|
||||||
@ -201,6 +209,10 @@ public enum AllItems {
|
|||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public TaggedItem getTaggable() {
|
||||||
|
return taggedItem;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean typeOf(ItemStack stack) {
|
public boolean typeOf(ItemStack stack) {
|
||||||
return stack.getItem() == item;
|
return stack.getItem() == item;
|
||||||
}
|
}
|
||||||
@ -209,6 +221,29 @@ public enum AllItems {
|
|||||||
return new ItemStack(item);
|
return new ItemStack(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class TaggedItem implements ITaggable<TaggedItem> {
|
||||||
|
|
||||||
|
private Set<ResourceLocation> tagSetItem = new HashSet<>();
|
||||||
|
private Function<Properties, Item> itemSupplier;
|
||||||
|
|
||||||
|
public TaggedItem(){
|
||||||
|
this(Item::new);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TaggedItem(Function<Properties, Item> itemSupplierIn){
|
||||||
|
this.itemSupplier = itemSupplierIn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Function<Properties, Item> getItemSupplier() {
|
||||||
|
return itemSupplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Set<ResourceLocation> getTagSet(TagType type) {
|
||||||
|
return tagSetItem;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Client
|
// Client
|
||||||
|
|
||||||
@OnlyIn(Dist.CLIENT)
|
@OnlyIn(Dist.CLIENT)
|
||||||
|
@ -46,7 +46,7 @@ public final class CreateItemGroup extends ItemGroup {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
def.asItem().fillItemGroup(this, items);
|
def.asItem().fillItemGroup(this, items);
|
||||||
for (AllBlocks.TaggedBlock<?> alsoRegistered : block.alsoRegistered)
|
for (AllBlocks.TaggedBlock alsoRegistered : block.alsoRegistered)
|
||||||
alsoRegistered.getBlock().asItem().fillItemGroup(this, items);
|
alsoRegistered.getBlock().asItem().fillItemGroup(this, items);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,67 @@
|
|||||||
|
package com.simibubi.create.foundation.utility.data;
|
||||||
|
|
||||||
|
import com.simibubi.create.AllBlocks;
|
||||||
|
import com.simibubi.create.AllItems;
|
||||||
|
import net.minecraft.block.Block;
|
||||||
|
import net.minecraft.data.BlockTagsProvider;
|
||||||
|
import net.minecraft.data.DataGenerator;
|
||||||
|
import net.minecraft.data.ItemTagsProvider;
|
||||||
|
import net.minecraft.item.Item;
|
||||||
|
import net.minecraft.tags.BlockTags;
|
||||||
|
import net.minecraft.tags.ItemTags;
|
||||||
|
import net.minecraft.tags.Tag;
|
||||||
|
import net.minecraft.util.ResourceLocation;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class AllItemsTagProvider extends ItemTagsProvider {
|
||||||
|
|
||||||
|
static Map<ResourceLocation, ItemTags.Wrapper> createdTags;
|
||||||
|
|
||||||
|
protected AllItemsTagProvider(DataGenerator generatorIn) {
|
||||||
|
super(generatorIn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void registerTags() {
|
||||||
|
createdTags = new HashMap<>();
|
||||||
|
|
||||||
|
//first create all tags for AllBlocks as ItemBlocks
|
||||||
|
for (AllBlocks entry :
|
||||||
|
AllBlocks.values()) {
|
||||||
|
entry.getTaggable().getTagSet(ITaggable.TagType.ITEM).forEach(resLoc -> {
|
||||||
|
if (resLoc.getNamespace().equals("forge") && resLoc.getPath().contains("/"))
|
||||||
|
builder(new ResourceLocation(resLoc.getNamespace(), resLoc.getPath().split("/")[0])).add(new Tag<>(resLoc));
|
||||||
|
builder(resLoc).add(entry.get().asItem());
|
||||||
|
});
|
||||||
|
if (entry.alsoRegistered == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
Arrays.stream(entry.alsoRegistered).forEach(
|
||||||
|
taggedBlock -> taggedBlock.getTagSet(ITaggable.TagType.ITEM).forEach(
|
||||||
|
resLoc -> builder(resLoc).add(taggedBlock.getBlock().asItem())));
|
||||||
|
}
|
||||||
|
//now do the same for AllItems
|
||||||
|
for (AllItems entry :
|
||||||
|
AllItems.values()){
|
||||||
|
entry.getTaggable().getTagSet(ITaggable.TagType.ITEM).forEach(resLoc -> {
|
||||||
|
if (resLoc.getNamespace().equals("forge") && resLoc.getPath().contains("/"))
|
||||||
|
builder(new ResourceLocation(resLoc.getNamespace(), resLoc.getPath().split("/")[0])).add(new Tag<>(resLoc));
|
||||||
|
builder(resLoc).add(entry.get().asItem());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private Tag.Builder<Item> builder(ResourceLocation resLoc) {
|
||||||
|
return this.getBuilder(createdTags.computeIfAbsent(resLoc, ItemTags.Wrapper::new));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getName() {
|
||||||
|
return "Create Item Tags";
|
||||||
|
}
|
||||||
|
}
|
@ -13,6 +13,7 @@ public class Generator {
|
|||||||
DataGenerator gen = event.getGenerator();
|
DataGenerator gen = event.getGenerator();
|
||||||
//gen.addProvider(AllSoundEvents.CUCKOO_PIG);
|
//gen.addProvider(AllSoundEvents.CUCKOO_PIG);
|
||||||
gen.addProvider(new AllBlocksTagProvider(gen));
|
gen.addProvider(new AllBlocksTagProvider(gen));
|
||||||
|
gen.addProvider(new AllItemsTagProvider(gen));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,16 +4,14 @@ import net.minecraft.util.ResourceLocation;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
public interface ITaggable<T> {
|
public interface ITaggable<T extends ITaggable<T>> {
|
||||||
|
|
||||||
enum TagType {
|
enum TagType {
|
||||||
BLOCK, ITEM;
|
BLOCK, ITEM
|
||||||
}
|
}
|
||||||
|
|
||||||
default T withTags(ResourceLocation... tagsIn) {
|
default T withTags(ResourceLocation... tagsIn) {
|
||||||
Collections.addAll(getTagSet(TagType.BLOCK), tagsIn);
|
return this.withTags(TagType.BLOCK, tagsIn).withTags(TagType.ITEM, tagsIn);
|
||||||
Collections.addAll(getTagSet(TagType.ITEM), tagsIn);
|
|
||||||
return (T) this;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
default T withTags(TagType type, ResourceLocation... tagsIn) {
|
default T withTags(TagType type, ResourceLocation... tagsIn) {
|
||||||
|
Loading…
Reference in New Issue
Block a user