Added variable incense - issue with build needs to be resolved in build.gradle
This commit is contained in:
parent
f1ebade718
commit
c71edfb937
13 changed files with 360 additions and 32 deletions
|
@ -1,36 +1,116 @@
|
|||
package WayofTime.alchemicalWizardry.api.sacrifice;
|
||||
|
||||
import WayofTime.alchemicalWizardry.api.spell.APISpellHelper;
|
||||
import net.minecraft.entity.player.EntityPlayer;
|
||||
import net.minecraft.potion.PotionEffect;
|
||||
import net.minecraft.tileentity.TileEntity;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.alchemicalWizardry.AlchemicalWizardry;
|
||||
import WayofTime.alchemicalWizardry.api.spell.APISpellHelper;
|
||||
import WayofTime.alchemicalWizardry.api.tile.IBloodAltar;
|
||||
|
||||
public class PlayerSacrificeHandler
|
||||
{
|
||||
public int getPlayerIncense(EntityPlayer player)
|
||||
public static float scalingOfSacrifice = 0.0025f;
|
||||
public static int soulFrayDuration = 400;
|
||||
public static int getPlayerIncense(EntityPlayer player)
|
||||
{
|
||||
return APISpellHelper.getCurrentIncense(player);
|
||||
}
|
||||
|
||||
public void setPlayerIncense(EntityPlayer player, int amount)
|
||||
public static void setPlayerIncense(EntityPlayer player, int amount)
|
||||
{
|
||||
APISpellHelper.setCurrentIncense(player, amount);
|
||||
}
|
||||
|
||||
public boolean incrementIncense(EntityPlayer player, int min, int max)
|
||||
public static boolean incrementIncense(EntityPlayer player, int min, int max)
|
||||
{
|
||||
int amount = this.getPlayerIncense(player);
|
||||
int amount = getPlayerIncense(player);
|
||||
if(amount < min || amount >= max)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
amount++;
|
||||
setPlayerIncense(player, amount);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean sacrificePlayerHealth(EntityPlayer player)
|
||||
public static boolean sacrificePlayerHealth(EntityPlayer player)
|
||||
{
|
||||
if(player.isPotionActive(AlchemicalWizardry.customPotionSoulFray))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
int amount = getPlayerIncense(player);
|
||||
|
||||
if(amount >= 0)
|
||||
{
|
||||
float health = player.getHealth();
|
||||
float maxHealth = player.getMaxHealth();
|
||||
|
||||
if(health > maxHealth/10.0)
|
||||
{
|
||||
float sacrificedHealth = health - maxHealth/10.0f;
|
||||
|
||||
if(findAndFillAltar(player.getEntityWorld(), player, (int)(sacrificedHealth * 100f * getModifier(amount))))
|
||||
{
|
||||
player.setHealth(maxHealth/10.0f);
|
||||
setPlayerIncense(player, 0);
|
||||
player.addPotionEffect(new PotionEffect(AlchemicalWizardry.customPotionSoulFray.id, soulFrayDuration));
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static float getModifier(int incense)
|
||||
{
|
||||
return 1 + incense*scalingOfSacrifice;
|
||||
}
|
||||
|
||||
public static boolean findAndFillAltar(World world, EntityPlayer player, int amount)
|
||||
{
|
||||
int posX = (int) Math.round(player.posX - 0.5f);
|
||||
int posY = (int) player.posY;
|
||||
int posZ = (int) Math.round(player.posZ - 0.5f);
|
||||
IBloodAltar altarEntity = getAltar(world, posX, posY, posZ);
|
||||
|
||||
if (altarEntity == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
altarEntity.sacrificialDaggerCall(amount, false);
|
||||
altarEntity.startCycle();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public static IBloodAltar getAltar(World world, int x, int y, int z)
|
||||
{
|
||||
TileEntity tileEntity = null;
|
||||
|
||||
for (int i = -2; i <= 2; i++)
|
||||
{
|
||||
for (int j = -2; j <= 2; j++)
|
||||
{
|
||||
for (int k = -2; k <= 1; k++)
|
||||
{
|
||||
tileEntity = world.getTileEntity(i + x, k + y, j + z);
|
||||
|
||||
if(tileEntity instanceof IBloodAltar)
|
||||
{
|
||||
return (IBloodAltar)tileEntity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue