Cleanup
This commit is contained in:
parent
081698c6f9
commit
fa1bb906d3
7 changed files with 111 additions and 164 deletions
|
@ -2,6 +2,7 @@ package WayofTime.bloodmagic.tile;
|
|||
|
||||
import WayofTime.bloodmagic.altar.BloodAltar;
|
||||
import WayofTime.bloodmagic.api.BloodMagicAPI;
|
||||
import WayofTime.bloodmagic.api.NBTHolder;
|
||||
import WayofTime.bloodmagic.api.altar.AltarRecipe;
|
||||
import WayofTime.bloodmagic.api.altar.AltarUpgrade;
|
||||
import WayofTime.bloodmagic.api.altar.EnumAltarTier;
|
||||
|
@ -15,17 +16,15 @@ import net.minecraft.util.EnumFacing;
|
|||
import net.minecraftforge.fluids.*;
|
||||
|
||||
public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlayerListBox, IFluidTank, IFluidHandler {
|
||||
private int tier;
|
||||
|
||||
private EnumAltarTier altarTier = EnumAltarTier.ONE;
|
||||
private AltarUpgrade upgrade = new AltarUpgrade();
|
||||
private int capacity = FluidContainerRegistry.BUCKET_VOLUME * 10;
|
||||
|
||||
private FluidStack fluid = new FluidStack(BloodMagicAPI.getLifeEssence(), 0);
|
||||
protected FluidStack fluidOutput = new FluidStack(BlockLifeEssence.getLifeEssence(), 0);
|
||||
protected FluidStack fluidInput = new FluidStack(BlockLifeEssence.getLifeEssence(), 0);
|
||||
private int capacity;
|
||||
|
||||
private int upgradeLevel;
|
||||
|
||||
private int resultID;
|
||||
private int resultDamage;
|
||||
private int liquidRequired; //mB
|
||||
private boolean canBeFilled;
|
||||
private int consumptionRate;
|
||||
|
@ -34,13 +33,13 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
|
|||
private float efficiencyMultiplier;
|
||||
private float sacrificeEfficiencyMultiplier;
|
||||
private float selfSacrificeEfficiencyMultiplier;
|
||||
private float capacityMultiplier;
|
||||
private float capacityMultiplier = 1;
|
||||
private float orbCapacityMultiplier;
|
||||
private float dislocationMultiplier;
|
||||
private int accelerationUpgrades;
|
||||
private boolean isUpgraded;
|
||||
private boolean isResultBlock;
|
||||
private int bufferCapacity;
|
||||
private int bufferCapacity = FluidContainerRegistry.BUCKET_VOLUME;
|
||||
private int progress;
|
||||
|
||||
public boolean isActive;
|
||||
|
@ -52,134 +51,99 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
|
|||
|
||||
public TileAltar() {
|
||||
super(1, "altar");
|
||||
|
||||
this.capacity = FluidContainerRegistry.BUCKET_VOLUME * 10;
|
||||
this.bufferCapacity = FluidContainerRegistry.BUCKET_VOLUME;
|
||||
this.resultID = 0;
|
||||
this.resultDamage = 0;
|
||||
this.isActive = false;
|
||||
this.consumptionRate = 0;
|
||||
this.drainRate = 0;
|
||||
this.consumptionMultiplier = 0;
|
||||
this.efficiencyMultiplier = 0;
|
||||
this.capacityMultiplier = 1;
|
||||
this.isUpgraded = false;
|
||||
this.isResultBlock = false;
|
||||
this.upgradeLevel = 0;
|
||||
this.progress = 0;
|
||||
this.lockdownDuration = 0;
|
||||
this.demonBloodDuration = 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound par1NBTTagCompound) {
|
||||
super.readFromNBT(par1NBTTagCompound);
|
||||
public void readFromNBT(NBTTagCompound tagCompound) {
|
||||
super.readFromNBT(tagCompound);
|
||||
|
||||
resultID = par1NBTTagCompound.getInteger("resultID");
|
||||
resultDamage = par1NBTTagCompound.getInteger("resultDamage");
|
||||
if (!tagCompound.hasKey("Empty")) {
|
||||
FluidStack fluid = FluidStack.loadFluidStackFromNBT(tagCompound);
|
||||
|
||||
if (!par1NBTTagCompound.hasKey("Empty")) {
|
||||
FluidStack fluid = this.fluid.loadFluidStackFromNBT(par1NBTTagCompound);
|
||||
|
||||
if (fluid != null) {
|
||||
if (fluid != null)
|
||||
setMainFluid(fluid);
|
||||
}
|
||||
|
||||
FluidStack fluidOut = new FluidStack(BloodMagicAPI.getLifeEssence(), par1NBTTagCompound.getInteger("outputAmount"));
|
||||
FluidStack fluidOut = new FluidStack(BloodMagicAPI.getLifeEssence(), tagCompound.getInteger("outputAmount"));
|
||||
setOutputFluid(fluidOut);
|
||||
|
||||
if (fluidOut != null) {
|
||||
setOutputFluid(fluidOut);
|
||||
}
|
||||
|
||||
FluidStack fluidIn = new FluidStack(BloodMagicAPI.getLifeEssence(), par1NBTTagCompound.getInteger("inputAmount"));
|
||||
|
||||
if (fluidIn != null) {
|
||||
setInputFluid(fluidIn);
|
||||
}
|
||||
FluidStack fluidIn = new FluidStack(BloodMagicAPI.getLifeEssence(), tagCompound.getInteger("inputAmount"));
|
||||
setInputFluid(fluidIn);
|
||||
}
|
||||
|
||||
upgradeLevel = par1NBTTagCompound.getInteger("upgradeLevel");
|
||||
isActive = par1NBTTagCompound.getBoolean("isActive");
|
||||
liquidRequired = par1NBTTagCompound.getInteger("liquidRequired");
|
||||
canBeFilled = par1NBTTagCompound.getBoolean("canBeFilled");
|
||||
isUpgraded = par1NBTTagCompound.getBoolean("isUpgraded");
|
||||
consumptionRate = par1NBTTagCompound.getInteger("consumptionRate");
|
||||
drainRate = par1NBTTagCompound.getInteger("drainRate");
|
||||
consumptionMultiplier = par1NBTTagCompound.getFloat("consumptionMultiplier");
|
||||
efficiencyMultiplier = par1NBTTagCompound.getFloat("efficiencyMultiplier");
|
||||
selfSacrificeEfficiencyMultiplier = par1NBTTagCompound.getFloat("selfSacrificeEfficiencyMultiplier");
|
||||
sacrificeEfficiencyMultiplier = par1NBTTagCompound.getFloat("sacrificeEfficiencyMultiplier");
|
||||
capacityMultiplier = par1NBTTagCompound.getFloat("capacityMultiplier");
|
||||
orbCapacityMultiplier = par1NBTTagCompound.getFloat("orbCapacityMultiplier");
|
||||
dislocationMultiplier = par1NBTTagCompound.getFloat("dislocationMultiplier");
|
||||
capacity = par1NBTTagCompound.getInteger("capacity");
|
||||
bufferCapacity = par1NBTTagCompound.getInteger("bufferCapacity");
|
||||
progress = par1NBTTagCompound.getInteger("progress");
|
||||
isResultBlock = par1NBTTagCompound.getBoolean("isResultBlock");
|
||||
lockdownDuration = par1NBTTagCompound.getInteger("lockdownDuration");
|
||||
accelerationUpgrades = par1NBTTagCompound.getInteger("accelerationUpgrades");
|
||||
demonBloodDuration = par1NBTTagCompound.getInteger("demonBloodDuration");
|
||||
cooldownAfterCrafting = par1NBTTagCompound.getInteger("cooldownAfterCrafting");
|
||||
altarTier = EnumAltarTier.valueOf(tagCompound.getString(NBTHolder.NBT_ALTAR_TIER));
|
||||
isActive = tagCompound.getBoolean(NBTHolder.NBT_ALTAR_ACTIVE);
|
||||
liquidRequired = tagCompound.getInteger(NBTHolder.NBT_ALTAR_LIQUID_REQ);
|
||||
canBeFilled = tagCompound.getBoolean(NBTHolder.NBT_ALTAR_FILLABLE);
|
||||
isUpgraded = tagCompound.getBoolean("isUpgraded");
|
||||
consumptionRate = tagCompound.getInteger("consumptionRate");
|
||||
drainRate = tagCompound.getInteger("drainRate");
|
||||
consumptionMultiplier = tagCompound.getFloat("consumptionMultiplier");
|
||||
efficiencyMultiplier = tagCompound.getFloat("efficiencyMultiplier");
|
||||
selfSacrificeEfficiencyMultiplier = tagCompound.getFloat("selfSacrificeEfficiencyMultiplier");
|
||||
sacrificeEfficiencyMultiplier = tagCompound.getFloat("sacrificeEfficiencyMultiplier");
|
||||
capacityMultiplier = tagCompound.getFloat("capacityMultiplier");
|
||||
orbCapacityMultiplier = tagCompound.getFloat("orbCapacityMultiplier");
|
||||
dislocationMultiplier = tagCompound.getFloat("dislocationMultiplier");
|
||||
capacity = tagCompound.getInteger("capacity");
|
||||
bufferCapacity = tagCompound.getInteger("bufferCapacity");
|
||||
progress = tagCompound.getInteger("progress");
|
||||
isResultBlock = tagCompound.getBoolean("isResultBlock");
|
||||
lockdownDuration = tagCompound.getInteger("lockdownDuration");
|
||||
accelerationUpgrades = tagCompound.getInteger("accelerationUpgrades");
|
||||
demonBloodDuration = tagCompound.getInteger("demonBloodDuration");
|
||||
cooldownAfterCrafting = tagCompound.getInteger("cooldownAfterCrafting");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound par1NBTTagCompound) {
|
||||
super.writeToNBT(par1NBTTagCompound);
|
||||
public void writeToNBT(NBTTagCompound tagCompound) {
|
||||
super.writeToNBT(tagCompound);
|
||||
|
||||
par1NBTTagCompound.setInteger("resultID", resultID);
|
||||
par1NBTTagCompound.setInteger("resultDamage", resultDamage);
|
||||
if (fluid != null)
|
||||
fluid.writeToNBT(tagCompound);
|
||||
else
|
||||
tagCompound.setString("Empty", "");
|
||||
|
||||
if (fluid != null) {
|
||||
fluid.writeToNBT(par1NBTTagCompound);
|
||||
} else {
|
||||
par1NBTTagCompound.setString("Empty", "");
|
||||
}
|
||||
|
||||
if (fluidOutput != null) {
|
||||
par1NBTTagCompound.setInteger("outputAmount", fluidOutput.amount);
|
||||
}
|
||||
if (fluidOutput != null)
|
||||
tagCompound.setInteger("outputAmount", fluidOutput.amount);
|
||||
|
||||
if (fluidInput != null) {
|
||||
par1NBTTagCompound.setInteger("inputAmount", fluidInput.amount);
|
||||
}
|
||||
if (fluidInput != null)
|
||||
tagCompound.setInteger("inputAmount", fluidInput.amount);
|
||||
|
||||
par1NBTTagCompound.setInteger("upgradeLevel", upgradeLevel);
|
||||
par1NBTTagCompound.setBoolean("isActive", isActive);
|
||||
par1NBTTagCompound.setInteger("liquidRequired", liquidRequired);
|
||||
par1NBTTagCompound.setBoolean("canBeFilled", canBeFilled);
|
||||
par1NBTTagCompound.setBoolean("isUpgraded", isUpgraded);
|
||||
par1NBTTagCompound.setInteger("consumptionRate", consumptionRate);
|
||||
par1NBTTagCompound.setInteger("drainRate", drainRate);
|
||||
par1NBTTagCompound.setFloat("consumptionMultiplier", consumptionMultiplier);
|
||||
par1NBTTagCompound.setFloat("efficiencyMultiplier", efficiencyMultiplier);
|
||||
par1NBTTagCompound.setFloat("sacrificeEfficiencyMultiplier", sacrificeEfficiencyMultiplier);
|
||||
par1NBTTagCompound.setFloat("selfSacrificeEfficiencyMultiplier", selfSacrificeEfficiencyMultiplier);
|
||||
par1NBTTagCompound.setBoolean("isResultBlock", isResultBlock);
|
||||
par1NBTTagCompound.setFloat("capacityMultiplier", capacityMultiplier);
|
||||
par1NBTTagCompound.setFloat("orbCapacityMultiplier", orbCapacityMultiplier);
|
||||
par1NBTTagCompound.setFloat("dislocationMultiplier", dislocationMultiplier);
|
||||
par1NBTTagCompound.setInteger("capacity", capacity);
|
||||
par1NBTTagCompound.setInteger("progress", progress);
|
||||
par1NBTTagCompound.setInteger("bufferCapacity", bufferCapacity);
|
||||
par1NBTTagCompound.setInteger("lockdownDuration", lockdownDuration);
|
||||
par1NBTTagCompound.setInteger("accelerationUpgrades", this.accelerationUpgrades);
|
||||
par1NBTTagCompound.setInteger("demonBloodDuration", demonBloodDuration);
|
||||
par1NBTTagCompound.setInteger("cooldownAfterCrafting", cooldownAfterCrafting);
|
||||
tagCompound.setString("upgradeLevel", altarTier.name());
|
||||
tagCompound.setBoolean("isActive", isActive);
|
||||
tagCompound.setInteger("liquidRequired", liquidRequired);
|
||||
tagCompound.setBoolean("canBeFilled", canBeFilled);
|
||||
tagCompound.setBoolean("isUpgraded", isUpgraded);
|
||||
tagCompound.setInteger("consumptionRate", consumptionRate);
|
||||
tagCompound.setInteger("drainRate", drainRate);
|
||||
tagCompound.setFloat("consumptionMultiplier", consumptionMultiplier);
|
||||
tagCompound.setFloat("efficiencyMultiplier", efficiencyMultiplier);
|
||||
tagCompound.setFloat("sacrificeEfficiencyMultiplier", sacrificeEfficiencyMultiplier);
|
||||
tagCompound.setFloat("selfSacrificeEfficiencyMultiplier", selfSacrificeEfficiencyMultiplier);
|
||||
tagCompound.setBoolean("isResultBlock", isResultBlock);
|
||||
tagCompound.setFloat("capacityMultiplier", capacityMultiplier);
|
||||
tagCompound.setFloat("orbCapacityMultiplier", orbCapacityMultiplier);
|
||||
tagCompound.setFloat("dislocationMultiplier", dislocationMultiplier);
|
||||
tagCompound.setInteger("capacity", capacity);
|
||||
tagCompound.setInteger("progress", progress);
|
||||
tagCompound.setInteger("bufferCapacity", bufferCapacity);
|
||||
tagCompound.setInteger("lockdownDuration", lockdownDuration);
|
||||
tagCompound.setInteger("accelerationUpgrades", this.accelerationUpgrades);
|
||||
tagCompound.setInteger("demonBloodDuration", demonBloodDuration);
|
||||
tagCompound.setInteger("cooldownAfterCrafting", cooldownAfterCrafting);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (getWorld().isRemote) {
|
||||
if (getWorld().isRemote)
|
||||
return;
|
||||
}
|
||||
|
||||
if (getWorld().getTotalWorldTime() % (Math.max(20 - getUpgrade().getSpeedCount(), 1)) == 0) {
|
||||
if (getWorld().getTotalWorldTime() % (Math.max(20 - getUpgrade().getSpeedCount(), 1)) == 0)
|
||||
everySecond();
|
||||
}
|
||||
|
||||
if (getWorld().getTotalWorldTime() % 100 == 0) {
|
||||
if (getWorld().getTotalWorldTime() % 100 == 0)
|
||||
everyFiveSeconds();
|
||||
}
|
||||
}
|
||||
|
||||
private void everySecond() {
|
||||
|
@ -191,20 +155,18 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
|
|||
}
|
||||
|
||||
public void startCycle() {
|
||||
if (worldObj != null) {
|
||||
if (worldObj != null)
|
||||
worldObj.markBlockForUpdate(pos);
|
||||
}
|
||||
|
||||
if (fluid == null || fluid.amount <= 0) {
|
||||
if (fluid == null || fluid.amount <= 0)
|
||||
return;
|
||||
}
|
||||
|
||||
if (getStackInSlot(0) != null) {
|
||||
// Do recipes
|
||||
if (AltarRecipeRegistry.getRecipes().containsKey(getStackInSlot(0))) {
|
||||
AltarRecipe recipe = AltarRecipeRegistry.getRecipeForInput(getStackInSlot(0));
|
||||
|
||||
if (tier >= recipe.getMinTier()) {
|
||||
if (altarTier.ordinal() >= recipe.getMinTier().ordinal()) {
|
||||
this.liquidRequired = recipe.getSyphon();
|
||||
// this.canBeFilled = recipe
|
||||
this.consumptionRate = recipe.getConsumeRate();
|
||||
|
@ -220,21 +182,19 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
|
|||
|
||||
EnumAltarTier tier = BloodAltar.getAltarTier(getWorld(), getPos());
|
||||
|
||||
if (tier.equals(EnumAltarTier.ONE)) {
|
||||
if (tier.equals(EnumAltarTier.ONE))
|
||||
upgrade = new AltarUpgrade();
|
||||
} else {
|
||||
else
|
||||
upgrade = BloodAltar.getUpgrades(worldObj, pos, tier);
|
||||
}
|
||||
|
||||
if (this.fluid.amount > this.capacity) {
|
||||
if (this.fluid.amount > this.capacity)
|
||||
this.fluid.amount = this.capacity;
|
||||
}
|
||||
|
||||
worldObj.markBlockForUpdate(pos);
|
||||
}
|
||||
|
||||
public void sacrificialDaggerCall(int amount, boolean isSacrifice) {
|
||||
if (!isSacrifice && this.lockdownDuration > 0) {
|
||||
if (this.lockdownDuration > 0) {
|
||||
int amt = (int) Math.min(bufferCapacity - fluidInput.amount, (isSacrifice ? 1 + sacrificeEfficiencyMultiplier : 1 + selfSacrificeEfficiencyMultiplier) * amount);
|
||||
fluidInput.amount += amt;
|
||||
} else {
|
||||
|
@ -256,8 +216,8 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
|
|||
return upgrade;
|
||||
}
|
||||
|
||||
public TileAltar setTier(int tier) {
|
||||
this.tier = tier;
|
||||
public TileAltar setTier(EnumAltarTier tier) {
|
||||
this.altarTier = tier;
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -272,8 +232,8 @@ public class TileAltar extends TileInventory implements IBloodAltar, IUpdatePlay
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getTier() {
|
||||
return upgradeLevel;
|
||||
public EnumAltarTier getTier() {
|
||||
return altarTier;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue