mirror of
https://github.com/FabricMC/fabric.git
synced 2025-03-28 07:40:02 -04:00
Datagen Additions (#1911)
* Datagen additions Now separated from #1889 * add throws javadoc tag, and test for copying a block tag that contains a block without an item form to an item tag * linkplain Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com> * Add javadoc note about copy filtering Co-authored-by: Juuxel <6596629+Juuxel@users.noreply.github.com>
This commit is contained in:
parent
b71809b4fb
commit
252fd7d614
5 changed files with 44 additions and 6 deletions
fabric-data-generation-api-v1
src
main
java/net/fabricmc/fabric/api/datagen/v1/provider
resources
testmod/java/net/fabricmc/fabric/test/datagen
|
@ -140,13 +140,15 @@ public abstract class FabricTagProvider<T> extends AbstractTagProvider<T> {
|
|||
*
|
||||
* <p>The {@link ItemTagProvider} tag provider must be constructed with an associated {@link BlockTagProvider} tag provider to use this method.
|
||||
*
|
||||
* <p>Any block ids that do not exist in the item registry will be filtered out automatically.
|
||||
*
|
||||
* @param blockTag The block tag to copy from.
|
||||
* @param itemTag The item tag to copy to.
|
||||
*/
|
||||
public void copy(Tag.Identified<Block> blockTag, Tag.Identified<Item> itemTag) {
|
||||
Tag.Builder blockTagBuilder = Objects.requireNonNull(this.blockTagBuilderProvider, "Pass Block tag provider via constructor to use copy").apply(blockTag);
|
||||
Tag.Builder itemTagBuilder = this.getTagBuilder(itemTag);
|
||||
blockTagBuilder.streamEntries().forEach(itemTagBuilder::add);
|
||||
blockTagBuilder.streamEntries().filter((entry) -> entry.getEntry().canAdd(this.registry::containsId, (id) -> true)).forEach(itemTagBuilder::add);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -233,6 +235,17 @@ public abstract class FabricTagProvider<T> extends AbstractTagProvider<T> {
|
|||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add another tag to this tag.
|
||||
*
|
||||
* @return the {@link FabricTagBuilder} instance
|
||||
* @throws ClassCastException if tag is not {@linkplain Tag.Identified identified}
|
||||
*/
|
||||
public FabricTagBuilder<T> addTag(Tag<T> tag) {
|
||||
parent.addTag((Tag.Identified<T>) tag);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add another optional tag to this tag.
|
||||
*
|
||||
|
|
|
@ -7,6 +7,8 @@ accessible field net/minecraft/data/server/AbstractTagProvider$ObjectBuilder
|
|||
accessible field net/minecraft/data/server/AbstractTagProvider$ObjectBuilder registry Lnet/minecraft/util/registry/Registry;
|
||||
accessible field net/minecraft/data/server/AbstractTagProvider$ObjectBuilder source Ljava/lang/String;
|
||||
|
||||
accessible field net/minecraft/data/server/AbstractTagProvider tagBuilders Ljava/util/Map;
|
||||
|
||||
accessible field net/minecraft/data/server/BlockLootTableGenerator lootTables Ljava/util/Map;
|
||||
|
||||
transitive-accessible method net/minecraft/data/family/BlockFamilies register (Lnet/minecraft/block/Block;)Lnet/minecraft/data/family/BlockFamily$Builder;
|
||||
|
@ -15,6 +17,12 @@ transitive-accessible method net/minecraft/data/client/ItemModelGenerator
|
|||
transitive-accessible method net/minecraft/data/client/ItemModelGenerator register (Lnet/minecraft/item/Item;Lnet/minecraft/item/Item;Lnet/minecraft/data/client/model/Model;)V
|
||||
transitive-accessible method net/minecraft/data/client/ItemModelGenerator register (Lnet/minecraft/item/Item;Ljava/lang/String;Lnet/minecraft/data/client/model/Model;)V
|
||||
|
||||
transitive-accessible field net/minecraft/data/client/model/BlockStateModelGenerator blockStateCollector Ljava/util/function/Consumer;
|
||||
transitive-accessible field net/minecraft/data/client/model/BlockStateModelGenerator modelCollector Ljava/util/function/BiConsumer;
|
||||
|
||||
transitive-accessible method net/minecraft/data/client/model/TextureKey of (Ljava/lang/String;)Lnet/minecraft/data/client/model/TextureKey;
|
||||
transitive-accessible method net/minecraft/data/client/model/TextureKey of (Ljava/lang/String;Lnet/minecraft/data/client/model/TextureKey;)Lnet/minecraft/data/client/model/TextureKey;
|
||||
|
||||
transitive-accessible method net/minecraft/data/server/RecipesProvider saveRecipe (Lnet/minecraft/data/DataCache;Lcom/google/gson/JsonObject;Ljava/nio/file/Path;)V
|
||||
transitive-accessible method net/minecraft/data/server/RecipesProvider saveRecipeAdvancement (Lnet/minecraft/data/DataCache;Lcom/google/gson/JsonObject;Ljava/nio/file/Path;)V
|
||||
transitive-accessible method net/minecraft/data/server/RecipesProvider generate (Ljava/util/function/Consumer;)V
|
||||
|
|
|
@ -33,18 +33,24 @@ public class DataGeneratorTestContent implements ModInitializer {
|
|||
public static final String MOD_ID = "fabric-data-gen-api-v1-testmod";
|
||||
|
||||
public static Block SIMPLE_BLOCK;
|
||||
public static Block BLOCK_WITHOUT_ITEM;
|
||||
|
||||
@Override
|
||||
public void onInitialize() {
|
||||
SIMPLE_BLOCK = createBlock("simple_block");
|
||||
SIMPLE_BLOCK = createBlock("simple_block", true);
|
||||
BLOCK_WITHOUT_ITEM = createBlock("block_without_item", false);
|
||||
}
|
||||
|
||||
private static Block createBlock(String name) {
|
||||
private static Block createBlock(String name, boolean hasItem) {
|
||||
Identifier identifier = new Identifier(MOD_ID, name);
|
||||
Block block = Registry.register(Registry.BLOCK, identifier, new Block(AbstractBlock.Settings.of(Material.STONE)));
|
||||
Registry.register(Registry.ITEM, identifier, new BlockItem(block, new Item.Settings().group(ItemGroup.MISC)));
|
||||
|
||||
Objects.requireNonNull(block.asItem().getGroup());
|
||||
if (hasItem) {
|
||||
Registry.register(Registry.ITEM, identifier, new BlockItem(block, new Item.Settings().group(ItemGroup.MISC)));
|
||||
|
||||
Objects.requireNonNull(block.asItem().getGroup());
|
||||
}
|
||||
|
||||
return block;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
package net.fabricmc.fabric.test.datagen;
|
||||
|
||||
import static net.fabricmc.fabric.test.datagen.DataGeneratorTestContent.BLOCK_WITHOUT_ITEM;
|
||||
import static net.fabricmc.fabric.test.datagen.DataGeneratorTestContent.MOD_ID;
|
||||
import static net.fabricmc.fabric.test.datagen.DataGeneratorTestContent.SIMPLE_BLOCK;
|
||||
|
||||
|
@ -80,6 +81,7 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint {
|
|||
@Override
|
||||
public void generateBlockStateModels(BlockStateModelGenerator blockStateModelGenerator) {
|
||||
blockStateModelGenerator.registerSimpleCubeAll(SIMPLE_BLOCK);
|
||||
blockStateModelGenerator.registerSimpleCubeAll(BLOCK_WITHOUT_ITEM);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -96,7 +98,7 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint {
|
|||
@Override
|
||||
protected void generateTags() {
|
||||
getOrCreateTagBuilder(BlockTags.FIRE).add(SIMPLE_BLOCK);
|
||||
getOrCreateTagBuilder(BlockTags.ANVIL).setReplace(true).add(SIMPLE_BLOCK);
|
||||
getOrCreateTagBuilder(BlockTags.ANVIL).setReplace(true).add(SIMPLE_BLOCK, BLOCK_WITHOUT_ITEM);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -139,6 +141,7 @@ public class DataGeneratorTestEntrypoint implements DataGeneratorEntrypoint {
|
|||
@Override
|
||||
protected void generateBlockLootTables() {
|
||||
addDrop(SIMPLE_BLOCK);
|
||||
addDrop(BLOCK_WITHOUT_ITEM, drops(SIMPLE_BLOCK));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@ accessible field net/minecraft/data/server/AbstractTagProvider$ObjectBuilder
|
|||
accessible field net/minecraft/data/server/AbstractTagProvider$ObjectBuilder registry Lnet/minecraft/util/registry/Registry;
|
||||
accessible field net/minecraft/data/server/AbstractTagProvider$ObjectBuilder source Ljava/lang/String;
|
||||
|
||||
accessible field net/minecraft/data/server/AbstractTagProvider tagBuilders Ljava/util/Map;
|
||||
|
||||
accessible field net/minecraft/data/server/BlockLootTableGenerator lootTables Ljava/util/Map;
|
||||
|
||||
transitive-accessible method net/minecraft/data/family/BlockFamilies register (Lnet/minecraft/block/Block;)Lnet/minecraft/data/family/BlockFamily$Builder;
|
||||
|
@ -14,3 +16,9 @@ transitive-accessible method net/minecraft/data/family/BlockFamilies register
|
|||
transitive-accessible method net/minecraft/data/client/ItemModelGenerator register (Lnet/minecraft/item/Item;Lnet/minecraft/data/client/model/Model;)V
|
||||
transitive-accessible method net/minecraft/data/client/ItemModelGenerator register (Lnet/minecraft/item/Item;Lnet/minecraft/item/Item;Lnet/minecraft/data/client/model/Model;)V
|
||||
transitive-accessible method net/minecraft/data/client/ItemModelGenerator register (Lnet/minecraft/item/Item;Ljava/lang/String;Lnet/minecraft/data/client/model/Model;)V
|
||||
|
||||
transitive-accessible field net/minecraft/data/client/model/BlockStateModelGenerator blockStateCollector Ljava/util/function/Consumer;
|
||||
transitive-accessible field net/minecraft/data/client/model/BlockStateModelGenerator modelCollector Ljava/util/function/BiConsumer;
|
||||
|
||||
transitive-accessible method net/minecraft/data/client/model/TextureKey of (Ljava/lang/String;)Lnet/minecraft/data/client/model/TextureKey;
|
||||
transitive-accessible method net/minecraft/data/client/model/TextureKey of (Ljava/lang/String;Lnet/minecraft/data/client/model/TextureKey;)Lnet/minecraft/data/client/model/TextureKey;
|
||||
|
|
Loading…
Add table
Reference in a new issue