Finished fixing issues in the rituals. Added an initial system for setting a boundary for an effect in a ritual.

This commit is contained in:
WayofTime 2015-12-30 15:24:25 -05:00
parent 27fa98b3cd
commit e5eddd6c45
8 changed files with 431 additions and 224 deletions

View file

@ -0,0 +1,18 @@
package WayofTime.bloodmagic.api.ritual;
import java.util.ArrayList;
import java.util.List;
import net.minecraft.util.AxisAlignedBB;
import net.minecraft.util.BlockPos;
public class AreaDescriptor {
public List<BlockPos> getContainedPositions() {
return new ArrayList();
}
public AxisAlignedBB getAABB() {
return null;
}
}

View file

@ -1,5 +1,9 @@
package WayofTime.bloodmagic.api.ritual; package WayofTime.bloodmagic.api.ritual;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import lombok.Getter; import lombok.Getter;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@ -9,121 +13,148 @@ import net.minecraft.item.ItemStack;
import net.minecraft.util.BlockPos; import net.minecraft.util.BlockPos;
import net.minecraft.world.World; import net.minecraft.world.World;
import java.util.ArrayList;
/** /**
* Abstract class for creating new rituals. Rituals need be registered with * Abstract class for creating new rituals. Rituals need be registered with
* {@link WayofTime.bloodmagic.api.registry.RitualRegistry#registerRitual(Ritual, String)} * {@link WayofTime.bloodmagic.api.registry.RitualRegistry#registerRitual(Ritual, String)}
*/ */
@Getter @Getter
@RequiredArgsConstructor @RequiredArgsConstructor
@EqualsAndHashCode @EqualsAndHashCode(exclude = { "modableRangeMap" })
@ToString @ToString
public abstract class Ritual { public abstract class Ritual {
public final ArrayList<RitualComponent> ritualComponents = new ArrayList<RitualComponent>(); public final ArrayList<RitualComponent> ritualComponents = new ArrayList<RitualComponent>();
private final String name; private final String name;
private final int crystalLevel; private final int crystalLevel;
private final int activationCost; private final int activationCost;
private final RitualRenderer renderer; private final RitualRenderer renderer;
private final String unlocalizedName; private final String unlocalizedName;
/** private final Map<String, BlockPos[]> modableRangeMap = new HashMap<String, BlockPos[]>();
* @param name - The name of the ritual
* @param crystalLevel - Required Activation Crystal tier
* @param activationCost - Base LP cost for activating the ritual
*/
public Ritual(String name, int crystalLevel, int activationCost, String unlocalizedName) {
this(name, crystalLevel, activationCost, null, unlocalizedName);
}
/** /**
* Called when the player attempts to activate the ritual. * @param name
* * - The name of the ritual
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#activateRitual(ItemStack, EntityPlayer, Ritual)} * @param crystalLevel
* * - Required Activation Crystal tier
* @param masterRitualStone - The {@link IMasterRitualStone} that the ritual is bound to * @param activationCost
* @param player - The activating player * - Base LP cost for activating the ritual
* @return - Whether activation was successful */
*/ public Ritual(String name, int crystalLevel, int activationCost, String unlocalizedName) {
this(name, crystalLevel, activationCost, null, unlocalizedName);
}
/**
* Called when the player attempts to activate the ritual.
*
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#activateRitual(ItemStack, EntityPlayer, Ritual)}
*
* @param masterRitualStone
* - The {@link IMasterRitualStone} that the ritual is bound to
* @param player
* - The activating player
* @return - Whether activation was successful
*/
public boolean activateRitual(IMasterRitualStone masterRitualStone, EntityPlayer player) { public boolean activateRitual(IMasterRitualStone masterRitualStone, EntityPlayer player) {
return true; return true;
} }
/** /**
* Called every {@link #getRefreshTime()} ticks while active. * Called every {@link #getRefreshTime()} ticks while active.
* *
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#performRitual(World, BlockPos)} * {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#performRitual(World, BlockPos)}
* *
* @param masterRitualStone - The {@link IMasterRitualStone} that the ritual is bound to * @param masterRitualStone
*/ * - The {@link IMasterRitualStone} that the ritual is bound to
public abstract void performRitual(IMasterRitualStone masterRitualStone); */
public abstract void performRitual(IMasterRitualStone masterRitualStone);
/** /**
* Called when the ritual is stopped for a given {@link BreakType}. * Called when the ritual is stopped for a given {@link BreakType}.
* *
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#stopRitual(BreakType)} * {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#stopRitual(BreakType)}
* *
* @param masterRitualStone - The {@link IMasterRitualStone} that the ritual is bound to * @param masterRitualStone
* @param breakType - The type of break that caused the stoppage. * - The {@link IMasterRitualStone} that the ritual is bound to
*/ * @param breakType
* - The type of break that caused the stoppage.
*/
public void stopRitual(IMasterRitualStone masterRitualStone, BreakType breakType) { public void stopRitual(IMasterRitualStone masterRitualStone, BreakType breakType) {
} }
/** /**
* Used to set the amount of LP drained every {@link #getRefreshTime()} ticks. * Used to set the amount of LP drained every {@link #getRefreshTime()}
* * ticks.
* @return - The amount of LP drained per refresh *
*/ * @return - The amount of LP drained per refresh
public abstract int getRefreshCost(); */
public abstract int getRefreshCost();
/** /**
* Used to set the refresh rate of the ritual. (How often {@link #performRitual(IMasterRitualStone)} * Used to set the refresh rate of the ritual. (How often
* is called. * {@link #performRitual(IMasterRitualStone)} is called.
* *
* @return - How often to perform the effect in ticks. * @return - How often to perform the effect in ticks.
*/ */
public int getRefreshTime() { public int getRefreshTime() {
return 20; return 20;
} }
/** public void addBlockRange(String range, BlockPos[] defaultRange) {
* @return a list of {@link RitualComponent} for checking the ritual. modableRangeMap.put(range, defaultRange);
*/ }
public abstract ArrayList<RitualComponent> getComponents();
public void addOffsetRunes(ArrayList<RitualComponent> components, int offset1, int offset2, int y, EnumRuneType rune) { /**
components.add(new RitualComponent(new BlockPos(offset1, y, offset2), rune)); * Used to grab the range of a ritual for a given effect. The order of the
components.add(new RitualComponent(new BlockPos(offset2, y, offset1), rune)); * blockPos array is: bottom corner, top corner.
components.add(new RitualComponent(new BlockPos(offset1, y, -offset2), rune)); *
components.add(new RitualComponent(new BlockPos(-offset2, y, offset1), rune)); * @param range
components.add(new RitualComponent(new BlockPos(-offset1, y, offset2), rune)); * - Range that needs to be pulled.
components.add(new RitualComponent(new BlockPos(offset2, y, -offset1), rune)); * @return - The range of the ritual effect. Array must be of size 2 and
components.add(new RitualComponent(new BlockPos(-offset1, y, -offset2), rune)); * have non-null values, with the first BlockPos having the lower
components.add(new RitualComponent(new BlockPos(-offset2, y, -offset1), rune)); * offset values and the second BlockPos having the higher offset
} * values
*/
public BlockPos[] getBlockRange(String range) {
if (modableRangeMap.containsKey(range)) {
return modableRangeMap.get(range);
}
return new BlockPos[] { new BlockPos(0, 0, 0), new BlockPos(0, 0, 0) };
}
public void addCornerRunes(ArrayList<RitualComponent> components, int offset, int y, EnumRuneType rune) { /**
components.add(new RitualComponent(new BlockPos(offset, y, offset), rune)); * @return a list of {@link RitualComponent} for checking the ritual.
components.add(new RitualComponent(new BlockPos(offset, y, -offset), rune)); */
components.add(new RitualComponent(new BlockPos(-offset, y, -offset), rune)); public abstract ArrayList<RitualComponent> getComponents();
components.add(new RitualComponent(new BlockPos(-offset, y, offset), rune));
}
public void addParallelRunes(ArrayList<RitualComponent> components, int offset, int y, EnumRuneType rune) { public void addOffsetRunes(ArrayList<RitualComponent> components, int offset1, int offset2, int y, EnumRuneType rune) {
components.add(new RitualComponent(new BlockPos(offset, y, 0), rune)); components.add(new RitualComponent(new BlockPos(offset1, y, offset2), rune));
components.add(new RitualComponent(new BlockPos(-offset, y, 0), rune)); components.add(new RitualComponent(new BlockPos(offset2, y, offset1), rune));
components.add(new RitualComponent(new BlockPos(0, y, -offset), rune)); components.add(new RitualComponent(new BlockPos(offset1, y, -offset2), rune));
components.add(new RitualComponent(new BlockPos(0, y, offset), rune)); components.add(new RitualComponent(new BlockPos(-offset2, y, offset1), rune));
} components.add(new RitualComponent(new BlockPos(-offset1, y, offset2), rune));
components.add(new RitualComponent(new BlockPos(offset2, y, -offset1), rune));
components.add(new RitualComponent(new BlockPos(-offset1, y, -offset2), rune));
components.add(new RitualComponent(new BlockPos(-offset2, y, -offset1), rune));
}
public enum BreakType { public void addCornerRunes(ArrayList<RitualComponent> components, int offset, int y, EnumRuneType rune) {
REDSTONE, components.add(new RitualComponent(new BlockPos(offset, y, offset), rune));
BREAK_MRS, components.add(new RitualComponent(new BlockPos(offset, y, -offset), rune));
BREAK_STONE, components.add(new RitualComponent(new BlockPos(-offset, y, -offset), rune));
ACTIVATE, components.add(new RitualComponent(new BlockPos(-offset, y, offset), rune));
DEACTIVATE, }
EXPLOSION,
} public void addParallelRunes(ArrayList<RitualComponent> components, int offset, int y, EnumRuneType rune) {
components.add(new RitualComponent(new BlockPos(offset, y, 0), rune));
components.add(new RitualComponent(new BlockPos(-offset, y, 0), rune));
components.add(new RitualComponent(new BlockPos(0, y, -offset), rune));
components.add(new RitualComponent(new BlockPos(0, y, offset), rune));
}
public enum BreakType {
REDSTONE, BREAK_MRS, BREAK_STONE, ACTIVATE, DEACTIVATE, EXPLOSION,
}
} }

