Added the "Resonance of the Faceted Crystal"
This commit is contained in:
parent
7e2dc3f4e7
commit
60c8441115
9 changed files with 296 additions and 58 deletions
|
@ -1,16 +1,17 @@
|
|||
package WayofTime.bloodmagic.tile;
|
||||
|
||||
import WayofTime.bloodmagic.soul.DemonWillHolder;
|
||||
import WayofTime.bloodmagic.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.block.BlockDemonCrystal;
|
||||
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
||||
import WayofTime.bloodmagic.tile.base.TileTicking;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.inventory.InventoryHelper;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
import WayofTime.bloodmagic.block.BlockDemonCrystal;
|
||||
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
||||
import WayofTime.bloodmagic.soul.DemonWillHolder;
|
||||
import WayofTime.bloodmagic.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.tile.base.TileTicking;
|
||||
|
||||
public class TileDemonCrystal extends TileTicking
|
||||
{
|
||||
|
@ -42,12 +43,12 @@ public class TileDemonCrystal extends TileTicking
|
|||
|
||||
if (internalCounter % 20 == 0 && crystalCount < 7)
|
||||
{
|
||||
EnumDemonWillType type = EnumDemonWillType.values()[this.getBlockMetadata()];
|
||||
EnumDemonWillType type = getType();
|
||||
|
||||
double value = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type);
|
||||
if (type != EnumDemonWillType.DEFAULT)
|
||||
{
|
||||
if (value >= 100)
|
||||
if (value >= 0.5)
|
||||
{
|
||||
double nextProgress = getCrystalGrowthPerSecond(value);
|
||||
progressToNextCrystal += WorldDemonWillHandler.drainWill(getWorld(), getPos(), type, nextProgress * sameWillConversionRate, true) / sameWillConversionRate;
|
||||
|
@ -118,6 +119,11 @@ public class TileDemonCrystal extends TileTicking
|
|||
return percentDrain * progressPercentage;
|
||||
}
|
||||
|
||||
public EnumDemonWillType getType()
|
||||
{
|
||||
return EnumDemonWillType.values()[this.getBlockMetadata()];
|
||||
}
|
||||
|
||||
public void checkAndGrowCrystal()
|
||||
{
|
||||
if (progressToNextCrystal >= 1 && internalCounter % 100 == 0)
|
||||
|
|
|
@ -1,17 +1,18 @@
|
|||
package WayofTime.bloodmagic.tile;
|
||||
|
||||
import WayofTime.bloodmagic.soul.DemonWillHolder;
|
||||
import WayofTime.bloodmagic.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.soul.IDemonWillConduit;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
||||
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
||||
import WayofTime.bloodmagic.tile.base.TileTicking;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import WayofTime.bloodmagic.core.RegistrarBloodMagicBlocks;
|
||||
import WayofTime.bloodmagic.demonAura.WorldDemonWillHandler;
|
||||
import WayofTime.bloodmagic.soul.DemonWillHolder;
|
||||
import WayofTime.bloodmagic.soul.EnumDemonWillType;
|
||||
import WayofTime.bloodmagic.soul.IDemonWillConduit;
|
||||
import WayofTime.bloodmagic.tile.base.TileTicking;
|
||||
|
||||
public class TileDemonCrystallizer extends TileTicking implements IDemonWillConduit {
|
||||
public class TileDemonCrystallizer extends TileTicking implements IDemonWillConduit
|
||||
{
|
||||
public static final int maxWill = 100;
|
||||
public static final double drainRate = 1;
|
||||
public static final double willToFormCrystal = 99;
|
||||
|
@ -20,13 +21,16 @@ public class TileDemonCrystallizer extends TileTicking implements IDemonWillCond
|
|||
public DemonWillHolder holder = new DemonWillHolder();
|
||||
public double internalCounter = 0;
|
||||
|
||||
public TileDemonCrystallizer() {
|
||||
public TileDemonCrystallizer()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate() {
|
||||
if (getWorld().isRemote) {
|
||||
public void onUpdate()
|
||||
{
|
||||
if (getWorld().isRemote)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -35,11 +39,15 @@ public class TileDemonCrystallizer extends TileTicking implements IDemonWillCond
|
|||
{
|
||||
EnumDemonWillType highestType = WorldDemonWillHandler.getHighestDemonWillType(getWorld(), pos);
|
||||
double amount = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, highestType);
|
||||
if (amount >= willToFormCrystal) {
|
||||
if (amount >= willToFormCrystal)
|
||||
{
|
||||
internalCounter += getCrystalFormationRate(amount);
|
||||
if (internalCounter >= totalFormationTime) {
|
||||
if (WorldDemonWillHandler.drainWill(getWorld(), getPos(), highestType, willToFormCrystal, false) >= willToFormCrystal) {
|
||||
if (highestType == EnumDemonWillType.DEFAULT && formRandomSpecialCrystal(offsetPos) || formCrystal(highestType, offsetPos)) {
|
||||
if (internalCounter >= totalFormationTime)
|
||||
{
|
||||
if (WorldDemonWillHandler.drainWill(getWorld(), getPos(), highestType, willToFormCrystal, false) >= willToFormCrystal)
|
||||
{
|
||||
if (formCrystal(highestType, offsetPos))
|
||||
{
|
||||
WorldDemonWillHandler.drainWill(getWorld(), getPos(), highestType, willToFormCrystal, true);
|
||||
internalCounter = 0;
|
||||
}
|
||||
|
@ -49,10 +57,12 @@ public class TileDemonCrystallizer extends TileTicking implements IDemonWillCond
|
|||
}
|
||||
}
|
||||
|
||||
public boolean formCrystal(EnumDemonWillType type, BlockPos position) {
|
||||
public boolean formCrystal(EnumDemonWillType type, BlockPos position)
|
||||
{
|
||||
getWorld().setBlockState(position, RegistrarBloodMagicBlocks.DEMON_CRYSTAL.getStateFromMeta(type.ordinal()));
|
||||
TileEntity tile = getWorld().getTileEntity(position);
|
||||
if (tile instanceof TileDemonCrystal) {
|
||||
if (tile instanceof TileDemonCrystal)
|
||||
{
|
||||
((TileDemonCrystal) tile).setPlacement(EnumFacing.UP);
|
||||
return true;
|
||||
}
|
||||
|
@ -60,26 +70,21 @@ public class TileDemonCrystallizer extends TileTicking implements IDemonWillCond
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean formRandomSpecialCrystal(BlockPos position) {
|
||||
if (getWorld().rand.nextDouble() > 0.1) {
|
||||
return formCrystal(EnumDemonWillType.DEFAULT, position);
|
||||
}
|
||||
EnumDemonWillType crystalType = EnumDemonWillType.values()[getWorld().rand.nextInt(EnumDemonWillType.values().length - 1) + 1];
|
||||
return formCrystal(crystalType, position);
|
||||
}
|
||||
|
||||
public double getCrystalFormationRate(double currentWill) {
|
||||
public double getCrystalFormationRate(double currentWill)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(NBTTagCompound tag) {
|
||||
public void deserialize(NBTTagCompound tag)
|
||||
{
|
||||
holder.readFromNBT(tag, "Will");
|
||||
internalCounter = tag.getDouble("internalCounter");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound serialize(NBTTagCompound tag) {
|
||||
public NBTTagCompound serialize(NBTTagCompound tag)
|
||||
{
|
||||
holder.writeToNBT(tag, "Will");
|
||||
tag.setDouble("internalCounter", internalCounter);
|
||||
return tag;
|
||||
|
@ -88,21 +93,26 @@ public class TileDemonCrystallizer extends TileTicking implements IDemonWillCond
|
|||
// IDemonWillConduit
|
||||
|
||||
@Override
|
||||
public int getWeight() {
|
||||
public int getWeight()
|
||||
{
|
||||
return 10;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double fillDemonWill(EnumDemonWillType type, double amount, boolean doFill) {
|
||||
if (amount <= 0) {
|
||||
public double fillDemonWill(EnumDemonWillType type, double amount, boolean doFill)
|
||||
{
|
||||
if (amount <= 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!canFill(type)) {
|
||||
if (!canFill(type))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!doFill) {
|
||||
if (!doFill)
|
||||
{
|
||||
return Math.min(maxWill - holder.getWill(type), amount);
|
||||
}
|
||||
|
||||
|
@ -110,14 +120,17 @@ public class TileDemonCrystallizer extends TileTicking implements IDemonWillCond
|
|||
}
|
||||
|
||||
@Override
|
||||
public double drainDemonWill(EnumDemonWillType type, double amount, boolean doDrain) {
|
||||
public double drainDemonWill(EnumDemonWillType type, double amount, boolean doDrain)
|
||||
{
|
||||
double drained = amount;
|
||||
double current = holder.getWill(type);
|
||||
if (current < drained) {
|
||||
if (current < drained)
|
||||
{
|
||||
drained = current;
|
||||
}
|
||||
|
||||
if (doDrain) {
|
||||
if (doDrain)
|
||||
{
|
||||
return holder.drainWill(type, amount);
|
||||
}
|
||||
|
||||
|
@ -125,17 +138,20 @@ public class TileDemonCrystallizer extends TileTicking implements IDemonWillCond
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean canFill(EnumDemonWillType type) {
|
||||
public boolean canFill(EnumDemonWillType type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canDrain(EnumDemonWillType type) {
|
||||
public boolean canDrain(EnumDemonWillType type)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCurrentWill(EnumDemonWillType type) {
|
||||
public double getCurrentWill(EnumDemonWillType type)
|
||||
{
|
||||
return holder.getWill(type);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue