Run formatter
This commit is contained in:
parent
61c44a831b
commit
08258fd6ef
606 changed files with 13464 additions and 22975 deletions
|
@ -1,5 +1,9 @@
|
|||
package WayofTime.bloodmagic.tile;
|
||||
|
||||
import WayofTime.bloodmagic.api.soul.DemonWillHolder;
|
||||
import WayofTime.bloodmagic.api.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.entity.item.EntityItem;
|
||||
|
@ -7,64 +11,48 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.MathHelper;
|
||||
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 TileTicking
|
||||
{
|
||||
public DemonWillHolder holder = new DemonWillHolder();
|
||||
public final int maxWill = 100;
|
||||
public final double drainRate = 1;
|
||||
public class TileDemonCrystal extends TileTicking {
|
||||
public static final double sameWillConversionRate = 50;
|
||||
public static final double defaultWillConversionRate = 100;
|
||||
public static final double timeDelayForWrongWill = 0.6;
|
||||
|
||||
public final int maxWill = 100;
|
||||
public final double drainRate = 1;
|
||||
public DemonWillHolder holder = new DemonWillHolder();
|
||||
public double progressToNextCrystal = 0;
|
||||
public int internalCounter = 0;
|
||||
public int crystalCount = 1;
|
||||
public EnumFacing placement = EnumFacing.UP; //Side that this crystal is placed on.
|
||||
|
||||
public TileDemonCrystal()
|
||||
{
|
||||
public TileDemonCrystal() {
|
||||
this.crystalCount = 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate()
|
||||
{
|
||||
if (getWorld().isRemote)
|
||||
{
|
||||
public void onUpdate() {
|
||||
if (getWorld().isRemote) {
|
||||
return;
|
||||
}
|
||||
|
||||
internalCounter++;
|
||||
|
||||
if (internalCounter % 20 == 0 && crystalCount < 7)
|
||||
{
|
||||
if (internalCounter % 20 == 0 && crystalCount < 7) {
|
||||
EnumDemonWillType type = EnumDemonWillType.values()[this.getBlockMetadata()];
|
||||
|
||||
double value = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type);
|
||||
if (type != EnumDemonWillType.DEFAULT)
|
||||
{
|
||||
if (value >= 100)
|
||||
{
|
||||
if (type != EnumDemonWillType.DEFAULT) {
|
||||
if (value >= 100) {
|
||||
double nextProgress = getCrystalGrowthPerSecond(value);
|
||||
progressToNextCrystal += WorldDemonWillHandler.drainWill(getWorld(), getPos(), type, nextProgress * sameWillConversionRate, true) / sameWillConversionRate;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
value = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, EnumDemonWillType.DEFAULT);
|
||||
if (value > 0.5)
|
||||
{
|
||||
if (value > 0.5) {
|
||||
double nextProgress = getCrystalGrowthPerSecond(value) * timeDelayForWrongWill;
|
||||
progressToNextCrystal += WorldDemonWillHandler.drainWill(getWorld(), getPos(), EnumDemonWillType.DEFAULT, nextProgress * defaultWillConversionRate, true) / defaultWillConversionRate;
|
||||
}
|
||||
}
|
||||
} else
|
||||
{
|
||||
if (value > 0.5)
|
||||
{
|
||||
} else {
|
||||
if (value > 0.5) {
|
||||
double nextProgress = getCrystalGrowthPerSecond(value);
|
||||
progressToNextCrystal += WorldDemonWillHandler.drainWill(getWorld(), getPos(), type, nextProgress * sameWillConversionRate, true) / sameWillConversionRate;
|
||||
}
|
||||
|
@ -83,18 +71,15 @@ public class TileDemonCrystal extends TileTicking
|
|||
/**
|
||||
* 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 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)
|
||||
{
|
||||
public double growCrystalWithWillAmount(double willDrain, double progressPercentage) {
|
||||
if (crystalCount >= 7) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -104,8 +89,7 @@ public class TileDemonCrystal extends TileTicking
|
|||
|
||||
double value = WorldDemonWillHandler.getCurrentWill(getWorld(), pos, type);
|
||||
double percentDrain = willDrain <= 0 ? 1 : Math.min(1, value / willDrain);
|
||||
if (percentDrain <= 0)
|
||||
{
|
||||
if (percentDrain <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -118,10 +102,8 @@ public class TileDemonCrystal extends TileTicking
|
|||
return percentDrain * progressPercentage;
|
||||
}
|
||||
|
||||
public void checkAndGrowCrystal()
|
||||
{
|
||||
if (progressToNextCrystal >= 1)
|
||||
{
|
||||
public void checkAndGrowCrystal() {
|
||||
if (progressToNextCrystal >= 1) {
|
||||
progressToNextCrystal--;
|
||||
crystalCount++;
|
||||
IBlockState thisState = getWorld().getBlockState(pos);
|
||||
|
@ -130,20 +112,16 @@ public class TileDemonCrystal extends TileTicking
|
|||
}
|
||||
}
|
||||
|
||||
public double getMaxWillForCrystal()
|
||||
{
|
||||
public double getMaxWillForCrystal() {
|
||||
return 50;
|
||||
}
|
||||
|
||||
public boolean dropSingleCrystal()
|
||||
{
|
||||
if (!getWorld().isRemote && crystalCount > 1)
|
||||
{
|
||||
public boolean dropSingleCrystal() {
|
||||
if (!getWorld().isRemote && crystalCount > 1) {
|
||||
IBlockState state = getWorld().getBlockState(pos);
|
||||
EnumDemonWillType type = state.getValue(BlockDemonCrystal.TYPE);
|
||||
ItemStack stack = BlockDemonCrystal.getItemStackDropped(type, 1);
|
||||
if (stack != null)
|
||||
{
|
||||
if (stack != null) {
|
||||
crystalCount--;
|
||||
getWorld().spawnEntity(new EntityItem(getWorld(), pos.getX() + 0.5, pos.getY() + 0.5, pos.getZ() + 0.5, stack));
|
||||
return true;
|
||||
|
@ -153,19 +131,16 @@ public class TileDemonCrystal extends TileTicking
|
|||
return false;
|
||||
}
|
||||
|
||||
public double getCrystalGrowthPerSecond(double will)
|
||||
{
|
||||
public double getCrystalGrowthPerSecond(double will) {
|
||||
return 1.0 / 800 * Math.sqrt(will / 200);
|
||||
}
|
||||
|
||||
public int getCrystalCountForRender()
|
||||
{
|
||||
public int getCrystalCountForRender() {
|
||||
return MathHelper.clamp(crystalCount - 1, 0, 6);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(NBTTagCompound tag)
|
||||
{
|
||||
public void deserialize(NBTTagCompound tag) {
|
||||
holder.readFromNBT(tag, "Will");
|
||||
crystalCount = tag.getInteger("crystalCount");
|
||||
placement = EnumFacing.getFront(tag.getInteger("placement"));
|
||||
|
@ -173,8 +148,7 @@ public class TileDemonCrystal extends TileTicking
|
|||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound serialize(NBTTagCompound tag)
|
||||
{
|
||||
public NBTTagCompound serialize(NBTTagCompound tag) {
|
||||
holder.writeToNBT(tag, "Will");
|
||||
tag.setInteger("crystalCount", crystalCount);
|
||||
tag.setInteger("placement", placement.getIndex());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue