Changed formatting to have bracing on a new line

This commit is contained in:
WayofTime 2015-12-30 15:34:40 -05:00
parent e5eddd6c45
commit e48eedb874
189 changed files with 6092 additions and 4041 deletions

View file

@ -19,20 +19,24 @@ import WayofTime.bloodmagic.api.ritual.Ritual;
import WayofTime.bloodmagic.api.ritual.RitualComponent;
import WayofTime.bloodmagic.api.ritual.imperfect.ImperfectRitual;
public class RitualHelper {
public class RitualHelper
{
public static boolean canCrystalActivate(Ritual ritual, int crystalLevel) {
public static boolean canCrystalActivate(Ritual ritual, int crystalLevel)
{
return ritual.getCrystalLevel() <= crystalLevel && RitualRegistry.ritualEnabled(ritual);
}
public static String getNextRitualKey(String currentKey) {
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) {
public static String getPrevRitualKey(String currentKey)
{
int currentIndex = RitualRegistry.getIds().indexOf(currentKey);
int previousIndex = RitualRegistry.getIds().listIterator(currentIndex).previousIndex();
@ -40,87 +44,106 @@ public class RitualHelper {
}
/**
* Checks the RitualRegistry to see if the configuration of the ritual stones in the world is valid
* for the given EnumFacing.
*
* Checks the RitualRegistry to see if the configuration of the ritual
* stones in the world is valid for the given EnumFacing.
*
* @return The ID of the valid ritual
*/
public static String getValidRitual(World world, BlockPos pos) {
for(String key : RitualRegistry.getIds()) {
for(EnumFacing direction : EnumFacing.HORIZONTALS) {
boolean test = checkValidRitual(world, pos, key, direction);
if(test) {
return key;
}
}
}
return "";
public static String getValidRitual(World world, BlockPos pos)
{
for (String key : RitualRegistry.getIds())
{
for (EnumFacing direction : EnumFacing.HORIZONTALS)
{
boolean test = checkValidRitual(world, pos, key, direction);
if (test)
{
return key;
}
}
}
return "";
}
public static EnumFacing getDirectionOfRitual(World world, BlockPos pos, String key) {
for(EnumFacing direction : EnumFacing.HORIZONTALS) {
boolean test = checkValidRitual(world, pos, key, direction);
if(test) {
return direction;
}
}
return null;
public static EnumFacing getDirectionOfRitual(World world, BlockPos pos, String key)
{
for (EnumFacing direction : EnumFacing.HORIZONTALS)
{
boolean test = checkValidRitual(world, pos, key, direction);
if (test)
{
return direction;
}
}
return null;
}
public static boolean checkValidRitual(World world, BlockPos pos, String ritualId, EnumFacing direction) {
Ritual ritual = RitualRegistry.getRitualForId(ritualId);
if(ritual == null) {
return false;
}
public static boolean checkValidRitual(World world, BlockPos pos, String ritualId, EnumFacing direction)
{
Ritual ritual = RitualRegistry.getRitualForId(ritualId);
if (ritual == null)
{
return false;
}
ArrayList<RitualComponent> components = ritual.getComponents();
if (components == null)
return false;
for (RitualComponent component : components) {
BlockPos newPos = pos.add(component.getOffset(direction));
for (RitualComponent component : components)
{
BlockPos newPos = pos.add(component.getOffset(direction));
IBlockState worldState = world.getBlockState(newPos);
Block block = worldState.getBlock();
if (block instanceof IRitualStone) {
if(!((IRitualStone)block).isRuneType(world, newPos, component.getRuneType())) {
return false;
}
}else {
return false;
if (block instanceof IRitualStone)
{
if (!((IRitualStone) block).isRuneType(world, newPos, component.getRuneType()))
{
return false;
}
} else
{
return false;
}
}
return true;
}
public static void checkImperfectRituals(Configuration config, String packageName, String category) {
public static void checkImperfectRituals(Configuration config, String packageName, String category)
{
checkRituals(config, packageName, category, ImperfectRitual.class, ImperfectRitualRegistry.enabledRituals);
}
public static void checkRituals(Configuration config, String packageName, String category) {
public static void checkRituals(Configuration config, String packageName, String category)
{
checkRituals(config, packageName, category, Ritual.class, RitualRegistry.enabledRituals);
}
/**
* Adds your Ritual to the {@link RitualRegistry#enabledRituals} Map.
* This is used to determine whether your effect is enabled or not.
*
* The config option will be created as {@code B:ClassName=true} with a comment of
* {@code Enables the ClassName ritual}.
*
* Adds your Ritual to the {@link RitualRegistry#enabledRituals} Map. This
* is used to determine whether your effect is enabled or not.
*
* The config option will be created as {@code B:ClassName=true} with a
* comment of {@code Enables the ClassName ritual}.
*
* Use {@link #}
*
*
* Should be safe to modify at any point.
*
* @param config - Your mod's Forge {@link Configuration} object.
* @param packageName - The package your Rituals are located in.
* @param category - The config category to write to.
*
* @param config
* - Your mod's Forge {@link Configuration} object.
* @param packageName
* - The package your Rituals are located in.
* @param category
* - The config category to write to.
*/
@SuppressWarnings("unchecked")
private static void checkRituals(Configuration config, String packageName, String category, Class ritualClass, Map enabledMap) {
private static void checkRituals(Configuration config, String packageName, String category, Class ritualClass, Map enabledMap)
{
String name = packageName;
if (!name.startsWith("/"))
name = "/" + name;
@ -129,24 +152,31 @@ public class RitualHelper {
URL url = BloodMagic.class.getResource(name);
File directory = new File(url.getFile());
if (directory.exists()) {
if (directory.exists())
{
String[] files = directory.list();
for (String file : files) {
if (file.endsWith(".class")) {
for (String file : files)
{
if (file.endsWith(".class"))
{
String className = file.substring(0, file.length() - 6);
try {
try
{
Object o = Class.forName(packageName + "." + className).newInstance();
if (ritualClass.isInstance(o))
enabledMap.put(ritualClass.cast(o), config.get(category, className, true).getBoolean());
} catch (ClassNotFoundException e) {
} catch (ClassNotFoundException e)
{
e.printStackTrace();
} catch (InstantiationException e) {
} catch (InstantiationException e)
{
e.printStackTrace();
} catch (IllegalAccessException e) {
} catch (IllegalAccessException e)
{
e.printStackTrace();
}
}