diff --git a/build.gradle b/build.gradle index 171d7fc89..873f2bb7a 100644 --- a/build.gradle +++ b/build.gradle @@ -26,6 +26,7 @@ minecraft { client { workingDirectory project.file('run') property 'forge.logging.console.level', 'info' + property 'fml.earlyprogresswindow', 'false' mods { create { source sourceSets.main @@ -45,8 +46,9 @@ minecraft { data { workingDirectory project.file('run') - property 'forge.logging.markers', 'SCAN,REGISTRIES,REGISTRYDUMP' + property 'forge.logging.markers', 'REGISTRIES,REGISTRYDUMP' property 'forge.logging.console.level', 'debug' + property 'fml.earlyprogresswindow', 'false' args '--mod', 'create', '--all', '--output', file('src/generated/resources/') mods { create { diff --git a/src/main/java/com/simibubi/create/AllBlocks.java b/src/main/java/com/simibubi/create/AllBlocks.java index 0ccf8401c..e3a6c32d8 100644 --- a/src/main/java/com/simibubi/create/AllBlocks.java +++ b/src/main/java/com/simibubi/create/AllBlocks.java @@ -5,6 +5,7 @@ import com.simibubi.create.foundation.block.IHaveCustomBlockItem; import com.simibubi.create.foundation.block.IHaveNoBlockItem; import com.simibubi.create.foundation.block.ProperStairsBlock; import com.simibubi.create.foundation.utility.Lang; +import com.simibubi.create.foundation.utility.data.ITaggable; import com.simibubi.create.foundation.world.OxidizingBlock; import com.simibubi.create.modules.IModule; import com.simibubi.create.modules.contraptions.CasingBlock; @@ -99,12 +100,16 @@ import net.minecraft.client.Minecraft; import net.minecraft.client.renderer.color.BlockColors; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; +import net.minecraft.util.ResourceLocation; import net.minecraftforge.api.distmarker.Dist; import net.minecraftforge.api.distmarker.OnlyIn; import net.minecraftforge.common.ToolType; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.registries.IForgeRegistry; +import java.util.HashSet; +import java.util.Set; + public enum AllBlocks { __SCHEMATICS__(), @@ -150,7 +155,7 @@ public enum AllBlocks { ROPE_PULLEY(new PulleyBlock()), ROPE(new PulleyBlock.RopeBlock()), PULLEY_MAGNET(new PulleyBlock.MagnetBlock()), - CART_ASSEMBLER(new CartAssemblerBlock()), + CART_ASSEMBLER(new TaggedBlock<>(new CartAssemblerBlock()).withVanillaTags(ITaggable.TagType.BLOCK, "rails")), MINECART_ANCHOR(new MinecartAnchorBlock()), TRANSLATION_CHASSIS(new LinearChassisBlock()), TRANSLATION_CHASSIS_SECONDARY(new LinearChassisBlock()), @@ -200,10 +205,10 @@ public enum AllBlocks { SYMMETRY_CROSSPLANE(new CrossPlaneSymmetryBlock()), SYMMETRY_TRIPLEPLANE(new TriplePlaneSymmetryBlock()), WINDOW_IN_A_BLOCK(new WindowInABlockBlock()), - COCOA_LOG(new CocoaLogBlock()), + COCOA_LOG(new TaggedBlock<>(new CocoaLogBlock()).withVanillaTags(ITaggable.TagType.BLOCK, "jungle_logs")), __PALETTES__(), - TILED_GLASS(new GlassBlock(Properties.from(Blocks.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)), HORIZONTAL_FRAMED_GLASS(new HorizontalCTGlassBlock(AllCTs.HORIZONTAL_FRAMED_GLASS, AllCTs.FRAMED_GLASS, false)), VERTICAL_FRAMED_GLASS(new VerticalCTGlassBlock(AllCTs.VERTICAL_FRAMED_GLASS, false)), @@ -216,17 +221,17 @@ public enum AllBlocks { ACACIA_GLASS(new CTWindowBlock(AllCTs.ACACIA_GLASS, false)), IRON_GLASS(new CTWindowBlock(AllCTs.IRON_GLASS, false)), - TILED_GLASS_PANE(new GlassPaneBlock(Properties.from(Blocks.GLASS))), - FRAMED_GLASS_PANE(new CTGlassPaneBlock(FRAMED_GLASS.block)), - HORIZONTAL_FRAMED_GLASS_PANE(new CTGlassPaneBlock(HORIZONTAL_FRAMED_GLASS.block)), - VERTICAL_FRAMED_GLASS_PANE(new CTGlassPaneBlock(VERTICAL_FRAMED_GLASS.block)), - OAK_GLASS_PANE(new CTGlassPaneBlock(OAK_GLASS.block)), - SPRUCE_GLASS_PANE(new CTGlassPaneBlock(SPRUCE_GLASS.block)), - BIRCH_GLASS_PANE(new CTGlassPaneBlock(BIRCH_GLASS.block)), - JUNGLE_GLASS_PANE(new CTGlassPaneBlock(JUNGLE_GLASS.block)), - DARK_OAK_GLASS_PANE(new CTGlassPaneBlock(DARK_OAK_GLASS.block)), - ACACIA_GLASS_PANE(new CTGlassPaneBlock(ACACIA_GLASS.block)), - IRON_GLASS_PANE(new CTGlassPaneBlock(IRON_GLASS.block)), + TILED_GLASS_PANE(new TaggedBlock<>(new GlassPaneBlock(Properties.from(Blocks.GLASS))).withForgeTags("glass_panes")), + FRAMED_GLASS_PANE(new CTGlassPaneBlock(FRAMED_GLASS.get())), + HORIZONTAL_FRAMED_GLASS_PANE(new CTGlassPaneBlock(HORIZONTAL_FRAMED_GLASS.get())), + VERTICAL_FRAMED_GLASS_PANE(new CTGlassPaneBlock(VERTICAL_FRAMED_GLASS.get())), + OAK_GLASS_PANE(new CTGlassPaneBlock(OAK_GLASS.get())), + SPRUCE_GLASS_PANE(new CTGlassPaneBlock(SPRUCE_GLASS.get())), + BIRCH_GLASS_PANE(new CTGlassPaneBlock(BIRCH_GLASS.get())), + JUNGLE_GLASS_PANE(new CTGlassPaneBlock(JUNGLE_GLASS.get())), + DARK_OAK_GLASS_PANE(new CTGlassPaneBlock(DARK_OAK_GLASS.get())), + ACACIA_GLASS_PANE(new CTGlassPaneBlock(ACACIA_GLASS.get())), + IRON_GLASS_PANE(new CTGlassPaneBlock(IRON_GLASS.get())), GRANITE_BRICKS(new Block(Properties.from(Blocks.GRANITE))), GRANITE_LAYERS(new LayeredCTBlock(Properties.from(Blocks.GRANITE), AllCTs.GRANITE_LAYERS, AllCTs.POLISHED_GRANITE)), @@ -236,56 +241,56 @@ public enum AllBlocks { ANDESITE_LAYERS( new LayeredCTBlock(Properties.from(Blocks.ANDESITE), AllCTs.ANDESITE_LAYERS, AllCTs.POLISHED_ANDESITE)), - GABBRO(new Block(Properties.from(Blocks.GRANITE)), ComesWith.STAIRS, ComesWith.SLAB, ComesWith.WALL), - POLISHED_GABBRO(new Block(Properties.from(GABBRO.block))), - GABBRO_BRICKS(new Block(Properties.from(GABBRO.block)), ComesWith.STAIRS, ComesWith.WALL), - PAVED_GABBRO_BRICKS(new Block(Properties.from(GABBRO.block)), ComesWith.SLAB), - INDENTED_GABBRO(new Block(Properties.from(GABBRO.block)), ComesWith.SLAB), - SLIGHTLY_MOSSY_GABBRO_BRICKS(new Block(Properties.from(GABBRO.block))), - MOSSY_GABBRO_BRICKS(new Block(Properties.from(GABBRO.block))), - GABBRO_LAYERS(new LayeredCTBlock(Properties.from(GABBRO.block), AllCTs.GABBRO_LAYERS, AllCTs.POLISHED_GABBRO)), + 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")), + GABBRO_BRICKS(new Block(Properties.from(GABBRO.get())), ComesWith.STAIRS, ComesWith.WALL), + PAVED_GABBRO_BRICKS(new Block(Properties.from(GABBRO.get())), ComesWith.SLAB), + INDENTED_GABBRO(new Block(Properties.from(GABBRO.get())), ComesWith.SLAB), + SLIGHTLY_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)), - DOLOMITE(new Block(Properties.from(Blocks.QUARTZ_BLOCK)), ComesWith.STAIRS, ComesWith.SLAB, ComesWith.WALL), - DOLOMITE_BRICKS(new Block(Properties.from(DOLOMITE.block))), - POLISHED_DOLOMITE(new Block(Properties.from(DOLOMITE.block))), - DOLOMITE_PILLAR(new RotatedPillarBlock(Properties.from(DOLOMITE.block))), + 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()))), + POLISHED_DOLOMITE(new TaggedBlock<>(new Block(Properties.from(DOLOMITE.get()))).withForgeTags("stone")), + DOLOMITE_PILLAR(new RotatedPillarBlock(Properties.from(DOLOMITE.get()))), DOLOMITE_LAYERS( - new LayeredCTBlock(Properties.from(DOLOMITE.block), 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))), - LIMESTONE(new Block(Properties.from(Blocks.SANDSTONE)), ComesWith.STAIRS, ComesWith.SLAB, ComesWith.WALL), - LIMESTONE_BRICKS(new Block(Properties.from(LIMESTONE.block)), ComesWith.STAIRS, ComesWith.SLAB, ComesWith.WALL), - POLISHED_LIMESTONE(new Block(Properties.from(LIMESTONE.block)), ComesWith.SLAB), - LIMESTONE_PILLAR(new RotatedPillarBlock(Properties.from(LIMESTONE.block))), + 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), + POLISHED_LIMESTONE(new TaggedBlock<>(new Block(Properties.from(LIMESTONE.get()))).withForgeTags("stone"), ComesWith.SLAB), + LIMESTONE_PILLAR(new RotatedPillarBlock(Properties.from(LIMESTONE.get()))), LIMESTONE_LAYERS( - new LayeredCTBlock(Properties.from(LIMESTONE.block), AllCTs.LIMESTONE_LAYERS, AllCTs.POLISHED_LIMESTONE)), - WEATHERED_LIMESTONE(new Block(Properties.from(Blocks.ANDESITE)), ComesWith.STAIRS, ComesWith.SLAB, ComesWith.WALL), - WEATHERED_LIMESTONE_BRICKS(new Block(Properties.from(WEATHERED_LIMESTONE.block)), ComesWith.STAIRS, ComesWith.SLAB, + 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_BRICKS(new Block(Properties.from(WEATHERED_LIMESTONE.get())), ComesWith.STAIRS, ComesWith.SLAB, ComesWith.WALL), - POLISHED_WEATHERED_LIMESTONE(new Block(Properties.from(WEATHERED_LIMESTONE.block)), ComesWith.SLAB), - WEATHERED_LIMESTONE_PILLAR(new RotatedPillarBlock(Properties.from(WEATHERED_LIMESTONE.block))), - WEATHERED_LIMESTONE_LAYERS(new LayeredCTBlock(Properties.from(WEATHERED_LIMESTONE.block), + 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_LAYERS(new LayeredCTBlock(Properties.from(WEATHERED_LIMESTONE.get()), AllCTs.WEATHERED_LIMESTONE_LAYERS, AllCTs.POLISHED_WEATHERED_LIMESTONE)), NATURAL_SCORIA(new ScoriaBlock()), - SCORIA(new Block(Properties.from(Blocks.ANDESITE)), ComesWith.STAIRS, ComesWith.SLAB, ComesWith.WALL), - POLISHED_SCORIA(new Block(Properties.from(SCORIA.block)), ComesWith.SLAB), - SCORIA_BRICKS(new Block(Properties.from(SCORIA.block))), - SCORIA_LAYERS(new LayeredCTBlock(Properties.from(SCORIA.block), AllCTs.SCORIA_LAYERS, AllCTs.POLISHED_SCORIA)), - SCORIA_PILLAR(new RotatedPillarBlock(Properties.from(SCORIA.block))), + 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), + SCORIA_BRICKS(new Block(Properties.from(SCORIA.get()))), + SCORIA_LAYERS(new LayeredCTBlock(Properties.from(SCORIA.get()), AllCTs.SCORIA_LAYERS, AllCTs.POLISHED_SCORIA)), + SCORIA_PILLAR(new RotatedPillarBlock(Properties.from(SCORIA.get()))), DARK_SCORIA(new Block(Properties.from(Blocks.ANDESITE))), - POLISHED_DARK_SCORIA(new Block(Properties.from(DARK_SCORIA.block))), - DARK_SCORIA_TILES(new Block(Properties.from(DARK_SCORIA.block)), ComesWith.STAIRS, ComesWith.SLAB), - DARK_SCORIA_BRICKS(new Block(Properties.from(DARK_SCORIA.block)), ComesWith.STAIRS, ComesWith.SLAB, ComesWith.WALL), + POLISHED_DARK_SCORIA(new Block(Properties.from(DARK_SCORIA.get()))), + DARK_SCORIA_TILES(new Block(Properties.from(DARK_SCORIA.get())), ComesWith.STAIRS, ComesWith.SLAB), + DARK_SCORIA_BRICKS(new Block(Properties.from(DARK_SCORIA.get())), ComesWith.STAIRS, ComesWith.SLAB, ComesWith.WALL), __MATERIALS__(), - COPPER_ORE(new OxidizingBlock(Properties.from(Blocks.IRON_ORE), 1)), - ZINC_ORE(new Block(Properties.from(Blocks.GOLD_ORE).harvestLevel(2).harvestTool(ToolType.PICKAXE))), - COPPER_BLOCK(new OxidizingBlock(Properties.from(Blocks.IRON_BLOCK), 1 / 32f)), + 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")), + 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)), - ZINC_BLOCK(new Block(Properties.from(Blocks.IRON_BLOCK))), - BRASS_BLOCK(new Block(Properties.from(Blocks.IRON_BLOCK))), + 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")), ; @@ -297,27 +302,28 @@ public enum AllBlocks { static IModule currentModule; } - public Block block; - public Block[] alsoRegistered; + private TaggedBlock taggedBlock; + public TaggedBlock[] alsoRegistered; public IModule module; - private AllBlocks() { - CategoryTracker.currentModule = new IModule() { - @Override - public String getModuleName() { - return Lang.asId(name()).replaceAll("__", ""); - } - }; + AllBlocks() { + CategoryTracker.currentModule = () -> Lang.asId(name()).replaceAll("__", ""); + taggedBlock = new TaggedBlock<>(null); } - private AllBlocks(Block block, ComesWith... comesWith) { - this.block = block; - this.block.setRegistryName(Create.ID, Lang.asId(name())); + AllBlocks(Block block, ComesWith... comesWith) { + this(new TaggedBlock<>(block), comesWith); + } + + AllBlocks(TaggedBlock taggedBlockIn, ComesWith... comesWith){ + this.taggedBlock = taggedBlockIn; + this.taggedBlock.getBlock().setRegistryName(Create.ID, Lang.asId(name())); this.module = CategoryTracker.currentModule; - alsoRegistered = new Block[comesWith.length]; + alsoRegistered = new TaggedBlock[comesWith.length]; for (int i = 0; i < comesWith.length; i++) - alsoRegistered[i] = makeRelatedBlock(block, comesWith[i]); + alsoRegistered[i] = makeRelatedBlock(taggedBlock.getBlock(), comesWith[i]); + } public static void register(RegistryEvent.Register event) { @@ -327,9 +333,9 @@ public enum AllBlocks { if (block.get() == null) continue; - registry.register(block.block); - for (Block extra : block.alsoRegistered) - registry.register(extra); + registry.register(block.get()); + for (TaggedBlock extra : block.alsoRegistered) + registry.register(extra.block); } } @@ -342,8 +348,8 @@ public enum AllBlocks { continue; registerAsItem(registry, def); - for (Block extra : block.alsoRegistered) - registerAsItem(registry, extra); + for (TaggedBlock extra : block.alsoRegistered) + registerAsItem(registry, extra.block); } } @@ -360,52 +366,77 @@ public enum AllBlocks { } public Block get() { - return block; + return taggedBlock.getBlock(); + } + + public ITaggable getTaggable() { + return taggedBlock; } public BlockState getDefault() { - return block.getDefaultState(); + return get().getDefaultState(); } public boolean typeOf(BlockState state) { - return state.getBlock() == block; + return state.getBlock() == get(); } - private Block makeRelatedBlock(Block block, ComesWith feature) { + private TaggedBlock makeRelatedBlock(Block block, ComesWith feature) { Properties properties = Properties.from(block); - Block featured = null; + TaggedBlock featured = null; switch (feature) { case FENCE: - featured = new FenceBlock(properties); + featured = new TaggedBlock<>(new FenceBlock(properties)).withVanillaTags(ITaggable.TagType.BLOCK, "fences"); break; case SLAB: - featured = new SlabBlock(properties); + featured = new TaggedBlock<>(new SlabBlock(properties)).withVanillaTags(ITaggable.TagType.BLOCK, "slabs"); break; case STAIRS: - featured = new ProperStairsBlock(block); + featured = new TaggedBlock<>(new ProperStairsBlock(block)).withVanillaTags(ITaggable.TagType.BLOCK, "stairs"); break; case WALL: - featured = new WallBlock(properties); + featured = new TaggedBlock<>(new WallBlock(properties)).withVanillaTags(ITaggable.TagType.BLOCK, "walls"); break; case FENCE_GATE: - featured = new FenceGateBlock(properties); + featured = new TaggedBlock<>(new FenceGateBlock(properties)); break; default: return null; } - return featured.setRegistryName(Create.ID, block.getRegistryName().getPath() + "_" + Lang.asId(feature.name())); + featured.block.setRegistryName(Create.ID, block.getRegistryName().getPath() + "_" + Lang.asId(feature.name())); + return featured; } @OnlyIn(Dist.CLIENT) public static void registerColorHandlers() { BlockColors blockColors = Minecraft.getInstance().getBlockColors(); for (AllBlocks block : values()) { - if (block.block instanceof IHaveColorHandler) { - blockColors.register(((IHaveColorHandler) block.block).getColorHandler(), block.block); + if (block.get() instanceof IHaveColorHandler) { + blockColors.register(((IHaveColorHandler) block.get()).getColorHandler(), block.get()); } } } + public static class TaggedBlock implements ITaggable> { + //A wrapper around Block that allows for tags to be included. needed for datagen + + private Set tagSetBlock = new HashSet<>(); + private Set tagSetBlockItem = new HashSet<>(); + private T block; + + public TaggedBlock(T blockIn){ + block = blockIn; + } + + public T getBlock() { + return block; + } + + @Override + public Set getTagSet(TagType type) { + return type == TagType.BLOCK ? tagSetBlock : tagSetBlockItem; + } + } } diff --git a/src/main/java/com/simibubi/create/AllSoundEvents.java b/src/main/java/com/simibubi/create/AllSoundEvents.java index 3d0defc41..e778e611e 100644 --- a/src/main/java/com/simibubi/create/AllSoundEvents.java +++ b/src/main/java/com/simibubi/create/AllSoundEvents.java @@ -8,7 +8,6 @@ import com.google.gson.GsonBuilder; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.simibubi.create.foundation.utility.Lang; -import com.simibubi.create.foundation.utility.data.ICanGenerateJson; import net.minecraft.data.DirectoryCache; import net.minecraft.data.IDataProvider; @@ -18,7 +17,7 @@ import net.minecraft.util.SoundEvents; import net.minecraftforge.event.RegistryEvent; import net.minecraftforge.registries.IForgeRegistry; -public enum AllSoundEvents implements ICanGenerateJson { +public enum AllSoundEvents implements IDataProvider { CUCKOO_PIG("creeperclock"), CUCKOO_CREEPER("pigclock"), @@ -59,7 +58,7 @@ public enum AllSoundEvents implements ICanGenerateJson { return event; } - private String getName() { + private String getEventName() { return id; } @@ -68,7 +67,7 @@ public enum AllSoundEvents implements ICanGenerateJson { for (AllSoundEvents entry : values()) { - ResourceLocation rec = new ResourceLocation(Create.ID, entry.getName()); + ResourceLocation rec = new ResourceLocation(Create.ID, entry.getEventName()); SoundEvent sound = new SoundEvent(rec).setRegistryName(rec); registry.register(sound); entry.event = sound; @@ -92,11 +91,11 @@ public enum AllSoundEvents implements ICanGenerateJson { arr.add(s); } else { // own sound - arr.add(Create.ID + ":" + soundEvent.getName()); + arr.add(Create.ID + ":" + soundEvent.getEventName()); } entry.add("sounds", arr); - entry.addProperty("subtitle", Create.ID + ".subtitle." + soundEvent.getName()); - json.add(soundEvent.getName(), entry); + entry.addProperty("subtitle", Create.ID + ".subtitle." + soundEvent.getEventName()); + json.add(soundEvent.getEventName(), entry); } IDataProvider.save(GSON, cache, json, path.resolve("sounds.json")); @@ -105,4 +104,14 @@ public enum AllSoundEvents implements ICanGenerateJson { } } + + @Override + public void act(DirectoryCache cache) throws IOException { + + } + + @Override + public String getName() { + return null; + } } diff --git a/src/main/java/com/simibubi/create/AllTileEntities.java b/src/main/java/com/simibubi/create/AllTileEntities.java index 6ed91379b..5825be755 100644 --- a/src/main/java/com/simibubi/create/AllTileEntities.java +++ b/src/main/java/com/simibubi/create/AllTileEntities.java @@ -183,7 +183,7 @@ public enum AllTileEntities { for (AllTileEntities tileEntity : values()) { Block[] blocks = new Block[tileEntity.blocks.length]; for (int i = 0; i < blocks.length; i++) - blocks[i] = tileEntity.blocks[i].block; + blocks[i] = tileEntity.blocks[i].get(); ResourceLocation resourceLocation = new ResourceLocation(Create.ID, Lang.asId(tileEntity.name())); tileEntity.type = TileEntityType.Builder.create(tileEntity.supplier, blocks).build(null) diff --git a/src/main/java/com/simibubi/create/CreateClient.java b/src/main/java/com/simibubi/create/CreateClient.java index 06882c481..6809029d2 100644 --- a/src/main/java/com/simibubi/create/CreateClient.java +++ b/src/main/java/com/simibubi/create/CreateClient.java @@ -147,7 +147,7 @@ public class CreateClient { @OnlyIn(Dist.CLIENT) protected static ModelResourceLocation getBlockModelLocation(AllBlocks block, String suffix) { - return new ModelResourceLocation(block.block.getRegistryName(), suffix); + return new ModelResourceLocation(block.get().getRegistryName(), suffix); } @OnlyIn(Dist.CLIENT) diff --git a/src/main/java/com/simibubi/create/CreateItemGroup.java b/src/main/java/com/simibubi/create/CreateItemGroup.java index 726ce1675..e882e1647 100644 --- a/src/main/java/com/simibubi/create/CreateItemGroup.java +++ b/src/main/java/com/simibubi/create/CreateItemGroup.java @@ -46,8 +46,8 @@ public final class CreateItemGroup extends ItemGroup { continue; def.asItem().fillItemGroup(this, items); - for (Block alsoRegistered : block.alsoRegistered) - alsoRegistered.asItem().fillItemGroup(this, items); + for (AllBlocks.TaggedBlock alsoRegistered : block.alsoRegistered) + alsoRegistered.getBlock().asItem().fillItemGroup(this, items); } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/data/AllBlocksTagProvider.java b/src/main/java/com/simibubi/create/foundation/utility/data/AllBlocksTagProvider.java new file mode 100644 index 000000000..6d2a3550e --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/utility/data/AllBlocksTagProvider.java @@ -0,0 +1,52 @@ +package com.simibubi.create.foundation.utility.data; + +import com.simibubi.create.AllBlocks; +import net.minecraft.block.Block; +import net.minecraft.data.BlockTagsProvider; +import net.minecraft.data.DataGenerator; +import net.minecraft.tags.BlockTags; +import net.minecraft.tags.Tag; +import net.minecraft.util.ResourceLocation; + +import java.util.Arrays; +import java.util.HashMap; +import java.util.Map; + +public class AllBlocksTagProvider extends BlockTagsProvider { + + static Map createdTags; + + protected AllBlocksTagProvider(DataGenerator generatorIn) { + super(generatorIn); + } + + @Override + protected void registerTags() { + createdTags = new HashMap<>(); + + for (AllBlocks entry : + AllBlocks.values()) { + entry.getTaggable().getTagSet(ITaggable.TagType.BLOCK).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()); + }); + if (entry.alsoRegistered == null) + continue; + + Arrays.stream(entry.alsoRegistered).forEach( + taggedBlock -> taggedBlock.getTagSet(ITaggable.TagType.BLOCK).forEach( + resLoc -> builder(resLoc).add(taggedBlock.getBlock()))); + } + } + + private Tag.Builder builder(ResourceLocation resLoc) { + return this.getBuilder(createdTags.computeIfAbsent(resLoc, BlockTags.Wrapper::new)); + + } + + @Override + public String getName() { + return "Create Block Tags"; + } +} diff --git a/src/main/java/com/simibubi/create/foundation/utility/data/Generator.java b/src/main/java/com/simibubi/create/foundation/utility/data/Generator.java index 7411a85c7..b09467276 100644 --- a/src/main/java/com/simibubi/create/foundation/utility/data/Generator.java +++ b/src/main/java/com/simibubi/create/foundation/utility/data/Generator.java @@ -1,36 +1,18 @@ package com.simibubi.create.foundation.utility.data; -import java.io.IOException; -import java.nio.file.Path; -import java.nio.file.Paths; - -import com.simibubi.create.AllSoundEvents; - -import net.minecraft.data.DirectoryCache; +import net.minecraft.data.DataGenerator; +import net.minecraftforge.eventbus.api.SubscribeEvent; +import net.minecraftforge.fml.common.Mod; +import net.minecraftforge.fml.event.lifecycle.GatherDataEvent; +@Mod.EventBusSubscriber(bus = Mod.EventBusSubscriber.Bus.MOD) public class Generator { - /* - * this can probably be called by some gradle task or so but im not know how, so for now i just added a main below and execute from there when we need to generate jsons - **/ - public static void generateJsonFiles(){ - Path base = Paths.get("src/main/resources"); - DirectoryCache cache; - try { - - cache = new DirectoryCache(base, "cache"); - - for (ICanGenerateJson gen: - new ICanGenerateJson[]{AllSoundEvents.CUCKOO_CREEPER}) { - gen.generate(base, cache); - } - - } catch (IOException e) { - e.printStackTrace(); - } + @SubscribeEvent + public static void gatherData(GatherDataEvent event){ + DataGenerator gen = event.getGenerator(); + //gen.addProvider(AllSoundEvents.CUCKOO_PIG); + gen.addProvider(new AllBlocksTagProvider(gen)); } - public static void main(String[] args) { - generateJsonFiles(); - } } diff --git a/src/main/java/com/simibubi/create/foundation/utility/data/ICanGenerateJson.java b/src/main/java/com/simibubi/create/foundation/utility/data/ICanGenerateJson.java deleted file mode 100644 index 1caf2acb5..000000000 --- a/src/main/java/com/simibubi/create/foundation/utility/data/ICanGenerateJson.java +++ /dev/null @@ -1,11 +0,0 @@ -package com.simibubi.create.foundation.utility.data; - -import java.nio.file.Path; - -import net.minecraft.data.DirectoryCache; - -public interface ICanGenerateJson { - - //path points to the resource1s base folder - void generate(Path path, DirectoryCache cache); -} diff --git a/src/main/java/com/simibubi/create/foundation/utility/data/ITaggable.java b/src/main/java/com/simibubi/create/foundation/utility/data/ITaggable.java new file mode 100644 index 000000000..a99072332 --- /dev/null +++ b/src/main/java/com/simibubi/create/foundation/utility/data/ITaggable.java @@ -0,0 +1,50 @@ +package com.simibubi.create.foundation.utility.data; + +import net.minecraft.util.ResourceLocation; + +import java.util.*; + +public interface ITaggable { + + enum TagType { + BLOCK, ITEM; + } + + default T withTags(ResourceLocation... tagsIn) { + Collections.addAll(getTagSet(TagType.BLOCK), tagsIn); + Collections.addAll(getTagSet(TagType.ITEM), tagsIn); + return (T) this; + } + + default T withTags(TagType type, ResourceLocation... tagsIn) { + Collections.addAll(getTagSet(type), tagsIn); + return (T) this; + } + + default T withTagsInNamespace(String namespace, String... tagsIn) { + return withTags(Arrays.stream(tagsIn).map(s -> new ResourceLocation(namespace, s)).toArray(ResourceLocation[]::new)); + } + + default T withTagsInNamespace(TagType type, String namespace, String... tagsIn) { + return withTags(type, Arrays.stream(tagsIn).map(s -> new ResourceLocation(namespace, s)).toArray(ResourceLocation[]::new)); + } + + default T withCreateTags(String... tagsIn) { + return withTagsInNamespace("create", tagsIn); + } + + default T withForgeTags(String... tagsIn) { + return withTagsInNamespace("forge", tagsIn); + } + + default T withVanillaTags(String... tagsIn) { + return withTagsInNamespace("minecraft", tagsIn); + } + + default T withVanillaTags(TagType type, String... tagsIn) { + return withTagsInNamespace(type, "minecraft", tagsIn); + } + + //take a look at AllBlocks.TaggedBlock for more info + Set getTagSet(TagType type); +} diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/mounted/MountedContraption.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/mounted/MountedContraption.java index 364d01a19..1dd193592 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/mounted/MountedContraption.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/mounted/MountedContraption.java @@ -44,7 +44,7 @@ public class MountedContraption extends Contraption { Axis axis = state.get(RAIL_SHAPE) == RailShape.EAST_WEST ? Axis.X : Axis.Z; contraption.add(pos, Pair.of(new BlockInfo(pos, - AllBlocks.MINECART_ANCHOR.block.getDefaultState().with(BlockStateProperties.HORIZONTAL_AXIS, axis), + AllBlocks.MINECART_ANCHOR.get().getDefaultState().with(BlockStateProperties.HORIZONTAL_AXIS, axis), null), null)); contraption.removeBlocksFromWorld(world, BlockPos.ZERO); contraption.initActors(world); diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonTileEntityRenderer.java index 4e3bde060..092e9eda4 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/contraptions/piston/MechanicalPistonTileEntityRenderer.java @@ -19,7 +19,7 @@ public class MechanicalPistonTileEntityRenderer extends KineticTileEntityRendere @Override protected BlockState getRenderedBlockState(KineticTileEntity te) { - return AllBlocks.SHAFT.block.getDefaultState().with(BlockStateProperties.AXIS, + return AllBlocks.SHAFT.get().getDefaultState().with(BlockStateProperties.AXIS, ((IRotate) te.getBlockState().getBlock()).getRotationAxis(te.getBlockState())); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/crusher/CrushingWheelBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/components/crusher/CrushingWheelBlock.java index 33218cfc3..f4e64a5eb 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/crusher/CrushingWheelBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/crusher/CrushingWheelBlock.java @@ -101,7 +101,7 @@ public class CrushingWheelBlock extends RotatedPillarKineticBlock { world.setBlockState(controllerPos, world.getBlockState(controllerPos).with(VALID, controllerShouldBeValid)); } - ((CrushingWheelControllerBlock) AllBlocks.CRUSHING_WHEEL_CONTROLLER.block) + ((CrushingWheelControllerBlock) AllBlocks.CRUSHING_WHEEL_CONTROLLER.get()) .updateSpeed(world.getBlockState(controllerPos), world, controllerPos); } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntityRenderer.java index 3a1630c42..af0917779 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/components/deployer/DeployerTileEntityRenderer.java @@ -135,7 +135,7 @@ public class DeployerTileEntityRenderer extends SafeTileEntityRenderer protected BlockState getRenderedBlockState(KineticTileEntity te) { BlockState state = te.getBlockState(); - return AllBlocks.SHAFT.block.getDefaultState().with(AXIS, ((IRotate) state.getBlock()).getRotationAxis(state)); + return AllBlocks.SHAFT.get().getDefaultState().with(AXIS, ((IRotate) state.getBlock()).getRotationAxis(state)); } } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltBlock.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltBlock.java index 2073e752e..70c33b0f6 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltBlock.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltBlock.java @@ -281,7 +281,7 @@ public class BeltBlock extends HorizontalKineticBlock return ActionResultType.SUCCESS; world.setBlockState(context.getPos(), state.with(CASING, false), 3); if (!player.isCreative()) - player.inventory.placeItemBackInInventory(world, new ItemStack(AllBlocks.BRASS_CASING.block)); + player.inventory.placeItemBackInInventory(world, new ItemStack(AllBlocks.BRASS_CASING.get())); return ActionResultType.SUCCESS; } @@ -292,7 +292,7 @@ public class BeltBlock extends HorizontalKineticBlock belt.detachKinetics(); belt.attachKinetics(); if (!player.isCreative()) - player.inventory.placeItemBackInInventory(world, new ItemStack(AllBlocks.SHAFT.block)); + player.inventory.placeItemBackInInventory(world, new ItemStack(AllBlocks.SHAFT.get())); return ActionResultType.SUCCESS; } diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltConnectorItem.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltConnectorItem.java index 500d3e069..0ae6ba1ec 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltConnectorItem.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/belt/BeltConnectorItem.java @@ -27,7 +27,7 @@ import net.minecraft.world.World; public class BeltConnectorItem extends BlockItem implements IAddedByOther { public BeltConnectorItem(Properties properties) { - super(AllBlocks.BELT.block, properties); + super(AllBlocks.BELT.get(), properties); } @Override diff --git a/src/main/java/com/simibubi/create/modules/contraptions/relays/gauge/GaugeTileEntityRenderer.java b/src/main/java/com/simibubi/create/modules/contraptions/relays/gauge/GaugeTileEntityRenderer.java index ca504251d..2936928cc 100644 --- a/src/main/java/com/simibubi/create/modules/contraptions/relays/gauge/GaugeTileEntityRenderer.java +++ b/src/main/java/com/simibubi/create/modules/contraptions/relays/gauge/GaugeTileEntityRenderer.java @@ -53,7 +53,7 @@ public class GaugeTileEntityRenderer extends KineticTileEntityRenderer { @Override protected BlockState getRenderedBlockState(KineticTileEntity te) { - return AllBlocks.SHAFT.block.getDefaultState().with(BlockStateProperties.AXIS, + return AllBlocks.SHAFT.get().getDefaultState().with(BlockStateProperties.AXIS, ((IRotate) te.getBlockState().getBlock()).getRotationAxis(te.getBlockState())); } diff --git a/src/main/java/com/simibubi/create/modules/curiosities/symmetry/mirror/CrossPlaneMirror.java b/src/main/java/com/simibubi/create/modules/curiosities/symmetry/mirror/CrossPlaneMirror.java index 2b39d9533..e5218d133 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/symmetry/mirror/CrossPlaneMirror.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/symmetry/mirror/CrossPlaneMirror.java @@ -85,7 +85,7 @@ public class CrossPlaneMirror extends SymmetryMirror { @Override public BlockState getModel() { - return AllBlocks.SYMMETRY_CROSSPLANE.block.getDefaultState().with(CrossPlaneSymmetryBlock.align, + return AllBlocks.SYMMETRY_CROSSPLANE.get().getDefaultState().with(CrossPlaneSymmetryBlock.align, (Align) orientation); } diff --git a/src/main/java/com/simibubi/create/modules/curiosities/symmetry/mirror/PlaneMirror.java b/src/main/java/com/simibubi/create/modules/curiosities/symmetry/mirror/PlaneMirror.java index 485dd9719..dcd670f95 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/symmetry/mirror/PlaneMirror.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/symmetry/mirror/PlaneMirror.java @@ -81,7 +81,7 @@ public class PlaneMirror extends SymmetryMirror { @Override public BlockState getModel() { - return AllBlocks.SYMMETRY_PLANE.block.getDefaultState().with(PlaneSymmetryBlock.align, (Align) orientation); + return AllBlocks.SYMMETRY_PLANE.get().getDefaultState().with(PlaneSymmetryBlock.align, (Align) orientation); } @Override diff --git a/src/main/java/com/simibubi/create/modules/curiosities/symmetry/mirror/TriplePlaneMirror.java b/src/main/java/com/simibubi/create/modules/curiosities/symmetry/mirror/TriplePlaneMirror.java index 13cdf7cc9..c65b8e379 100644 --- a/src/main/java/com/simibubi/create/modules/curiosities/symmetry/mirror/TriplePlaneMirror.java +++ b/src/main/java/com/simibubi/create/modules/curiosities/symmetry/mirror/TriplePlaneMirror.java @@ -43,7 +43,7 @@ public class TriplePlaneMirror extends SymmetryMirror { @Override public BlockState getModel() { - return AllBlocks.SYMMETRY_TRIPLEPLANE.block.getDefaultState(); + return AllBlocks.SYMMETRY_TRIPLEPLANE.get().getDefaultState(); } @Override diff --git a/src/main/java/com/simibubi/create/modules/schematics/block/SchematicannonScreen.java b/src/main/java/com/simibubi/create/modules/schematics/block/SchematicannonScreen.java index 00f38641d..9bfff0b58 100644 --- a/src/main/java/com/simibubi/create/modules/schematics/block/SchematicannonScreen.java +++ b/src/main/java/com/simibubi/create/modules/schematics/block/SchematicannonScreen.java @@ -244,7 +244,7 @@ public class SchematicannonScreen extends AbstractSimiContainerScreen