From 7435d498245840f9a72ade48c30d23879489b35a Mon Sep 17 00:00:00 2001 From: Tobias Gremeyer Date: Mon, 31 Dec 2018 01:11:54 +0100 Subject: [PATCH] Refactored Cry of Eternal Soul for BM2. (#1488) * Refactored Cry of Eternal Soul for BM2. * Added entries for the english translation strings * Ticket handling fix * Using more comprehensive `addOffsetRunes` instead of `addRune`'s * Update src/main/java/WayofTime/bloodmagic/ritual/types/RitualEternalSoul.java Co-Authored-By: Iorce * Update src/main/java/WayofTime/bloodmagic/ritual/types/RitualEternalSoul.java Co-Authored-By: Iorce * Cleanup round 1 * cleanup round 2 --- .../ritual/types/RitualEternalSoul.java | 124 ++++++++++++++++++ .../assets/bloodmagic/lang/en_US.lang | 4 + 2 files changed, 128 insertions(+) create mode 100644 src/main/java/WayofTime/bloodmagic/ritual/types/RitualEternalSoul.java diff --git a/src/main/java/WayofTime/bloodmagic/ritual/types/RitualEternalSoul.java b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualEternalSoul.java new file mode 100644 index 00000000..01ff6e08 --- /dev/null +++ b/src/main/java/WayofTime/bloodmagic/ritual/types/RitualEternalSoul.java @@ -0,0 +1,124 @@ +package WayofTime.bloodmagic.ritual.types; + +import WayofTime.bloodmagic.BloodMagic; +import WayofTime.bloodmagic.altar.IBloodAltar; +import WayofTime.bloodmagic.block.BlockLifeEssence; +import WayofTime.bloodmagic.ritual.*; +import WayofTime.bloodmagic.util.helper.NetworkHelper; +import WayofTime.bloodmagic.util.helper.PlayerHelper; +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.util.math.AxisAlignedBB; +import net.minecraft.util.math.BlockPos; +import net.minecraft.world.World; +import net.minecraftforge.fluids.FluidStack; +import net.minecraftforge.fluids.capability.IFluidHandler; + +import java.util.List; +import java.util.UUID; +import java.util.function.Consumer; + +@RitualRegister("eternal_soul") +public class RitualEternalSoul extends Ritual { + + + private IBloodAltar altar = null; + + public RitualEternalSoul() { + super("ritualEternalSoul", 2, 2000000, "ritual." + BloodMagic.MODID + ".eternalSoulRitual"); + } + + @Override + public void performRitual(IMasterRitualStone masterRitualStone) { + UUID owner = masterRitualStone.getOwner(); + int currentEssence = NetworkHelper.getSoulNetwork(owner).getCurrentEssence(); + World world = masterRitualStone.getWorldObj(); + BlockPos pos = masterRitualStone.getBlockPos(); + + if (this.altar == null) { + for (int i = -5; i <= 5; i++) { + for (int j = -5; j <= 5; j++) { + for (int k = -10; k <= 10; k++) { + if (world.getTileEntity(new BlockPos(pos.getX() + i, pos.getY() + j, pos.getZ() + k)) instanceof IBloodAltar) { + this.altar = (IBloodAltar) world.getTileEntity(new BlockPos(pos.getX() + i, pos.getY() + j, pos.getZ() + k)); + } + } + } + } + } + if (!(this.altar instanceof IFluidHandler)) + return; + + int horizontalRange = 15; + int verticalRange = 20; + + List list = world.getEntitiesWithinAABB(EntityPlayer.class, + new AxisAlignedBB(pos.getX() - 0.5f, pos.getY() - 0.5f, pos.getZ() - 0.5f, + pos.getX() + 0.5f, pos.getY() + 0.5f, pos.getZ() + 0.5f) + .expand(horizontalRange, verticalRange, horizontalRange)); + + EntityPlayer entityOwner = null; + for (EntityPlayer player : list) { + if (PlayerHelper.getUUIDFromPlayer(player) == owner) + entityOwner = player; + } + + int fillAmount = Math.min(currentEssence / 2, ((IFluidHandler) this.altar).fill(new FluidStack(BlockLifeEssence.getLifeEssence(), 10000), false)); + + ((IFluidHandler) this.altar).fill(new FluidStack(BlockLifeEssence.getLifeEssence(), fillAmount), true); + + if (entityOwner != null && entityOwner.getHealth() > 2.0f && fillAmount != 0) + entityOwner.setHealth(2.0f); + + masterRitualStone.getOwnerNetwork().syphon(masterRitualStone.ticket(fillAmount * 2)); + + } + + + @Override + public int getRefreshCost() { + return 0; + } + + @Override + public int getRefreshTime() { + return 1; + } + + @Override + public void gatherComponents(Consumer components) { + addCornerRunes(components, 0, 1, EnumRuneType.FIRE); + + for (int i = 0; i < 4; i++) { + addCornerRunes(components, 2, i, EnumRuneType.AIR); + } + + addCornerRunes(components, 4, 1, EnumRuneType.EARTH); + + addOffsetRunes(components, 3, 4, 1, EnumRuneType.EARTH); + + + for (int i = 0; i < 2; i++) { + addCornerRunes(components, 4, i + 2, EnumRuneType.WATER); + } + + addCornerRunes(components, 4, 4, EnumRuneType.DUSK); + + addOffsetRunes(components, 6, 5, 0, EnumRuneType.FIRE); + + + for (int i = 0; i < 2; i++) { + addCornerRunes(components, 6, i, EnumRuneType.FIRE); + } + + for (int i = 0; i < 3; i++) { + addCornerRunes(components, 6, i + 2, EnumRuneType.BLANK); + } + + addCornerRunes(components, 6, 5, EnumRuneType.DUSK); + } + + @Override + public Ritual getNewCopy() { + return new RitualEternalSoul(); + } +} diff --git a/src/main/resources/assets/bloodmagic/lang/en_US.lang b/src/main/resources/assets/bloodmagic/lang/en_US.lang index 4e51e06b..a1a159b0 100644 --- a/src/main/resources/assets/bloodmagic/lang/en_US.lang +++ b/src/main/resources/assets/bloodmagic/lang/en_US.lang @@ -618,6 +618,7 @@ ritual.bloodmagic.altarBuilderRitual=The Assembly of the High Altar ritual.bloodmagic.portalRitual=The Gate of the Fold ritual.bloodmagic.downgradeRitual=Penance of the Leadened Soul ritual.bloodmagic.crystalSplitRitual=Resonance of the Faceted Crystal +ritual.bloodmagic.eternalSoulRitual=Cry of the Eternal Soul ritual.bloodmagic.waterRitual.info=Generates a source of water from the master ritual stone. ritual.bloodmagic.lavaRitual.info=Generates a source of lava from the master ritual stone. @@ -748,6 +749,9 @@ ritual.bloodmagic.downgradeRitual.dialogue.slowHeal.100=Unlike my comrades, I of ritual.bloodmagic.downgradeRitual.dialogue.slowHeal.300=Although your wounds may heal, they will do so slowly if you accept my "offering," and the stings of battle will plague you even more. ritual.bloodmagic.downgradeRitual.dialogue.slowHeal.500=So think carefully before you rush into something that you may regret, since even though your cup may be empty it will be almost impossible to fill once more... + +ritual.bloodmagic.eternalSoulRitual.info=Capable of transferring Life Essence from a Network back into an Altar at a cost. + # Chat chat.bloodmagic.altarMaker.setTier=Set Tier to: %d chat.bloodmagic.altarMaker.building=Building a Tier %d Altar