BloodMagic/1.7.10/main/java/WayofTime/alchemicalWizardry/common/rituals/RitualEffectSpawnWard.java

123 lines
5 KiB
Java
Raw Normal View History

2014-08-25 11:58:39 +00:00
package WayofTime.alchemicalWizardry.common.rituals;
import WayofTime.alchemicalWizardry.api.rituals.IMasterRitualStone;
import WayofTime.alchemicalWizardry.api.rituals.RitualComponent;
import WayofTime.alchemicalWizardry.api.rituals.RitualEffect;
import WayofTime.alchemicalWizardry.api.soulNetwork.SoulNetworkHandler;
import WayofTime.alchemicalWizardry.common.AlchemicalWizardryEventHooks;
import WayofTime.alchemicalWizardry.common.CoordAndRange;
2014-10-13 20:33:20 +00:00
import net.minecraft.world.World;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
2014-08-25 11:58:39 +00:00
public class RitualEffectSpawnWard extends RitualEffect
{
@Override
public void performEffect(IMasterRitualStone ritualStone)
{
String owner = ritualStone.getOwner();
2014-10-09 11:48:45 +00:00
int currentEssence = SoulNetworkHandler.getCurrentEssence(owner);
2014-08-25 11:58:39 +00:00
World world = ritualStone.getWorld();
int x = ritualStone.getXCoord();
int y = ritualStone.getYCoord();
int z = ritualStone.getZCoord();
if (currentEssence < this.getCostPerRefresh())
{
2014-10-13 20:33:20 +00:00
SoulNetworkHandler.causeNauseaToPlayer(owner);
2014-08-25 11:58:39 +00:00
} else
{
2014-10-13 20:33:20 +00:00
int horizRange = 32;
int vertRange = 32;
int dimension = world.provider.dimensionId;
if (AlchemicalWizardryEventHooks.respawnMap.containsKey(new Integer(dimension)))
{
List<CoordAndRange> list = AlchemicalWizardryEventHooks.respawnMap.get(new Integer(dimension));
if (list != null)
{
if (!list.contains(new CoordAndRange(x, y, z, horizRange, vertRange)))
{
boolean hasFoundAndRemoved = false;
for (CoordAndRange coords : list)
{
int xLocation = coords.xCoord;
int yLocation = coords.yCoord;
int zLocation = coords.zCoord;
if (xLocation == x && yLocation == y && zLocation == z)
{
list.remove(coords);
hasFoundAndRemoved = true;
break;
}
}
list.add(new CoordAndRange(x, y, z, horizRange, vertRange));
}
} else
{
list = new LinkedList();
list.add(new CoordAndRange(x, y, z, horizRange, vertRange));
AlchemicalWizardryEventHooks.respawnMap.put(new Integer(dimension), list);
}
} else
{
List<CoordAndRange> list = new LinkedList();
list.add(new CoordAndRange(x, y, z, horizRange, vertRange));
AlchemicalWizardryEventHooks.respawnMap.put(new Integer(dimension), list);
}
2014-08-25 11:58:39 +00:00
2014-10-09 11:48:45 +00:00
SoulNetworkHandler.syphonFromNetwork(owner, this.getCostPerRefresh());
2014-08-25 11:58:39 +00:00
}
}
@Override
public int getCostPerRefresh()
{
2014-09-14 22:21:45 +00:00
return 15;
2014-08-25 11:58:39 +00:00
}
@Override
2014-10-13 20:33:20 +00:00
public List<RitualComponent> getRitualComponentList()
{
ArrayList<RitualComponent> wardRitualRitual = new ArrayList();
for (int i = 2; i <= 4; i++)
{
if (i <= 3)
{
wardRitualRitual.add(new RitualComponent(0, 0, i, RitualComponent.AIR));
wardRitualRitual.add(new RitualComponent(0, 0, -i, RitualComponent.AIR));
wardRitualRitual.add(new RitualComponent(i, 0, 0, RitualComponent.AIR));
wardRitualRitual.add(new RitualComponent(-i, 0, 0, RitualComponent.AIR));
}
wardRitualRitual.add(new RitualComponent(i, 0, i, RitualComponent.FIRE));
wardRitualRitual.add(new RitualComponent(i, 0, -i, RitualComponent.FIRE));
wardRitualRitual.add(new RitualComponent(-i, 0, -i, RitualComponent.FIRE));
wardRitualRitual.add(new RitualComponent(-i, 0, i, RitualComponent.FIRE));
}
2014-09-14 22:21:45 +00:00
wardRitualRitual.add(new RitualComponent(0, 0, 5, RitualComponent.DUSK));
wardRitualRitual.add(new RitualComponent(0, 0, -5, RitualComponent.DUSK));
wardRitualRitual.add(new RitualComponent(5, 0, 0, RitualComponent.DUSK));
wardRitualRitual.add(new RitualComponent(-5, 0, 0, RitualComponent.DUSK));
wardRitualRitual.add(new RitualComponent(6, 0, 5, RitualComponent.WATER));
wardRitualRitual.add(new RitualComponent(5, 0, 6, RitualComponent.WATER));
wardRitualRitual.add(new RitualComponent(6, 0, -5, RitualComponent.WATER));
wardRitualRitual.add(new RitualComponent(-5, 0, 6, RitualComponent.WATER));
wardRitualRitual.add(new RitualComponent(-6, 0, 5, RitualComponent.WATER));
wardRitualRitual.add(new RitualComponent(5, 0, -6, RitualComponent.WATER));
wardRitualRitual.add(new RitualComponent(-6, 0, -5, RitualComponent.WATER));
wardRitualRitual.add(new RitualComponent(-5, 0, -6, RitualComponent.WATER));
2014-10-13 20:33:20 +00:00
2014-09-14 22:21:45 +00:00
return wardRitualRitual;
2014-10-13 20:33:20 +00:00
}
2014-08-25 11:58:39 +00:00
}