- Made it so peaceful animals provide more LP by default (to encourage creating your own farm).
- Increased the effectiveness of animals for the Gathering of the Forsaken Souls ritual by a factor of 4. - Added the framework for the Purification Altar.
This commit is contained in:
parent
da4de55c2e
commit
faef980e59
14 changed files with 290 additions and 31 deletions
|
@ -0,0 +1,96 @@
|
|||
package WayofTime.bloodmagic.tile;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.entity.passive.EntityAnimal;
|
||||
import net.minecraft.item.ItemStack;
|
||||
import net.minecraft.nbt.NBTTagCompound;
|
||||
import net.minecraft.util.EnumParticleTypes;
|
||||
import net.minecraft.util.ITickable;
|
||||
import net.minecraft.util.math.AxisAlignedBB;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.WorldServer;
|
||||
import WayofTime.bloodmagic.api.iface.IPurificationAsh;
|
||||
import WayofTime.bloodmagic.api.ritual.AreaDescriptor;
|
||||
import WayofTime.bloodmagic.api.util.helper.PurificationHelper;
|
||||
|
||||
public class TilePurificationAltar extends TileInventory implements ITickable
|
||||
{
|
||||
public AreaDescriptor purityArea = new AreaDescriptor.Rectangle(new BlockPos(-5, -5, -5), 11);
|
||||
|
||||
public double totalPurity = 0;
|
||||
public double maxPurity = 0;
|
||||
public double purityRate = 0;
|
||||
|
||||
public TilePurificationAltar()
|
||||
{
|
||||
super(1, "purificationAltar");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update()
|
||||
{
|
||||
if (totalPurity <= 0)
|
||||
{
|
||||
ItemStack stack = this.getStackInSlot(0);
|
||||
if (stack != null && stack.getItem() instanceof IPurificationAsh)
|
||||
{
|
||||
totalPurity = ((IPurificationAsh) stack.getItem()).getTotalPurity(stack);
|
||||
maxPurity = ((IPurificationAsh) stack.getItem()).getMaxPurity(stack);
|
||||
purityRate = ((IPurificationAsh) stack.getItem()).getPurityRate(stack);
|
||||
}
|
||||
} else
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AxisAlignedBB aabb = purityArea.getAABB(getPos());
|
||||
List<EntityAnimal> animalList = worldObj.getEntitiesWithinAABB(EntityAnimal.class, aabb);
|
||||
if (animalList.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
boolean hasPerformed = false;
|
||||
|
||||
for (EntityAnimal animal : animalList)
|
||||
{
|
||||
double added = PurificationHelper.addPurity(animal, Math.min(purityRate, totalPurity), maxPurity);
|
||||
if (added > 0)
|
||||
{
|
||||
totalPurity -= purityRate;
|
||||
hasPerformed = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasPerformed)
|
||||
{
|
||||
if (worldObj.rand.nextInt(4) == 0 && worldObj instanceof WorldServer)
|
||||
{
|
||||
WorldServer server = (WorldServer) worldObj;
|
||||
server.spawnParticle(EnumParticleTypes.FLAME, pos.getX() + 0.5, pos.getY() + 1.2, pos.getZ() + 0.5, 1, 0.02, 0.03, 0.02, 0, new int[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deserialize(NBTTagCompound tag)
|
||||
{
|
||||
super.deserialize(tag);
|
||||
totalPurity = tag.getDouble("totalPurity");
|
||||
maxPurity = tag.getDouble("maxPurity");
|
||||
purityRate = tag.getDouble("purityRate");
|
||||
}
|
||||
|
||||
@Override
|
||||
public NBTTagCompound serialize(NBTTagCompound tag)
|
||||
{
|
||||
super.serialize(tag);
|
||||
|
||||
tag.setDouble("totalPurity", totalPurity);
|
||||
tag.setDouble("maxPurity", maxPurity);
|
||||
tag.setDouble("purityRate", purityRate);
|
||||
|
||||
return tag;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue