diff --git a/src/generated/resources/data/vampirism/loot_tables/chests/vampire_altar.json b/src/generated/resources/data/vampirism/loot_tables/chests/vampire_altar.json new file mode 100644 index 0000000000..1680e8c163 --- /dev/null +++ b/src/generated/resources/data/vampirism/loot_tables/chests/vampire_altar.json @@ -0,0 +1,99 @@ +{ + "type": "minecraft:chest", + "pools": [ + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "name": "vampirism:vampire_fang", + "weight": 20 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "damage": { + "type": "minecraft:uniform", + "max": 0.6, + "min": 0.0 + }, + "function": "minecraft:set_damage" + } + ], + "name": "vampirism:blood_bottle", + "weight": 20 + } + ], + "rolls": { + "type": "minecraft:uniform", + "max": 8.0, + "min": 5.0 + } + }, + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "name": "minecraft:gold_ingot", + "weight": 16 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "damage": 1.0, + "function": "minecraft:set_damage" + } + ], + "name": "minecraft:iron_ingot", + "weight": 22 + } + ], + "rolls": { + "type": "minecraft:uniform", + "max": 18.0, + "min": 10.0 + } + }, + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "name": "vampirism:pure_blood_0", + "weight": 25 + }, + { + "type": "minecraft:item", + "name": "vampirism:pure_blood_1", + "weight": 20 + }, + { + "type": "minecraft:item", + "name": "vampirism:pure_blood_2", + "weight": 15 + }, + { + "type": "minecraft:item", + "name": "vampirism:pure_blood_3", + "weight": 10 + }, + { + "type": "minecraft:item", + "name": "vampirism:pure_blood_4", + "weight": 5 + }, + { + "type": "minecraft:empty", + "weight": 25 + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "vampirism:chests/vampire_altar" +} \ No newline at end of file diff --git a/src/generated/resources/data/vampirism/loot_tables/chests/vampire_hut.json b/src/generated/resources/data/vampirism/loot_tables/chests/vampire_hut.json new file mode 100644 index 0000000000..ede0e04d3f --- /dev/null +++ b/src/generated/resources/data/vampirism/loot_tables/chests/vampire_hut.json @@ -0,0 +1,199 @@ +{ + "type": "minecraft:chest", + "pools": [ + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "name": "vampirism:vampire_fang", + "weight": 20 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "damage": { + "type": "minecraft:uniform", + "max": 0.6, + "min": 0.0 + }, + "function": "minecraft:set_damage" + } + ], + "name": "vampirism:blood_bottle", + "weight": 20 + } + ], + "rolls": { + "type": "minecraft:uniform", + "max": 5.0, + "min": 3.0 + } + }, + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "functions": [ + { + "function": "vampirism:add_book_nbt" + } + ], + "name": "vampirism:vampire_book", + "weight": 70 + } + ], + "rolls": { + "type": "minecraft:uniform", + "max": 1.0, + "min": 0.0 + } + }, + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "functions": [ + { + "faction": "vampirism:vampire", + "function": "vampirism:add_refinement_set" + } + ], + "name": "vampirism:amulet" + }, + { + "type": "minecraft:item", + "functions": [ + { + "faction": "vampirism:vampire", + "function": "vampirism:add_refinement_set" + } + ], + "name": "vampirism:ring" + }, + { + "type": "minecraft:item", + "functions": [ + { + "faction": "vampirism:vampire", + "function": "vampirism:add_refinement_set" + } + ], + "name": "vampirism:obi_belt" + } + ], + "rolls": 2.0 + }, + { + "bonus_rolls": 0.0, + "entries": [ + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "damage": { + "type": "minecraft:uniform", + "max": 0.99, + "min": 0.6 + }, + "function": "minecraft:set_damage" + }, + { + "charge": { + "type": "minecraft:uniform", + "max": 2000.0, + "min": 500.0 + }, + "function": "vampirism:set_item_blood_charge" + } + ], + "name": "vampirism:heart_seeker_enhanced", + "weight": 21 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "damage": { + "type": "minecraft:uniform", + "max": 0.99, + "min": 0.6 + }, + "function": "minecraft:set_damage" + }, + { + "charge": { + "type": "minecraft:uniform", + "max": 2000.0, + "min": 500.0 + }, + "function": "vampirism:set_item_blood_charge" + } + ], + "name": "vampirism:heart_seeker_ultimate", + "weight": 9 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "damage": { + "type": "minecraft:uniform", + "max": 0.99, + "min": 0.6 + }, + "function": "minecraft:set_damage" + }, + { + "charge": { + "type": "minecraft:uniform", + "max": 2000.0, + "min": 500.0 + }, + "function": "vampirism:set_item_blood_charge" + } + ], + "name": "vampirism:heart_striker_enhanced", + "weight": 21 + }, + { + "type": "minecraft:item", + "functions": [ + { + "add": false, + "damage": { + "type": "minecraft:uniform", + "max": 0.99, + "min": 0.6 + }, + "function": "minecraft:set_damage" + }, + { + "charge": { + "type": "minecraft:uniform", + "max": 2000.0, + "min": 500.0 + }, + "function": "vampirism:set_item_blood_charge" + } + ], + "name": "vampirism:heart_striker_ultimate", + "weight": 9 + }, + { + "type": "minecraft:empty", + "weight": 60 + } + ], + "rolls": 1.0 + } + ], + "random_sequence": "vampirism:chests/vampire_hut" +} \ No newline at end of file diff --git a/src/generated/resources/data/vampirism/tags/worldgen/biome/has_faction.json b/src/generated/resources/data/vampirism/tags/worldgen/biome/has_faction.json index 41d3682253..0e545055c2 100644 --- a/src/generated/resources/data/vampirism/tags/worldgen/biome/has_faction.json +++ b/src/generated/resources/data/vampirism/tags/worldgen/biome/has_faction.json @@ -1,5 +1,6 @@ { "values": [ - "#vampirism:has_faction/vampire" + "#vampirism:has_faction/vampire", + "#vampirism:has_faction/hunter" ] } \ No newline at end of file diff --git a/src/generated/resources/data/vampirism/tags/worldgen/biome/has_structure/vampire_altar.json b/src/generated/resources/data/vampirism/tags/worldgen/biome/has_structure/vampire_altar.json new file mode 100644 index 0000000000..c94bde09ba --- /dev/null +++ b/src/generated/resources/data/vampirism/tags/worldgen/biome/has_structure/vampire_altar.json @@ -0,0 +1,10 @@ +{ + "values": [ + "#forge:is_wasteland", + "#forge:is_plateau", + "#forge:is_rare", + "#forge:is_spooky", + "#forge:is_swamp", + "#vampirism:has_faction/vampire" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/vampirism/tags/worldgen/biome/has_structure/vampire_hut.json b/src/generated/resources/data/vampirism/tags/worldgen/biome/has_structure/vampire_hut.json new file mode 100644 index 0000000000..41d3682253 --- /dev/null +++ b/src/generated/resources/data/vampirism/tags/worldgen/biome/has_structure/vampire_hut.json @@ -0,0 +1,5 @@ +{ + "values": [ + "#vampirism:has_faction/vampire" + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/vampirism/vampirism/tasks/hunter_lord1.json b/src/generated/resources/data/vampirism/vampirism/tasks/hunter_lord1.json index ab6279faab..4c25c7bc20 100644 --- a/src/generated/resources/data/vampirism/vampirism/tasks/hunter_lord1.json +++ b/src/generated/resources/data/vampirism/vampirism/tasks/hunter_lord1.json @@ -1,6 +1,15 @@ { "requirements": { "requirements": [ + { + "type": "vampirism:entity_type", + "amount": 50, + "description": { + "translate": "entity_tag.vampirism.vampire" + }, + "entityType": "vampirism:vampire", + "id": "vampirism:vampire" + }, { "type": "vampirism:stat", "amount": 3, @@ -20,15 +29,6 @@ "Count": 32, "id": "minecraft:gold_ingot" } - }, - { - "type": "vampirism:entity_type", - "amount": 50, - "description": { - "translate": "entity_tag.vampirism.vampire" - }, - "entityType": "vampirism:vampire", - "id": "vampirism:vampire" } ] }, diff --git a/src/generated/resources/data/vampirism/vampirism/tasks/hunter_lord2.json b/src/generated/resources/data/vampirism/vampirism/tasks/hunter_lord2.json index e9b23e0ab6..42d2b293d7 100644 --- a/src/generated/resources/data/vampirism/vampirism/tasks/hunter_lord2.json +++ b/src/generated/resources/data/vampirism/vampirism/tasks/hunter_lord2.json @@ -1,6 +1,15 @@ { "requirements": { "requirements": [ + { + "type": "vampirism:entity_type", + "amount": 50, + "description": { + "translate": "entity_tag.vampirism.vampire" + }, + "entityType": "vampirism:vampire", + "id": "vampirism:vampire" + }, { "type": "vampirism:item", "description": { @@ -11,15 +20,6 @@ "Count": 32, "id": "minecraft:gold_ingot" } - }, - { - "type": "vampirism:entity_type", - "amount": 50, - "description": { - "translate": "entity_tag.vampirism.vampire" - }, - "entityType": "vampirism:vampire", - "id": "vampirism:vampire" } ] }, diff --git a/src/generated/resources/data/vampirism/vampirism/tasks/hunter_lord3.json b/src/generated/resources/data/vampirism/vampirism/tasks/hunter_lord3.json index f4439af8c8..7f828116ec 100644 --- a/src/generated/resources/data/vampirism/vampirism/tasks/hunter_lord3.json +++ b/src/generated/resources/data/vampirism/vampirism/tasks/hunter_lord3.json @@ -1,6 +1,15 @@ { "requirements": { "requirements": [ + { + "type": "vampirism:entity_type", + "amount": 50, + "description": { + "translate": "entity_tag.vampirism.vampire" + }, + "entityType": "vampirism:vampire", + "id": "vampirism:vampire" + }, { "type": "vampirism:item", "description": { @@ -11,15 +20,6 @@ "Count": 32, "id": "minecraft:gold_ingot" } - }, - { - "type": "vampirism:entity_type", - "amount": 50, - "description": { - "translate": "entity_tag.vampirism.vampire" - }, - "entityType": "vampirism:vampire", - "id": "vampirism:vampire" } ] }, diff --git a/src/generated/resources/data/vampirism/vampirism/tasks/hunter_lord4.json b/src/generated/resources/data/vampirism/vampirism/tasks/hunter_lord4.json index 5a53a37620..8863c3a74c 100644 --- a/src/generated/resources/data/vampirism/vampirism/tasks/hunter_lord4.json +++ b/src/generated/resources/data/vampirism/vampirism/tasks/hunter_lord4.json @@ -1,6 +1,15 @@ { "requirements": { "requirements": [ + { + "type": "vampirism:entity_type", + "amount": 75, + "description": { + "translate": "entity_tag.vampirism.vampire" + }, + "entityType": "vampirism:vampire", + "id": "vampirism:vampire" + }, { "type": "vampirism:item", "description": { @@ -11,15 +20,6 @@ "Count": 64, "id": "minecraft:gold_ingot" } - }, - { - "type": "vampirism:entity_type", - "amount": 75, - "description": { - "translate": "entity_tag.vampirism.vampire" - }, - "entityType": "vampirism:vampire", - "id": "vampirism:vampire" } ] }, diff --git a/src/generated/resources/data/vampirism/vampirism/tasks/hunter_lord5.json b/src/generated/resources/data/vampirism/vampirism/tasks/hunter_lord5.json index ab295d82ae..266395f110 100644 --- a/src/generated/resources/data/vampirism/vampirism/tasks/hunter_lord5.json +++ b/src/generated/resources/data/vampirism/vampirism/tasks/hunter_lord5.json @@ -1,6 +1,15 @@ { "requirements": { "requirements": [ + { + "type": "vampirism:entity_type", + "amount": 100, + "description": { + "translate": "entity_tag.vampirism.vampire" + }, + "entityType": "vampirism:vampire", + "id": "vampirism:vampire" + }, { "type": "vampirism:stat", "amount": 6, @@ -20,15 +29,6 @@ "Count": 64, "id": "minecraft:gold_ingot" } - }, - { - "type": "vampirism:entity_type", - "amount": 100, - "description": { - "translate": "entity_tag.vampirism.vampire" - }, - "entityType": "vampirism:vampire", - "id": "vampirism:vampire" } ] }, diff --git a/src/generated/resources/data/vampirism/vampirism/tasks/hunter_minion_equipment.json b/src/generated/resources/data/vampirism/vampirism/tasks/hunter_minion_equipment.json index f6bc7a9454..d65776b0c1 100644 --- a/src/generated/resources/data/vampirism/vampirism/tasks/hunter_minion_equipment.json +++ b/src/generated/resources/data/vampirism/vampirism/tasks/hunter_minion_equipment.json @@ -2,13 +2,13 @@ "requirements": { "requirements": [ { - "type": "vampirism:entity", - "amount": 5, + "type": "vampirism:entity_type", + "amount": 4, "description": { - "translate": "entity.vampirism.vampire_baron" + "translate": "entity_tag.vampirism.advanced_vampire" }, - "entityType": "vampirism:vampire_baron", - "id": "vampirism:vampire_baron" + "entityType": "vampirism:advanced_vampire", + "id": "vampirism:advanced_vampire" }, { "type": "vampirism:item", @@ -22,13 +22,13 @@ } }, { - "type": "vampirism:entity_type", - "amount": 4, + "type": "vampirism:entity", + "amount": 5, "description": { - "translate": "entity_tag.vampirism.advanced_vampire" + "translate": "entity.vampirism.vampire_baron" }, - "entityType": "vampirism:advanced_vampire", - "id": "vampirism:advanced_vampire" + "entityType": "vampirism:vampire_baron", + "id": "vampirism:vampire_baron" } ] }, diff --git a/src/generated/resources/data/vampirism/vampirism/tasks/hunter_minion_upgrade_simple.json b/src/generated/resources/data/vampirism/vampirism/tasks/hunter_minion_upgrade_simple.json index f2bc02f691..e40816bfa5 100644 --- a/src/generated/resources/data/vampirism/vampirism/tasks/hunter_minion_upgrade_simple.json +++ b/src/generated/resources/data/vampirism/vampirism/tasks/hunter_minion_upgrade_simple.json @@ -1,6 +1,15 @@ { "requirements": { "requirements": [ + { + "type": "vampirism:entity_type", + "amount": 8, + "description": { + "translate": "entity_tag.vampirism.advanced_vampire" + }, + "entityType": "vampirism:advanced_vampire", + "id": "vampirism:advanced_vampire" + }, { "type": "vampirism:item", "description": { @@ -11,15 +20,6 @@ "Count": 16, "id": "minecraft:gold_block" } - }, - { - "type": "vampirism:entity_type", - "amount": 8, - "description": { - "translate": "entity_tag.vampirism.advanced_vampire" - }, - "entityType": "vampirism:advanced_vampire", - "id": "vampirism:advanced_vampire" } ] }, diff --git a/src/generated/resources/data/vampirism/vampirism/tasks/vampire_minion_binding.json b/src/generated/resources/data/vampirism/vampirism/tasks/vampire_minion_binding.json index 4244320ada..c509ca34a3 100644 --- a/src/generated/resources/data/vampirism/vampirism/tasks/vampire_minion_binding.json +++ b/src/generated/resources/data/vampirism/vampirism/tasks/vampire_minion_binding.json @@ -1,15 +1,6 @@ { "requirements": { "requirements": [ - { - "type": "vampirism:entity", - "amount": 5, - "description": { - "translate": "entity.vampirism.vampire_baron" - }, - "entityType": "vampirism:vampire_baron", - "id": "vampirism:vampire_baron" - }, { "type": "vampirism:entity_type", "amount": 4, @@ -29,6 +20,15 @@ "Count": 32, "id": "minecraft:gold_ingot" } + }, + { + "type": "vampirism:entity", + "amount": 5, + "description": { + "translate": "entity.vampirism.vampire_baron" + }, + "entityType": "vampirism:vampire_baron", + "id": "vampirism:vampire_baron" } ] }, diff --git a/src/generated/resources/data/vampirism/worldgen/structure/vampire_altar.json b/src/generated/resources/data/vampirism/worldgen/structure/vampire_altar.json new file mode 100644 index 0000000000..b7407c1f74 --- /dev/null +++ b/src/generated/resources/data/vampirism/worldgen/structure/vampire_altar.json @@ -0,0 +1,6 @@ +{ + "type": "vampirism:vampire_altar", + "biomes": "#vampirism:has_structure/vampire_altar", + "spawn_overrides": {}, + "step": "surface_structures" +} \ No newline at end of file diff --git a/src/generated/resources/data/vampirism/worldgen/structure/vampire_hut.json b/src/generated/resources/data/vampirism/worldgen/structure/vampire_hut.json new file mode 100644 index 0000000000..14d6ad56d0 --- /dev/null +++ b/src/generated/resources/data/vampirism/worldgen/structure/vampire_hut.json @@ -0,0 +1,6 @@ +{ + "type": "vampirism:vampire_hut", + "biomes": "#vampirism:has_structure/vampire_hut", + "spawn_overrides": {}, + "step": "surface_structures" +} \ No newline at end of file diff --git a/src/generated/resources/data/vampirism/worldgen/structure_set/vampire_altar.json b/src/generated/resources/data/vampirism/worldgen/structure_set/vampire_altar.json new file mode 100644 index 0000000000..5b4a9e0175 --- /dev/null +++ b/src/generated/resources/data/vampirism/worldgen/structure_set/vampire_altar.json @@ -0,0 +1,14 @@ +{ + "placement": { + "type": "minecraft:random_spread", + "salt": 823476514, + "separation": 9, + "spacing": 48 + }, + "structures": [ + { + "structure": "vampirism:vampire_altar", + "weight": 1 + } + ] +} \ No newline at end of file diff --git a/src/generated/resources/data/vampirism/worldgen/structure_set/vampire_hut.json b/src/generated/resources/data/vampirism/worldgen/structure_set/vampire_hut.json new file mode 100644 index 0000000000..3d03eeb1ae --- /dev/null +++ b/src/generated/resources/data/vampirism/worldgen/structure_set/vampire_hut.json @@ -0,0 +1,14 @@ +{ + "placement": { + "type": "minecraft:random_spread", + "salt": 1937195837, + "separation": 8, + "spacing": 32 + }, + "structures": [ + { + "structure": "vampirism:vampire_hut", + "weight": 1 + } + ] +} \ No newline at end of file diff --git a/src/main/java/de/teamlapen/vampirism/core/ModFeatures.java b/src/main/java/de/teamlapen/vampirism/core/ModFeatures.java index 4b1fed3f45..7a5b2eee49 100644 --- a/src/main/java/de/teamlapen/vampirism/core/ModFeatures.java +++ b/src/main/java/de/teamlapen/vampirism/core/ModFeatures.java @@ -8,7 +8,9 @@ import de.teamlapen.vampirism.world.gen.feature.VampireDungeonFeature; import de.teamlapen.vampirism.world.gen.feature.treedecorators.TrunkCursedVineDecorator; import de.teamlapen.vampirism.world.gen.structure.huntercamp.HunterCampStructure; -import net.minecraft.core.*; +import de.teamlapen.vampirism.world.gen.structure.vampirealtar.VampireAltarStructure; +import de.teamlapen.vampirism.world.gen.structure.vampirehut.VampireHutStructure; +import net.minecraft.core.HolderGetter; import net.minecraft.core.registries.Registries; import net.minecraft.data.worldgen.BootstapContext; import net.minecraft.resources.ResourceKey; @@ -34,8 +36,12 @@ public class ModFeatures { public static final DeferredRegister> TREE_DECORATOR = DeferredRegister.create(ForgeRegistries.TREE_DECORATOR_TYPES, REFERENCE.MODID); public static final ResourceKey HUNTER_CAMP = ResourceKey.create(Registries.STRUCTURE, new ResourceLocation(REFERENCE.MODID, "hunter_camp")); + public static final ResourceKey VAMPIRE_HUT = ResourceKey.create(Registries.STRUCTURE, new ResourceLocation(REFERENCE.MODID, "vampire_hut")); + public static final ResourceKey VAMPIRE_ALTAR = ResourceKey.create(Registries.STRUCTURE, new ResourceLocation(REFERENCE.MODID, "vampire_altar")); public static final RegistryObject> HUNTER_CAMP_TYPE = STRUCTURE_TYPES.register("hunter_camp", () -> () -> HunterCampStructure.CODEC); + public static final RegistryObject> VAMPIRE_HUT_TYPE = STRUCTURE_TYPES.register("vampire_hut", () -> () -> VampireHutStructure.CODEC); + public static final RegistryObject> VAMPIRE_ALTAR_TYPE = STRUCTURE_TYPES.register("vampire_altar", () -> () -> VampireAltarStructure.CODEC); public static final RegistryObject VAMPIRE_DUNGEON = FEATURES.register("vampire_dungeon", () -> new VampireDungeonFeature(NoneFeatureConfiguration.CODEC)); @@ -51,5 +57,7 @@ public static void createStructures(BootstapContext context) { HolderGetter lookup = context.lookup(Registries.BIOME); context.register(ModFeatures.HUNTER_CAMP, new HunterCampStructure(StructuresAccessor.structure(lookup.getOrThrow(ModTags.Biomes.HasStructure.HUNTER_TENT), TerrainAdjustment.NONE))); + context.register(ModFeatures.VAMPIRE_HUT, new VampireHutStructure(StructuresAccessor.structure(lookup.getOrThrow(ModTags.Biomes.HasStructure.VAMPIRE_HUT), TerrainAdjustment.NONE))); + context.register(ModFeatures.VAMPIRE_ALTAR, new VampireAltarStructure(StructuresAccessor.structure(lookup.getOrThrow(ModTags.Biomes.HasStructure.VAMPIRE_ALTAR), TerrainAdjustment.NONE))); } } diff --git a/src/main/java/de/teamlapen/vampirism/core/ModLootTables.java b/src/main/java/de/teamlapen/vampirism/core/ModLootTables.java index 741bbabbfc..b7c29c6eae 100644 --- a/src/main/java/de/teamlapen/vampirism/core/ModLootTables.java +++ b/src/main/java/de/teamlapen/vampirism/core/ModLootTables.java @@ -29,15 +29,18 @@ public class ModLootTables { private final static Logger LOGGER = LogManager.getLogger(); private static final Set LOOT_TABLES = Sets.newHashSet(); //chests - public static final ResourceLocation chest_hunter_trainer = register("chests/village/hunter_trainer"); - public static final ResourceLocation chest_vampire_dungeon = register("chests/dungeon/vampire_dungeon"); + public static final ResourceLocation CHEST_HUNTER_TRAINER = register("chests/village/hunter_trainer"); + public static final ResourceLocation CHEST_VAMPIRE_DUNGEON = register("chests/dungeon/vampire_dungeon"); + public static final ResourceLocation CHEST_VAMPIRE_HUT = register("chests/vampire_hut"); + public static final ResourceLocation CHEST_VAMPIRE_ALTAR = register("chests/vampire_altar"); + private static final Map INJECTION_TABLES = Maps.newHashMap(); //inject - public static final ResourceLocation abandoned_mineshaft = registerInject("abandoned_mineshaft"); - public static final ResourceLocation jungle_temple = registerInject("jungle_temple"); - public static final ResourceLocation stronghold_corridor = registerInject("stronghold_corridor"); - public static final ResourceLocation desert_pyramid = registerInject("desert_pyramid"); - public static final ResourceLocation stronghold_library = registerInject("stronghold_library"); + public static final ResourceLocation ABANDONED_MINESHAFT = registerInject("abandoned_mineshaft"); + public static final ResourceLocation JUNGLE_TEMPLE = registerInject("jungle_temple"); + public static final ResourceLocation STRONGHOLD_CORRIDOR = registerInject("stronghold_corridor"); + public static final ResourceLocation DESERT_PYRAMID = registerInject("desert_pyramid"); + public static final ResourceLocation STRONGHOLD_LIBRARY = registerInject("stronghold_library"); private static int injected = 0; static @NotNull ResourceLocation registerInject(String resourceName) { diff --git a/src/main/java/de/teamlapen/vampirism/core/ModTags.java b/src/main/java/de/teamlapen/vampirism/core/ModTags.java index 9f6a69ffd8..7b7b1134bf 100644 --- a/src/main/java/de/teamlapen/vampirism/core/ModTags.java +++ b/src/main/java/de/teamlapen/vampirism/core/ModTags.java @@ -131,6 +131,8 @@ public static class Biomes { public static class HasStructure { public static final TagKey HUNTER_TENT = tag("has_structure/hunter_tent"); public static final TagKey VAMPIRE_DUNGEON = tag("has_structure/vampire_dungeon"); + public static final TagKey VAMPIRE_HUT = tag("has_structure/vampire_hut"); + public static final TagKey VAMPIRE_ALTAR = tag("has_structure/vampire_altar"); } public static class HasSpawn { diff --git a/src/main/java/de/teamlapen/vampirism/data/LootTablesGenerator.java b/src/main/java/de/teamlapen/vampirism/data/LootTablesGenerator.java index f18d69f4ee..ba5511d060 100644 --- a/src/main/java/de/teamlapen/vampirism/data/LootTablesGenerator.java +++ b/src/main/java/de/teamlapen/vampirism/data/LootTablesGenerator.java @@ -157,7 +157,7 @@ public void generate() { private static class ModChestLootTables implements LootTableSubProvider { @Override public void generate(@NotNull BiConsumer consumer) { - consumer.accept(ModLootTables.chest_hunter_trainer, LootTable.lootTable() + consumer.accept(ModLootTables.CHEST_HUNTER_TRAINER, LootTable.lootTable() .withPool(LootPool.lootPool().setRolls(UniformGenerator.between(5, 9)) .add(LootItem.lootTableItem(Items.IRON_INGOT).setWeight(40)) .add(LootItem.lootTableItem(ModItems.VAMPIRE_BLOOD_BOTTLE.get()).setWeight(20)) @@ -185,7 +185,7 @@ public void generate(@NotNull BiConsumer co .add(LootItem.lootTableItem(ModItems.HOLY_WATER_BOTTLE_NORMAL.get()).setWeight(20)) .add(LootItem.lootTableItem(ModItems.HOLY_WATER_BOTTLE_ENHANCED.get()).setWeight(20)) .add(LootItem.lootTableItem(ModItems.HOLY_WATER_BOTTLE_ULTIMATE.get()).setWeight(10)))); - consumer.accept(ModLootTables.chest_vampire_dungeon, LootTable.lootTable() + consumer.accept(ModLootTables.CHEST_VAMPIRE_DUNGEON, LootTable.lootTable() .withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(7)) .add(LootItem.lootTableItem(ModItems.VAMPIRE_FANG.get()).setWeight(35)) .add(LootItem.lootTableItem(ModItems.BLOOD_BOTTLE.get()).setWeight(20).apply(SetItemDamageFunction.setDamage(ConstantValue.exactly(1f))))) @@ -202,6 +202,39 @@ public void generate(@NotNull BiConsumer co .add(LootItem.lootTableItem(ModItems.AMULET.get()).setWeight(1).apply(RefinementSetFunction.builder(VReference.VAMPIRE_FACTION))) .add(LootItem.lootTableItem(ModItems.RING.get()).setWeight(1).apply(RefinementSetFunction.builder(VReference.VAMPIRE_FACTION))) .add(LootItem.lootTableItem(ModItems.OBI_BELT.get()).setWeight(1).apply(RefinementSetFunction.builder(VReference.VAMPIRE_FACTION))))); + consumer.accept(ModLootTables.CHEST_VAMPIRE_HUT, LootTable.lootTable() + .withPool(LootPool.lootPool().setRolls(UniformGenerator.between(3, 5)) + .add(LootItem.lootTableItem(ModItems.VAMPIRE_FANG.get()).setWeight(20)) + .add(LootItem.lootTableItem(ModItems.BLOOD_BOTTLE.get()).setWeight(20).apply(SetItemDamageFunction.setDamage(UniformGenerator.between(0,0.6f))))) + .withPool(LootPool.lootPool().setRolls(UniformGenerator.between(0, 1)) + .add(LootItem.lootTableItem(ModItems.VAMPIRE_BOOK.get()).setWeight(70).apply(AddBookNbtFunction.builder()))) + .withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(2)) + .add(LootItem.lootTableItem(ModItems.AMULET.get()).setWeight(1).apply(RefinementSetFunction.builder(VReference.VAMPIRE_FACTION))) + .add(LootItem.lootTableItem(ModItems.RING.get()).setWeight(1).apply(RefinementSetFunction.builder(VReference.VAMPIRE_FACTION))) + .add(LootItem.lootTableItem(ModItems.OBI_BELT.get()).setWeight(1).apply(RefinementSetFunction.builder(VReference.VAMPIRE_FACTION)))) + .withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1)) + .add(LootItem.lootTableItem(ModItems.HEART_SEEKER_ENHANCED.get()).setWeight(21).apply(SetItemDamageFunction.setDamage(UniformGenerator.between(0.6f, 0.99f))).apply(SetItemBloodChargeFunction.builder(UniformGenerator.between(500f, 2000f)))) + .add(LootItem.lootTableItem(ModItems.HEART_SEEKER_ULTIMATE.get()).setWeight(9).apply(SetItemDamageFunction.setDamage(UniformGenerator.between(0.6f, 0.99f))).apply(SetItemBloodChargeFunction.builder(UniformGenerator.between(500f, 2000f)))) + .add(LootItem.lootTableItem(ModItems.HEART_STRIKER_ENHANCED.get()).setWeight(21).apply(SetItemDamageFunction.setDamage(UniformGenerator.between(0.6f, 0.99f))).apply(SetItemBloodChargeFunction.builder(UniformGenerator.between(500f, 2000f)))) + .add(LootItem.lootTableItem(ModItems.HEART_STRIKER_ULTIMATE.get()).setWeight(9).apply(SetItemDamageFunction.setDamage(UniformGenerator.between(0.6f, 0.99f))).apply(SetItemBloodChargeFunction.builder(UniformGenerator.between(500f, 2000f)))) + .add(EmptyLootItem.emptyItem().setWeight(60))) + ); + consumer.accept(ModLootTables.CHEST_VAMPIRE_ALTAR, LootTable.lootTable() + .withPool(LootPool.lootPool().setRolls(UniformGenerator.between(5, 8)) + .add(LootItem.lootTableItem(ModItems.VAMPIRE_FANG.get()).setWeight(20)) + .add(LootItem.lootTableItem(ModItems.BLOOD_BOTTLE.get()).setWeight(20).apply(SetItemDamageFunction.setDamage(UniformGenerator.between(0,0.6f))))) + .withPool(LootPool.lootPool().setRolls(UniformGenerator.between(10, 18)) + .add(LootItem.lootTableItem(Items.GOLD_INGOT).setWeight(16)) + .add(LootItem.lootTableItem(Items.IRON_INGOT).setWeight(22).apply(SetItemDamageFunction.setDamage(ConstantValue.exactly(1f))))) + .withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1)) + .add(LootItem.lootTableItem(ModItems.PURE_BLOOD_0.get()).setWeight(25)) + .add(LootItem.lootTableItem(ModItems.PURE_BLOOD_1.get()).setWeight(20)) + .add(LootItem.lootTableItem(ModItems.PURE_BLOOD_2.get()).setWeight(15)) + .add(LootItem.lootTableItem(ModItems.PURE_BLOOD_3.get()).setWeight(10)) + .add(LootItem.lootTableItem(ModItems.PURE_BLOOD_4.get()).setWeight(5)) + .add(EmptyLootItem.emptyItem().setWeight(25)) + ) + ); } } @@ -339,7 +372,7 @@ protected Iterable getKnownBlocks() { private static class InjectLootTables implements LootTableSubProvider { @Override public void generate(@NotNull BiConsumer consumer) { - consumer.accept(ModLootTables.abandoned_mineshaft, LootTable.lootTable() + consumer.accept(ModLootTables.ABANDONED_MINESHAFT, LootTable.lootTable() .withPool(LootPool.lootPool().setRolls(UniformGenerator.between(0f, 4f)) .add(LootItem.lootTableItem(ModItems.VAMPIRE_FANG.get()).setWeight(20)) .add(LootItem.lootTableItem(ModItems.ITEM_GARLIC.get()).setWeight(20)) @@ -368,7 +401,7 @@ public void generate(@NotNull BiConsumer co .add(LootItem.lootTableItem(ModItems.RING.get()).setWeight(1).apply(RefinementSetFunction.builder(VReference.VAMPIRE_FACTION))) .add(LootItem.lootTableItem(ModItems.OBI_BELT.get()).setWeight(1).apply(RefinementSetFunction.builder(VReference.VAMPIRE_FACTION)))) ); - consumer.accept(ModLootTables.desert_pyramid, LootTable.lootTable() + consumer.accept(ModLootTables.DESERT_PYRAMID, LootTable.lootTable() .withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1)) .add(LootItem.lootTableItem(ModItems.ITEM_GARLIC.get()).setWeight(15)) .add(LootItem.lootTableItem(ModItems.BLOOD_BOTTLE.get()).setWeight(20).apply(SetItemDamageFunction.setDamage(UniformGenerator.between(0.6f, 0.6f)))) @@ -379,7 +412,7 @@ public void generate(@NotNull BiConsumer co .add(LootItem.lootTableItem(ModItems.RING.get()).setWeight(1).apply(RefinementSetFunction.builder(VReference.VAMPIRE_FACTION))) .add(LootItem.lootTableItem(ModItems.OBI_BELT.get()).setWeight(1).apply(RefinementSetFunction.builder(VReference.VAMPIRE_FACTION)))) ); - consumer.accept(ModLootTables.jungle_temple, LootTable.lootTable() + consumer.accept(ModLootTables.JUNGLE_TEMPLE, LootTable.lootTable() .withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(2)) .add(LootItem.lootTableItem(ModItems.ITEM_GARLIC.get()).setWeight(20)) .add(LootItem.lootTableItem(ModItems.BLOOD_BOTTLE.get()).setWeight(20).apply(SetItemDamageFunction.setDamage(UniformGenerator.between(1f, 1f)))) @@ -403,7 +436,7 @@ public void generate(@NotNull BiConsumer co .add(LootItem.lootTableItem(ModItems.RING.get()).setWeight(1).apply(RefinementSetFunction.builder(VReference.VAMPIRE_FACTION))) .add(LootItem.lootTableItem(ModItems.OBI_BELT.get()).setWeight(1).apply(RefinementSetFunction.builder(VReference.VAMPIRE_FACTION)))) ); - consumer.accept(ModLootTables.stronghold_corridor, LootTable.lootTable() + consumer.accept(ModLootTables.STRONGHOLD_CORRIDOR, LootTable.lootTable() .withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(2)) .add(LootItem.lootTableItem(ModItems.ITEM_GARLIC.get()).setWeight(50)) .add(LootItem.lootTableItem(ModItems.VAMPIRE_BOOK.get()).setWeight(20).apply(AddBookNbtFunction.builder())) @@ -423,7 +456,7 @@ public void generate(@NotNull BiConsumer co .add(LootItem.lootTableItem(ModItems.RING.get()).setWeight(1).apply(RefinementSetFunction.builder(VReference.VAMPIRE_FACTION))) .add(LootItem.lootTableItem(ModItems.OBI_BELT.get()).setWeight(1).apply(RefinementSetFunction.builder(VReference.VAMPIRE_FACTION)))) ); - consumer.accept(ModLootTables.stronghold_library, LootTable.lootTable() + consumer.accept(ModLootTables.STRONGHOLD_LIBRARY, LootTable.lootTable() .withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(1)) .add(LootItem.lootTableItem(ModItems.VAMPIRE_BOOK.get()).setWeight(1).apply(AddBookNbtFunction.builder()))) .withPool(LootPool.lootPool().setRolls(ConstantValue.exactly(3)) diff --git a/src/main/java/de/teamlapen/vampirism/data/TagGenerator.java b/src/main/java/de/teamlapen/vampirism/data/TagGenerator.java index 896475d330..f27f601c5b 100644 --- a/src/main/java/de/teamlapen/vampirism/data/TagGenerator.java +++ b/src/main/java/de/teamlapen/vampirism/data/TagGenerator.java @@ -270,9 +270,10 @@ public ModBiomeTagsProvider(PackOutput output, CompletableFuture HUNTER_CAMP_FIREPLACE = STRUCTURE_PIECES.register("hunter_camp_fireplace", () -> (StructurePieceType.ContextlessType) HunterCampPieces.Fireplace::new); public static final RegistryObject HUNTER_CAMP_TENT = STRUCTURE_PIECES.register("hunter_camp_tent", () -> (StructurePieceType.ContextlessType) HunterCampPieces.Tent::new); public static final RegistryObject HUNTER_CAMP_SPECIAL = STRUCTURE_PIECES.register("hunter_camp_craftingtable", () -> (StructurePieceType.ContextlessType) HunterCampPieces.SpecialBlock::new); + public static final RegistryObject VAMPIRE_HUT_PIECE = STRUCTURE_PIECES.register("vampire_hut", () -> (StructurePieceType.StructureTemplateType) VampireHutPieces.VampireHutPiece::new); + public static final RegistryObject VAMPIRE_ALTAR_PIECE = STRUCTURE_PIECES.register("vampire_altar", () -> (StructurePieceType.StructureTemplateType) VampireAltarPieces.VampireAltarPiece::new); public static final RegistryObject> RANDOM_SELECTOR = STRUCTURE_PROCESSOR_TYPES.register("random_selector", () -> () -> RandomStructureProcessor.CODEC); public static final RegistryObject> BIOME_BASED = STRUCTURE_PROCESSOR_TYPES.register("biome_based", () -> () -> BiomeTopBlockProcessor.CODEC); @@ -104,6 +105,8 @@ public class VampirismFeatures { public static final ResourceKey VAMPIRE_DUNGEON_MODIFIER = createModifierKey("feature/vampire_dungeon"); public static final ResourceKey HUNTER_CAMP = createStructureSetKey("hunter_camp"); + public static final ResourceKey VAMPIRE_HUT = createStructureSetKey("vampire_hut"); + public static final ResourceKey VAMPIRE_ALTAR = createStructureSetKey("vampire_altar"); public static void register(IEventBus ctx) { @@ -168,6 +171,8 @@ public static void createBiomeModifier(BootstapContext context) { public static void createStructureSets(BootstapContext context) { HolderGetter structureLookup = context.lookup(Registries.STRUCTURE); context.register(HUNTER_CAMP, new StructureSet(structureLookup.getOrThrow(ModFeatures.HUNTER_CAMP), new RandomSpreadStructurePlacement(9, 4, RandomSpreadType.LINEAR, 1724616580))); + context.register(VAMPIRE_HUT, new StructureSet(structureLookup.getOrThrow(ModFeatures.VAMPIRE_HUT), new RandomSpreadStructurePlacement(32, 8, RandomSpreadType.LINEAR, 1937195837))); + context.register(VAMPIRE_ALTAR, new StructureSet(structureLookup.getOrThrow(ModFeatures.VAMPIRE_ALTAR), new RandomSpreadStructurePlacement(48, 9, RandomSpreadType.LINEAR, 823476514))); } } diff --git a/src/main/java/de/teamlapen/vampirism/world/gen/feature/VampireDungeonFeature.java b/src/main/java/de/teamlapen/vampirism/world/gen/feature/VampireDungeonFeature.java index 89f2924c83..a324fc6f4a 100644 --- a/src/main/java/de/teamlapen/vampirism/world/gen/feature/VampireDungeonFeature.java +++ b/src/main/java/de/teamlapen/vampirism/world/gen/feature/VampireDungeonFeature.java @@ -41,7 +41,7 @@ public VampireDungeonFeature(@NotNull Codec featureCon *

* - changed {@link Blocks#MOSSY_COBBLESTONE} to {@link ModBlocks#CASTLE_BLOCK_DARK_BRICK} and {@link ModBlocks#CASTLE_BLOCK_DARK_BRICK_BLOODY} * - changed {@link Blocks#COBBLESTONE} to {@link Blocks#SPRUCE_PLANKS} - * - changed {@link net.minecraft.world.level.storage.loot.BuiltInLootTables#SIMPLE_DUNGEON} to {@link ModLootTables#chest_vampire_dungeon} + * - changed {@link net.minecraft.world.level.storage.loot.BuiltInLootTables#SIMPLE_DUNGEON} to {@link ModLootTables#CHEST_VAMPIRE_DUNGEON} * - changed {@link MonsterRoomFeature#randomEntityId(net.minecraft.util.RandomSource)} to {@link ModEntities#VAMPIRE} */ @SuppressWarnings("JavadocReference") @@ -122,7 +122,7 @@ public boolean place(@NotNull FeaturePlaceContext p_16 if (j3 == 1) { this.safeSetBlock(worldgenlevel, blockpos3, StructurePiece.reorient(worldgenlevel, blockpos3, Blocks.CHEST.defaultBlockState()), predicate); - RandomizableContainerBlockEntity.setLootTable(worldgenlevel, randomsource, blockpos3, ModLootTables.chest_vampire_dungeon); + RandomizableContainerBlockEntity.setLootTable(worldgenlevel, randomsource, blockpos3, ModLootTables.CHEST_VAMPIRE_DUNGEON); break; } } diff --git a/src/main/java/de/teamlapen/vampirism/world/gen/structure/vampirealtar/VampireAltarPieces.java b/src/main/java/de/teamlapen/vampirism/world/gen/structure/vampirealtar/VampireAltarPieces.java new file mode 100644 index 0000000000..1e52e745b6 --- /dev/null +++ b/src/main/java/de/teamlapen/vampirism/world/gen/structure/vampirealtar/VampireAltarPieces.java @@ -0,0 +1,72 @@ +package de.teamlapen.vampirism.world.gen.structure.vampirealtar; + +import de.teamlapen.vampirism.REFERENCE; +import de.teamlapen.vampirism.core.ModBlocks; +import de.teamlapen.vampirism.core.ModLootTables; +import de.teamlapen.vampirism.world.gen.VampirismFeatures; +import net.minecraft.core.BlockPos; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.ServerLevelAccessor; +import net.minecraft.world.level.StructureManager; +import net.minecraft.world.level.WorldGenLevel; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.ChestBlockEntity; +import net.minecraft.world.level.chunk.ChunkGenerator; +import net.minecraft.world.level.levelgen.Heightmap; +import net.minecraft.world.level.levelgen.structure.BoundingBox; +import net.minecraft.world.level.levelgen.structure.StructurePieceAccessor; +import net.minecraft.world.level.levelgen.structure.TemplateStructurePiece; +import net.minecraft.world.level.levelgen.structure.templatesystem.BlockIgnoreProcessor; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager; +import org.jetbrains.annotations.NotNull; + +public class VampireAltarPieces { + + private static final ResourceLocation LOCATION_SMALL = new ResourceLocation(REFERENCE.MODID, "altar_small"); + private static final ResourceLocation LOCATION_BIG = new ResourceLocation(REFERENCE.MODID, "altar_big"); + + public static void addPieces(StructureTemplateManager structureTemplateManager, StructurePieceAccessor pieceAccessor, RandomSource random, BlockPos pos) { + pieceAccessor.addPiece(new VampireAltarPiece(structureTemplateManager, random.nextFloat() < 0.2 ? LOCATION_BIG : LOCATION_SMALL, pos)); + } + + public static class VampireAltarPiece extends TemplateStructurePiece { + + public VampireAltarPiece(StructureTemplateManager pStructureTemplateManager, ResourceLocation pLocation, BlockPos pPos) { + super(VampirismFeatures.VAMPIRE_ALTAR_PIECE.get(), 0, pStructureTemplateManager, pLocation, pLocation.toString(), makeSettings(), pPos); + } + + public VampireAltarPiece(StructureTemplateManager pStructureTemplateManager, CompoundTag pTag) { + super(VampirismFeatures.VAMPIRE_ALTAR_PIECE.get(), pTag, pStructureTemplateManager, (id) -> makeSettings()); + } + + @Override + protected void handleDataMarker(@NotNull String pName, @NotNull BlockPos pPos, @NotNull ServerLevelAccessor pLevel, @NotNull RandomSource pRandom, @NotNull BoundingBox pBox) { + if(pName.equals("chest")) { + pLevel.setBlock(pPos, ModBlocks.CASTLE_BLOCK_DARK_BRICK.get().defaultBlockState(), 3); + BlockEntity blockEntity = pLevel.getBlockEntity(pPos.below()); + if (blockEntity instanceof ChestBlockEntity chest) { + chest.setLootTable(ModLootTables.CHEST_VAMPIRE_ALTAR, pRandom.nextLong()); + } + } + } + + @Override + public void postProcess(WorldGenLevel pLevel, @NotNull StructureManager pStructureManager, @NotNull ChunkGenerator pGenerator, @NotNull RandomSource pRandom, @NotNull BoundingBox pBox, @NotNull ChunkPos pChunkPos, BlockPos pPos) { + int i = pLevel.getHeight(Heightmap.Types.WORLD_SURFACE_WG, pPos.getX(), pPos.getZ()); + var oldPos = this.templatePosition; + this.templatePosition = this.templatePosition.offset(0,i - 90,0); + super.postProcess(pLevel, pStructureManager, pGenerator, pRandom, pBox, pChunkPos, pPos); + this.templatePosition = oldPos; + } + + private static @NotNull StructurePlaceSettings makeSettings() { + return (new StructurePlaceSettings()).setRotation(Rotation.NONE).setMirror(Mirror.NONE).addProcessor(BlockIgnoreProcessor.STRUCTURE_AND_AIR); + } + } +} diff --git a/src/main/java/de/teamlapen/vampirism/world/gen/structure/vampirealtar/VampireAltarStructure.java b/src/main/java/de/teamlapen/vampirism/world/gen/structure/vampirealtar/VampireAltarStructure.java new file mode 100644 index 0000000000..a3ebbe615b --- /dev/null +++ b/src/main/java/de/teamlapen/vampirism/world/gen/structure/vampirealtar/VampireAltarStructure.java @@ -0,0 +1,42 @@ +package de.teamlapen.vampirism.world.gen.structure.vampirealtar; + +import com.mojang.serialization.Codec; +import de.teamlapen.vampirism.core.ModFeatures; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.levelgen.Heightmap; +import net.minecraft.world.level.levelgen.WorldgenRandom; +import net.minecraft.world.level.levelgen.structure.Structure; +import net.minecraft.world.level.levelgen.structure.StructureType; +import net.minecraft.world.level.levelgen.structure.pieces.StructurePiecesBuilder; +import org.jetbrains.annotations.NotNull; + +import java.util.Optional; + +public class VampireAltarStructure extends Structure { + + public static final Codec CODEC = simpleCodec(VampireAltarStructure::new); + + public VampireAltarStructure(StructureSettings settings) { + super(settings); + } + + @Override + protected @NotNull Optional findGenerationPoint(@NotNull GenerationContext pContext) { + return onTopOfChunkCenter(pContext, Heightmap.Types.WORLD_SURFACE_WG, (builder) -> { + this.generatePieces(builder, pContext); + }); + } + + private void generatePieces(StructurePiecesBuilder builder, GenerationContext context) { + ChunkPos chunk = context.chunkPos(); + WorldgenRandom random = context.random(); + VampireAltarPieces.addPieces(context.structureTemplateManager(), builder, random, new BlockPos(chunk.getMinBlockX(), 90, chunk.getMinBlockZ())); + } + + @Override + public @NotNull StructureType type() { + return ModFeatures.VAMPIRE_ALTAR_TYPE.get(); + } + +} diff --git a/src/main/java/de/teamlapen/vampirism/world/gen/structure/vampirehut/VampireHutPieces.java b/src/main/java/de/teamlapen/vampirism/world/gen/structure/vampirehut/VampireHutPieces.java new file mode 100644 index 0000000000..728841df8c --- /dev/null +++ b/src/main/java/de/teamlapen/vampirism/world/gen/structure/vampirehut/VampireHutPieces.java @@ -0,0 +1,92 @@ +package de.teamlapen.vampirism.world.gen.structure.vampirehut; + +import de.teamlapen.vampirism.REFERENCE; +import de.teamlapen.vampirism.core.ModBlocks; +import de.teamlapen.vampirism.core.ModLootTables; +import de.teamlapen.vampirism.world.gen.VampirismFeatures; +import net.minecraft.core.BlockPos; +import net.minecraft.core.Direction; +import net.minecraft.nbt.CompoundTag; +import net.minecraft.resources.ResourceLocation; +import net.minecraft.util.RandomSource; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.ServerLevelAccessor; +import net.minecraft.world.level.StructureManager; +import net.minecraft.world.level.WorldGenLevel; +import net.minecraft.world.level.block.Blocks; +import net.minecraft.world.level.block.Mirror; +import net.minecraft.world.level.block.Rotation; +import net.minecraft.world.level.block.entity.BlockEntity; +import net.minecraft.world.level.block.entity.ChestBlockEntity; +import net.minecraft.world.level.block.state.properties.BlockStateProperties; +import net.minecraft.world.level.chunk.ChunkGenerator; +import net.minecraft.world.level.levelgen.Heightmap; +import net.minecraft.world.level.levelgen.structure.BoundingBox; +import net.minecraft.world.level.levelgen.structure.StructurePieceAccessor; +import net.minecraft.world.level.levelgen.structure.TemplateStructurePiece; +import net.minecraft.world.level.levelgen.structure.pieces.StructurePieceSerializationContext; +import net.minecraft.world.level.levelgen.structure.templatesystem.BlockIgnoreProcessor; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructurePlaceSettings; +import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplateManager; +import org.jetbrains.annotations.NotNull; + +public class VampireHutPieces { + + private static final ResourceLocation LOCATION = new ResourceLocation(REFERENCE.MODID, "vampire_hut"); + + public static void addPieces(StructureTemplateManager structureTemplateManager, StructurePieceAccessor pieceAccessor, RandomSource random, BlockPos pos) { + Rotation rotation = Rotation.getRandom(random); + pieceAccessor.addPiece(new VampireHutPiece(structureTemplateManager, LOCATION, pos, rotation)); + } + + public static class VampireHutPiece extends TemplateStructurePiece { + + public VampireHutPiece(StructureTemplateManager pStructureTemplateManager, ResourceLocation pLocation, BlockPos pPos, Rotation pRotation) { + super(VampirismFeatures.VAMPIRE_HUT_PIECE.get(), 0, pStructureTemplateManager, pLocation, pLocation.toString(), makeSettings(pRotation), pPos); + } + + public VampireHutPiece(StructureTemplateManager pStructureTemplateManager, CompoundTag pTag) { + super(VampirismFeatures.VAMPIRE_HUT_PIECE.get(), pTag, pStructureTemplateManager, (id) -> makeSettings(Rotation.valueOf(pTag.getString("Rot")))); + } + + protected void addAdditionalSaveData(@NotNull StructurePieceSerializationContext pContext, @NotNull CompoundTag pTag) { + super.addAdditionalSaveData(pContext, pTag); + pTag.putString("Rot", this.placeSettings.getRotation().name()); + } + + @Override + protected void handleDataMarker(@NotNull String pName, @NotNull BlockPos pPos, @NotNull ServerLevelAccessor pLevel, @NotNull RandomSource pRandom, @NotNull BoundingBox pBox) { + switch (pName) { + case "chest" -> { + pLevel.setBlock(pPos, Blocks.AIR.defaultBlockState(), 3); + BlockEntity blockEntity = pLevel.getBlockEntity(pPos.below()); + if (blockEntity instanceof ChestBlockEntity chest) { + chest.setLootTable(ModLootTables.CHEST_VAMPIRE_HUT, pRandom.nextLong()); + } + } + case "log" -> { + var state = ModBlocks.DARK_SPRUCE_LOG.get().defaultBlockState().setValue(BlockStateProperties.AXIS, Direction.Axis.Y); + pLevel.setBlock(pPos, state, 3); + BlockPos down = pPos.below(); + while (pLevel.getBlockState(down).canBeReplaced()) { + pLevel.setBlock(down, state, 3); + down = down.below(); + } + } + } + } + + @Override + public void postProcess(WorldGenLevel pLevel, @NotNull StructureManager pStructureManager, @NotNull ChunkGenerator pGenerator, @NotNull RandomSource pRandom, @NotNull BoundingBox pBox, @NotNull ChunkPos pChunkPos, BlockPos pPos) { + int i = pLevel.getHeight(Heightmap.Types.WORLD_SURFACE_WG, pPos.getX(), pPos.getZ()); + var oldPos = this.templatePosition; + this.templatePosition = this.templatePosition.offset(0,i - 90 -1,0); + super.postProcess(pLevel, pStructureManager, pGenerator, pRandom, pBox, pChunkPos, pPos); + this.templatePosition = oldPos; + } + + private static @NotNull StructurePlaceSettings makeSettings(Rotation pRotation) { + return (new StructurePlaceSettings()).setRotation(pRotation).setMirror(Mirror.NONE).addProcessor(BlockIgnoreProcessor.STRUCTURE_AND_AIR); + } + } +} diff --git a/src/main/java/de/teamlapen/vampirism/world/gen/structure/vampirehut/VampireHutStructure.java b/src/main/java/de/teamlapen/vampirism/world/gen/structure/vampirehut/VampireHutStructure.java new file mode 100644 index 0000000000..ed4eb9fe5b --- /dev/null +++ b/src/main/java/de/teamlapen/vampirism/world/gen/structure/vampirehut/VampireHutStructure.java @@ -0,0 +1,42 @@ +package de.teamlapen.vampirism.world.gen.structure.vampirehut; + +import com.mojang.serialization.Codec; +import de.teamlapen.vampirism.core.ModFeatures; +import net.minecraft.core.BlockPos; +import net.minecraft.world.level.ChunkPos; +import net.minecraft.world.level.levelgen.Heightmap; +import net.minecraft.world.level.levelgen.WorldgenRandom; +import net.minecraft.world.level.levelgen.structure.Structure; +import net.minecraft.world.level.levelgen.structure.StructureType; +import net.minecraft.world.level.levelgen.structure.pieces.StructurePiecesBuilder; +import org.jetbrains.annotations.NotNull; + +import java.util.Optional; + +public class VampireHutStructure extends Structure { + + public static final Codec CODEC = simpleCodec(VampireHutStructure::new); + + public VampireHutStructure(Structure.StructureSettings settings) { + super(settings); + } + + @Override + protected @NotNull Optional findGenerationPoint(@NotNull GenerationContext pContext) { + return onTopOfChunkCenter(pContext, Heightmap.Types.WORLD_SURFACE_WG, (builder) -> { + this.generatePieces(builder, pContext); + }); + } + + private void generatePieces(StructurePiecesBuilder builder, Structure.GenerationContext context) { + ChunkPos chunk = context.chunkPos(); + WorldgenRandom random = context.random(); + VampireHutPieces.addPieces(context.structureTemplateManager(), builder, random, new BlockPos(chunk.getMinBlockX(), 90, chunk.getMinBlockZ())); + } + + @Override + public @NotNull StructureType type() { + return ModFeatures.VAMPIRE_HUT_TYPE.get(); + } + +} diff --git a/src/main/resources/data/vampirism/structures/altar_big.nbt b/src/main/resources/data/vampirism/structures/altar_big.nbt new file mode 100644 index 0000000000..09d30806df Binary files /dev/null and b/src/main/resources/data/vampirism/structures/altar_big.nbt differ diff --git a/src/main/resources/data/vampirism/structures/altar_small.nbt b/src/main/resources/data/vampirism/structures/altar_small.nbt new file mode 100644 index 0000000000..7efbf7a110 Binary files /dev/null and b/src/main/resources/data/vampirism/structures/altar_small.nbt differ diff --git a/src/main/resources/data/vampirism/structures/vampire_hut.nbt b/src/main/resources/data/vampirism/structures/vampire_hut.nbt new file mode 100644 index 0000000000..7d82b48485 Binary files /dev/null and b/src/main/resources/data/vampirism/structures/vampire_hut.nbt differ