2015-11-02 20:39:44 +00:00
|
|
|
package WayofTime.bloodmagic.tile;
|
2015-10-30 03:22:14 +00:00
|
|
|
|
2015-11-03 02:30:28 +00:00
|
|
|
import WayofTime.bloodmagic.altar.BloodAltar;
|
2015-11-02 20:39:44 +00:00
|
|
|
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
2015-11-03 02:30:28 +00:00
|
|
|
import WayofTime.bloodmagic.api.altar.AltarRecipe;
|
2015-11-02 20:39:44 +00:00
|
|
|
import WayofTime.bloodmagic.api.altar.AltarUpgrade;
|
2015-11-03 02:30:28 +00:00
|
|
|
import WayofTime.bloodmagic.api.altar.EnumAltarTier;
|
|
|
|
import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry;
|
2015-10-30 03:22:14 +00:00
|
|
|
import net.minecraft.server.gui.IUpdatePlayerListBox;
|
|
|
|
import net.minecraft.util.EnumFacing;
|
|
|
|
import net.minecraftforge.fluids.*;
|
|
|
|
|
2015-11-03 02:30:28 +00:00
|
|
|
public class TileAltar extends TileInventory implements IUpdatePlayerListBox, IFluidTank, IFluidHandler
|
|
|
|
{
|
2015-10-30 03:22:14 +00:00
|
|
|
private int tier;
|
|
|
|
private AltarUpgrade upgrade = new AltarUpgrade();
|
2015-11-02 20:39:44 +00:00
|
|
|
private FluidStack fluid = new FluidStack(BloodMagicAPI.getLifeEssence(), 0);
|
2015-10-30 03:22:14 +00:00
|
|
|
private int capacity;
|
|
|
|
|
2015-11-03 02:30:28 +00:00
|
|
|
public TileAltar()
|
|
|
|
{
|
2015-10-30 03:22:14 +00:00
|
|
|
super(1, "altar");
|
|
|
|
|
|
|
|
this.capacity = 10000;
|
|
|
|
}
|
|
|
|
|
2015-11-03 02:30:28 +00:00
|
|
|
@Override
|
|
|
|
public void update()
|
|
|
|
{
|
|
|
|
if (getWorld().isRemote)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (getWorld().getTotalWorldTime() % (Math.max(20 - getUpgrade().getSpeedCount(), 1)) == 0)
|
|
|
|
{
|
|
|
|
everySecond();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (getWorld().getTotalWorldTime() % 100 == 0)
|
|
|
|
{
|
|
|
|
everyFiveSeconds();
|
|
|
|
}
|
|
|
|
}
|
2015-10-30 03:22:14 +00:00
|
|
|
|
2015-11-03 02:30:28 +00:00
|
|
|
private void everySecond()
|
|
|
|
{
|
|
|
|
// Do recipes
|
|
|
|
if (AltarRecipeRegistry.getRecipes().containsKey(getStackInSlot(0)))
|
|
|
|
{
|
|
|
|
AltarRecipe recipe = AltarRecipeRegistry.getRecipeForInput(getStackInSlot(0));
|
|
|
|
|
|
|
|
if (!(tier >= recipe.minTier))
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-10-30 03:22:14 +00:00
|
|
|
|
2015-11-03 02:30:28 +00:00
|
|
|
private void everyFiveSeconds()
|
|
|
|
{
|
|
|
|
checkTier();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void checkTier()
|
|
|
|
{
|
|
|
|
// TODO - Write checking for tier stuff
|
|
|
|
|
|
|
|
EnumAltarTier tier = BloodAltar.getAltarTier(getWorld(), getPos());
|
|
|
|
|
|
|
|
if (tier.equals(EnumAltarTier.ONE))
|
|
|
|
{
|
|
|
|
upgrade = new AltarUpgrade();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public TileAltar setUpgrade(AltarUpgrade upgrade)
|
|
|
|
{
|
2015-10-30 03:22:14 +00:00
|
|
|
this.upgrade = upgrade;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2015-11-03 02:30:28 +00:00
|
|
|
public AltarUpgrade getUpgrade()
|
|
|
|
{
|
2015-10-30 03:22:14 +00:00
|
|
|
return upgrade;
|
|
|
|
}
|
|
|
|
|
2015-11-03 02:30:28 +00:00
|
|
|
public TileAltar setTier(int tier)
|
|
|
|
{
|
2015-10-30 03:22:14 +00:00
|
|
|
this.tier = tier;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getTier() {
|
|
|
|
return tier;
|
|
|
|
}
|
|
|
|
|
|
|
|
// IFluidHandler
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public FluidTankInfo[] getTankInfo(EnumFacing from) {
|
|
|
|
return new FluidTankInfo[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int fill(EnumFacing from, FluidStack resource, boolean doFill) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canFill(EnumFacing from, Fluid fluid) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public boolean canDrain(EnumFacing from, Fluid fluid) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
// IFluidTank
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public FluidStack getFluid() {
|
|
|
|
return fluid;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getFluidAmount() {
|
|
|
|
return fluid.amount;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getCapacity() {
|
|
|
|
return capacity;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public FluidTankInfo getInfo() {
|
|
|
|
return new FluidTankInfo(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int fill(FluidStack resource, boolean doFill) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public FluidStack drain(int maxDrain, boolean doDrain) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|