- 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
This commit is contained in:
WayofTime 2016-03-24 14:11:05 -04:00
parent 78ed6a18e4
commit f0730791f7
20 changed files with 298 additions and 109 deletions

View file

@ -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

View file

@ -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();

View file

@ -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));
}
}

View file

@ -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<BlockPos>
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<BlockPos>
@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<BlockPos>
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<BlockPos>
{
}
@Override
public void resetIterator()
{
currentPosition = null;
}
}
public static class HemiSphere extends AreaDescriptor
@ -280,6 +286,13 @@ public abstract class AreaDescriptor implements Iterator<BlockPos>
// 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<BlockPos>
{
return null;
}
@Override
public void forEachRemaining(Consumer<? super BlockPos> arg0)
{
// TODO Auto-generated method stub
}
@Override
public void remove()
{
// TODO Auto-generated method stub
}
@Override
public void resetIterator()
{
// TODO Auto-generated method stub
}
}
}

View file

@ -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));
}
}

View file

@ -96,7 +96,7 @@ public class ItemDemonCrystal extends Item implements IDiscreteDemonWill, IVaria
@Override
public double getDiscretization(ItemStack willStack)
{
return 10;
return 50;
}
@Override

View file

@ -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<String> 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<ItemStack> onItemRightClick(ItemStack stack, World world, EntityPlayer player, EnumHand hand)
{
if (player.isSneaking() && !world.isRemote)
{
cycleRitual(stack, player);
return new ActionResult<ItemStack>(EnumActionResult.SUCCESS, stack);
}
return stack;
return new ActionResult<ItemStack>(EnumActionResult.PASS, stack);
}
@Override

View file

@ -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();

View file

@ -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));
}
}
}

View file

@ -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"));

View file

@ -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));
}
}
}

View file

@ -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));
}
}
}

View file

@ -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);

View file

@ -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<TileDemonCrystal> crystalList = new ArrayList<TileDemonCrystal>();
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<EntityLivingBase> 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<RitualComponent> getComponents()
{
ArrayList<RitualComponent> components = new ArrayList<RitualComponent>();
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();
}
}

View file

@ -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++;

View file

@ -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;
}

View file

@ -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);

View file

@ -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)
{

View file

@ -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)
{

View file

@ -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())
{