From 91a52460f927204b97b823253469d790601c0a40 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Thu, 20 Dec 2018 21:43:19 +0100 Subject: [PATCH] made passive effects have their own advancements so that they're not gated behind random generators --- .../java/de/ellpeck/naturesaura/Helper.java | 11 +++++++++++ .../naturesaura/events/CommonEvents.java | 16 ++++++++++++++++ .../advancements/negative_imbalance.json | 19 +++++++++++++++++++ .../advancements/positive_imbalance.json | 19 +++++++++++++++++++ .../assets/naturesaura/lang/en_US.lang | 4 ++++ .../book/en_us/entries/effects/animal.json | 2 +- .../en_us/entries/effects/breathlessness.json | 2 +- .../en_us/entries/effects/cache_recharge.json | 2 +- .../book/en_us/entries/effects/decay.json | 2 +- .../en_us/entries/effects/effect_powder.json | 2 +- .../en_us/entries/effects/explosions.json | 2 +- .../en_us/entries/effects/plant_boost.json | 2 +- 12 files changed, 76 insertions(+), 7 deletions(-) create mode 100644 src/main/resources/assets/naturesaura/advancements/negative_imbalance.json create mode 100644 src/main/resources/assets/naturesaura/advancements/positive_imbalance.json diff --git a/src/main/java/de/ellpeck/naturesaura/Helper.java b/src/main/java/de/ellpeck/naturesaura/Helper.java index 3dcc984a..f6486ad0 100644 --- a/src/main/java/de/ellpeck/naturesaura/Helper.java +++ b/src/main/java/de/ellpeck/naturesaura/Helper.java @@ -3,6 +3,7 @@ package de.ellpeck.naturesaura; import de.ellpeck.naturesaura.api.NaturesAuraAPI; import de.ellpeck.naturesaura.api.aura.item.IAuraRecharge; import de.ellpeck.naturesaura.blocks.tiles.TileEntityImpl; +import net.minecraft.advancements.Advancement; import net.minecraft.block.Block; import net.minecraft.block.properties.IProperty; import net.minecraft.block.state.IBlockState; @@ -12,6 +13,7 @@ import net.minecraft.client.renderer.RenderHelper; import net.minecraft.client.renderer.block.model.ItemCameraTransforms; import net.minecraft.entity.item.EntityItemFrame; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.entity.player.EntityPlayerMP; import net.minecraft.init.SoundEvents; import net.minecraft.item.ItemStack; import net.minecraft.item.crafting.Ingredient; @@ -230,4 +232,13 @@ public final class Helper { public static Ingredient blockIng(Block block) { return Ingredient.fromStacks(new ItemStack(block)); } + + public static void addAdvancement(EntityPlayer player, ResourceLocation advancement, String criterion) { + if (!(player instanceof EntityPlayerMP)) + return; + EntityPlayerMP playerMp = (EntityPlayerMP) player; + Advancement adv = playerMp.getServerWorld().getAdvancementManager().getAdvancement(advancement); + if (adv != null) + playerMp.getAdvancements().grantCriterion(adv, criterion); + } } diff --git a/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java b/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java index 37bf6ee3..24c84c78 100644 --- a/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java +++ b/src/main/java/de/ellpeck/naturesaura/events/CommonEvents.java @@ -1,8 +1,10 @@ package de.ellpeck.naturesaura.events; +import de.ellpeck.naturesaura.Helper; import de.ellpeck.naturesaura.ModConfig; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.api.NaturesAuraAPI; +import de.ellpeck.naturesaura.api.aura.chunk.IAuraChunk; import de.ellpeck.naturesaura.api.aura.type.IAuraType; import de.ellpeck.naturesaura.chunk.AuraChunk; import de.ellpeck.naturesaura.packet.PacketHandler; @@ -46,6 +48,20 @@ public class CommonEvents { } } + @SubscribeEvent + public void onPlayerTick(TickEvent.PlayerTickEvent event) { + if (!event.player.world.isRemote && event.phase == TickEvent.Phase.END) { + if (event.player.world.getTotalWorldTime() % 200 != 0) + return; + + int aura = IAuraChunk.triangulateAuraInArea(event.player.world, event.player.getPosition(), 25); + if (aura <= 0) + Helper.addAdvancement(event.player, new ResourceLocation(NaturesAura.MOD_ID, "negative_imbalance"), "triggered_in_code"); + else if (aura >= 15000) + Helper.addAdvancement(event.player, new ResourceLocation(NaturesAura.MOD_ID, "positive_imbalance"), "triggered_in_code"); + } + } + @SubscribeEvent public void onChunkWatch(ChunkWatchEvent.Watch event) { Chunk chunk = event.getChunkInstance(); diff --git a/src/main/resources/assets/naturesaura/advancements/negative_imbalance.json b/src/main/resources/assets/naturesaura/advancements/negative_imbalance.json new file mode 100644 index 00000000..8b540fa4 --- /dev/null +++ b/src/main/resources/assets/naturesaura/advancements/negative_imbalance.json @@ -0,0 +1,19 @@ +{ + "display": { + "icon": { + "item": "naturesaura:decayed_leaves" + }, + "title": { + "translate": "advancement.naturesaura.negative_imbalance" + }, + "description": { + "translate": "advancement.naturesaura.negative_imbalance.desc" + } + }, + "parent": "naturesaura:altar", + "criteria": { + "triggered_in_code": { + "trigger": "minecraft:impossible" + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/advancements/positive_imbalance.json b/src/main/resources/assets/naturesaura/advancements/positive_imbalance.json new file mode 100644 index 00000000..50e1fde1 --- /dev/null +++ b/src/main/resources/assets/naturesaura/advancements/positive_imbalance.json @@ -0,0 +1,19 @@ +{ + "display": { + "icon": { + "item": "minecraft:wheat_seeds" + }, + "title": { + "translate": "advancement.naturesaura.positive_imbalance" + }, + "description": { + "translate": "advancement.naturesaura.positive_imbalance.desc" + } + }, + "parent": "naturesaura:altar", + "criteria": { + "triggered_in_code": { + "trigger": "minecraft:impossible" + } + } +} \ No newline at end of file diff --git a/src/main/resources/assets/naturesaura/lang/en_US.lang b/src/main/resources/assets/naturesaura/lang/en_US.lang index a3bb0253..09fcde03 100644 --- a/src/main/resources/assets/naturesaura/lang/en_US.lang +++ b/src/main/resources/assets/naturesaura/lang/en_US.lang @@ -116,6 +116,10 @@ advancement.naturesaura.sky_ingot=Sturdy and light advancement.naturesaura.sky_ingot.desc=Create an Ingot of the Skies using the Offering to the Gods advancement.naturesaura.aura_cache=Ca-ching advancement.naturesaura.aura_cache.desc=Create an Aura Cache to store Aura in your inventory +advancement.naturesaura.positive_imbalance=Luscious Surroundings +advancement.naturesaura.positive_imbalance.desc=Create enough Aura to cause positive imbalance effects +advancement.naturesaura.negative_imbalance=Deadly Day +advancement.naturesaura.negative_imbalance.desc=Drain enough Aura to cause negative imbalance effects command.naturesaura.aura.usage=/naaura diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/animal.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/animal.json index d67e3ec6..686669cb 100644 --- a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/animal.json +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/animal.json @@ -2,7 +2,7 @@ "name": "Increase of Fertility", "icon": "minecraft:egg", "category": "effects", - "advancement": "naturesaura:flower_generator", + "advancement": "naturesaura:positive_imbalance", "pages": [ { "type": "text", diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/breathlessness.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/breathlessness.json index 4e6f133f..9b84b5aa 100644 --- a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/breathlessness.json +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/breathlessness.json @@ -2,7 +2,7 @@ "name": "Breathlessness", "icon": "minecraft:wool", "category": "effects", - "advancement": "naturesaura:furnace_heater", + "advancement": "naturesaura:negative_imbalance", "pages": [ { "type": "text", diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/cache_recharge.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/cache_recharge.json index d9e44cc8..51d721c1 100644 --- a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/cache_recharge.json +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/cache_recharge.json @@ -2,7 +2,7 @@ "name": "Natural Storage", "icon": "naturesaura:aura_cache", "category": "effects", - "advancement": "naturesaura:aura_cache", + "advancement": "naturesaura:positive_imbalance", "pages": [ { "type": "text", diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/decay.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/decay.json index 7231f661..25f97b30 100644 --- a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/decay.json +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/decay.json @@ -2,7 +2,7 @@ "name": "Natural Decay", "icon": "naturesaura:decayed_leaves", "category": "effects", - "advancement": "naturesaura:furnace_heater", + "advancement": "naturesaura:negative_imbalance", "pages": [ { "type": "text", diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/effect_powder.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/effect_powder.json index f4f9b4cb..a7e39ba0 100644 --- a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/effect_powder.json +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/effect_powder.json @@ -2,7 +2,7 @@ "name": "Effect Powder", "icon": "naturesaura:effect_powder{effect:'naturesaura:plant_boost'}", "category": "effects", - "advancement": "naturesaura:aura_cache", + "advancement": "naturesaura:positive_imbalance", "priority": true, "pages": [ { diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/explosions.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/explosions.json index 0d4799b0..0f5e5f01 100644 --- a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/explosions.json +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/explosions.json @@ -2,7 +2,7 @@ "name": "Unstable Outbreak", "icon": "minecraft:tnt", "category": "effects", - "advancement": "naturesaura:furnace_heater", + "advancement": "naturesaura:negative_imbalance", "pages": [ { "type": "text", diff --git a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/plant_boost.json b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/plant_boost.json index db41c16e..e14dcd6a 100644 --- a/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/plant_boost.json +++ b/src/main/resources/assets/naturesaura/patchouli_books/book/en_us/entries/effects/plant_boost.json @@ -2,7 +2,7 @@ "name": "Vegetational Increase", "icon": "minecraft:wheat_seeds", "category": "effects", - "advancement": "naturesaura:flower_generator", + "advancement": "naturesaura:positive_imbalance", "pages": [ { "type": "text",