Made the Blood Altar respect the new capability system for fluid management.
This commit is contained in:
parent
db33b87b1c
commit
77b5f898ca
|
@ -3,6 +3,8 @@ Version 2.1.0-67
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
- Added the Destructive Will effect to the Ritual of the Green Grove. This ritual now is done~
|
- Added the Destructive Will effect to the Ritual of the Green Grove. This ritual now is done~
|
||||||
- Added more augmentations for the Lava Ritual.
|
- Added more augmentations for the Lava Ritual.
|
||||||
|
- Implemented a new model for the Blood Altar to be more in-line with the rest of the mod (Thanks, wiiv!)
|
||||||
|
- Made the Blood Altar respect the new capability system for fluid management.
|
||||||
|
|
||||||
------------------------------------------------------
|
------------------------------------------------------
|
||||||
Version 2.1.0-66
|
Version 2.1.0-66
|
||||||
|
|
|
@ -12,11 +12,12 @@ import net.minecraft.util.math.BlockPos;
|
||||||
import net.minecraft.world.World;
|
import net.minecraft.world.World;
|
||||||
import net.minecraft.world.WorldServer;
|
import net.minecraft.world.WorldServer;
|
||||||
import net.minecraftforge.common.MinecraftForge;
|
import net.minecraftforge.common.MinecraftForge;
|
||||||
import net.minecraftforge.fluids.Fluid;
|
|
||||||
import net.minecraftforge.fluids.FluidContainerRegistry;
|
import net.minecraftforge.fluids.FluidContainerRegistry;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.FluidStack;
|
||||||
import net.minecraftforge.fluids.FluidTankInfo;
|
import net.minecraftforge.fluids.FluidTank;
|
||||||
import net.minecraftforge.fluids.IFluidHandler;
|
import net.minecraftforge.fluids.capability.FluidTankPropertiesWrapper;
|
||||||
|
import net.minecraftforge.fluids.capability.IFluidHandler;
|
||||||
|
import net.minecraftforge.fluids.capability.IFluidTankProperties;
|
||||||
|
|
||||||
import org.apache.commons.lang3.tuple.ImmutablePair;
|
import org.apache.commons.lang3.tuple.ImmutablePair;
|
||||||
import org.apache.commons.lang3.tuple.Pair;
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
|
@ -788,7 +789,7 @@ public class BloodAltar implements IFluidHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill)
|
public int fill(FluidStack resource, boolean doFill)
|
||||||
{
|
{
|
||||||
if (resource == null || resource.getFluid() != BlockLifeEssence.getLifeEssence())
|
if (resource == null || resource.getFluid() != BlockLifeEssence.getLifeEssence())
|
||||||
{
|
{
|
||||||
|
@ -836,17 +837,17 @@ public class BloodAltar implements IFluidHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain)
|
public FluidStack drain(FluidStack resource, boolean doDrain)
|
||||||
{
|
{
|
||||||
if (resource == null || !resource.isFluidEqual(fluidOutput))
|
if (resource == null || !resource.isFluidEqual(fluidOutput))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return drain(from, resource.amount, doDrain);
|
return drain(resource.amount, doDrain);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain)
|
public FluidStack drain(int maxDrain, boolean doDrain)
|
||||||
{
|
{
|
||||||
if (fluidOutput == null)
|
if (fluidOutput == null)
|
||||||
{
|
{
|
||||||
|
@ -868,20 +869,8 @@ public class BloodAltar implements IFluidHandler
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean canFill(EnumFacing from, Fluid fluid)
|
public IFluidTankProperties[] getTankProperties()
|
||||||
{
|
{
|
||||||
return fluid == BlockLifeEssence.getLifeEssence();
|
return new IFluidTankProperties[] { new FluidTankPropertiesWrapper(new FluidTank(fluid, capacity)) };
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canDrain(EnumFacing from, Fluid fluid)
|
|
||||||
{
|
|
||||||
return fluid == BlockLifeEssence.getLifeEssence();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FluidTankInfo[] getTankInfo(EnumFacing from)
|
|
||||||
{
|
|
||||||
return new FluidTankInfo[] { new FluidTankInfo(fluid, capacity) };
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,6 +62,7 @@ public class RitualLava extends Ritual
|
||||||
World world = masterRitualStone.getWorldObj();
|
World world = masterRitualStone.getWorldObj();
|
||||||
SoulNetwork network = NetworkHelper.getSoulNetwork(masterRitualStone.getOwner());
|
SoulNetwork network = NetworkHelper.getSoulNetwork(masterRitualStone.getOwner());
|
||||||
int currentEssence = network.getCurrentEssence();
|
int currentEssence = network.getCurrentEssence();
|
||||||
|
int lpDrain = 0;
|
||||||
|
|
||||||
if (currentEssence < getRefreshCost())
|
if (currentEssence < getRefreshCost())
|
||||||
{
|
{
|
||||||
|
@ -70,10 +71,11 @@ public class RitualLava extends Ritual
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockPos pos = masterRitualStone.getBlockPos();
|
BlockPos pos = masterRitualStone.getBlockPos();
|
||||||
int maxEffects = currentEssence / getRefreshCost();
|
|
||||||
int totalEffects = 0;
|
|
||||||
|
|
||||||
List<EnumDemonWillType> willConfig = masterRitualStone.getActiveWillConfig();
|
List<EnumDemonWillType> willConfig = masterRitualStone.getActiveWillConfig();
|
||||||
|
|
||||||
|
double rawWill = this.getWillRespectingConfig(world, pos, EnumDemonWillType.DEFAULT, willConfig);
|
||||||
|
double rawDrained = 0;
|
||||||
|
|
||||||
DemonWillHolder holder = WorldDemonWillHandler.getWillHolder(world, pos);
|
DemonWillHolder holder = WorldDemonWillHandler.getWillHolder(world, pos);
|
||||||
AreaDescriptor lavaRange = getBlockRange(LAVA_RANGE);
|
AreaDescriptor lavaRange = getBlockRange(LAVA_RANGE);
|
||||||
|
|
||||||
|
@ -88,13 +90,20 @@ public class RitualLava extends Ritual
|
||||||
IBlockState state = world.getBlockState(newPos);
|
IBlockState state = world.getBlockState(newPos);
|
||||||
if (world.isAirBlock(newPos) || Utils.isFlowingLiquid(world, newPos, state))
|
if (world.isAirBlock(newPos) || Utils.isFlowingLiquid(world, newPos, state))
|
||||||
{
|
{
|
||||||
|
int lpCost = getLPCostForRawWill(rawWill);
|
||||||
|
if (currentEssence < lpCost)
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
world.setBlockState(newPos, Blocks.FLOWING_LAVA.getDefaultState());
|
world.setBlockState(newPos, Blocks.FLOWING_LAVA.getDefaultState());
|
||||||
totalEffects++;
|
currentEssence -= lpCost;
|
||||||
}
|
lpDrain += lpCost;
|
||||||
|
if (rawWill > 0)
|
||||||
if (totalEffects >= maxEffects)
|
{
|
||||||
{
|
double drain = getWillCostForRawWill(rawWill);
|
||||||
break;
|
rawWill -= drain;
|
||||||
|
rawDrained += drain;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +210,12 @@ public class RitualLava extends Ritual
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
network.syphon(getRefreshCost() * totalEffects);
|
if (rawDrained > 0)
|
||||||
|
{
|
||||||
|
WorldDemonWillHandler.drainWill(world, pos, EnumDemonWillType.DEFAULT, rawDrained, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
network.syphon(lpDrain);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -292,4 +306,14 @@ public class RitualLava extends Ritual
|
||||||
{
|
{
|
||||||
return (float) (1 + corrosiveWill * 0.05);
|
return (float) (1 + corrosiveWill * 0.05);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getLPCostForRawWill(double raw)
|
||||||
|
{
|
||||||
|
return Math.max((int) (500 - raw), 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getWillCostForRawWill(double raw)
|
||||||
|
{
|
||||||
|
return Math.min(1, raw / 500);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,18 +1,20 @@
|
||||||
package WayofTime.bloodmagic.tile;
|
package WayofTime.bloodmagic.tile;
|
||||||
|
|
||||||
import WayofTime.bloodmagic.altar.BloodAltar;
|
import javax.annotation.Nonnull;
|
||||||
import WayofTime.bloodmagic.api.altar.EnumAltarTier;
|
|
||||||
import WayofTime.bloodmagic.api.altar.IBloodAltar;
|
|
||||||
import net.minecraft.item.ItemStack;
|
import net.minecraft.item.ItemStack;
|
||||||
import net.minecraft.nbt.NBTTagCompound;
|
import net.minecraft.nbt.NBTTagCompound;
|
||||||
import net.minecraft.util.EnumFacing;
|
import net.minecraft.util.EnumFacing;
|
||||||
import net.minecraft.util.ITickable;
|
import net.minecraft.util.ITickable;
|
||||||
import net.minecraftforge.fluids.Fluid;
|
import net.minecraftforge.common.capabilities.Capability;
|
||||||
import net.minecraftforge.fluids.FluidStack;
|
import net.minecraftforge.fluids.capability.CapabilityFluidHandler;
|
||||||
import net.minecraftforge.fluids.FluidTankInfo;
|
import WayofTime.bloodmagic.altar.BloodAltar;
|
||||||
import net.minecraftforge.fluids.IFluidHandler;
|
import WayofTime.bloodmagic.api.altar.EnumAltarTier;
|
||||||
|
import WayofTime.bloodmagic.api.altar.IBloodAltar;
|
||||||
|
|
||||||
public class TileAltar extends TileInventory implements IBloodAltar, ITickable, IFluidHandler
|
import com.sun.istack.internal.Nullable;
|
||||||
|
|
||||||
|
public class TileAltar extends TileInventory implements IBloodAltar, ITickable
|
||||||
{
|
{
|
||||||
private BloodAltar bloodAltar;
|
private BloodAltar bloodAltar;
|
||||||
|
|
||||||
|
@ -62,43 +64,6 @@ public class TileAltar extends TileInventory implements IBloodAltar, ITickable,
|
||||||
return slot == 0;
|
return slot == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* IFluidHandler */
|
|
||||||
@Override
|
|
||||||
public int fill(EnumFacing from, FluidStack resource, boolean doFill)
|
|
||||||
{
|
|
||||||
return bloodAltar.fill(from, resource, doFill);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FluidStack drain(EnumFacing from, FluidStack resource, boolean doDrain)
|
|
||||||
{
|
|
||||||
return bloodAltar.drain(from, resource, doDrain);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FluidStack drain(EnumFacing from, int maxDrain, boolean doDrain)
|
|
||||||
{
|
|
||||||
return bloodAltar.drain(from, maxDrain, doDrain);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canFill(EnumFacing from, Fluid fluid)
|
|
||||||
{
|
|
||||||
return bloodAltar.canFill(from, fluid);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean canDrain(EnumFacing from, Fluid fluid)
|
|
||||||
{
|
|
||||||
return bloodAltar.canDrain(from, fluid);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public FluidTankInfo[] getTankInfo(EnumFacing from)
|
|
||||||
{
|
|
||||||
return bloodAltar.getTankInfo(from);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getCapacity()
|
public int getCapacity()
|
||||||
{
|
{
|
||||||
|
@ -234,4 +199,27 @@ public class TileAltar extends TileInventory implements IBloodAltar, ITickable,
|
||||||
{
|
{
|
||||||
return bloodAltar.setCurrentTierDisplayed(altarTier);
|
return bloodAltar.setCurrentTierDisplayed(altarTier);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean hasCapability(@Nonnull Capability<?> capability, @Nullable EnumFacing facing)
|
||||||
|
{
|
||||||
|
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.hasCapability(capability, facing);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public <T> T getCapability(@Nonnull Capability<T> capability, @Nullable EnumFacing facing)
|
||||||
|
{
|
||||||
|
if (capability == CapabilityFluidHandler.FLUID_HANDLER_CAPABILITY)
|
||||||
|
{
|
||||||
|
return (T) bloodAltar;
|
||||||
|
}
|
||||||
|
|
||||||
|
return super.getCapability(capability, facing);
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Reference in a new issue