Cache the bound SoulNetwork for rituals

Avoids looking up the map data once or more each tick
This commit is contained in:
Nicholas Ignoffo 2017-02-12 17:00:18 -08:00
parent 59c20971ab
commit c13be9ebce
29 changed files with 93 additions and 164 deletions

View file

@ -1,9 +1,7 @@
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.block.BlockLiquid;
import net.minecraft.init.Blocks;
import net.minecraft.tileentity.TileEntity;
@ -40,13 +38,12 @@ public class RitualPump extends Ritual
public void performRitual(IMasterRitualStone masterRitualStone)
{
World world = masterRitualStone.getWorldObj();
SoulNetwork network = NetworkHelper.getSoulNetwork(masterRitualStone.getOwner());
int currentEssence = network.getCurrentEssence();
int currentEssence = masterRitualStone.getOwnerNetwork().getCurrentEssence();
TileEntity tileEntity = world.getTileEntity(masterRitualStone.getBlockPos().up());
if (currentEssence < getRefreshCost())
{
network.causeNausea();
masterRitualStone.getOwnerNetwork().causeNausea();
return;
}
@ -79,7 +76,7 @@ public class RitualPump extends Ritual
if (blockPosIterator.hasNext())
{
network.syphon(getRefreshCost());
masterRitualStone.getOwnerNetwork().syphon(getRefreshCost());
currentPos = blockPosIterator.next();
fluidHandler.fill(fluidHandler.drain(1000, false), true);
world.setBlockState(currentPos, Blocks.STONE.getDefaultState());