From bd505cbe73de79a52bd449ca8ddd029120ed99c0 Mon Sep 17 00:00:00 2001 From: Treetrain1 Date: Tue, 31 Oct 2023 20:47:16 -0500 Subject: [PATCH] convert kill all mobs --- .../misc/mod_compat/FrozenLibIntegration.java | 62 +- .../advancements/adventure/kill_all_mobs.json | 655 ------------------ 2 files changed, 40 insertions(+), 677 deletions(-) delete mode 100644 src/main/resources/data/minecraft/advancements/adventure/kill_all_mobs.json diff --git a/src/main/java/net/frozenblock/wilderwild/misc/mod_compat/FrozenLibIntegration.java b/src/main/java/net/frozenblock/wilderwild/misc/mod_compat/FrozenLibIntegration.java index dce875197c..909613176d 100644 --- a/src/main/java/net/frozenblock/wilderwild/misc/mod_compat/FrozenLibIntegration.java +++ b/src/main/java/net/frozenblock/wilderwild/misc/mod_compat/FrozenLibIntegration.java @@ -46,17 +46,22 @@ import net.frozenblock.wilderwild.registry.RegisterBlockSoundTypes; import static net.frozenblock.wilderwild.registry.RegisterBlockSoundTypes.*; import static net.frozenblock.wilderwild.registry.RegisterBlocks.*; +import net.frozenblock.wilderwild.registry.RegisterEntities; import net.frozenblock.wilderwild.registry.RegisterSounds; import net.frozenblock.wilderwild.registry.RegisterWorldgen; import net.minecraft.advancements.Advancement; import net.minecraft.advancements.AdvancementRequirements; import net.minecraft.advancements.Criterion; +import net.minecraft.advancements.critereon.EntityPredicate; +import net.minecraft.advancements.critereon.KilledTrigger; import net.minecraft.advancements.critereon.LocationPredicate; import net.minecraft.advancements.critereon.PlayerTrigger; import net.minecraft.core.BlockPos; +import net.minecraft.core.registries.BuiltInRegistries; import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceLocation; import net.minecraft.server.level.ServerLevel; +import net.minecraft.world.entity.EntityType; import net.minecraft.world.entity.LivingEntity; import net.minecraft.world.entity.monster.EnderMan; import net.minecraft.world.item.InstrumentItem; @@ -156,28 +161,36 @@ public void init() { AdvancementEvents.INIT.register(holder -> { Advancement advancement = holder.value(); - if (holder.id().equals(new ResourceLocation("adventure/adventuring_time"))) { - addBiomeRequirement(advancement, RegisterWorldgen.CYPRESS_WETLANDS); - addBiomeRequirement(advancement, RegisterWorldgen.MIXED_FOREST); - addBiomeRequirement(advancement, RegisterWorldgen.OASIS); - addBiomeRequirement(advancement, RegisterWorldgen.WARM_RIVER); - addBiomeRequirement(advancement, RegisterWorldgen.WARM_BEACH); - addBiomeRequirement(advancement, RegisterWorldgen.JELLYFISH_CAVES); - addBiomeRequirement(advancement, RegisterWorldgen.ARID_FOREST); - addBiomeRequirement(advancement, RegisterWorldgen.ARID_SAVANNA); - addBiomeRequirement(advancement, RegisterWorldgen.PARCHED_FOREST); - addBiomeRequirement(advancement, RegisterWorldgen.BIRCH_JUNGLE); - addBiomeRequirement(advancement, RegisterWorldgen.SPARSE_BIRCH_JUNGLE); - addBiomeRequirement(advancement, RegisterWorldgen.BIRCH_TAIGA); - addBiomeRequirement(advancement, RegisterWorldgen.SEMI_BIRCH_FOREST); - addBiomeRequirement(advancement, RegisterWorldgen.DARK_BIRCH_FOREST); - addBiomeRequirement(advancement, RegisterWorldgen.FLOWER_FIELD); - addBiomeRequirement(advancement, RegisterWorldgen.TEMPERATE_RAINFOREST); - addBiomeRequirement(advancement, RegisterWorldgen.RAINFOREST); - addBiomeRequirement(advancement, RegisterWorldgen.DARK_TAIGA); - addBiomeRequirement(advancement, RegisterWorldgen.OLD_GROWTH_BIRCH_TAIGA); - addBiomeRequirement(advancement, RegisterWorldgen.OLD_GROWTH_DARK_FOREST); - addBiomeRequirement(advancement, RegisterWorldgen.SNOWY_OLD_GROWTH_PINE_TAIGA); + switch (holder.id().toString()) { + case "minecraft:adventure/adventuring_time" -> { + addBiomeRequirement(advancement, RegisterWorldgen.CYPRESS_WETLANDS); + addBiomeRequirement(advancement, RegisterWorldgen.MIXED_FOREST); + addBiomeRequirement(advancement, RegisterWorldgen.OASIS); + addBiomeRequirement(advancement, RegisterWorldgen.WARM_RIVER); + addBiomeRequirement(advancement, RegisterWorldgen.WARM_BEACH); + addBiomeRequirement(advancement, RegisterWorldgen.JELLYFISH_CAVES); + addBiomeRequirement(advancement, RegisterWorldgen.ARID_FOREST); + addBiomeRequirement(advancement, RegisterWorldgen.ARID_SAVANNA); + addBiomeRequirement(advancement, RegisterWorldgen.PARCHED_FOREST); + addBiomeRequirement(advancement, RegisterWorldgen.BIRCH_JUNGLE); + addBiomeRequirement(advancement, RegisterWorldgen.SPARSE_BIRCH_JUNGLE); + addBiomeRequirement(advancement, RegisterWorldgen.BIRCH_TAIGA); + addBiomeRequirement(advancement, RegisterWorldgen.SEMI_BIRCH_FOREST); + addBiomeRequirement(advancement, RegisterWorldgen.DARK_BIRCH_FOREST); + addBiomeRequirement(advancement, RegisterWorldgen.FLOWER_FIELD); + addBiomeRequirement(advancement, RegisterWorldgen.TEMPERATE_RAINFOREST); + addBiomeRequirement(advancement, RegisterWorldgen.RAINFOREST); + addBiomeRequirement(advancement, RegisterWorldgen.DARK_TAIGA); + addBiomeRequirement(advancement, RegisterWorldgen.OLD_GROWTH_BIRCH_TAIGA); + addBiomeRequirement(advancement, RegisterWorldgen.OLD_GROWTH_DARK_FOREST); + addBiomeRequirement(advancement, RegisterWorldgen.SNOWY_OLD_GROWTH_PINE_TAIGA); + } + case "minecraft:adventure/kill_all_mobs" -> { + addEntityKillRequirement(advancement, RegisterEntities.CRAB); + addEntityKillRequirement(advancement, RegisterEntities.FIREFLY); + addEntityKillRequirement(advancement, RegisterEntities.JELLYFISH); + } + default -> {} } }); } @@ -187,6 +200,11 @@ private static void addBiomeRequirement(Advancement advancement, ResourceKey type) { + ResourceLocation key = BuiltInRegistries.ENTITY_TYPE.getKey(type); + AdvancementAPI.addCriteria(advancement, key.toString(), KilledTrigger.TriggerInstance.playerKilledEntity(EntityPredicate.Builder.entity().of(type))); + } + private static Criterion inBiome(ResourceKey key) { return PlayerTrigger.TriggerInstance.located(LocationPredicate.Builder.inBiome(key)); } diff --git a/src/main/resources/data/minecraft/advancements/adventure/kill_all_mobs.json b/src/main/resources/data/minecraft/advancements/adventure/kill_all_mobs.json deleted file mode 100644 index 159549b169..0000000000 --- a/src/main/resources/data/minecraft/advancements/adventure/kill_all_mobs.json +++ /dev/null @@ -1,655 +0,0 @@ -{ - "parent": "minecraft:adventure/kill_a_mob", - "criteria": { - "minecraft:blaze": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:blaze" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:cave_spider": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:cave_spider" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:creeper": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:creeper" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:drowned": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:drowned" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:elder_guardian": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:elder_guardian" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:ender_dragon": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:ender_dragon" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:enderman": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:enderman" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:endermite": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:endermite" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:evoker": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:evoker" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:ghast": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:ghast" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:guardian": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:guardian" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:hoglin": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:hoglin" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:husk": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:husk" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:magma_cube": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:magma_cube" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:phantom": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:phantom" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:piglin": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:piglin" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:piglin_brute": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:piglin_brute" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:pillager": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:pillager" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:ravager": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:ravager" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:shulker": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:shulker" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:silverfish": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:silverfish" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:skeleton": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:skeleton" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:slime": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:slime" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:spider": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:spider" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:stray": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:stray" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:vex": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:vex" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:vindicator": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:vindicator" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:witch": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:witch" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:wither": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:wither" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:wither_skeleton": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:wither_skeleton" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:zoglin": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:zoglin" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:zombie": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:zombie" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:zombie_villager": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:zombie_villager" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "minecraft:zombified_piglin": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "minecraft:zombified_piglin" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "wilderwild:firefly": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "wilderwild:firefly" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "wilderwild:jellyfish": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "wilderwild:jellyfish" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - }, - "wilderwild:crab": { - "conditions": { - "entity": [ - { - "condition": "minecraft:entity_properties", - "entity": "this", - "predicate": { - "type": "wilderwild:crab" - } - } - ] - }, - "trigger": "minecraft:player_killed_entity" - } - }, - "display": { - "announce_to_chat": true, - "description": { - "translate": "advancements.adventure.kill_all_mobs.description" - }, - "frame": "challenge", - "hidden": false, - "icon": { - "item": "minecraft:diamond_sword", - "nbt": "{Damage:0}" - }, - "show_toast": true, - "title": { - "translate": "advancements.adventure.kill_all_mobs.title" - } - }, - "requirements": [ - [ - "minecraft:blaze" - ], - [ - "minecraft:cave_spider" - ], - [ - "minecraft:creeper" - ], - [ - "minecraft:drowned" - ], - [ - "minecraft:elder_guardian" - ], - [ - "minecraft:ender_dragon" - ], - [ - "minecraft:enderman" - ], - [ - "minecraft:endermite" - ], - [ - "minecraft:evoker" - ], - [ - "minecraft:ghast" - ], - [ - "minecraft:guardian" - ], - [ - "minecraft:hoglin" - ], - [ - "minecraft:husk" - ], - [ - "minecraft:magma_cube" - ], - [ - "minecraft:phantom" - ], - [ - "minecraft:piglin" - ], - [ - "minecraft:piglin_brute" - ], - [ - "minecraft:pillager" - ], - [ - "minecraft:ravager" - ], - [ - "minecraft:shulker" - ], - [ - "minecraft:silverfish" - ], - [ - "minecraft:skeleton" - ], - [ - "minecraft:slime" - ], - [ - "minecraft:spider" - ], - [ - "minecraft:stray" - ], - [ - "minecraft:vex" - ], - [ - "minecraft:vindicator" - ], - [ - "minecraft:witch" - ], - [ - "minecraft:wither_skeleton" - ], - [ - "minecraft:wither" - ], - [ - "minecraft:zoglin" - ], - [ - "minecraft:zombie_villager" - ], - [ - "minecraft:zombie" - ], - [ - "minecraft:zombified_piglin" - ], - [ - "wilderwild:firefly" - ], - [ - "wilderwild:jellyfish" - ], - [ - "wilderwild:crab" - ] - ], - "rewards": { - "experience": 100 - } -}