From 492ea2eec985b753cd65ec5a7dfe5910d317eba1 Mon Sep 17 00:00:00 2001 From: Ellpeck Date: Sat, 1 Feb 2020 17:22:34 +0100 Subject: [PATCH] added nature's heal --- build.gradle | 4 ++- .../de/ellpeck/naturesaura/compat/Compat.java | 2 ++ .../EnchantibilityAuraMending.java | 36 +++++++++++++++++++ .../enchantibility/EnchantibilityCompat.java | 34 ++++++++++++++++++ .../assets/naturesaura/lang/en_us.json | 3 +- .../using/aura_mending_enchantability.json | 17 +++++++++ 6 files changed, 94 insertions(+), 2 deletions(-) create mode 100644 src/main/java/de/ellpeck/naturesaura/compat/enchantibility/EnchantibilityAuraMending.java create mode 100644 src/main/java/de/ellpeck/naturesaura/compat/enchantibility/EnchantibilityCompat.java create mode 100644 src/main/resources/data/naturesaura/patchouli_books/book/en_us/entries/using/aura_mending_enchantability.json diff --git a/build.gradle b/build.gradle index c1bf131e..30913d87 100644 --- a/build.gradle +++ b/build.gradle @@ -92,7 +92,7 @@ repositories { } dependencies { - minecraft 'net.minecraftforge:forge:1.15.2-31.0.4' + minecraft 'net.minecraftforge:forge:1.15.2-31.0.14' compileOnly fg.deobf("mezz.jei:jei-1.15.2:6.0.0.2:api") runtimeOnly fg.deobf("mezz.jei:jei-1.15.2:6.0.0.2") @@ -102,6 +102,8 @@ dependencies { runtimeOnly fg.deobf("top.theillusivec4.curios:curios:FORGE-1.15.2-2.0-beta2") compileOnly fg.deobf("top.theillusivec4.curios:curios:FORGE-1.15.2-2.0-beta2:api") + + compile fileTree(dir: 'lib', include: '*.jar') } // Example for how to get properties into the manifest for reading by the runtime.. diff --git a/src/main/java/de/ellpeck/naturesaura/compat/Compat.java b/src/main/java/de/ellpeck/naturesaura/compat/Compat.java index 524b24e9..bcae9af6 100644 --- a/src/main/java/de/ellpeck/naturesaura/compat/Compat.java +++ b/src/main/java/de/ellpeck/naturesaura/compat/Compat.java @@ -3,6 +3,7 @@ package de.ellpeck.naturesaura.compat; import com.google.common.collect.ImmutableMap; import de.ellpeck.naturesaura.NaturesAura; import de.ellpeck.naturesaura.compat.crafttweaker.CraftTweakerCompat; +import de.ellpeck.naturesaura.compat.enchantibility.EnchantibilityCompat; import de.ellpeck.naturesaura.compat.patchouli.PatchouliCompat; import de.ellpeck.naturesaura.data.ItemTagProvider; import net.minecraftforge.fml.ModList; @@ -18,6 +19,7 @@ public final class Compat { .put("patchouli", PatchouliCompat::new) .put("curios", CuriosCompat::new) .put("crafttweaker", CraftTweakerCompat::new) + .put("enchantability", EnchantibilityCompat::new) .build(); private static final Map MODULES = new HashMap<>(); diff --git a/src/main/java/de/ellpeck/naturesaura/compat/enchantibility/EnchantibilityAuraMending.java b/src/main/java/de/ellpeck/naturesaura/compat/enchantibility/EnchantibilityAuraMending.java new file mode 100644 index 00000000..e53575fa --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/compat/enchantibility/EnchantibilityAuraMending.java @@ -0,0 +1,36 @@ +package de.ellpeck.naturesaura.compat.enchantibility; + +import de.ellpeck.naturesaura.NaturesAura; +import de.ellpeck.naturesaura.api.NaturesAuraAPI; +import net.minecraft.enchantment.Enchantment; +import net.minecraft.entity.player.PlayerEntity; +import net.minecraft.util.ResourceLocation; +import net.minecraftforge.event.TickEvent; +import net.minecraftforge.event.TickEvent.PlayerTickEvent; +import quarris.enchantability.api.enchants.AbstractEnchantEffect; + +public class EnchantibilityAuraMending extends AbstractEnchantEffect { + + public static final ResourceLocation RES = new ResourceLocation(NaturesAura.MOD_ID, "aura_mending"); + + public EnchantibilityAuraMending(PlayerEntity player, Enchantment enchantment, int level) { + super(player, enchantment, level); + } + + public static void onPlayerTick(EnchantibilityAuraMending enchant, PlayerTickEvent event) { + if (event.phase != TickEvent.Phase.END) + return; + if (event.player.world.isRemote || event.player.world.getGameTime() % 10 != 0) + return; + if (!event.player.isShiftKeyDown() || event.player.getHealth() >= event.player.getMaxHealth()) + return; + int usage = 5000; + if (NaturesAuraAPI.instance().extractAuraFromPlayer(event.player, usage, false)) + event.player.heal(1); + } + + @Override + public ResourceLocation getName() { + return RES; + } +} diff --git a/src/main/java/de/ellpeck/naturesaura/compat/enchantibility/EnchantibilityCompat.java b/src/main/java/de/ellpeck/naturesaura/compat/enchantibility/EnchantibilityCompat.java new file mode 100644 index 00000000..b0375ad7 --- /dev/null +++ b/src/main/java/de/ellpeck/naturesaura/compat/enchantibility/EnchantibilityCompat.java @@ -0,0 +1,34 @@ +package de.ellpeck.naturesaura.compat.enchantibility; + +import de.ellpeck.naturesaura.compat.ICompat; +import de.ellpeck.naturesaura.data.ItemTagProvider; +import de.ellpeck.naturesaura.enchant.ModEnchantments; +import net.minecraftforge.event.TickEvent.PlayerTickEvent; +import quarris.enchantability.api.EnchantabilityApi; +import quarris.enchantability.api.EnchantabilityApi.IInternals; + +import java.util.Collections; + +public class EnchantibilityCompat implements ICompat { + @Override + public void preInit() { + IInternals api = EnchantabilityApi.getInstance(); + api.registerEnchantEffect(EnchantibilityAuraMending.RES, ModEnchantments.AURA_MENDING, EnchantibilityAuraMending::new); + api.registerEffectComponent(EnchantibilityAuraMending.RES, PlayerTickEvent.class, EnchantibilityAuraMending::onPlayerTick, e -> Collections.singletonList(e.player)); + } + + @Override + public void preInitClient() { + + } + + @Override + public void postInit() { + + } + + @Override + public void addItemTags(ItemTagProvider provider) { + + } +} diff --git a/src/main/resources/assets/naturesaura/lang/en_us.json b/src/main/resources/assets/naturesaura/lang/en_us.json index 39e38b9d..52cbdf13 100644 --- a/src/main/resources/assets/naturesaura/lang/en_us.json +++ b/src/main/resources/assets/naturesaura/lang/en_us.json @@ -172,5 +172,6 @@ "entity.naturesaura.effect_inhibitor": "Effect Powder", "entity.naturesaura.mover_cart": "Aura Attraction Cart", "enchantment.naturesaura.aura_mending": "Nature's Mend", - "enchantment.naturesaura.aura_mending.desc": "Nature's Aura Enchantment" + "enchantment.naturesaura.aura_mending.desc": "Nature's Aura Enchantment", + "naturesaura:aura_mending.enchant.desc": "Heals the Player Using Aura" } \ No newline at end of file diff --git a/src/main/resources/data/naturesaura/patchouli_books/book/en_us/entries/using/aura_mending_enchantability.json b/src/main/resources/data/naturesaura/patchouli_books/book/en_us/entries/using/aura_mending_enchantability.json new file mode 100644 index 00000000..b07be5a2 --- /dev/null +++ b/src/main/resources/data/naturesaura/patchouli_books/book/en_us/entries/using/aura_mending_enchantability.json @@ -0,0 +1,17 @@ +{ + "name": "Nature's Heal", + "icon": "minecraft:enchanted_book", + "category": "using", + "advancement": "naturesaura:infused_tools", + "flag": "mod:enchantability", + "pages": [ + { + "type": "text", + "text": "Any sort of tool being repaired through the use of $(aura) is good and well, until the magical botanist comes in contact with viscious enemies or dangerous heights. At that point, the ability to $(thing)heal oneself$() would certainly be of use." + }, + { + "type": "text", + "text": "A $(item)Nature's Mend$() enchanted book, once obtained, can be inserted into an $(item)Ender Chest$()'s enchantment slots to gain the $(item)Nature's Heal$() effect, which will, while $(thing)sneaking$(), top off the user's health slowly while draining $(aura) from an $(aura) container in their inventory." + } + ] +} \ No newline at end of file