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:
parent
27fa98b3cd
commit
e5eddd6c45
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -1,5 +1,9 @@
|
|||
package WayofTime.bloodmagic.api.ritual;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
|
@ -9,121 +13,148 @@ import net.minecraft.item.ItemStack;
|
|||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Abstract class for creating new rituals. Rituals need be registered with
|
||||
* {@link WayofTime.bloodmagic.api.registry.RitualRegistry#registerRitual(Ritual, String)}
|
||||
*/
|
||||
@Getter
|
||||
@RequiredArgsConstructor
|
||||
@EqualsAndHashCode
|
||||
@EqualsAndHashCode(exclude = { "modableRangeMap" })
|
||||
@ToString
|
||||
public abstract class Ritual {
|
||||
|
||||
public final ArrayList<RitualComponent> ritualComponents = new ArrayList<RitualComponent>();
|
||||
private final String name;
|
||||
private final int crystalLevel;
|
||||
private final int activationCost;
|
||||
private final RitualRenderer renderer;
|
||||
private final String unlocalizedName;
|
||||
public final ArrayList<RitualComponent> ritualComponents = new ArrayList<RitualComponent>();
|
||||
private final String name;
|
||||
private final int crystalLevel;
|
||||
private final int activationCost;
|
||||
private final RitualRenderer renderer;
|
||||
private final String unlocalizedName;
|
||||
|
||||
/**
|
||||
* @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);
|
||||
}
|
||||
private final Map<String, BlockPos[]> modableRangeMap = new HashMap<String, BlockPos[]>();
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
/**
|
||||
* @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.
|
||||
*
|
||||
* {@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) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called every {@link #getRefreshTime()} ticks while active.
|
||||
*
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#performRitual(World, BlockPos)}
|
||||
*
|
||||
* @param masterRitualStone - The {@link IMasterRitualStone} that the ritual is bound to
|
||||
*/
|
||||
public abstract void performRitual(IMasterRitualStone masterRitualStone);
|
||||
/**
|
||||
* Called every {@link #getRefreshTime()} ticks while active.
|
||||
*
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#performRitual(World, BlockPos)}
|
||||
*
|
||||
* @param masterRitualStone
|
||||
* - The {@link IMasterRitualStone} that the ritual is bound to
|
||||
*/
|
||||
public abstract void performRitual(IMasterRitualStone masterRitualStone);
|
||||
|
||||
/**
|
||||
* Called when the ritual is stopped for a given {@link BreakType}.
|
||||
*
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#stopRitual(BreakType)}
|
||||
*
|
||||
* @param masterRitualStone - The {@link IMasterRitualStone} that the ritual is bound to
|
||||
* @param breakType - The type of break that caused the stoppage.
|
||||
*/
|
||||
/**
|
||||
* Called when the ritual is stopped for a given {@link BreakType}.
|
||||
*
|
||||
* {@link WayofTime.bloodmagic.tile.TileMasterRitualStone#stopRitual(BreakType)}
|
||||
*
|
||||
* @param masterRitualStone
|
||||
* - 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) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to set the amount of LP drained every {@link #getRefreshTime()} ticks.
|
||||
*
|
||||
* @return - The amount of LP drained per refresh
|
||||
*/
|
||||
public abstract int getRefreshCost();
|
||||
/**
|
||||
* Used to set the amount of LP drained every {@link #getRefreshTime()}
|
||||
* ticks.
|
||||
*
|
||||
* @return - The amount of LP drained per refresh
|
||||
*/
|
||||
public abstract int getRefreshCost();
|
||||
|
||||
/**
|
||||
* Used to set the refresh rate of the ritual. (How often {@link #performRitual(IMasterRitualStone)}
|
||||
* is called.
|
||||
*
|
||||
* @return - How often to perform the effect in ticks.
|
||||
*/
|
||||
public int getRefreshTime() {
|
||||
return 20;
|
||||
}
|
||||
/**
|
||||
* Used to set the refresh rate of the ritual. (How often
|
||||
* {@link #performRitual(IMasterRitualStone)} is called.
|
||||
*
|
||||
* @return - How often to perform the effect in ticks.
|
||||
*/
|
||||
public int getRefreshTime() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list of {@link RitualComponent} for checking the ritual.
|
||||
*/
|
||||
public abstract ArrayList<RitualComponent> getComponents();
|
||||
public void addBlockRange(String range, BlockPos[] defaultRange) {
|
||||
modableRangeMap.put(range, defaultRange);
|
||||
}
|
||||
|
||||
public void addOffsetRunes(ArrayList<RitualComponent> components, int offset1, int offset2, int y, EnumRuneType 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));
|
||||
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));
|
||||
}
|
||||
/**
|
||||
* Used to grab the range of a ritual for a given effect. The order of the
|
||||
* blockPos array is: bottom corner, top corner.
|
||||
*
|
||||
* @param range
|
||||
* - Range that needs to be pulled.
|
||||
* @return - The range of the ritual effect. Array must be of size 2 and
|
||||
* have non-null values, with the first BlockPos having the lower
|
||||
* 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));
|
||||
components.add(new RitualComponent(new BlockPos(offset, y, -offset), rune));
|
||||
components.add(new RitualComponent(new BlockPos(-offset, y, -offset), rune));
|
||||
components.add(new RitualComponent(new BlockPos(-offset, y, offset), rune));
|
||||
}
|
||||
/**
|
||||
* @return a list of {@link RitualComponent} for checking the ritual.
|
||||
*/
|
||||
public abstract ArrayList<RitualComponent> getComponents();
|
||||
|
||||
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 void addOffsetRunes(ArrayList<RitualComponent> components, int offset1, int offset2, int y, EnumRuneType 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));
|
||||
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 {
|
||||
REDSTONE,
|
||||
BREAK_MRS,
|
||||
BREAK_STONE,
|
||||
ACTIVATE,
|
||||
DEACTIVATE,
|
||||
EXPLOSION,
|
||||
}
|
||||
public void addCornerRunes(ArrayList<RitualComponent> components, int offset, int y, EnumRuneType rune) {
|
||||
components.add(new RitualComponent(new BlockPos(offset, y, offset), rune));
|
||||
components.add(new RitualComponent(new BlockPos(offset, y, -offset), rune));
|
||||
components.add(new RitualComponent(new BlockPos(-offset, y, -offset), rune));
|
||||
components.add(new RitualComponent(new BlockPos(-offset, y, offset), rune));
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -302,7 +302,7 @@ public class ItemRitualDiviner extends Item {
|
|||
|
||||
for (String str : idList) {
|
||||
Ritual ritual = RitualRegistry.getRitualForId(str);
|
||||
|
||||
|
||||
if (!RitualRegistry.ritualEnabled(ritual) || !canDivinerPerformRitual(stack, ritual)) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,8 @@ import WayofTime.bloodmagic.api.registry.ImperfectRitualRegistry;
|
|||
import WayofTime.bloodmagic.api.registry.RitualRegistry;
|
||||
import WayofTime.bloodmagic.api.ritual.Ritual;
|
||||
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.RitualWater;
|
||||
import WayofTime.bloodmagic.ritual.imperfect.ImperfectRitualNight;
|
||||
|
@ -15,6 +17,8 @@ public class ModRituals {
|
|||
|
||||
public static Ritual testRitual;
|
||||
public static Ritual waterRitual;
|
||||
public static Ritual lavaRitual;
|
||||
public static Ritual greenGroveRitual;
|
||||
|
||||
public static ImperfectRitual imperfectNight;
|
||||
public static ImperfectRitual imperfectRain;
|
||||
|
@ -24,9 +28,13 @@ public class ModRituals {
|
|||
public static void initRituals() {
|
||||
testRitual = new RitualTest();
|
||||
waterRitual = new RitualWater();
|
||||
lavaRitual = new RitualLava();
|
||||
greenGroveRitual = new RitualGreenGrove();
|
||||
|
||||
RitualRegistry.registerRitual(testRitual, testRitual.getName());
|
||||
RitualRegistry.registerRitual(waterRitual, waterRitual.getName());
|
||||
RitualRegistry.registerRitual(lavaRitual, lavaRitual.getName());
|
||||
RitualRegistry.registerRitual(greenGroveRitual, greenGroveRitual.getName());
|
||||
}
|
||||
|
||||
public static void initImperfectRituals() {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
56
src/main/java/WayofTime/bloodmagic/ritual/RitualLava.java
Normal file
56
src/main/java/WayofTime/bloodmagic/ritual/RitualLava.java
Normal 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;
|
||||
}
|
||||
}
|
|
@ -16,7 +16,7 @@ import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
|||
public class RitualWater extends Ritual {
|
||||
|
||||
public RitualWater() {
|
||||
super("ritualWater", 0, 1000, "ritual." + Constants.Mod.MODID + ".waterRitual");
|
||||
super("ritualWater", 0, 500, "ritual." + Constants.Mod.MODID + ".waterRitual");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -42,7 +42,7 @@ public class RitualWater extends Ritual {
|
|||
|
||||
@Override
|
||||
public int getRefreshCost() {
|
||||
return 50;
|
||||
return 25;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -31,165 +31,169 @@ import net.minecraftforge.fml.common.eventhandler.Event;
|
|||
@NoArgsConstructor
|
||||
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 boolean active;
|
||||
private int activeTime;
|
||||
private int cooldown;
|
||||
private Ritual currentRitual;
|
||||
@Setter
|
||||
private EnumFacing direction = EnumFacing.NORTH;
|
||||
private String owner;
|
||||
private boolean active;
|
||||
private int activeTime;
|
||||
private int cooldown;
|
||||
private Ritual currentRitual;
|
||||
@Setter
|
||||
private EnumFacing direction = EnumFacing.NORTH;
|
||||
|
||||
@Override
|
||||
public void update() {
|
||||
if (getCurrentRitual() != null && isActive()) {
|
||||
if (activeTime % getCurrentRitual().getRefreshTime() == 0)
|
||||
performRitual(getWorld(), getPos());
|
||||
@Override
|
||||
public void update() {
|
||||
if (getCurrentRitual() != null && isActive()) {
|
||||
if (activeTime % getCurrentRitual().getRefreshTime() == 0)
|
||||
performRitual(getWorld(), getPos());
|
||||
|
||||
activeTime++;
|
||||
}
|
||||
}
|
||||
activeTime++;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
owner = tag.getString(Constants.NBT.OWNER_UUID);
|
||||
currentRitual = RitualRegistry.getRitualForId(tag.getString(Constants.NBT.CURRENT_RITUAL));
|
||||
active = tag.getBoolean(Constants.NBT.IS_RUNNING);
|
||||
activeTime = tag.getInteger(Constants.NBT.RUNTIME);
|
||||
direction = EnumFacing.VALUES[tag.getInteger(Constants.NBT.DIRECTION)];
|
||||
}
|
||||
@Override
|
||||
public void readFromNBT(NBTTagCompound tag) {
|
||||
super.readFromNBT(tag);
|
||||
owner = tag.getString(Constants.NBT.OWNER_UUID);
|
||||
currentRitual = RitualRegistry.getRitualForId(tag.getString(Constants.NBT.CURRENT_RITUAL));
|
||||
active = tag.getBoolean(Constants.NBT.IS_RUNNING);
|
||||
activeTime = tag.getInteger(Constants.NBT.RUNTIME);
|
||||
direction = EnumFacing.VALUES[tag.getInteger(Constants.NBT.DIRECTION)];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
String ritualId = RitualRegistry.getIdForRitual(getCurrentRitual());
|
||||
tag.setString(Constants.NBT.OWNER_UUID, Strings.isNullOrEmpty(getOwner()) ? "" : getOwner());
|
||||
tag.setString(Constants.NBT.CURRENT_RITUAL, Strings.isNullOrEmpty(ritualId) ? "" : ritualId);
|
||||
tag.setBoolean(Constants.NBT.IS_RUNNING, isActive());
|
||||
tag.setInteger(Constants.NBT.RUNTIME, getActiveTime());
|
||||
tag.setInteger(Constants.NBT.DIRECTION, direction.getIndex());
|
||||
}
|
||||
@Override
|
||||
public void writeToNBT(NBTTagCompound tag) {
|
||||
super.writeToNBT(tag);
|
||||
String ritualId = RitualRegistry.getIdForRitual(getCurrentRitual());
|
||||
tag.setString(Constants.NBT.OWNER_UUID, Strings.isNullOrEmpty(getOwner()) ? "" : getOwner());
|
||||
tag.setString(Constants.NBT.CURRENT_RITUAL, Strings.isNullOrEmpty(ritualId) ? "" : ritualId);
|
||||
tag.setBoolean(Constants.NBT.IS_RUNNING, isActive());
|
||||
tag.setInteger(Constants.NBT.RUNTIME, getActiveTime());
|
||||
tag.setInteger(Constants.NBT.DIRECTION, direction.getIndex());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean activateRitual(ItemStack activationCrystal, EntityPlayer activator, Ritual ritual) {
|
||||
@Override
|
||||
public boolean activateRitual(ItemStack activationCrystal, EntityPlayer activator, Ritual ritual) {
|
||||
|
||||
if (PlayerHelper.isFakePlayer(activator))
|
||||
return false;
|
||||
if (PlayerHelper.isFakePlayer(activator))
|
||||
return false;
|
||||
|
||||
activationCrystal = NBTHelper.checkNBT(activationCrystal);
|
||||
String crystalOwner = activationCrystal.getTagCompound().getString(Constants.NBT.OWNER_UUID);
|
||||
activationCrystal = NBTHelper.checkNBT(activationCrystal);
|
||||
String crystalOwner = activationCrystal.getTagCompound().getString(Constants.NBT.OWNER_UUID);
|
||||
|
||||
if (!Strings.isNullOrEmpty(crystalOwner) && ritual != null) {
|
||||
if (activationCrystal.getItem() instanceof ItemActivationCrystal) {
|
||||
int crystalLevel = ((ItemActivationCrystal) activationCrystal.getItem()).getCrystalLevel(activationCrystal);
|
||||
if (RitualHelper.canCrystalActivate(ritual, crystalLevel)) {
|
||||
if (!Strings.isNullOrEmpty(crystalOwner) && ritual != null) {
|
||||
if (activationCrystal.getItem() instanceof ItemActivationCrystal) {
|
||||
int crystalLevel = ((ItemActivationCrystal) activationCrystal.getItem()).getCrystalLevel(activationCrystal);
|
||||
if (RitualHelper.canCrystalActivate(ritual, crystalLevel)) {
|
||||
|
||||
SoulNetwork network = NetworkHelper.getSoulNetwork(crystalOwner, getWorld());
|
||||
|
||||
if (network.getCurrentEssence() < ritual.getActivationCost()) {
|
||||
ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.weak");
|
||||
return false;
|
||||
}
|
||||
SoulNetwork network = NetworkHelper.getSoulNetwork(crystalOwner, getWorld());
|
||||
|
||||
if (currentRitual != null)
|
||||
currentRitual.stopRitual(this, Ritual.BreakType.ACTIVATE);
|
||||
if (network.getCurrentEssence() < ritual.getActivationCost()) {
|
||||
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) {
|
||||
ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.prevent");
|
||||
return false;
|
||||
}
|
||||
RitualEvent.RitualActivatedEvent event = new RitualEvent.RitualActivatedEvent(this, crystalOwner, ritual, activator, activationCrystal, crystalLevel);
|
||||
|
||||
if (ritual.activateRitual(this, activator)) {
|
||||
network.syphon(ritual.getActivationCost());
|
||||
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY) {
|
||||
ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.prevent");
|
||||
return false;
|
||||
}
|
||||
|
||||
this.active = true;
|
||||
this.owner = crystalOwner; //Set the owner of the ritual to the crystal's owner
|
||||
this.currentRitual = ritual;
|
||||
if (ritual.activateRitual(this, activator)) {
|
||||
network.syphon(ritual.getActivationCost());
|
||||
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
|
||||
public void performRitual(World world, BlockPos pos) {
|
||||
if (getCurrentRitual() != null && RitualRegistry.ritualEnabled(getCurrentRitual()) && RitualHelper.checkValidRitual(getWorld(), getPos(), RitualRegistry.getIdForRitual(currentRitual), getDirection())) {
|
||||
RitualEvent.RitualRunEvent event = new RitualEvent.RitualRunEvent(this, getOwner(), getCurrentRitual());
|
||||
@Override
|
||||
public void performRitual(World world, BlockPos pos) {
|
||||
if (getCurrentRitual() != null && RitualRegistry.ritualEnabled(getCurrentRitual()) && RitualHelper.checkValidRitual(getWorld(), getPos(), RitualRegistry.getIdForRitual(currentRitual), getDirection())) {
|
||||
RitualEvent.RitualRunEvent event = new RitualEvent.RitualRunEvent(this, getOwner(), getCurrentRitual());
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
|
||||
return;
|
||||
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
|
||||
return;
|
||||
|
||||
SoulNetwork network = NetworkHelper.getSoulNetwork(getOwner(), getWorld());
|
||||
network.syphonAndDamage(getCurrentRitual().getRefreshCost());
|
||||
getCurrentRitual().performRitual(this);
|
||||
}
|
||||
}
|
||||
SoulNetwork network = NetworkHelper.getSoulNetwork(getOwner(), getWorld());
|
||||
network.syphonAndDamage(getCurrentRitual().getRefreshCost());
|
||||
getCurrentRitual().performRitual(this);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void stopRitual(Ritual.BreakType breakType) {
|
||||
if (getCurrentRitual() != null) {
|
||||
RitualEvent.RitualStopEvent event = new RitualEvent.RitualStopEvent(this, getOwner(), getCurrentRitual(), breakType);
|
||||
@Override
|
||||
public void stopRitual(Ritual.BreakType breakType) {
|
||||
if (getCurrentRitual() != null) {
|
||||
RitualEvent.RitualStopEvent event = new RitualEvent.RitualStopEvent(this, getOwner(), getCurrentRitual(), breakType);
|
||||
|
||||
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
|
||||
return;
|
||||
if (MinecraftForge.EVENT_BUS.post(event) || event.getResult() == Event.Result.DENY)
|
||||
return;
|
||||
|
||||
getCurrentRitual().stopRitual(this, breakType);
|
||||
this.currentRitual = null;
|
||||
this.active = false;
|
||||
this.activeTime = 0;
|
||||
}
|
||||
}
|
||||
getCurrentRitual().stopRitual(this, breakType);
|
||||
this.currentRitual = null;
|
||||
this.active = false;
|
||||
this.activeTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getCooldown() {
|
||||
return cooldown;
|
||||
}
|
||||
@Override
|
||||
public int getCooldown() {
|
||||
return cooldown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCooldown(int cooldown) {
|
||||
this.cooldown = cooldown;
|
||||
}
|
||||
@Override
|
||||
public void setCooldown(int cooldown) {
|
||||
this.cooldown = cooldown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setActive(boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
@Override
|
||||
public void setActive(boolean active) {
|
||||
this.active = active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public EnumFacing getDirection() {
|
||||
return direction;
|
||||
}
|
||||
@Override
|
||||
public EnumFacing getDirection() {
|
||||
return direction;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areTanksEmpty() {
|
||||
return false;
|
||||
}
|
||||
@Override
|
||||
public boolean areTanksEmpty() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRunningTime() {
|
||||
return activeTime;
|
||||
}
|
||||
@Override
|
||||
public int getRunningTime() {
|
||||
return activeTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
@Override
|
||||
public String getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return super.getWorld();
|
||||
}
|
||||
@Override
|
||||
public World getWorld() {
|
||||
return super.getWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public BlockPos getPos() {
|
||||
return super.getPos();
|
||||
}
|
||||
@Override
|
||||
public BlockPos getPos() {
|
||||
return super.getPos();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue