Rework of ritual registration
Moves to annotation based registration. Configs are handled for automatically
This commit is contained in:
parent
e3d65a9e3a
commit
42c69eb557
54 changed files with 321 additions and 569 deletions
|
@ -4,7 +4,6 @@ import WayofTime.bloodmagic.BloodMagic;
|
|||
import WayofTime.bloodmagic.ConfigHandler;
|
||||
import WayofTime.bloodmagic.util.BMLog;
|
||||
import WayofTime.bloodmagic.util.Constants;
|
||||
import WayofTime.bloodmagic.ritual.RitualRegistry;
|
||||
import WayofTime.bloodmagic.ritual.Ritual;
|
||||
import WayofTime.bloodmagic.ritual.RitualComponent;
|
||||
import WayofTime.bloodmagic.client.key.KeyBindings;
|
||||
|
@ -246,7 +245,7 @@ public class ClientHandler {
|
|||
World world = player.getEntityWorld();
|
||||
ItemRitualDiviner ritualDiviner = (ItemRitualDiviner) player.inventory.getCurrentItem().getItem();
|
||||
EnumFacing direction = ritualDiviner.getDirection(player.inventory.getCurrentItem());
|
||||
Ritual ritual = RitualRegistry.getRitualForId(ritualDiviner.getCurrentRitual(player.inventory.getCurrentItem()));
|
||||
Ritual ritual = BloodMagic.RITUAL_MANAGER.getRitual(ritualDiviner.getCurrentRitual(player.inventory.getCurrentItem()));
|
||||
|
||||
if (ritual == null)
|
||||
return;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
package WayofTime.bloodmagic.util.helper;
|
||||
|
||||
import WayofTime.bloodmagic.ritual.RitualRegistry;
|
||||
import WayofTime.bloodmagic.BloodMagic;
|
||||
import WayofTime.bloodmagic.ritual.EnumRuneType;
|
||||
import WayofTime.bloodmagic.ritual.IRitualStone;
|
||||
import WayofTime.bloodmagic.ritual.Ritual;
|
||||
|
@ -22,21 +22,7 @@ public class RitualHelper {
|
|||
static Capability<IRitualStone.Tile> RUNE_CAPABILITY = null;
|
||||
|
||||
public static boolean canCrystalActivate(Ritual ritual, int crystalLevel) {
|
||||
return ritual.getCrystalLevel() <= crystalLevel && RitualRegistry.ritualEnabled(ritual);
|
||||
}
|
||||
|
||||
public static String getNextRitualKey(String currentKey) {
|
||||
int currentIndex = RitualRegistry.getIds().indexOf(currentKey);
|
||||
int nextIndex = RitualRegistry.getRituals().listIterator(currentIndex).nextIndex();
|
||||
|
||||
return RitualRegistry.getIds().get(nextIndex);
|
||||
}
|
||||
|
||||
public static String getPrevRitualKey(String currentKey) {
|
||||
int currentIndex = RitualRegistry.getIds().indexOf(currentKey);
|
||||
int previousIndex = RitualRegistry.getIds().listIterator(currentIndex).previousIndex();
|
||||
|
||||
return RitualRegistry.getIds().get(previousIndex);
|
||||
return ritual.getCrystalLevel() <= crystalLevel && BloodMagic.RITUAL_MANAGER.enabled(BloodMagic.RITUAL_MANAGER.getId(ritual), false);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -48,31 +34,26 @@ public class RitualHelper {
|
|||
* @return The ID of the valid ritual
|
||||
*/
|
||||
public static String getValidRitual(World world, BlockPos pos) {
|
||||
for (String key : RitualRegistry.getIds()) {
|
||||
for (Ritual ritual : BloodMagic.RITUAL_MANAGER.getRituals()) {
|
||||
for (EnumFacing direction : EnumFacing.HORIZONTALS) {
|
||||
boolean test = checkValidRitual(world, pos, key, direction);
|
||||
if (test) {
|
||||
return key;
|
||||
}
|
||||
if (checkValidRitual(world, pos, ritual, direction))
|
||||
return BloodMagic.RITUAL_MANAGER.getId(ritual);
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static EnumFacing getDirectionOfRitual(World world, BlockPos pos, String key) {
|
||||
public static EnumFacing getDirectionOfRitual(World world, BlockPos pos, Ritual ritual) {
|
||||
for (EnumFacing direction : EnumFacing.HORIZONTALS) {
|
||||
boolean test = checkValidRitual(world, pos, key, direction);
|
||||
if (test) {
|
||||
if (checkValidRitual(world, pos, ritual, direction))
|
||||
return direction;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean checkValidRitual(World world, BlockPos pos, String ritualId, EnumFacing direction) {
|
||||
Ritual ritual = RitualRegistry.getRitualForId(ritualId);
|
||||
public static boolean checkValidRitual(World world, BlockPos pos, Ritual ritual, EnumFacing direction) {
|
||||
if (ritual == null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -82,11 +63,8 @@ public class RitualHelper {
|
|||
|
||||
for (RitualComponent component : components) {
|
||||
BlockPos newPos = pos.add(component.getOffset(direction));
|
||||
if (isRuneType(world, newPos, component.getRuneType())) {
|
||||
continue;
|
||||
} else {
|
||||
if (!isRuneType(world, newPos, component.getRuneType()))
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue