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,42 +1,34 @@
package WayofTime.bloodmagic.inversion;
import java.util.HashMap;
import java.util.Map;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import net.minecraft.block.Block;
import net.minecraft.block.state.IBlockState;
import net.minecraft.util.math.BlockPos;
import net.minecraft.world.World;
import org.apache.commons.lang3.tuple.Pair;
import WayofTime.bloodmagic.api.soul.EnumDemonWillType;
import java.util.HashMap;
import java.util.Map;
public class CorruptionHandler
{
public class CorruptionHandler {
public static Map<Pair<Block, Integer>, Map<EnumDemonWillType, IBlockState>> corruptBlockMap = new HashMap<Pair<Block, Integer>, Map<EnumDemonWillType, IBlockState>>();
public static void registerBlockCorruption(EnumDemonWillType type, Block block, int meta, IBlockState corruptedState)
{
public static void registerBlockCorruption(EnumDemonWillType type, Block block, int meta, IBlockState corruptedState) {
Pair<Block, Integer> pair = Pair.of(block, meta);
if (corruptBlockMap.containsKey(pair))
{
if (corruptBlockMap.containsKey(pair)) {
Map<EnumDemonWillType, IBlockState> stateMap = corruptBlockMap.get(pair);
stateMap.put(type, corruptedState);
} else
{
} else {
Map<EnumDemonWillType, IBlockState> stateMap = new HashMap<EnumDemonWillType, IBlockState>();
stateMap.put(type, corruptedState);
corruptBlockMap.put(pair, stateMap);
}
}
public static boolean isBlockCorruptible(World world, EnumDemonWillType type, BlockPos pos, IBlockState state, Block block)
{
public static boolean isBlockCorruptible(World world, EnumDemonWillType type, BlockPos pos, IBlockState state, Block block) {
int meta = block.getMetaFromState(state);
Pair<Block, Integer> pair = Pair.of(block, meta);
if (corruptBlockMap.containsKey(pair))
{
if (corruptBlockMap.containsKey(pair)) {
Map<EnumDemonWillType, IBlockState> stateMap = corruptBlockMap.get(pair);
return stateMap.containsKey(type);
}
@ -44,15 +36,12 @@ public class CorruptionHandler
return false;
}
public static boolean corruptBlock(World world, EnumDemonWillType type, BlockPos pos, IBlockState state, Block block)
{
public static boolean corruptBlock(World world, EnumDemonWillType type, BlockPos pos, IBlockState state, Block block) {
int meta = block.getMetaFromState(state);
Pair<Block, Integer> pair = Pair.of(block, meta);
if (corruptBlockMap.containsKey(pair))
{
if (corruptBlockMap.containsKey(pair)) {
Map<EnumDemonWillType, IBlockState> stateMap = corruptBlockMap.get(pair);
if (stateMap.containsKey(type))
{
if (stateMap.containsKey(type)) {
return world.setBlockState(pos, stateMap.get(type));
}
}
@ -61,36 +50,27 @@ public class CorruptionHandler
}
/**
*
* @param world
* @param type
* @param centerPos
* @param radius
* @param featheringChance
* Chance that the block within the featheringDepth is NOT altered.
* @param featheringChance Chance that the block within the featheringDepth is NOT altered.
* @param featheringDepth
* @return
*/
public static boolean corruptSurroundingBlocks(World world, EnumDemonWillType type, BlockPos centerPos, int radius, double featheringChance, double featheringDepth)
{
for (int i = -radius; i <= radius; i++)
{
for (int j = -radius; j <= radius; j++)
{
for (int k = -radius; k <= radius; k++)
{
if (i * i + j * j + k * k > (radius + 0.5) * (radius + 0.5))
{
public static boolean corruptSurroundingBlocks(World world, EnumDemonWillType type, BlockPos centerPos, int radius, double featheringChance, double featheringDepth) {
for (int i = -radius; i <= radius; i++) {
for (int j = -radius; j <= radius; j++) {
for (int k = -radius; k <= radius; k++) {
if (i * i + j * j + k * k > (radius + 0.5) * (radius + 0.5)) {
continue;
}
if (featheringChance > 0 && i * i + j * j + k * k > (radius - featheringDepth + 0.5) * (radius - featheringDepth + 0.5) && world.rand.nextDouble() < featheringChance)
{
if (featheringChance > 0 && i * i + j * j + k * k > (radius - featheringDepth + 0.5) * (radius - featheringDepth + 0.5) && world.rand.nextDouble() < featheringChance) {
continue;
}
if (world.isAirBlock(centerPos))
{
if (world.isAirBlock(centerPos)) {
continue;
}

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>();