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-29 02:25:46 +00:00
|
|
|
import WayofTime.bloodmagic.api.Constants;
|
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;
|
2015-11-03 15:34:11 +00:00
|
|
|
import WayofTime.bloodmagic.api.altar.IBloodAltar;
|
2015-11-07 16:51:41 +00:00
|
|
|
import WayofTime.bloodmagic.api.orb.IBloodOrb;
|
2015-11-03 02:30:28 +00:00
|
|
|
import WayofTime.bloodmagic.api.registry.AltarRecipeRegistry;
|
2015-11-07 16:51:41 +00:00
|
|
|
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
2015-11-03 15:34:11 +00:00
|
|
|
import WayofTime.bloodmagic.block.BlockLifeEssence;
|
2015-11-03 16:31:34 +00:00
|
|
|
import com.google.common.base.Enums;
|
2015-11-29 02:25:46 +00:00
|
|
|
import com.google.common.base.Strings;
|
2015-11-28 01:15:19 +00:00
|
|
|
import net.minecraft.block.state.IBlockState;
|
2015-11-03 15:34:11 +00:00
|
|
|
import net.minecraft.item.ItemStack;
|
|
|
|
import net.minecraft.nbt.NBTTagCompound;
|
2015-10-30 03:22:14 +00:00
|
|
|
import net.minecraft.server.gui.IUpdatePlayerListBox;
|
2015-11-28 01:15:19 +00:00
|
|
|
import net.minecraft.util.BlockPos;
|
2015-10-30 03:22:14 +00:00
|
|
|
import net.minecraft.util.EnumFacing;
|
2015-11-28 01:15:19 +00:00
|
|
|
import net.minecraft.util.EnumParticleTypes;
|
2015-10-30 03:22:14 +00:00
|
|
|
import net.minecraftforge.fluids.*;
|
|
|
|
|
2015-11-03 15:34:11 +00:00
|
|
|
public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlayerListBox, IFluidTank, IFluidHandler {
|
2015-11-03 16:09:16 +00:00
|
|
|
|
2015-11-29 02:25:46 +00:00
|
|
|
public boolean isActive;
|
|
|
|
protected FluidStack fluidOutput = new FluidStack(BlockLifeEssence.getLifeEssence(), 0);
|
|
|
|
protected FluidStack fluidInput = new FluidStack(BlockLifeEssence.getLifeEssence(), 0);
|
2015-11-11 18:35:44 +00:00
|
|
|
private EnumAltarTier altarTier = EnumAltarTier.ONE;
|
2015-10-30 03:22:14 +00:00
|
|
|
private AltarUpgrade upgrade = new AltarUpgrade();
|
2015-11-03 16:09:16 +00:00
|
|
|
private int capacity = FluidContainerRegistry.BUCKET_VOLUME * 10;
|
2015-11-02 20:39:44 +00:00
|
|
|
private FluidStack fluid = new FluidStack(BloodMagicAPI.getLifeEssence(), 0);
|
2015-11-03 15:34:11 +00:00
|
|
|
private int liquidRequired; //mB
|
|
|
|
private boolean canBeFilled;
|
|
|
|
private int consumptionRate;
|
|
|
|
private int drainRate;
|
|
|
|
private float consumptionMultiplier;
|
|
|
|
private float efficiencyMultiplier;
|
|
|
|
private float sacrificeEfficiencyMultiplier;
|
|
|
|
private float selfSacrificeEfficiencyMultiplier;
|
2015-11-03 16:09:16 +00:00
|
|
|
private float capacityMultiplier = 1;
|
2015-11-03 15:34:11 +00:00
|
|
|
private float orbCapacityMultiplier;
|
|
|
|
private float dislocationMultiplier;
|
|
|
|
private int accelerationUpgrades;
|
|
|
|
private boolean isUpgraded;
|
|
|
|
private boolean isResultBlock;
|
2015-11-03 16:09:16 +00:00
|
|
|
private int bufferCapacity = FluidContainerRegistry.BUCKET_VOLUME;
|
2015-11-03 15:34:11 +00:00
|
|
|
private int progress;
|
|
|
|
private int lockdownDuration;
|
|
|
|
private int demonBloodDuration;
|
|
|
|
|
|
|
|
private int cooldownAfterCrafting = 500;
|
|
|
|
|
2015-11-28 01:15:19 +00:00
|
|
|
private ItemStack result;
|
|
|
|
|
2015-11-03 15:34:11 +00:00
|
|
|
public TileAltar() {
|
2015-10-30 03:22:14 +00:00
|
|
|
super(1, "altar");
|
2015-11-03 15:34:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-11-03 16:09:16 +00:00
|
|
|
public void readFromNBT(NBTTagCompound tagCompound) {
|
|
|
|
super.readFromNBT(tagCompound);
|
2015-11-03 15:34:11 +00:00
|
|
|
|
2015-11-29 02:25:46 +00:00
|
|
|
if (!tagCompound.hasKey(Constants.NBT.EMPTY)) {
|
2015-11-03 16:09:16 +00:00
|
|
|
FluidStack fluid = FluidStack.loadFluidStackFromNBT(tagCompound);
|
2015-11-03 15:34:11 +00:00
|
|
|
|
2015-11-03 16:09:16 +00:00
|
|
|
if (fluid != null)
|
2015-11-03 15:34:11 +00:00
|
|
|
setMainFluid(fluid);
|
|
|
|
|
2015-11-29 02:25:46 +00:00
|
|
|
FluidStack fluidOut = new FluidStack(BloodMagicAPI.getLifeEssence(), tagCompound.getInteger(Constants.NBT.OUTPUT_AMOUNT));
|
2015-11-03 16:09:16 +00:00
|
|
|
setOutputFluid(fluidOut);
|
2015-11-03 15:34:11 +00:00
|
|
|
|
2015-11-29 02:25:46 +00:00
|
|
|
FluidStack fluidIn = new FluidStack(BloodMagicAPI.getLifeEssence(), tagCompound.getInteger(Constants.NBT.INPUT_AMOUNT));
|
2015-11-03 16:09:16 +00:00
|
|
|
setInputFluid(fluidIn);
|
2015-11-03 15:34:11 +00:00
|
|
|
}
|
|
|
|
|
2015-11-29 02:25:46 +00:00
|
|
|
altarTier = Enums.getIfPresent(EnumAltarTier.class, tagCompound.getString(Constants.NBT.ALTAR_TIER)).or(EnumAltarTier.ONE);
|
|
|
|
isActive = tagCompound.getBoolean(Constants.NBT.ALTAR_ACTIVE);
|
|
|
|
liquidRequired = tagCompound.getInteger(Constants.NBT.ALTAR_LIQUID_REQ);
|
|
|
|
canBeFilled = tagCompound.getBoolean(Constants.NBT.ALTAR_FILLABLE);
|
|
|
|
isUpgraded = tagCompound.getBoolean(Constants.NBT.ALTAR_UPGRADED);
|
|
|
|
consumptionRate = tagCompound.getInteger(Constants.NBT.ALTAR_CONSUMPTION_RATE);
|
|
|
|
drainRate = tagCompound.getInteger(Constants.NBT.ALTAR_DRAIN_RATE);
|
|
|
|
consumptionMultiplier = tagCompound.getFloat(Constants.NBT.ALTAR_CONSUMPTION_MULTIPLIER);
|
|
|
|
efficiencyMultiplier = tagCompound.getFloat(Constants.NBT.ALTAR_EFFICIENCY_MULTIPLIER);
|
|
|
|
selfSacrificeEfficiencyMultiplier = tagCompound.getFloat(Constants.NBT.ALTAR_SELF_SACRIFICE_MULTIPLIER);
|
|
|
|
sacrificeEfficiencyMultiplier = tagCompound.getFloat(Constants.NBT.ALTAR_SACRIFICE_MULTIPLIER);
|
|
|
|
capacityMultiplier = tagCompound.getFloat(Constants.NBT.ALTAR_CAPACITY_MULTIPLIER);
|
|
|
|
orbCapacityMultiplier = tagCompound.getFloat(Constants.NBT.ALTAR_ORB_CAPACITY_MULTIPLIER);
|
|
|
|
dislocationMultiplier = tagCompound.getFloat(Constants.NBT.ALTAR_DISLOCATION_MULTIPLIER);
|
|
|
|
capacity = tagCompound.getInteger(Constants.NBT.ALTAR_CAPACITY);
|
|
|
|
bufferCapacity = tagCompound.getInteger(Constants.NBT.ALTAR_BUFFER_CAPACITY);
|
|
|
|
progress = tagCompound.getInteger(Constants.NBT.ALTAR_PROGRESS);
|
|
|
|
isResultBlock = tagCompound.getBoolean(Constants.NBT.ALTAR_IS_RESULT_BLOCK);
|
|
|
|
lockdownDuration = tagCompound.getInteger(Constants.NBT.ALTAR_LOCKDOWN_DURATION);
|
|
|
|
accelerationUpgrades = tagCompound.getInteger(Constants.NBT.ALTAR_ACCELERATION_UPGRADES);
|
|
|
|
demonBloodDuration = tagCompound.getInteger(Constants.NBT.ALTAR_DEMON_BLOOD_DURATION);
|
|
|
|
cooldownAfterCrafting = tagCompound.getInteger(Constants.NBT.ALTAR_COOLDOWN_AFTER_CRAFTING);
|
2015-10-30 03:22:14 +00:00
|
|
|
}
|
|
|
|
|
2015-11-03 02:30:28 +00:00
|
|
|
@Override
|
2015-11-03 16:09:16 +00:00
|
|
|
public void writeToNBT(NBTTagCompound tagCompound) {
|
|
|
|
super.writeToNBT(tagCompound);
|
|
|
|
|
|
|
|
if (fluid != null)
|
|
|
|
fluid.writeToNBT(tagCompound);
|
|
|
|
else
|
2015-11-29 02:25:46 +00:00
|
|
|
tagCompound.setString(Constants.NBT.EMPTY, "");
|
2015-11-03 16:09:16 +00:00
|
|
|
|
|
|
|
if (fluidOutput != null)
|
2015-11-29 02:25:46 +00:00
|
|
|
tagCompound.setInteger(Constants.NBT.OUTPUT_AMOUNT, fluidOutput.amount);
|
2015-11-03 16:09:16 +00:00
|
|
|
|
|
|
|
if (fluidInput != null)
|
2015-11-29 02:25:46 +00:00
|
|
|
tagCompound.setInteger(Constants.NBT.INPUT_AMOUNT, fluidInput.amount);
|
|
|
|
|
|
|
|
tagCompound.setString(Constants.NBT.ALTAR_TIER, altarTier.name());
|
|
|
|
tagCompound.setBoolean(Constants.NBT.ALTAR_ACTIVE, isActive);
|
|
|
|
tagCompound.setInteger(Constants.NBT.ALTAR_LIQUID_REQ, liquidRequired);
|
|
|
|
tagCompound.setBoolean(Constants.NBT.ALTAR_FILLABLE, canBeFilled);
|
|
|
|
tagCompound.setBoolean(Constants.NBT.ALTAR_UPGRADED, isUpgraded);
|
|
|
|
tagCompound.setInteger(Constants.NBT.ALTAR_CONSUMPTION_RATE, consumptionRate);
|
|
|
|
tagCompound.setInteger(Constants.NBT.ALTAR_DRAIN_RATE, drainRate);
|
|
|
|
tagCompound.setFloat(Constants.NBT.ALTAR_CONSUMPTION_MULTIPLIER, consumptionMultiplier);
|
|
|
|
tagCompound.setFloat(Constants.NBT.ALTAR_EFFICIENCY_MULTIPLIER, efficiencyMultiplier);
|
|
|
|
tagCompound.setFloat(Constants.NBT.ALTAR_SACRIFICE_MULTIPLIER, sacrificeEfficiencyMultiplier);
|
|
|
|
tagCompound.setFloat(Constants.NBT.ALTAR_SELF_SACRIFICE_MULTIPLIER, selfSacrificeEfficiencyMultiplier);
|
|
|
|
tagCompound.setBoolean(Constants.NBT.ALTAR_IS_RESULT_BLOCK, isResultBlock);
|
|
|
|
tagCompound.setFloat(Constants.NBT.ALTAR_CAPACITY_MULTIPLIER, capacityMultiplier);
|
|
|
|
tagCompound.setFloat(Constants.NBT.ALTAR_ORB_CAPACITY_MULTIPLIER, orbCapacityMultiplier);
|
|
|
|
tagCompound.setFloat(Constants.NBT.ALTAR_DISLOCATION_MULTIPLIER, dislocationMultiplier);
|
|
|
|
tagCompound.setInteger(Constants.NBT.ALTAR_CAPACITY, capacity);
|
|
|
|
tagCompound.setInteger(Constants.NBT.ALTAR_PROGRESS, progress);
|
|
|
|
tagCompound.setInteger(Constants.NBT.ALTAR_BUFFER_CAPACITY, bufferCapacity);
|
|
|
|
tagCompound.setInteger(Constants.NBT.ALTAR_LOCKDOWN_DURATION, lockdownDuration);
|
|
|
|
tagCompound.setInteger(Constants.NBT.ALTAR_ACCELERATION_UPGRADES, accelerationUpgrades);
|
|
|
|
tagCompound.setInteger(Constants.NBT.ALTAR_DEMON_BLOOD_DURATION, demonBloodDuration);
|
|
|
|
tagCompound.setInteger(Constants.NBT.ALTAR_COOLDOWN_AFTER_CRAFTING, cooldownAfterCrafting);
|
2015-11-03 15:34:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void update() {
|
2015-11-03 16:09:16 +00:00
|
|
|
if (getWorld().isRemote)
|
2015-11-03 02:30:28 +00:00
|
|
|
return;
|
|
|
|
|
2015-11-28 01:15:19 +00:00
|
|
|
this.decrementDemonBlood();
|
|
|
|
|
|
|
|
if (lockdownDuration > 0)
|
|
|
|
lockdownDuration--;
|
|
|
|
|
2015-11-29 02:25:46 +00:00
|
|
|
if (!getWorld().isRemote && getWorld().getWorldTime() % 20 == 0) {
|
|
|
|
IBlockState block = getWorld().getBlockState(new BlockPos(this.pos.getX() + 1, this.pos.getY(), this.pos.getZ()));
|
|
|
|
block.getBlock().onNeighborBlockChange(getWorld(), new BlockPos(this.pos.getX() + 1, this.pos.getY(), this.pos.getZ()), block, block.getBlock());
|
|
|
|
block = getWorld().getBlockState(new BlockPos(this.pos.getX() + 1, this.pos.getY(), this.pos.getZ()));
|
|
|
|
block.getBlock().onNeighborBlockChange(getWorld(), new BlockPos(this.pos.getX() - 1, this.pos.getY(), this.pos.getZ()), block, block.getBlock());
|
|
|
|
block = getWorld().getBlockState(new BlockPos(this.pos.getX(), this.pos.getY() + 1, this.pos.getZ()));
|
|
|
|
block.getBlock().onNeighborBlockChange(getWorld(), new BlockPos(this.pos.getX(), this.pos.getY() + 1, this.pos.getZ()), block, block.getBlock());
|
|
|
|
block = getWorld().getBlockState(new BlockPos(this.pos.getX(), this.pos.getY() - 1, this.pos.getZ()));
|
|
|
|
block.getBlock().onNeighborBlockChange(getWorld(), new BlockPos(this.pos.getX(), this.pos.getY() - 1, this.pos.getZ()), block, block.getBlock());
|
|
|
|
block = getWorld().getBlockState(new BlockPos(this.pos.getX(), this.pos.getY(), this.pos.getZ() + 1));
|
|
|
|
block.getBlock().onNeighborBlockChange(getWorld(), new BlockPos(this.pos.getX(), this.pos.getY(), this.pos.getZ() + 1), block, block.getBlock());
|
|
|
|
block = getWorld().getBlockState(new BlockPos(this.pos.getX(), this.pos.getY(), this.pos.getZ() - 1));
|
|
|
|
block.getBlock().onNeighborBlockChange(getWorld(), new BlockPos(this.pos.getX(), this.pos.getY(), this.pos.getZ() - 1), block, block.getBlock());
|
2015-11-28 01:15:19 +00:00
|
|
|
}
|
|
|
|
if (getWorld().getTotalWorldTime() % (Math.max(20 - this.accelerationUpgrades, 1)) == 0)
|
2015-11-03 02:30:28 +00:00
|
|
|
everySecond();
|
|
|
|
|
2015-11-29 02:25:46 +00:00
|
|
|
if (getWorld().getTotalWorldTime() % 100 == 0 && (this.isActive || this.cooldownAfterCrafting <= 0))
|
2015-11-03 02:30:28 +00:00
|
|
|
everyFiveSeconds();
|
2015-11-28 01:15:19 +00:00
|
|
|
|
|
|
|
updat();
|
2015-11-03 02:30:28 +00:00
|
|
|
}
|
2015-10-30 03:22:14 +00:00
|
|
|
|
2015-11-03 15:34:11 +00:00
|
|
|
private void everySecond() {
|
2015-11-07 16:51:41 +00:00
|
|
|
int syphonMax = (int) (20 * this.dislocationMultiplier);
|
|
|
|
int fluidInputted;
|
|
|
|
int fluidOutputted;
|
|
|
|
fluidInputted = Math.min(syphonMax, -this.fluid.amount + capacity);
|
|
|
|
fluidInputted = Math.min(this.fluidInput.amount, fluidInputted);
|
|
|
|
this.fluid.amount += fluidInputted;
|
|
|
|
this.fluidInput.amount -= fluidInputted;
|
|
|
|
fluidOutputted = Math.min(syphonMax, this.bufferCapacity - this.fluidOutput.amount);
|
|
|
|
fluidOutputted = Math.min(this.fluid.amount, fluidOutputted);
|
|
|
|
this.fluidOutput.amount += fluidOutputted;
|
|
|
|
this.fluid.amount -= fluidOutputted;
|
2015-11-03 02:30:28 +00:00
|
|
|
}
|
2015-10-30 03:22:14 +00:00
|
|
|
|
2015-11-03 15:34:11 +00:00
|
|
|
private void everyFiveSeconds() {
|
2015-11-07 16:51:41 +00:00
|
|
|
startCycle();
|
2015-11-03 02:30:28 +00:00
|
|
|
}
|
|
|
|
|
2015-11-28 01:15:19 +00:00
|
|
|
@Override
|
2015-11-03 15:34:11 +00:00
|
|
|
public void startCycle() {
|
2015-11-29 02:25:46 +00:00
|
|
|
if (getWorld() != null)
|
|
|
|
getWorld().markBlockForUpdate(pos);
|
2015-11-03 15:34:11 +00:00
|
|
|
|
2015-11-07 16:51:41 +00:00
|
|
|
checkTier();
|
|
|
|
|
2015-11-03 16:09:16 +00:00
|
|
|
if (fluid == null || fluid.amount <= 0)
|
2015-11-03 15:34:11 +00:00
|
|
|
return;
|
|
|
|
|
2015-11-29 02:25:46 +00:00
|
|
|
if (!isActive)
|
2015-11-07 16:51:41 +00:00
|
|
|
progress = 0;
|
|
|
|
|
2015-11-03 15:34:11 +00:00
|
|
|
if (getStackInSlot(0) != null) {
|
|
|
|
// Do recipes
|
2015-11-28 01:15:19 +00:00
|
|
|
for (ItemStack itemStack : AltarRecipeRegistry.getRecipes().keySet()) {
|
|
|
|
if (getStackInSlot(0).getIsItemStackEqual(AltarRecipeRegistry.getRecipes().get(itemStack).getInput())) {
|
|
|
|
AltarRecipe recipe = AltarRecipeRegistry.getRecipeForInput(itemStack);
|
|
|
|
|
|
|
|
if (altarTier.ordinal() >= recipe.getMinTier().ordinal()) {
|
|
|
|
this.isActive = true;
|
|
|
|
this.result = new ItemStack(recipe.getOutput().getItem(), 1, recipe.getOutput().getMetadata());
|
|
|
|
this.liquidRequired = recipe.getSyphon();
|
|
|
|
this.canBeFilled = recipe.isUseTag();
|
|
|
|
this.consumptionRate = recipe.getConsumeRate();
|
|
|
|
this.drainRate = recipe.getDrainRate();
|
|
|
|
return;
|
|
|
|
}
|
2015-11-03 15:34:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-11-07 16:51:41 +00:00
|
|
|
|
|
|
|
isActive = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void updat() {
|
|
|
|
if (!isActive) {
|
2015-11-29 02:25:46 +00:00
|
|
|
if (cooldownAfterCrafting > 0)
|
2015-11-07 16:51:41 +00:00
|
|
|
cooldownAfterCrafting--;
|
2015-11-28 01:15:19 +00:00
|
|
|
return;
|
2015-11-07 16:51:41 +00:00
|
|
|
}
|
|
|
|
|
2015-11-29 02:25:46 +00:00
|
|
|
if (getStackInSlot(0) == null)
|
2015-11-07 16:51:41 +00:00
|
|
|
return;
|
|
|
|
|
2015-11-29 02:25:46 +00:00
|
|
|
int worldTime = (int) (getWorld().getWorldTime() % 24000);
|
2015-11-07 16:51:41 +00:00
|
|
|
|
2015-11-29 02:25:46 +00:00
|
|
|
if (getWorld().isRemote)
|
2015-11-07 16:51:41 +00:00
|
|
|
return;
|
2015-11-28 01:15:19 +00:00
|
|
|
|
|
|
|
float f = 1.0F;
|
|
|
|
float f1 = f * 0.6F + 0.4F;
|
|
|
|
float f2 = f * f * 0.7F - 0.5F;
|
|
|
|
float f3 = f * f * 0.6F - 0.7F;
|
2015-11-07 16:51:41 +00:00
|
|
|
|
|
|
|
if (!canBeFilled) {
|
|
|
|
if (fluid != null && fluid.amount >= 1) {
|
|
|
|
int stackSize = getStackInSlot(0).stackSize;
|
|
|
|
int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? consumptionRate * (1 + consumptionMultiplier) : consumptionRate), fluid.amount);
|
|
|
|
|
2015-11-29 02:25:46 +00:00
|
|
|
if (liquidDrained > (liquidRequired * stackSize - progress))
|
2015-11-07 16:51:41 +00:00
|
|
|
liquidDrained = liquidRequired * stackSize - progress;
|
|
|
|
|
|
|
|
fluid.amount = fluid.amount - liquidDrained;
|
|
|
|
progress += liquidDrained;
|
|
|
|
|
2015-11-29 02:25:46 +00:00
|
|
|
if (worldTime % 4 == 0)
|
|
|
|
getWorld().spawnParticle(EnumParticleTypes.REDSTONE, this.pos.getX() + Math.random() - Math.random(), this.pos.getY() + Math.random() - Math.random(), this.pos.getZ() + Math.random() - Math.random(), f1, f2, f3);
|
2015-11-07 16:51:41 +00:00
|
|
|
|
|
|
|
if (progress >= liquidRequired * stackSize) {
|
2015-11-28 01:15:19 +00:00
|
|
|
ItemStack result = this.result;
|
2015-11-29 02:25:46 +00:00
|
|
|
|
|
|
|
if (result != null)
|
2015-11-07 16:51:41 +00:00
|
|
|
result.stackSize *= stackSize;
|
|
|
|
|
|
|
|
setInventorySlotContents(0, result);
|
|
|
|
progress = 0;
|
|
|
|
|
2015-11-29 02:25:46 +00:00
|
|
|
for (int i = 0; i < 8; i++)
|
|
|
|
getWorld().spawnParticle(EnumParticleTypes.REDSTONE, this.pos.getX() + Math.random() - Math.random(), this.pos.getY() + Math.random() - Math.random(), this.pos.getZ() + Math.random() - Math.random(), f1, f2, f3);
|
|
|
|
|
2015-11-07 16:51:41 +00:00
|
|
|
this.isActive = false;
|
|
|
|
}
|
|
|
|
} else if (progress > 0) {
|
|
|
|
progress -= (int) (efficiencyMultiplier * drainRate);
|
|
|
|
|
2015-11-29 02:25:46 +00:00
|
|
|
if (worldTime % 2 == 0)
|
|
|
|
getWorld().spawnParticle(EnumParticleTypes.REDSTONE, this.pos.getX() + Math.random() - Math.random(), this.pos.getY() + Math.random() - Math.random(), this.pos.getZ() + Math.random() - Math.random(), f1, f2, f3);
|
2015-11-07 16:51:41 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ItemStack returnedItem = getStackInSlot(0);
|
|
|
|
|
2015-11-29 02:25:46 +00:00
|
|
|
if (!(returnedItem.getItem() instanceof IBloodOrb))
|
2015-11-07 16:51:41 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
IBloodOrb item = (IBloodOrb) (returnedItem.getItem());
|
|
|
|
NBTTagCompound itemTag = returnedItem.getTagCompound();
|
|
|
|
|
2015-11-29 02:25:46 +00:00
|
|
|
if (itemTag == null)
|
2015-11-07 16:51:41 +00:00
|
|
|
return;
|
|
|
|
|
2015-11-29 02:25:46 +00:00
|
|
|
String ownerName = itemTag.getString(Constants.NBT.OWNER_NAME);
|
2015-11-07 16:51:41 +00:00
|
|
|
|
2015-11-29 02:25:46 +00:00
|
|
|
if (Strings.isNullOrEmpty(ownerName))
|
2015-11-07 16:51:41 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (fluid != null && fluid.amount >= 1) {
|
|
|
|
int liquidDrained = Math.min((int) (altarTier.ordinal() >= 2 ? consumptionRate * (1 + consumptionMultiplier) : consumptionRate), fluid.amount);
|
|
|
|
|
2015-11-22 22:02:56 +00:00
|
|
|
int drain = NetworkHelper.getSoulNetwork(ownerName, getWorld()).addLifeEssence(liquidDrained, (int) (item.getMaxEssence(returnedItem.getMetadata()) * this.orbCapacityMultiplier));
|
2015-11-07 16:51:41 +00:00
|
|
|
|
|
|
|
fluid.amount = fluid.amount - drain;
|
|
|
|
|
2015-11-29 02:25:46 +00:00
|
|
|
if (worldTime % 4 == 0)
|
|
|
|
getWorld().spawnParticle(EnumParticleTypes.REDSTONE, this.pos.getX() + Math.random() - Math.random(), this.pos.getY() + Math.random() - Math.random(), this.pos.getZ() + Math.random() - Math.random(), f1, f2, f3);
|
2015-11-07 16:51:41 +00:00
|
|
|
}
|
|
|
|
}
|
2015-11-29 02:25:46 +00:00
|
|
|
if (getWorld() != null)
|
|
|
|
getWorld().markBlockForUpdate(pos);
|
2015-11-03 15:34:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void checkTier() {
|
2015-11-03 02:30:28 +00:00
|
|
|
// TODO - Write checking for tier stuff
|
|
|
|
|
|
|
|
EnumAltarTier tier = BloodAltar.getAltarTier(getWorld(), getPos());
|
2015-11-08 02:37:12 +00:00
|
|
|
this.altarTier = tier;
|
2015-11-03 02:30:28 +00:00
|
|
|
|
2015-11-03 16:09:16 +00:00
|
|
|
if (tier.equals(EnumAltarTier.ONE))
|
2015-11-03 02:30:28 +00:00
|
|
|
upgrade = new AltarUpgrade();
|
2015-11-03 16:09:16 +00:00
|
|
|
else
|
2015-11-29 02:25:46 +00:00
|
|
|
upgrade = BloodAltar.getUpgrades(getWorld(), pos, tier);
|
2015-11-03 15:34:11 +00:00
|
|
|
|
2015-11-03 16:09:16 +00:00
|
|
|
if (this.fluid.amount > this.capacity)
|
2015-11-03 15:34:11 +00:00
|
|
|
this.fluid.amount = this.capacity;
|
|
|
|
|
2015-11-29 02:25:46 +00:00
|
|
|
getWorld().markBlockForUpdate(pos);
|
2015-11-03 15:34:11 +00:00
|
|
|
}
|
|
|
|
|
2015-11-11 18:45:46 +00:00
|
|
|
public int fillMainTank(int amount) {
|
|
|
|
int filledAmount = Math.min(capacity - fluid.amount, amount);
|
|
|
|
fluid.amount += filledAmount;
|
|
|
|
|
|
|
|
return filledAmount;
|
|
|
|
}
|
|
|
|
|
2015-11-28 01:15:19 +00:00
|
|
|
@Override
|
2015-11-03 15:34:11 +00:00
|
|
|
public void sacrificialDaggerCall(int amount, boolean isSacrifice) {
|
2015-11-03 16:09:16 +00:00
|
|
|
if (this.lockdownDuration > 0) {
|
2015-11-03 15:34:11 +00:00
|
|
|
int amt = (int) Math.min(bufferCapacity - fluidInput.amount, (isSacrifice ? 1 + sacrificeEfficiencyMultiplier : 1 + selfSacrificeEfficiencyMultiplier) * amount);
|
|
|
|
fluidInput.amount += amt;
|
|
|
|
} else {
|
|
|
|
fluid.amount += Math.min(capacity - fluid.amount, (isSacrifice ? 1 + sacrificeEfficiencyMultiplier : 1 + selfSacrificeEfficiencyMultiplier) * amount);
|
2015-11-03 02:30:28 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-11-03 15:34:11 +00:00
|
|
|
@Override
|
|
|
|
public boolean isItemValidForSlot(int slot, ItemStack itemstack) {
|
|
|
|
return slot == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public AltarUpgrade getUpgrade() {
|
2015-10-30 03:22:14 +00:00
|
|
|
return upgrade;
|
|
|
|
}
|
|
|
|
|
2015-11-29 02:25:46 +00:00
|
|
|
public TileAltar setUpgrade(AltarUpgrade upgrade) {
|
|
|
|
this.upgrade = upgrade;
|
2015-10-30 03:22:14 +00:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2015-11-03 15:34:11 +00:00
|
|
|
@Override
|
|
|
|
public int getCapacity() {
|
|
|
|
return capacity;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getCurrentBlood() {
|
|
|
|
return getFluidAmount();
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2015-11-03 16:09:16 +00:00
|
|
|
public EnumAltarTier getTier() {
|
|
|
|
return altarTier;
|
2015-11-03 15:34:11 +00:00
|
|
|
}
|
|
|
|
|
2015-11-29 02:25:46 +00:00
|
|
|
public TileAltar setTier(EnumAltarTier tier) {
|
|
|
|
this.altarTier = tier;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2015-11-03 15:34:11 +00:00
|
|
|
@Override
|
|
|
|
public int getProgress() {
|
|
|
|
return progress;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public float getSacrificeMultiplier() {
|
|
|
|
return sacrificeEfficiencyMultiplier;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public float getSelfSacrificeMultiplier() {
|
|
|
|
return selfSacrificeEfficiencyMultiplier;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public float getOrbMultiplier() {
|
|
|
|
return orbCapacityMultiplier;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public float getDislocationMultiplier() {
|
|
|
|
return dislocationMultiplier;
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getBufferCapacity() {
|
|
|
|
return bufferCapacity;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void addToDemonBloodDuration(int dur) {
|
|
|
|
this.demonBloodDuration += dur;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean hasDemonBlood() {
|
|
|
|
return this.demonBloodDuration > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void decrementDemonBlood() {
|
|
|
|
this.demonBloodDuration = Math.max(0, this.demonBloodDuration - 1);
|
|
|
|
}
|
|
|
|
|
2015-11-07 16:51:41 +00:00
|
|
|
public void setActive() {
|
|
|
|
isActive = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
public boolean isActive() {
|
|
|
|
return isActive;
|
|
|
|
}
|
|
|
|
|
2015-11-03 15:34:11 +00:00
|
|
|
@Override
|
|
|
|
public void requestPauseAfterCrafting(int amount) {
|
|
|
|
if (this.isActive) {
|
|
|
|
this.cooldownAfterCrafting = amount;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setMainFluid(FluidStack fluid) {
|
|
|
|
this.fluid = fluid;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setOutputFluid(FluidStack fluid) {
|
|
|
|
this.fluidOutput = fluid;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setInputFluid(FluidStack fluid) {
|
|
|
|
this.fluidInput = fluid;
|
2015-10-30 03:22:14 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// 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 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;
|
|
|
|
}
|
2015-11-07 16:51:41 +00:00
|
|
|
}
|