View file

@ -302,7 +302,7 @@ public class ItemRitualDiviner extends Item {
for (String str : idList) { for (String str : idList) {
Ritual ritual = RitualRegistry.getRitualForId(str); Ritual ritual = RitualRegistry.getRitualForId(str);
if (!RitualRegistry.ritualEnabled(ritual) || !canDivinerPerformRitual(stack, ritual)) { if (!RitualRegistry.ritualEnabled(ritual) || !canDivinerPerformRitual(stack, ritual)) {
continue; continue;
} }

View file

@ -4,6 +4,8 @@ import WayofTime.bloodmagic.api.registry.ImperfectRitualRegistry;
import WayofTime.bloodmagic.api.registry.RitualRegistry; import WayofTime.bloodmagic.api.registry.RitualRegistry;
import WayofTime.bloodmagic.api.ritual.Ritual; import WayofTime.bloodmagic.api.ritual.Ritual;
import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual; import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual;
import WayofTime.bloodmagic.ritual.RitualGreenGrove;
import WayofTime.bloodmagic.ritual.RitualLava;
import WayofTime.bloodmagic.ritual.RitualTest; import WayofTime.bloodmagic.ritual.RitualTest;
import WayofTime.bloodmagic.ritual.RitualWater; import WayofTime.bloodmagic.ritual.RitualWater;
import WayofTime.bloodmagic.ritual.imperfect.ImperfectRitualNight; import WayofTime.bloodmagic.ritual.imperfect.ImperfectRitualNight;
@ -15,6 +17,8 @@ public class ModRituals {
public static Ritual testRitual; public static Ritual testRitual;
public static Ritual waterRitual; public static Ritual waterRitual;
public static Ritual lavaRitual;
public static Ritual greenGroveRitual;
public static ImperfectRitual imperfectNight; public static ImperfectRitual imperfectNight;
public static ImperfectRitual imperfectRain; public static ImperfectRitual imperfectRain;
@ -24,9 +28,13 @@ public class ModRituals {
public static void initRituals() { public static void initRituals() {
testRitual = new RitualTest(); testRitual = new RitualTest();
waterRitual = new RitualWater(); waterRitual = new RitualWater();
lavaRitual = new RitualLava();
greenGroveRitual = new RitualGreenGrove();
RitualRegistry.registerRitual(testRitual, testRitual.getName()); RitualRegistry.registerRitual(testRitual, testRitual.getName());
RitualRegistry.registerRitual(waterRitual, waterRitual.getName()); RitualRegistry.registerRitual(waterRitual, waterRitual.getName());
RitualRegistry.registerRitual(lavaRitual, lavaRitual.getName());
RitualRegistry.registerRitual(greenGroveRitual, greenGroveRitual.getName());
} }
public static void initImperfectRituals() { public static void initImperfectRituals() {

View file

@ -0,0 +1,90 @@
package WayofTime.bloodmagic.ritual;
import java.util.ArrayList;
import java.util.Random;
import net.minecraft.block.Block;
import net.minecraft.block.IGrowable;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import net.minecraftforge.common.IPlantable;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.network.SoulNetwork;
import WayofTime.bloodmagic.api.ritual.EnumRuneType;
import WayofTime.bloodmagic.api.ritual.IMasterRitualStone;
import WayofTime.bloodmagic.api.ritual.Ritual;
import WayofTime.bloodmagic.api.ritual.RitualComponent;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
public class RitualGreenGrove extends Ritual {
public static final String GROW_RANGE = "growing";
public RitualGreenGrove() {
super("ritualGreenGrove", 0, 1000, "ritual." + Constants.Mod.MODID + ".greenGroveRitual");
addBlockRange(GROW_RANGE, new BlockPos[] { new BlockPos(-1, 2, -1), new BlockPos(1, 2, 1) });
}
@Override
public void performRitual(IMasterRitualStone masterRitualStone) {
World world = masterRitualStone.getWorld();
SoulNetwork network = NetworkHelper.getSoulNetwork(masterRitualStone.getOwner(), world);
int currentEssence = network.getCurrentEssence();
if (currentEssence < getRefreshCost())
return;
int maxGrowths = currentEssence / getRefreshCost();
int totalGrowths = 0;
BlockPos[] growingRange = getBlockRange(GROW_RANGE);
for (int i = growingRange[0].getX(); i <= growingRange[1].getX(); i++) {
for (int j = growingRange[0].getY(); j <= growingRange[1].getY(); j++) {
for (int k = growingRange[0].getZ(); k <= growingRange[1].getZ(); k++) {
BlockPos newPos = masterRitualStone.getPos().add(i, j, k);
IBlockState state = world.getBlockState(newPos);
Block block = state.getBlock();
if (block instanceof IPlantable || block instanceof IGrowable) {
block.updateTick(world, newPos, state, new Random());
totalGrowths++;
}
if (totalGrowths >= maxGrowths) {
break;
}
}
if (totalGrowths >= maxGrowths) {
break;
}
}
if (totalGrowths >= maxGrowths) {
break;
}
}
network.syphon(totalGrowths * getRefreshCost());
}
@Override
public int getRefreshTime() {
return 20;
}
@Override
public int getRefreshCost() {
return 20;
}
@Override
public ArrayList<RitualComponent> getComponents() {
ArrayList<RitualComponent> components = new ArrayList<RitualComponent>();
this.addCornerRunes(components, 1, 0, EnumRuneType.EARTH);
this.addParallelRunes(components, 1, 0, EnumRuneType.WATER);
return components;
}
}

View file

@ -0,0 +1,56 @@
package WayofTime.bloodmagic.ritual;
import java.util.ArrayList;
import net.minecraft.init.Blocks;
import net.minecraft.util.BlockPos;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.Constants;
import WayofTime.bloodmagic.api.network.SoulNetwork;
import WayofTime.bloodmagic.api.ritual.EnumRuneType;
import WayofTime.bloodmagic.api.ritual.IMasterRitualStone;
import WayofTime.bloodmagic.api.ritual.Ritual;
import WayofTime.bloodmagic.api.ritual.RitualComponent;
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
public class RitualLava extends Ritual {
public RitualLava() {
super("ritualLava", 0, 10000, "ritual." + Constants.Mod.MODID + ".lavaRitual");
}
@Override
public void performRitual(IMasterRitualStone masterRitualStone) {
World world = masterRitualStone.getWorld();
SoulNetwork network = NetworkHelper.getSoulNetwork(masterRitualStone.getOwner(), world);
int currentEssence = network.getCurrentEssence();
if(currentEssence < getRefreshCost())
return;
BlockPos pos = masterRitualStone.getPos().up();
if(world.isAirBlock(pos)) {
world.setBlockState(pos, Blocks.lava.getDefaultState());
network.syphon(getRefreshCost());
}
}
@Override
public int getRefreshTime() {
return 1;
}
@Override
public int getRefreshCost() {
return 500;
}
@Override
public ArrayList<RitualComponent> getComponents() {
ArrayList<RitualComponent> components = new ArrayList<RitualComponent>();
this.addParallelRunes(components, 1, 0, EnumRuneType.FIRE);
return components;
}
}

View file

@ -16,7 +16,7 @@ import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
public class RitualWater extends Ritual { public class RitualWater extends Ritual {
public RitualWater() { public RitualWater() {
super("ritualWater", 0, 1000, "ritual." + Constants.Mod.MODID + ".waterRitual"); super("ritualWater", 0, 500, "ritual." + Constants.Mod.MODID + ".waterRitual");
} }
@Override @Override
@ -42,7 +42,7 @@ public class RitualWater extends Ritual {
@Override @Override
public int getRefreshCost() { public int getRefreshCost() {
return 50; return 25;
} }
@Override @Override

View file

@ -31,165 +31,169 @@ import net.minecraftforge.fml.common.eventhandler.Event;
@NoArgsConstructor @NoArgsConstructor
public class TileMasterRitualStone extends TileEntity implements IMasterRitualStone, ITickable { public class TileMasterRitualStone extends TileEntity implements IMasterRitualStone, ITickable {
public static final int UPDATE_TIME = 20; public static final int UPDATE_TIME = 20;
private String owner; private String owner;
private boolean active; private boolean active;
private int activeTime; private int activeTime;
private int cooldown; private int cooldown;
private Ritual currentRitual; private Ritual currentRitual;
@Setter @Setter
private EnumFacing direction = EnumFacing.NORTH; private EnumFacing direction = EnumFacing.NORTH;
@Override @Override
public void update() { public void update() {
if (getCurrentRitual() != null && isActive()) { if (getCurrentRitual() != null && isActive()) {
if (activeTime % getCurrentRitual().getRefreshTime() == 0) if (activeTime % getCurrentRitual().getRefreshTime() == 0)
performRitual(getWorld(), getPos()); performRitual(getWorld(), getPos());
activeTime++; activeTime++;
} }
} }
@Override @Override
public void readFromNBT(NBTTagCompound tag) { public void readFromNBT(NBTTagCompound tag) {
super.readFromNBT(tag); super.readFromNBT(tag);
owner = tag.getString(Constants.NBT.OWNER_UUID); owner = tag.getString(Constants.NBT.OWNER_UUID);
currentRitual = RitualRegistry.getRitualForId(tag.getString(Constants.NBT.CURRENT_RITUAL)); currentRitual = RitualRegistry.getRitualForId(tag.getString(Constants.NBT.CURRENT_RITUAL));
active = tag.getBoolean(Constants.NBT.IS_RUNNING); active = tag.getBoolean(Constants.NBT.IS_RUNNING);
activeTime = tag.getInteger(Constants.NBT.RUNTIME); activeTime = tag.getInteger(Constants.NBT.RUNTIME);
direction = EnumFacing.VALUES[tag.getInteger(Constants.NBT.DIRECTION)]; direction = EnumFacing.VALUES[tag.getInteger(Constants.NBT.DIRECTION)];
} }
@Override @Override
public void writeToNBT(NBTTagCompound tag) { public void writeToNBT(NBTTagCompound tag) {
super.writeToNBT(tag); super.writeToNBT(tag);
String ritualId = RitualRegistry.getIdForRitual(getCurrentRitual()); String ritualId = RitualRegistry.getIdForRitual(getCurrentRitual());
tag.setString(Constants.NBT.OWNER_UUID, Strings.isNullOrEmpty(getOwner()) ? "" : getOwner()); tag.setString(Constants.NBT.OWNER_UUID, Strings.isNullOrEmpty(getOwner()) ? "" : getOwner());
tag.setString(Constants.NBT.CURRENT_RITUAL, Strings.isNullOrEmpty(ritualId) ? "" : ritualId); tag.setString(Constants.NBT.CURRENT_RITUAL, Strings.isNullOrEmpty(ritualId) ? "" : ritualId);
tag.setBoolean(Constants.NBT.IS_RUNNING, isActive()); tag.setBoolean(Constants.NBT.IS_RUNNING, isActive());
tag.setInteger(Constants.NBT.RUNTIME, getActiveTime()); tag.setInteger(Constants.NBT.RUNTIME, getActiveTime());
tag.setInteger(Constants.NBT.DIRECTION, direction.getIndex()); tag.setInteger(Constants.NBT.DIRECTION, direction.getIndex());
} }
@Override @Override
public boolean activateRitual(ItemStack activationCrystal, EntityPlayer activator, Ritual ritual) { public boolean activateRitual(ItemStack activationCrystal, EntityPlayer activator, Ritual ritual) {
if (PlayerHelper.isFakePlayer(activator)) if (PlayerHelper.isFakePlayer(activator))
return false; return false;
activationCrystal = NBTHelper.checkNBT(activationCrystal); activationCrystal = NBTHelper.checkNBT(activationCrystal);
String crystalOwner = activationCrystal.getTagCompound().getString(Constants.NBT.OWNER_UUID); String crystalOwner = activationCrystal.getTagCompound().getString(Constants.NBT.OWNER_UUID);
if (!Strings.isNullOrEmpty(crystalOwner) && ritual != null) { if (!Strings.isNullOrEmpty(crystalOwner) && ritual != null) {
if (activationCrystal.getItem() instanceof ItemActivationCrystal) { if (activationCrystal.getItem() instanceof ItemActivationCrystal) {
int crystalLevel = ((ItemActivationCrystal) activationCrystal.getItem()).getCrystalLevel(activationCrystal); int crystalLevel = ((ItemActivationCrystal) activationCrystal.getItem()).getCrystalLevel(activationCrystal);
if (RitualHelper.canCrystalActivate(ritual, crystalLevel)) { if (RitualHelper.canCrystalActivate(ritual, crystalLevel)) {
SoulNetwork network = NetworkHelper.getSoulNetwork(crystalOwner, getWorld()); SoulNetwork network = NetworkHelper.getSoulNetwork(crystalOwner, getWorld());
if (network.getCurrentEssence() < ritual.getActivationCost()) {
ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.weak");
return false;
}
if (currentRitual != null) if (network.getCurrentEssence() < ritual.getActivationCost()) {
currentRitual.stopRitual(this, Ritual.BreakType.ACTIVATE); ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.weak");
return false;
}
RitualEvent.RitualActivatedEvent event = new RitualEvent.RitualActivatedEvent(this, crystalOwner, ritual, activator, activationCrystal, crystalLevel); if (currentRitual != null)
currentRitual.stopRitual(this, Ritual.BreakType.ACTIVATE);
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) { RitualEvent.RitualActivatedEvent event = new RitualEvent.RitualActivatedEvent(this, crystalOwner, ritual, activator, activationCrystal, crystalLevel);
ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.prevent");
return false;
}
if (ritual.activateRitual(this, activator)) { if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) {
network.syphon(ritual.getActivationCost()); ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.prevent");
return false;
}
this.active = true; if (ritual.activateRitual(this, activator)) {
this.owner = crystalOwner; //Set the owner of the ritual to the crystal's owner network.syphon(ritual.getActivationCost());
this.currentRitual = ritual; ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.activate");
this.active = true;
this.owner = crystalOwner; // Set the owner of the
// ritual to the crystal's
// owner
this.currentRitual = ritual;
return true; return true;
} }
} }
} }
} } else {
ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.notValid");
}
return false; return false;
} }
@Override @Override
public void performRitual(World world, BlockPos pos) { public void performRitual(World world, BlockPos pos) {
if (getCurrentRitual() != null && RitualRegistry.ritualEnabled(getCurrentRitual()) && RitualHelper.checkValidRitual(getWorld(), getPos(), RitualRegistry.getIdForRitual(currentRitual), getDirection())) { if (getCurrentRitual() != null && RitualRegistry.ritualEnabled(getCurrentRitual()) && RitualHelper.checkValidRitual(getWorld(), getPos(), RitualRegistry.getIdForRitual(currentRitual), getDirection())) {
RitualEvent.RitualRunEvent event = new RitualEvent.RitualRunEvent(this, getOwner(), getCurrentRitual()); RitualEvent.RitualRunEvent event = new RitualEvent.RitualRunEvent(this, getOwner(), getCurrentRitual());
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
return; return;
SoulNetwork network = NetworkHelper.getSoulNetwork(getOwner(), getWorld()); SoulNetwork network = NetworkHelper.getSoulNetwork(getOwner(), getWorld());
network.syphonAndDamage(getCurrentRitual().getRefreshCost()); network.syphonAndDamage(getCurrentRitual().getRefreshCost());
getCurrentRitual().performRitual(this); getCurrentRitual().performRitual(this);
} }
} }
@Override @Override
public void stopRitual(Ritual.BreakType breakType) { public void stopRitual(Ritual.BreakType breakType) {
if (getCurrentRitual() != null) { if (getCurrentRitual() != null) {
RitualEvent.RitualStopEvent event = new RitualEvent.RitualStopEvent(this, getOwner(), getCurrentRitual(), breakType); RitualEvent.RitualStopEvent event = new RitualEvent.RitualStopEvent(this, getOwner(), getCurrentRitual(), breakType);
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
return; return;
getCurrentRitual().stopRitual(this, breakType); getCurrentRitual().stopRitual(this, breakType);
this.currentRitual = null; this.currentRitual = null;
this.active = false; this.active = false;
this.activeTime = 0; this.activeTime = 0;
} }
} }
@Override @Override
public int getCooldown() { public int getCooldown() {
return cooldown; return cooldown;
} }
@Override @Override
public void setCooldown(int cooldown) { public void setCooldown(int cooldown) {
this.cooldown = cooldown; this.cooldown = cooldown;
} }
@Override @Override
public void setActive(boolean active) { public void setActive(boolean active) {
this.active = active; this.active = active;
} }
@Override @Override
public EnumFacing getDirection() { public EnumFacing getDirection() {
return direction; return direction;
} }
@Override @Override
public boolean areTanksEmpty() { public boolean areTanksEmpty() {
return false; return false;
} }
@Override @Override
public int getRunningTime() { public int getRunningTime() {
return activeTime; return activeTime;
} }
@Override @Override
public String getOwner() { public String getOwner() {
return owner; return owner;
} }
@Override @Override
public World getWorld() { public World getWorld() {
return super.getWorld(); return super.getWorld();
} }
@Override @Override
public BlockPos getPos() { public BlockPos getPos() {
return super.getPos(); return super.getPos();
} }
} }