From b3f965cbe3209acda8561a75c48d327c28c32e94 Mon Sep 17 00:00:00 2001 From: WayofTime Date: Sat, 9 Jan 2016 18:51:55 -0500 Subject: [PATCH] Added Ritual of the Satiated Stomach --- changelog.txt | 15 +- .../bloodmagic/registry/ModRituals.java | 3 + .../bloodmagic/ritual/RitualFullStomach.java | 132 ++++++++++++++++++ .../assets/bloodmagic/lang/en_US.lang | 2 + 4 files changed, 145 insertions(+), 7 deletions(-) create mode 100644 src/main/java/WayofTime/bloodmagic/ritual/RitualFullStomach.java diff --git a/changelog.txt b/changelog.txt index 1f23e83d..8ae38c58 100644 --- a/changelog.txt +++ b/changelog.txt @@ -11,15 +11,16 @@ Version 2.0.0-4 - Harvest ritual - Magnetism ritual - Crushing ritual + - Full Stomach ritual -- Added parts for the new Soul System - - Added the Monster Soul - - Added the Soul Sword, which will be powered by consuming souls - - Added a Lesser Soul Gem in order to hold onto more souls +- Added parts for the new Demon Will System + - Added the Demon Will item + - Added the Sentient Sword, which will be powered by consuming demon will + - Added a Lesser Tartaric Gem in order to hold onto more will - SSSSSSSSoooooooouuuuuuulllllllllsssssss - - Added Soul Forge block - - Added soul snare and recipe - has 10% chance for monster to drop its soul - - Added bow + - Added Hellfire Forge block + - Added rudimentary snare and recipe - has 25% chance for monster to drop its soul + - Added Sentient Bow - Added Sentient Armour - Fixed binding of togglable sigils diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModRituals.java b/src/main/java/WayofTime/bloodmagic/registry/ModRituals.java index b3862dd2..ee780c76 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModRituals.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModRituals.java @@ -26,6 +26,7 @@ public class ModRituals public static Ritual harvestRitual; public static Ritual magneticRitual; public static Ritual crushingRitual; + public static Ritual stomachRitual; public static ImperfectRitual imperfectNight; public static ImperfectRitual imperfectRain; @@ -57,6 +58,8 @@ public class ModRituals RitualRegistry.registerRitual(magneticRitual, magneticRitual.getName()); crushingRitual = new RitualCrushing(); RitualRegistry.registerRitual(crushingRitual, crushingRitual.getName()); + stomachRitual = new RitualFullStomach(); + RitualRegistry.registerRitual(stomachRitual, stomachRitual.getName()); } public static void initImperfectRituals() diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualFullStomach.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualFullStomach.java new file mode 100644 index 00000000..e2eaad30 --- /dev/null +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualFullStomach.java @@ -0,0 +1,132 @@ +package WayofTime.bloodmagic.ritual; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.inventory.IInventory; +import net.minecraft.item.ItemFood; +import net.minecraft.item.ItemStack; +import net.minecraft.nbt.NBTTagCompound; +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.BlockPos; +import net.minecraft.util.FoodStats; +import net.minecraft.world.World; +import WayofTime.bloodmagic.api.Constants; +import WayofTime.bloodmagic.api.network.SoulNetwork; +import WayofTime.bloodmagic.api.ritual.AreaDescriptor; +import WayofTime.bloodmagic.api.ritual.EnumRuneType; +import WayofTime.bloodmagic.api.ritual.IMasterRitualStone; +import WayofTime.bloodmagic.api.ritual.Ritual; +import WayofTime.bloodmagic.api.ritual.RitualComponent; +import WayofTime.bloodmagic.api.util.helper.NetworkHelper; + +public class RitualFullStomach extends Ritual +{ + public static final String FILL_RANGE = "fillRange"; + + public RitualFullStomach() + { + super("ritualFullStomach", 0, 100000, "ritual." + Constants.Mod.MODID + ".fullStomachRitual"); + addBlockRange(FILL_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-25, -25, -25), 51)); + } + + @Override + public void performRitual(IMasterRitualStone masterRitualStone) + { + World world = masterRitualStone.getWorldObj(); + SoulNetwork network = NetworkHelper.getSoulNetwork(masterRitualStone.getOwner()); + int currentEssence = network.getCurrentEssence(); + + BlockPos pos = masterRitualStone.getBlockPos(); + + int maxEffects = currentEssence / getRefreshCost(); + int totalEffects = 0; + + TileEntity tile = world.getTileEntity(pos.up()); + if (!(tile instanceof IInventory)) + { + return; + } + + IInventory inventory = (IInventory) tile; + + int lastSlot = 0; + + AreaDescriptor fillingRange = getBlockRange(FILL_RANGE); + + List playerList = world.getEntitiesWithinAABB(EntityPlayer.class, fillingRange.getAABB(pos)); + + for (EntityPlayer player : playerList) + { + FoodStats foodStats = player.getFoodStats(); + float satLevel = foodStats.getSaturationLevel(); + + for (int i = lastSlot; i < inventory.getSizeInventory(); i++) + { + ItemStack stack = inventory.getStackInSlot(i); + if (stack != null && stack.getItem() instanceof ItemFood) + { + ItemFood foodItem = (ItemFood) stack.getItem(); + + int healAmount = foodItem.getHealAmount(stack); + float saturationAmount = foodItem.getSaturationModifier(stack) * healAmount * 2.0f; + + if (saturationAmount + satLevel <= 20) + { + NBTTagCompound nbt = new NBTTagCompound(); + foodStats.writeNBT(nbt); + nbt.setFloat("foodSaturationLevel", saturationAmount + satLevel); + foodStats.readNBT(nbt); + + inventory.decrStackSize(i, 1); + totalEffects++; + lastSlot = i; + break; + } + } + } + + if (totalEffects >= maxEffects) + { + network.causeNauseaToPlayer(); + + break; + } + } + + network.syphon(getRefreshCost() * totalEffects); + } + + @Override + public int getRefreshTime() + { + return 20; + } + + @Override + public int getRefreshCost() + { + return 100; + } + + @Override + public ArrayList getComponents() + { + ArrayList components = new ArrayList(); + + this.addParallelRunes(components, 3, 0, EnumRuneType.FIRE); + this.addCornerRunes(components, 1, 0, EnumRuneType.AIR); + this.addOffsetRunes(components, 1, 2, 0, EnumRuneType.AIR); + this.addCornerRunes(components, 4, 0, EnumRuneType.WATER); + this.addOffsetRunes(components, 4, 3, 0, EnumRuneType.EARTH); + + return components; + } + + @Override + public Ritual getNewCopy() + { + return new RitualFullStomach(); + } +} diff --git a/src/main/resources/assets/bloodmagic/lang/en_US.lang b/src/main/resources/assets/bloodmagic/lang/en_US.lang index 512f1ae2..cdaa68c9 100644 --- a/src/main/resources/assets/bloodmagic/lang/en_US.lang +++ b/src/main/resources/assets/bloodmagic/lang/en_US.lang @@ -264,6 +264,8 @@ ritual.BloodMagic.featheredKnifeRitual=Ritual of the Feathered Knife ritual.BloodMagic.regenerationRitual=Ritual of Regeneration ritual.BloodMagic.harvestRitual=Reap of the Harvest Moon ritual.BloodMagic.magneticRitual=Ritual of Magnetism +ritual.BloodMagic.crushingRitual=Ritual of the Crusher +ritual.BloodMagic.fullStomachRitual=Ritual of the Satiated Stomach # Chat chat.BloodMagic.altarMaker.setTier=Set Tier to: %d