Fully implemented discrete demon will, which means the demon crystals can be inserted into demon crucibles to create will.

This commit is contained in:
WayofTime 2016-02-27 16:36:56 -05:00
parent 83c1497609
commit 620023d098
13 changed files with 250 additions and 46 deletions

View file

@ -3,15 +3,18 @@ package WayofTime.bloodmagic.tile;
import java.util.HashMap;
import java.util.Map.Entry;
import net.minecraft.inventory.ISidedInventory;
import net.minecraft.item.ItemStack;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.util.EnumFacing;
import net.minecraft.util.ITickable;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import WayofTime.bloodmagic.api.soul.IDemonWillConduit;
import WayofTime.bloodmagic.api.soul.IDemonWillGem;
import WayofTime.bloodmagic.api.soul.IDiscreteDemonWill;
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
public class TileDemonCrucible extends TileInventory implements ITickable, IDemonWillConduit
public class TileDemonCrucible extends TileInventory implements ITickable, IDemonWillConduit, ISidedInventory
{
public HashMap<EnumDemonWillType, Double> willMap = new HashMap<EnumDemonWillType, Double>(); //TODO: Change to DemonWillHolder
public final int maxWill = 100;
@ -83,6 +86,25 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo
WorldDemonWillHandler.fillWillToMaximum(worldObj, pos, type, filled, maxWill, true);
}
}
} else if (stack.getItem() instanceof IDiscreteDemonWill) //TODO: Limit the speed of this process
{
IDiscreteDemonWill willItem = (IDiscreteDemonWill) stack.getItem();
EnumDemonWillType type = willItem.getType(stack);
double currentAmount = WorldDemonWillHandler.getCurrentWill(worldObj, pos, type);
double needed = maxWill - currentAmount;
double discreteAmount = willItem.getDiscretization(stack);
if (needed >= discreteAmount)
{
double filled = willItem.drainWill(stack, discreteAmount);
if (filled > 0)
{
WorldDemonWillHandler.fillWillToMaximum(worldObj, pos, type, filled, maxWill, true);
if (stack.stackSize <= 0)
{
this.setInventorySlotContents(0, null);
}
}
}
}
}
}
@ -218,4 +240,22 @@ public class TileDemonCrucible extends TileInventory implements ITickable, IDemo
{
return willMap.containsKey(type) ? willMap.get(type) : 0;
}
@Override
public int[] getSlotsForFace(EnumFacing side)
{
return new int[] { 0 };
}
@Override
public boolean canInsertItem(int index, ItemStack stack, EnumFacing direction)
{
return stack != null ? stack.getItem() instanceof IDemonWillGem || stack.getItem() instanceof IDiscreteDemonWill : false;
}
@Override
public boolean canExtractItem(int index, ItemStack stack, EnumFacing direction)
{
return true;
}
}

View file

@ -25,6 +25,7 @@ public class TileDemonCrystal extends TileEntity implements ITickable, IDemonWil
public final double drainRate = 1;
public static final double sameWillConversionRate = 5;
public static final double defaultWillConversionRate = 50;
public static final double timeDelayForWrongWill = 0.6;
public double progressToNextCrystal = 0;
public int internalCounter = 0;
@ -67,7 +68,7 @@ public class TileDemonCrystal extends TileEntity implements ITickable, IDemonWil
value = WorldDemonWillHandler.getCurrentWill(worldObj, pos, EnumDemonWillType.DEFAULT);
if (value > 0.5)
{
double nextProgress = getCrystalGrowthPerSecond(value);
double nextProgress = getCrystalGrowthPerSecond(value) * timeDelayForWrongWill;
progressToNextCrystal += WorldDemonWillHandler.drainWill(worldObj, getPos(), EnumDemonWillType.DEFAULT, nextProgress * defaultWillConversionRate, true) / defaultWillConversionRate;
}
}
@ -97,7 +98,7 @@ public class TileDemonCrystal extends TileEntity implements ITickable, IDemonWil
public double getCrystalGrowthPerSecond(double will)
{
return 1.0 / 80 * Math.sqrt(will / 200);
return 1.0 / 800 * Math.sqrt(will / 200);
}
public int getCrystalCountForRender()