From dca8293fd0d05c6205b97a544afe79581574d97b Mon Sep 17 00:00:00 2001 From: itsmeow Date: Fri, 27 Nov 2020 04:42:34 -0500 Subject: [PATCH] Add hirschgeist drops and entity loot datagen --- .../loot_tables/entities/hidebehind.json | 3 ++ .../loot_tables/entities/hirschgeist.json | 20 ++++++++++++ .../loot_tables/entities/moth.json | 3 ++ .../loot_tables/entities/wisp.json | 3 ++ .../loot_tables/entities/zotzpyre.json | 3 ++ .../itsmeow/whisperwoods/init/ModDataGen.java | 31 ++++++++++++++----- 6 files changed, 56 insertions(+), 7 deletions(-) create mode 100644 src/generated/resources/data/whisperwoods/loot_tables/entities/hidebehind.json create mode 100644 src/generated/resources/data/whisperwoods/loot_tables/entities/hirschgeist.json create mode 100644 src/generated/resources/data/whisperwoods/loot_tables/entities/moth.json create mode 100644 src/generated/resources/data/whisperwoods/loot_tables/entities/wisp.json create mode 100644 src/generated/resources/data/whisperwoods/loot_tables/entities/zotzpyre.json diff --git a/src/generated/resources/data/whisperwoods/loot_tables/entities/hidebehind.json b/src/generated/resources/data/whisperwoods/loot_tables/entities/hidebehind.json new file mode 100644 index 0000000..601c193 --- /dev/null +++ b/src/generated/resources/data/whisperwoods/loot_tables/entities/hidebehind.json @@ -0,0 +1,3 @@ +{ + "type": "minecraft:entity" +} \ No newline at end of file diff --git a/src/generated/resources/data/whisperwoods/loot_tables/entities/hirschgeist.json b/src/generated/resources/data/whisperwoods/loot_tables/entities/hirschgeist.json new file mode 100644 index 0000000..a9bebb8 --- /dev/null +++ b/src/generated/resources/data/whisperwoods/loot_tables/entities/hirschgeist.json @@ -0,0 +1,20 @@ +{ + "type": "minecraft:entity", + "pools": [ + { + "rolls": 1, + "entries": [ + { + "type": "minecraft:item", + "name": "whisperwoods:hirschgeist_skull" + } + ], + "functions": [ + { + "function": "minecraft:set_count", + "count": 1 + } + ] + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/whisperwoods/loot_tables/entities/moth.json b/src/generated/resources/data/whisperwoods/loot_tables/entities/moth.json new file mode 100644 index 0000000..601c193 --- /dev/null +++ b/src/generated/resources/data/whisperwoods/loot_tables/entities/moth.json @@ -0,0 +1,3 @@ +{ + "type": "minecraft:entity" +} \ No newline at end of file diff --git a/src/generated/resources/data/whisperwoods/loot_tables/entities/wisp.json b/src/generated/resources/data/whisperwoods/loot_tables/entities/wisp.json new file mode 100644 index 0000000..601c193 --- /dev/null +++ b/src/generated/resources/data/whisperwoods/loot_tables/entities/wisp.json @@ -0,0 +1,3 @@ +{ + "type": "minecraft:entity" +} \ No newline at end of file diff --git a/src/generated/resources/data/whisperwoods/loot_tables/entities/zotzpyre.json b/src/generated/resources/data/whisperwoods/loot_tables/entities/zotzpyre.json new file mode 100644 index 0000000..601c193 --- /dev/null +++ b/src/generated/resources/data/whisperwoods/loot_tables/entities/zotzpyre.json @@ -0,0 +1,3 @@ +{ + "type": "minecraft:entity" +} \ No newline at end of file diff --git a/src/main/java/dev/itsmeow/whisperwoods/init/ModDataGen.java b/src/main/java/dev/itsmeow/whisperwoods/init/ModDataGen.java index d992f8e..9621549 100644 --- a/src/main/java/dev/itsmeow/whisperwoods/init/ModDataGen.java +++ b/src/main/java/dev/itsmeow/whisperwoods/init/ModDataGen.java @@ -3,12 +3,14 @@ import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.function.BiConsumer; import java.util.function.Consumer; import java.util.function.Supplier; import java.util.stream.Collectors; import com.google.common.collect.ImmutableList; +import com.google.common.collect.Sets; import com.mojang.datafixers.util.Pair; import dev.itsmeow.whisperwoods.WhisperwoodsMod; @@ -27,19 +29,19 @@ import net.minecraft.data.RecipeProvider; import net.minecraft.data.ShapedRecipeBuilder; import net.minecraft.data.loot.BlockLootTables; +import net.minecraft.data.loot.EntityLootTables; +import net.minecraft.entity.EntityType; import net.minecraft.item.BlockItem; import net.minecraft.item.Item; import net.minecraft.item.Items; -import net.minecraft.loot.LootParameterSet; -import net.minecraft.loot.LootParameterSets; -import net.minecraft.loot.LootTable; +import net.minecraft.loot.*; import net.minecraft.loot.LootTable.Builder; -import net.minecraft.loot.ValidationTracker; +import net.minecraft.loot.functions.SetCount; import net.minecraft.state.properties.BlockStateProperties; -import net.minecraft.tags.ItemTags; import net.minecraft.util.Direction; import net.minecraft.util.Direction.Axis; import net.minecraft.util.ResourceLocation; +import net.minecraft.util.registry.Registry; import net.minecraftforge.client.model.generators.BlockModelBuilder; import net.minecraftforge.client.model.generators.BlockStateProvider; import net.minecraftforge.client.model.generators.ConfiguredModel; @@ -293,18 +295,33 @@ public WWLootTableProvider(DataGenerator generator) { @Override public String getName() { - return WhisperwoodsMod.MODID + "_block_loot_tables"; + return WhisperwoodsMod.MODID + "_loot_tables"; } @Override protected List>>, LootParameterSet>> getTables() { - return ImmutableList.of(Pair.of(WWBlockLootTables::new, LootParameterSets.BLOCK)); + return ImmutableList.of(Pair.of(WWBlockLootTables::new, LootParameterSets.BLOCK), Pair.of(WWEntityLootTables::new, LootParameterSets.ENTITY)); } @Override protected void validate(Map map, ValidationTracker validationtracker) { } + public static class WWEntityLootTables extends EntityLootTables { + @Override + protected void addTables() { + for(EntityType type : getKnownEntities()) { + this.registerLootTable(type, LootTable.builder()); + } + this.registerLootTable(ModEntities.HIRSCHGEIST.entityType, LootTable.builder().addLootPool(LootPool.builder().rolls(ConstantRange.of(1)).addEntry(ItemLootEntry.builder(ModItems.HIRSCHGEIST_SKULL.get())).acceptFunction(SetCount.builder(ConstantRange.of(1))))); + } + + @Override + protected Iterable> getKnownEntities() { + return ModEntities.getEntities().values().stream().map(e -> e.entityType).collect(Collectors.toList()); + } + } + public static class WWBlockLootTables extends BlockLootTables { @Override