Run formatter

This commit is contained in:
Nicholas Ignoffo 2017-08-15 21:30:48 -07:00
parent 61c44a831b
commit 08258fd6ef
606 changed files with 13464 additions and 22975 deletions

View file

@ -1,48 +1,36 @@
package WayofTime.bloodmagic.inversion;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
public class InversionPillarHandler
{
import java.util.*;
public class InversionPillarHandler {
public static final double farthestDistanceSquared = 16 * 16;
public static Map<Integer, Map<EnumDemonWillType, List<BlockPos>>> pillarMap = new HashMap<Integer, Map<EnumDemonWillType, List<BlockPos>>>();
public static Map<Integer, Map<EnumDemonWillType, Map<BlockPos, List<BlockPos>>>> nearPillarMap = new HashMap<Integer, Map<EnumDemonWillType, Map<BlockPos, List<BlockPos>>>>();
public static boolean addPillarToMap(World world, EnumDemonWillType type, BlockPos pos)
{
public static boolean addPillarToMap(World world, EnumDemonWillType type, BlockPos pos) {
int dim = world.provider.getDimension();
if (pillarMap.containsKey(dim))
{
if (pillarMap.containsKey(dim)) {
Map<EnumDemonWillType, List<BlockPos>> willMap = pillarMap.get(dim);
if (willMap.containsKey(type))
{
if (!willMap.get(type).contains(pos))
{
if (willMap.containsKey(type)) {
if (!willMap.get(type).contains(pos)) {
willMap.get(type).add(pos);
onPillarAdded(world, type, pos);
return true;
} else
{
} else {
return false;
}
} else
{
} else {
List<BlockPos> posList = new ArrayList<BlockPos>();
posList.add(pos);
willMap.put(type, posList);
onPillarAdded(world, type, pos);
return true;
}
} else
{
} else {
Map<EnumDemonWillType, List<BlockPos>> willMap = new HashMap<EnumDemonWillType, List<BlockPos>>();
List<BlockPos> posList = new ArrayList<BlockPos>();
posList.add(pos);
@ -54,44 +42,34 @@ public class InversionPillarHandler
}
}
public static boolean removePillarFromMap(World world, EnumDemonWillType type, BlockPos pos)
{
public static boolean removePillarFromMap(World world, EnumDemonWillType type, BlockPos pos) {
int dim = world.provider.getDimension();
if (pillarMap.containsKey(dim))
{
if (pillarMap.containsKey(dim)) {
Map<EnumDemonWillType, List<BlockPos>> willMap = pillarMap.get(dim);
if (willMap.containsKey(type))
{
if (willMap.get(type).contains(pos))
{
if (willMap.containsKey(type)) {
if (willMap.get(type).contains(pos)) {
onPillarRemoved(world, type, pos);
return willMap.get(type).remove(pos);
} else
{
} else {
return false;
}
} else
{
} else {
return false;
}
} else
{
} else {
return false;
}
}
//Assume that it has been added already.
private static void onPillarAdded(World world, EnumDemonWillType type, BlockPos pos)
{
private static void onPillarAdded(World world, EnumDemonWillType type, BlockPos pos) {
System.out.println("Adding...");
List<BlockPos> closePosList = new ArrayList<BlockPos>();
int dim = world.provider.getDimension();
if (pillarMap.containsKey(dim))
{
if (pillarMap.containsKey(dim)) {
Map<EnumDemonWillType, List<BlockPos>> willMap = pillarMap.get(dim);
if (willMap.containsKey(type))
{
if (willMap.containsKey(type)) {
List<BlockPos> otherPosList = willMap.get(type);
for (BlockPos closePos : otherPosList) {
@ -102,11 +80,9 @@ public class InversionPillarHandler
}
}
if (nearPillarMap.containsKey(dim))
{
if (nearPillarMap.containsKey(dim)) {
Map<EnumDemonWillType, Map<BlockPos, List<BlockPos>>> willMap = nearPillarMap.get(dim);
if (willMap.containsKey(type))
{
if (willMap.containsKey(type)) {
Map<BlockPos, List<BlockPos>> posMap = willMap.get(type);
for (BlockPos closePos : closePosList) {
@ -121,15 +97,13 @@ public class InversionPillarHandler
}
posMap.put(pos, closePosList);
} else
{
} else {
Map<BlockPos, List<BlockPos>> posMap = new HashMap<BlockPos, List<BlockPos>>();
posMap.put(pos, closePosList);
willMap.put(type, posMap);
}
} else
{
} else {
Map<EnumDemonWillType, Map<BlockPos, List<BlockPos>>> willMap = new HashMap<EnumDemonWillType, Map<BlockPos, List<BlockPos>>>();
Map<BlockPos, List<BlockPos>> posMap = new HashMap<BlockPos, List<BlockPos>>();
@ -139,26 +113,20 @@ public class InversionPillarHandler
}
}
private static void onPillarRemoved(World world, EnumDemonWillType type, BlockPos pos)
{
private static void onPillarRemoved(World world, EnumDemonWillType type, BlockPos pos) {
System.out.println("Removing...");
int dim = world.provider.getDimension();
if (nearPillarMap.containsKey(dim))
{
if (nearPillarMap.containsKey(dim)) {
Map<EnumDemonWillType, Map<BlockPos, List<BlockPos>>> willMap = nearPillarMap.get(dim);
if (willMap.containsKey(type))
{
if (willMap.containsKey(type)) {
Map<BlockPos, List<BlockPos>> posMap = willMap.get(type);
List<BlockPos> posList = posMap.get(pos);
if (posList != null)
{
if (posList != null) {
Iterator<BlockPos> itr = posList.iterator();
while (itr.hasNext())
{
while (itr.hasNext()) {
BlockPos checkPos = itr.next();
List<BlockPos> checkPosList = posMap.get(checkPos);
if (checkPosList != null)
{
if (checkPosList != null) {
checkPosList.remove(pos);
}
}
@ -170,18 +138,14 @@ public class InversionPillarHandler
}
//TODO: Change to use the nearPillarMap.
public static List<BlockPos> getNearbyPillars(World world, EnumDemonWillType type, BlockPos pos)
{
public static List<BlockPos> getNearbyPillars(World world, EnumDemonWillType type, BlockPos pos) {
int dim = world.provider.getDimension();
if (nearPillarMap.containsKey(dim))
{
if (nearPillarMap.containsKey(dim)) {
Map<EnumDemonWillType, Map<BlockPos, List<BlockPos>>> willMap = nearPillarMap.get(dim);
if (willMap.containsKey(type))
{
if (willMap.containsKey(type)) {
Map<BlockPos, List<BlockPos>> posMap = willMap.get(type);
List<BlockPos> posList = posMap.get(pos);
if (posList != null)
{
if (posList != null) {
return posList;
}
}
@ -190,24 +154,20 @@ public class InversionPillarHandler
return new ArrayList<BlockPos>();
}
public static List<BlockPos> getAllConnectedPillars(World world, EnumDemonWillType type, BlockPos pos)
{
public static List<BlockPos> getAllConnectedPillars(World world, EnumDemonWillType type, BlockPos pos) {
List<BlockPos> checkedPosList = new ArrayList<BlockPos>();
List<BlockPos> uncheckedPosList = new ArrayList<BlockPos>(); //Positions where we did not check their connections.
uncheckedPosList.add(pos);
int dim = world.provider.getDimension();
if (nearPillarMap.containsKey(dim))
{
if (nearPillarMap.containsKey(dim)) {
Map<EnumDemonWillType, Map<BlockPos, List<BlockPos>>> willMap = nearPillarMap.get(dim);
if (willMap.containsKey(type))
{
if (willMap.containsKey(type)) {
Map<BlockPos, List<BlockPos>> posMap = willMap.get(type);
// This is where the magic happens.
while (!uncheckedPosList.isEmpty())
{
while (!uncheckedPosList.isEmpty()) {
//Positions that are new this iteration and need to be dumped into uncheckedPosList next iteration.
List<BlockPos> newPosList = new ArrayList<BlockPos>();