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,15 +13,13 @@ 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 {
|
||||
|
||||
|
@ -28,10 +30,15 @@ public abstract class Ritual {
|
|||
private final RitualRenderer renderer;
|
||||
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
|
||||
* @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);
|
||||
|
@ -42,8 +49,10 @@ public abstract class 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
|
||||
* @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) {
|
||||
|
@ -55,7 +64,8 @@ public abstract class Ritual {
|
|||
*
|
||||
* {@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);
|
||||
|
||||
|
@ -64,23 +74,26 @@ public abstract class Ritual {
|
|||
*
|
||||
* {@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.
|
||||
* @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.
|
||||
* 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.
|
||||
* 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.
|
||||
*/
|
||||
|
@ -88,6 +101,29 @@ public abstract class Ritual {
|
|||
return 20;
|
||||
}
|
||||
|
||||
public void addBlockRange(String range, BlockPos[] defaultRange) {
|
||||
modableRangeMap.put(range, defaultRange);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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) };
|
||||
}
|
||||
|
||||
/**
|
||||
* @return a list of {@link RitualComponent} for checking the ritual.
|
||||
*/
|
||||
|
@ -119,11 +155,6 @@ public abstract class Ritual {
|
|||
}
|
||||
|
||||
public enum BreakType {
|
||||
REDSTONE,
|
||||
BREAK_MRS,
|
||||
BREAK_STONE,
|
||||
ACTIVATE,
|
||||
DEACTIVATE,
|
||||
EXPLOSION,
|
||||
REDSTONE, BREAK_MRS, BREAK_STONE, ACTIVATE, DEACTIVATE, EXPLOSION,
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -105,15 +105,19 @@ public class TileMasterRitualStone extends TileEntity implements IMasterRitualSt
|
|||
|
||||
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.owner = crystalOwner; // Set the owner of the
|
||||
// ritual to the crystal's
|
||||
// owner
|
||||
this.currentRitual = ritual;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
ChatUtil.sendNoSpamUnloc(activator, "chat.BloodMagic.ritual.notValid");
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue