BloodMagic/src/main/java/WayofTime/bloodmagic/ritual/RitualWater.java

87 lines
2.2 KiB
Java
Raw Normal View History

package WayofTime.bloodmagic.ritual;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.saving.SoulNetwork;
import WayofTime.bloodmagic.api.ritual.*;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
import net.minecraft.init.Blocks;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import java.util.ArrayList;
public class RitualWater extends Ritual
{
2015-12-31 01:22:39 +00:00
public static final String WATER_RANGE = "waterRange";
public RitualWater()
{
super("ritualWater", 0, 500, "ritual." + Constants.Mod.MODID + ".waterRitual");
addBlockRange(WATER_RANGE, new AreaDescriptor.Rectangle(new BlockPos(0, 1, 0), 1));
setMaximumVolumeAndDistanceOfRange(WATER_RANGE, 9, 3, 3);
}
@Override
public void performRitual(IMasterRitualStone masterRitualStone)
{
2016-01-03 13:30:59 +00:00
World world = masterRitualStone.getWorldObj();
SoulNetwork network = NetworkHelper.getSoulNetwork(masterRitualStone.getOwner());
int currentEssence = network.getCurrentEssence();
if (currentEssence < getRefreshCost())
{
network.causeNausea();
return;
}
int maxEffects = currentEssence / getRefreshCost();
int totalEffects = 0;
2015-12-31 18:50:38 +00:00
AreaDescriptor waterRange = getBlockRange(WATER_RANGE);
2015-12-31 01:22:39 +00:00
2016-01-03 13:30:59 +00:00
for (BlockPos newPos : waterRange.getContainedPositions(masterRitualStone.getBlockPos()))
{
2015-12-31 01:22:39 +00:00
if (world.isAirBlock(newPos))
{
2016-04-24 17:06:28 +00:00
world.setBlockState(newPos, Blocks.FLOWING_WATER.getDefaultState());
totalEffects++;
}
2015-12-31 18:50:38 +00:00
if (totalEffects >= maxEffects)
{
break;
2015-12-31 01:22:39 +00:00
}
}
2015-12-31 18:50:38 +00:00
network.syphon(getRefreshCost() * totalEffects);
}
@Override
public int getRefreshTime()
{
return 1;
}
@Override
public int getRefreshCost()
{
return 25;
}
@Override
public ArrayList<RitualComponent> getComponents()
{
ArrayList<RitualComponent> components = new ArrayList<RitualComponent>();
this.addCornerRunes(components, 1, 0, EnumRuneType.WATER);
return components;
}
2015-12-31 18:50:38 +00:00
@Override
public Ritual getNewCopy()
{
return new RitualWater();
}
}