diff --git a/changelog.txt b/changelog.txt index c1830cf5..ad465c3b 100644 --- a/changelog.txt +++ b/changelog.txt @@ -4,6 +4,10 @@ Version 2.0.0-23 - Fixed "see through world" syndrome for most blocks - Fixed .obj models so that they will properly render while in-hand - Fixed routing node attaching logic +- Changed the growth behavior of the crystals +- Fixed Potion getting for various methods +- Started work on crystal automation ritual +- Finished first iteration of the iterator of AreaDescriptor (hehe) ------------------------------------------------------ Version 2.0.0-22 diff --git a/src/main/java/WayofTime/bloodmagic/ConfigHandler.java b/src/main/java/WayofTime/bloodmagic/ConfigHandler.java index 70b33af1..fa24e0d9 100644 --- a/src/main/java/WayofTime/bloodmagic/ConfigHandler.java +++ b/src/main/java/WayofTime/bloodmagic/ConfigHandler.java @@ -58,6 +58,7 @@ public class ConfigHandler public static boolean ritualZephyr; public static boolean ritualUpgradeRemove; public static boolean ritualArmourEvolve; + public static boolean ritualForsakenSoul; public static boolean cobblestoneRitual; public static boolean placerRitual; @@ -254,6 +255,7 @@ public class ConfigHandler ritualZephyr = config.get(category, "ritualZephyr", true).getBoolean(); ritualUpgradeRemove = config.get(category, "ritualRemove", true).getBoolean(); ritualArmourEvolve = config.get(category, "ritualArmourEvolve", true).getBoolean(); + ritualForsakenSoul = config.get(category, "ritualForsakenSoul", true).getBoolean(); cobblestoneRitual = config.get(category, "ritualCobblestone", true).getBoolean(); placerRitual = config.get(category, "ritualPlacer", true).getBoolean(); diff --git a/src/main/java/WayofTime/bloodmagic/api/network/SoulNetwork.java b/src/main/java/WayofTime/bloodmagic/api/network/SoulNetwork.java index 3aca5fb0..453ea6ee 100644 --- a/src/main/java/WayofTime/bloodmagic/api/network/SoulNetwork.java +++ b/src/main/java/WayofTime/bloodmagic/api/network/SoulNetwork.java @@ -5,9 +5,12 @@ import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.event.AddToNetworkEvent; import WayofTime.bloodmagic.api.event.SoulNetworkEvent; import WayofTime.bloodmagic.api.util.helper.PlayerHelper; + import com.google.common.base.Strings; + import lombok.Getter; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.MobEffects; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; @@ -177,7 +180,7 @@ public class SoulNetwork extends WorldSavedData { if (getPlayer() != null) { - getPlayer().addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("confusion"), 99)); + getPlayer().addPotionEffect(new PotionEffect(MobEffects.confusion, 99)); } } diff --git a/src/main/java/WayofTime/bloodmagic/api/ritual/AreaDescriptor.java b/src/main/java/WayofTime/bloodmagic/api/ritual/AreaDescriptor.java index 7a1999a5..a0ec4745 100644 --- a/src/main/java/WayofTime/bloodmagic/api/ritual/AreaDescriptor.java +++ b/src/main/java/WayofTime/bloodmagic/api/ritual/AreaDescriptor.java @@ -1,6 +1,5 @@ package WayofTime.bloodmagic.api.ritual; - import net.minecraft.util.math.AxisAlignedBB; import net.minecraft.util.math.BlockPos; @@ -26,6 +25,8 @@ public abstract class AreaDescriptor implements Iterator public abstract boolean isWithinArea(BlockPos pos); + public abstract void resetIterator(); + public static class Rectangle extends AreaDescriptor { private BlockPos minimumOffset; @@ -138,8 +139,7 @@ public abstract class AreaDescriptor implements Iterator @Override public boolean hasNext() { - // TODO Auto-generated method stub - return false; + return currentPosition == null || !(currentPosition.getX() + 1 == maximumOffset.getX() && currentPosition.getY() + 1 == maximumOffset.getY() && currentPosition.getZ() + 1 == maximumOffset.getZ()); } @Override @@ -148,15 +148,15 @@ public abstract class AreaDescriptor implements Iterator if (currentPosition != null) { int nextX = currentPosition.getX() + 1 >= maximumOffset.getX() ? minimumOffset.getX() : currentPosition.getX() + 1; - int nextZ = nextX == minimumOffset.getX() ? currentPosition.getZ() : (currentPosition.getZ() + 1 >= maximumOffset.getZ() ? minimumOffset.getZ() : currentPosition.getZ() + 1); - int nextY = nextZ == minimumOffset.getZ() ? currentPosition.getY() : currentPosition.getY() + 1; + int nextZ = nextX != minimumOffset.getX() ? currentPosition.getZ() : (currentPosition.getZ() + 1 >= maximumOffset.getZ() ? minimumOffset.getZ() : currentPosition.getZ() + 1); + int nextY = (nextZ != minimumOffset.getZ() || nextX != minimumOffset.getX()) ? currentPosition.getY() : (currentPosition.getY() + 1); currentPosition = new BlockPos(nextX, nextY, nextZ); } else { currentPosition = minimumOffset; } - return cachedPosition.add(currentPosition); + return currentPosition; } @Override @@ -164,6 +164,12 @@ public abstract class AreaDescriptor implements Iterator { } + + @Override + public void resetIterator() + { + currentPosition = null; + } } public static class HemiSphere extends AreaDescriptor @@ -280,6 +286,13 @@ public abstract class AreaDescriptor implements Iterator // TODO Auto-generated method stub } + + @Override + public void resetIterator() + { + // TODO Auto-generated method stub + + } } public static class Cross extends AreaDescriptor @@ -345,5 +358,26 @@ public abstract class AreaDescriptor implements Iterator { return null; } + + @Override + public void forEachRemaining(Consumer arg0) + { + // TODO Auto-generated method stub + + } + + @Override + public void remove() + { + // TODO Auto-generated method stub + + } + + @Override + public void resetIterator() + { + // TODO Auto-generated method stub + + } } } diff --git a/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerHelper.java b/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerHelper.java index 23c8e282..a0972f9b 100644 --- a/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerHelper.java +++ b/src/main/java/WayofTime/bloodmagic/api/util/helper/PlayerHelper.java @@ -1,9 +1,12 @@ package WayofTime.bloodmagic.api.util.helper; import WayofTime.bloodmagic.api.Constants; + import com.google.common.base.Strings; import com.google.common.collect.Lists; + import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.MobEffects; import net.minecraft.item.ItemStack; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; @@ -93,6 +96,6 @@ public class PlayerHelper if (player == null) return; - player.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("confusion"), 80)); + player.addPotionEffect(new PotionEffect(MobEffects.confusion, 80)); } } diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemDemonCrystal.java b/src/main/java/WayofTime/bloodmagic/item/ItemDemonCrystal.java index 96f38a7e..a80b863c 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemDemonCrystal.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemDemonCrystal.java @@ -96,7 +96,7 @@ public class ItemDemonCrystal extends Item implements IDiscreteDemonWill, IVaria @Override public double getDiscretization(ItemStack willStack) { - return 10; + return 50; } @Override diff --git a/src/main/java/WayofTime/bloodmagic/item/ItemRitualDiviner.java b/src/main/java/WayofTime/bloodmagic/item/ItemRitualDiviner.java index 97b640f3..14b330ca 100644 --- a/src/main/java/WayofTime/bloodmagic/item/ItemRitualDiviner.java +++ b/src/main/java/WayofTime/bloodmagic/item/ItemRitualDiviner.java @@ -13,7 +13,10 @@ import net.minecraft.item.ItemBlock; import net.minecraft.item.ItemStack; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.ActionResult; +import net.minecraft.util.EnumActionResult; import net.minecraft.util.EnumFacing; +import net.minecraft.util.EnumHand; import net.minecraft.util.EnumParticleTypes; import net.minecraft.util.math.BlockPos; import net.minecraft.world.World; @@ -66,7 +69,8 @@ public class ItemRitualDiviner extends Item implements IVariantProvider list.add(new ItemStack(id, 1, i)); } - public boolean onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumFacing side, float hitX, float hitY, float hitZ) + @Override + public EnumActionResult onItemUse(ItemStack stack, EntityPlayer player, World world, BlockPos pos, EnumHand hand, EnumFacing facing, float hitX, float hitY, float hitZ) { if (addRuneToRitual(stack, world, pos, player)) { @@ -74,10 +78,12 @@ public class ItemRitualDiviner extends Item implements IVariantProvider { spawnParticles(world, pos.up(), 15); } + + return EnumActionResult.SUCCESS; // TODO: Have the diviner automagically build the ritual } - return false; + return EnumActionResult.PASS; } /** @@ -183,6 +189,7 @@ public class ItemRitualDiviner extends Item implements IVariantProvider return false; } + @Override @SideOnly(Side.CLIENT) public void addInformation(ItemStack stack, EntityPlayer player, List tooltip, boolean advanced) { @@ -276,15 +283,17 @@ public class ItemRitualDiviner extends Item implements IVariantProvider } } - public ItemStack onItemRightClick(ItemStack stack, World world, EntityPlayer player) + @Override + public ActionResult onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand) { - if (player.isSneaking() && !world.isRemote) { cycleRitual(stack, player); + + return new ActionResult(EnumActionResult.SUCCESS, stack); } - return stack; + return new ActionResult(EnumActionResult.PASS, stack); } @Override diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerPoison.java b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerPoison.java index 57ab91b7..61e35a21 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerPoison.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/tracker/StatTrackerPoison.java @@ -6,6 +6,7 @@ import WayofTime.bloodmagic.api.livingArmour.StatTracker; import WayofTime.bloodmagic.livingArmour.LivingArmour; import WayofTime.bloodmagic.livingArmour.upgrade.LivingArmourUpgradePoisonResist; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.MobEffects; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.world.World; @@ -46,7 +47,7 @@ public class StatTrackerPoison extends StatTracker @Override public boolean onTick(World world, EntityPlayer player, LivingArmour livingArmour) { - if (player.isPotionActive(Potion.getPotionFromResourceLocation("poison"))) + if (player.isPotionActive(MobEffects.poison)) { totalPoisonTicks++; this.markDirty(); diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeDigging.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeDigging.java index ac744824..a0596b9c 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeDigging.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeDigging.java @@ -5,6 +5,7 @@ import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.livingArmour.LivingArmour; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.MobEffects; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; @@ -39,10 +40,10 @@ public class LivingArmourUpgradeDigging extends LivingArmourUpgrade { changeMap.put(livingArmour, false); - player.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("digSpeed"), digHasteTime[this.level], digHasteLevel[this.level], false, false)); + player.addPotionEffect(new PotionEffect(MobEffects.digSpeed, digHasteTime[this.level], digHasteLevel[this.level], false, false)); if (digSpeedTime[this.level] > 0) { - player.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("moveSpeed"), digSpeedTime[this.level], digSpeedLevel[this.level], false, false)); + player.addPotionEffect(new PotionEffect(MobEffects.moveSpeed, digSpeedTime[this.level], digSpeedLevel[this.level], false, false)); } } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradePoisonResist.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradePoisonResist.java index ea572e22..72624932 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradePoisonResist.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradePoisonResist.java @@ -6,6 +6,7 @@ import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import WayofTime.bloodmagic.util.ChatUtil; import WayofTime.bloodmagic.util.helper.TextHelper; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.MobEffects; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; @@ -27,12 +28,12 @@ public class LivingArmourUpgradePoisonResist extends LivingArmourUpgrade @Override public void onTick(World world, EntityPlayer player, ILivingArmour livingArmour) { - if (player.isPotionActive(Potion.getPotionFromResourceLocation("poison")) && poisonCooldown <= 0) + if (player.isPotionActive(MobEffects.poison) && poisonCooldown <= 0) { - PotionEffect eff = player.getActivePotionEffect(Potion.getPotionFromResourceLocation("poison")); + PotionEffect eff = player.getActivePotionEffect(MobEffects.poison); if (eff.getAmplifier() <= poisonMaxCure[this.level]) { - player.removePotionEffect(Potion.getPotionFromResourceLocation("poison")); + player.removePotionEffect(MobEffects.poison); poisonCooldown = poisonCooldownTime[this.level]; ChatUtil.sendNoSpam(player, TextHelper.localize(chatBase + "poisonRemove")); diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSolarPowered.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSolarPowered.java index dec022be..fb899e0d 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSolarPowered.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSolarPowered.java @@ -5,6 +5,7 @@ import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.MobEffects; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; @@ -50,7 +51,7 @@ public class LivingArmourUpgradeSolarPowered extends LivingArmourUpgrade if (fireResistTime[this.level] != 0 && counter % fireResistCooldown[this.level] == 0) { - player.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("fireResistance"), fireResistTime[this.level], 0, false, false)); + player.addPotionEffect(new PotionEffect(MobEffects.fireResistance, fireResistTime[this.level], 0, false, false)); } } } diff --git a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSpeed.java b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSpeed.java index 608f125a..70367d28 100644 --- a/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSpeed.java +++ b/src/main/java/WayofTime/bloodmagic/livingArmour/upgrade/LivingArmourUpgradeSpeed.java @@ -3,11 +3,14 @@ package WayofTime.bloodmagic.livingArmour.upgrade; import WayofTime.bloodmagic.api.Constants; import WayofTime.bloodmagic.api.livingArmour.ILivingArmour; import WayofTime.bloodmagic.api.livingArmour.LivingArmourUpgrade; + import com.google.common.collect.HashMultimap; import com.google.common.collect.Multimap; + import net.minecraft.entity.SharedMonsterAttributes; import net.minecraft.entity.ai.attributes.AttributeModifier; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.MobEffects; import net.minecraft.nbt.NBTTagCompound; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; @@ -41,12 +44,12 @@ public class LivingArmourUpgradeSpeed extends LivingArmourUpgrade { if (sprintSpeedTime[this.level] > 0) { - player.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("moveSpeed"), sprintSpeedTime[this.level], sprintSpeedLevel[this.level], false, false)); + player.addPotionEffect(new PotionEffect(MobEffects.moveSpeed, sprintSpeedTime[this.level], sprintSpeedLevel[this.level], false, false)); } - if (sprintRegenTime[this.level] > 0 && !player.isPotionActive(Potion.getPotionFromResourceLocation("regeneration"))) + if (sprintRegenTime[this.level] > 0 && !player.isPotionActive(MobEffects.regeneration)) { - player.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("regeneration"), sprintRegenTime[this.level], 0, false, false)); + player.addPotionEffect(new PotionEffect(MobEffects.regeneration, sprintRegenTime[this.level], 0, false, false)); } } } diff --git a/src/main/java/WayofTime/bloodmagic/registry/ModRituals.java b/src/main/java/WayofTime/bloodmagic/registry/ModRituals.java index 8d1ebd7a..b0e3ee79 100644 --- a/src/main/java/WayofTime/bloodmagic/registry/ModRituals.java +++ b/src/main/java/WayofTime/bloodmagic/registry/ModRituals.java @@ -39,6 +39,7 @@ public class ModRituals public static Ritual zephyrRitual; public static Ritual upgradeRemoveRitual; public static Ritual armourEvolveRitual; + public static Ritual forsakenSoulRitual; public static Ritual cobblestoneRitual; public static Ritual placerRitual; @@ -95,6 +96,8 @@ public class ModRituals RitualRegistry.registerRitual(upgradeRemoveRitual, ConfigHandler.ritualUpgradeRemove); armourEvolveRitual = new RitualArmourEvolve(); RitualRegistry.registerRitual(armourEvolveRitual, ConfigHandler.ritualArmourEvolve); + forsakenSoulRitual = new RitualForsakenSoul(); + RitualRegistry.registerRitual(forsakenSoulRitual, ConfigHandler.ritualForsakenSoul); cobblestoneRitual = new RitualCobblestone(); RitualRegistry.registerRitual(cobblestoneRitual, ConfigHandler.cobblestoneRitual); diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualForsakenSoul.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualForsakenSoul.java new file mode 100644 index 00000000..a0be8f73 --- /dev/null +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualForsakenSoul.java @@ -0,0 +1,135 @@ +package WayofTime.bloodmagic.ritual; + +import java.util.ArrayList; +import java.util.List; + +import net.minecraft.tileentity.TileEntity; +import net.minecraft.util.math.BlockPos; +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; +import WayofTime.bloodmagic.tile.TileDemonCrystal; + +public class RitualForsakenSoul extends Ritual +{ + public static final String CRYSTAL_RANGE = "altar"; + public static final String DAMAGE_RANGE = "damage"; + + public RitualForsakenSoul() + { + super("ritualForsakenSoul", 0, 40000, "ritual." + Constants.Mod.MODID + ".forsakenSoulRitual"); + addBlockRange(CRYSTAL_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-1, -1, -1), 3)); + addBlockRange(DAMAGE_RANGE, new AreaDescriptor.Rectangle(new BlockPos(-10, -10, -10), 21)); + } + + @Override + public void performRitual(IMasterRitualStone masterRitualStone) + { + World world = masterRitualStone.getWorldObj(); + SoulNetwork network = NetworkHelper.getSoulNetwork(masterRitualStone.getOwner()); + int currentEssence = network.getCurrentEssence(); + BlockPos pos = masterRitualStone.getBlockPos(); + + if (currentEssence < getRefreshCost()) + { + network.causeNauseaToPlayer(); + return; + } + + int maxEffects = 100; + int totalEffects = 0; + + List crystalList = new ArrayList(); + + AreaDescriptor crystalRange = getBlockRange(CRYSTAL_RANGE); + + crystalRange.resetIterator(); + while (crystalRange.hasNext()) + { + BlockPos nextPos = crystalRange.next().add(pos); + TileEntity tile = world.getTileEntity(nextPos); + if (tile instanceof TileDemonCrystal) + { + crystalList.add((TileDemonCrystal) tile); + } + } + + if (crystalList.size() > 0) + { + TileDemonCrystal chosenCrystal = crystalList.get(world.rand.nextInt(crystalList.size())); + chosenCrystal.growCrystalWithWillAmount(40, 1); + } +// if (tile instanceof TileAltar) +// { +// TileAltar tileAltar = (TileAltar) tile; +// +// AreaDescriptor damageRange = getBlockRange(DAMAGE_RANGE); +// AxisAlignedBB range = damageRange.getAABB(pos); +// +// List entities = world.getEntitiesWithinAABB(EntityLivingBase.class, range); +// +// for (EntityLivingBase entity : entities) +// { +// if (!ConfigHandler.wellOfSufferingBlacklist.contains(entity.getClass().getSimpleName())) +// { +// if (entity.isEntityAlive() && !(entity instanceof EntityPlayer)) +// { +// if (entity.attackEntityFrom(DamageSource.outOfWorld, 1)) +// { +// tileAltar.sacrificialDaggerCall(SACRIFICE_AMOUNT, true); +// +// totalEffects++; +// +// if (totalEffects >= maxEffects) +// { +// break; +// } +// } +// } +// } +// } +// } + + network.syphon(getRefreshCost() * totalEffects); + } + + @Override + public int getRefreshTime() + { + return 25; + } + + @Override + public int getRefreshCost() + { + return 0; + } + + @Override + public ArrayList getComponents() + { + ArrayList components = new ArrayList(); + + this.addCornerRunes(components, 1, 0, EnumRuneType.DUSK); + this.addCornerRunes(components, 2, -1, EnumRuneType.DUSK); + this.addParallelRunes(components, 2, -1, EnumRuneType.EARTH); + this.addCornerRunes(components, -3, -1, EnumRuneType.DUSK); + this.addOffsetRunes(components, 2, 4, -1, EnumRuneType.WATER); + this.addOffsetRunes(components, 1, 4, 0, EnumRuneType.WATER); + this.addParallelRunes(components, 4, 1, EnumRuneType.AIR); + + return components; + } + + @Override + public Ritual getNewCopy() + { + return new RitualForsakenSoul(); + } +} diff --git a/src/main/java/WayofTime/bloodmagic/ritual/RitualRegeneration.java b/src/main/java/WayofTime/bloodmagic/ritual/RitualRegeneration.java index 5ac6a8d5..c58d6691 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/RitualRegeneration.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/RitualRegeneration.java @@ -6,6 +6,7 @@ import WayofTime.bloodmagic.api.ritual.*; import WayofTime.bloodmagic.api.util.helper.NetworkHelper; import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.player.EntityPlayer; +import net.minecraft.init.MobEffects; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; import net.minecraft.util.math.AxisAlignedBB; @@ -55,7 +56,7 @@ public class RitualRegeneration extends Ritual float health = player.getHealth(); if (health <= player.getMaxHealth() - 1) { - player.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("regeneration"), 50, 0, false, false)); + player.addPotionEffect(new PotionEffect(MobEffects.regeneration, 50, 0, false, false)); totalEffects++; diff --git a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualResistance.java b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualResistance.java index 4552be32..ce7e1ec4 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualResistance.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualResistance.java @@ -6,6 +6,7 @@ import WayofTime.bloodmagic.api.ritual.imperfect.IImperfectRitualStone; import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.init.MobEffects; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; @@ -20,7 +21,7 @@ public class ImperfectRitualResistance extends ImperfectRitual public boolean onActivate(IImperfectRitualStone imperfectRitualStone, EntityPlayer player) { - player.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("resistance"), 1200, 1)); + player.addPotionEffect(new PotionEffect(MobEffects.fireResistance, 1200, 1)); return true; } diff --git a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualZombie.java b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualZombie.java index e00b5a7e..0e2fd1be 100644 --- a/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualZombie.java +++ b/src/main/java/WayofTime/bloodmagic/ritual/imperfect/ImperfectRitualZombie.java @@ -7,6 +7,7 @@ import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual; import net.minecraft.entity.monster.EntityZombie; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.init.MobEffects; import net.minecraft.potion.Potion; import net.minecraft.potion.PotionEffect; @@ -22,9 +23,9 @@ public class ImperfectRitualZombie extends ImperfectRitual { EntityZombie zombie = new EntityZombie(imperfectRitualStone.getRitualWorld()); zombie.setPosition(imperfectRitualStone.getRitualPos().getX() + 0.5, imperfectRitualStone.getRitualPos().getY() + 2.1, imperfectRitualStone.getRitualPos().getZ() + 0.5); - zombie.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("fireResistance"), 2000)); - zombie.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("damageBoost"), 20000, 7)); - zombie.addPotionEffect(new PotionEffect(Potion.getPotionFromResourceLocation("resistance"), 20000, 3)); + zombie.addPotionEffect(new PotionEffect(MobEffects.fireResistance, 2000)); + zombie.addPotionEffect(new PotionEffect(MobEffects.damageBoost, 20000, 7)); + zombie.addPotionEffect(new PotionEffect(MobEffects.resistance, 20000, 3)); if (!imperfectRitualStone.getRitualWorld().isRemote) imperfectRitualStone.getRitualWorld().spawnEntityInWorld(zombie); diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystal.java b/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystal.java index 563352fa..cc2c829c 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystal.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileDemonCrystal.java @@ -1,10 +1,5 @@ package WayofTime.bloodmagic.tile; -import WayofTime.bloodmagic.api.soul.DemonWillHolder; -import WayofTime.bloodmagic.api.soul.EnumDemonWillType; -import WayofTime.bloodmagic.api.soul.IDemonWillConduit; -import WayofTime.bloodmagic.block.BlockDemonCrystal; -import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; import lombok.Getter; import lombok.Setter; import net.minecraft.block.state.IBlockState; @@ -20,14 +15,18 @@ import net.minecraft.util.ITickable; import net.minecraft.util.math.BlockPos; import net.minecraft.util.math.MathHelper; import net.minecraft.world.World; +import WayofTime.bloodmagic.api.soul.DemonWillHolder; +import WayofTime.bloodmagic.api.soul.EnumDemonWillType; +import WayofTime.bloodmagic.block.BlockDemonCrystal; +import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler; -public class TileDemonCrystal extends TileEntity implements ITickable, IDemonWillConduit +public class TileDemonCrystal extends TileEntity implements ITickable { public DemonWillHolder holder = new DemonWillHolder(); public final int maxWill = 100; public final double drainRate = 1; - public static final double sameWillConversionRate = 5; - public static final double defaultWillConversionRate = 50; + public static final double sameWillConversionRate = 50; + public static final double defaultWillConversionRate = 100; public static final double timeDelayForWrongWill = 0.6; public double progressToNextCrystal = 0; @@ -84,12 +83,7 @@ public class TileDemonCrystal extends TileEntity implements ITickable, IDemonWil } } - if (progressToNextCrystal >= 1) - { - progressToNextCrystal--; - crystalCount++; - markDirty(); - } + checkAndGrowCrystal(); } // if (worldObj.getWorldTime() % 200 == 0) @@ -99,6 +93,59 @@ public class TileDemonCrystal extends TileEntity implements ITickable, IDemonWil // } } + /** + * Encourages the crystal to grow by a large percentage by telling it to + * drain will from the aura. + * + * @param willDrain + * The amount of drain that is needed for the crystal to grow + * successfully for the desired amount. Can be more than the base + * amount. + * @param progressPercentage + * @return percentage actually grown. + */ + public double growCrystalWithWillAmount(double willDrain, double progressPercentage) + { + if (crystalCount >= 7) + { + return 0; + } + + EnumDemonWillType type = EnumDemonWillType.values()[this.getBlockMetadata()]; + + double value = WorldDemonWillHandler.getCurrentWill(worldObj, pos, type); + double percentDrain = willDrain <= 0 ? 1 : Math.min(1, value / willDrain); + if (percentDrain <= 0) + { + return 0; + } + + // Verification that you can actually drain the will from this chunk, for future proofing. + WorldDemonWillHandler.drainWill(worldObj, pos, type, percentDrain * willDrain, true); + progressToNextCrystal += percentDrain * progressPercentage; + + checkAndGrowCrystal(); + + return percentDrain * progressPercentage; + } + + public void checkAndGrowCrystal() + { + if (progressToNextCrystal >= 1) + { + progressToNextCrystal--; + crystalCount++; + IBlockState thisState = worldObj.getBlockState(pos); + worldObj.notifyBlockUpdate(pos, thisState, thisState, 3); + markDirty(); + } + } + + public double getMaxWillForCrystal() + { + return 50; + } + public boolean dropSingleCrystal() { if (!worldObj.isRemote && crystalCount > 1) @@ -149,71 +196,6 @@ public class TileDemonCrystal extends TileEntity implements ITickable, IDemonWil tag.setDouble("progress", progressToNextCrystal); } - // IDemonWillConduit - - @Override - public int getWeight() - { - return 10; - } - - @Override - public double fillDemonWill(EnumDemonWillType type, double amount, boolean doFill) - { - if (amount <= 0) - { - return 0; - } - - if (!canFill(type)) - { - return 0; - } - - if (!doFill) - { - return Math.min(maxWill - holder.getWill(type), amount); - } - - return holder.addWill(type, amount, maxWill); - } - - @Override - public double drainDemonWill(EnumDemonWillType type, double amount, boolean doDrain) - { - double drained = amount; - double current = holder.getWill(type); - if (current < drained) - { - drained = current; - } - - if (doDrain) - { - return holder.drainWill(type, amount); - } - - return drained; - } - - @Override - public boolean canFill(EnumDemonWillType type) - { - return true; - } - - @Override - public boolean canDrain(EnumDemonWillType type) - { - return true; - } - - @Override - public double getCurrentWill(EnumDemonWillType type) - { - return holder.getWill(type); - } - @Override public boolean shouldRefresh(World world, BlockPos pos, IBlockState oldState, IBlockState newState) { diff --git a/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java b/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java index ac42cfa4..ce758aab 100644 --- a/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java +++ b/src/main/java/WayofTime/bloodmagic/tile/TileMasterRitualStone.java @@ -123,6 +123,7 @@ public class TileMasterRitualStone extends TileEntity implements IMasterRitualSt activationCrystal = NBTHelper.checkNBT(activationCrystal); String crystalOwner = activationCrystal.getTagCompound().getString(Constants.NBT.OWNER_UUID); + crystalOwner = PlayerHelper.getUUIDFromPlayer(activator).toString(); //Temporary patch job if (!Strings.isNullOrEmpty(crystalOwner) && ritual != null) { diff --git a/src/main/java/WayofTime/bloodmagic/util/Utils.java b/src/main/java/WayofTime/bloodmagic/util/Utils.java index d0fcf104..ba9d9397 100644 --- a/src/main/java/WayofTime/bloodmagic/util/Utils.java +++ b/src/main/java/WayofTime/bloodmagic/util/Utils.java @@ -3,7 +3,9 @@ package WayofTime.bloodmagic.util; import WayofTime.bloodmagic.api.altar.EnumAltarComponent; import WayofTime.bloodmagic.registry.ModBlocks; import WayofTime.bloodmagic.tile.TileInventory; + import com.google.common.collect.Iterables; + import net.minecraft.block.Block; import net.minecraft.block.state.IBlockState; import net.minecraft.enchantment.EnchantmentHelper; @@ -11,6 +13,7 @@ import net.minecraft.entity.EntityLivingBase; import net.minecraft.entity.item.EntityItem; import net.minecraft.entity.player.EntityPlayer; import net.minecraft.init.Blocks; +import net.minecraft.init.MobEffects; import net.minecraft.inventory.IInventory; import net.minecraft.inventory.ISidedInventory; import net.minecraft.item.Item; @@ -212,7 +215,7 @@ public class Utils public static float applyPotionDamageCalculations(EntityLivingBase attackedEntity, DamageSource source, float damage) { - Potion resistance = Potion.getPotionFromResourceLocation("resistance"); + Potion resistance = MobEffects.resistance; if (source.isDamageAbsolute()) {