- 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

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