Run formatter
This commit is contained in:
parent
61c44a831b
commit
08258fd6ef
606 changed files with 13464 additions and 22975 deletions
|
@ -5,59 +5,51 @@ import net.minecraft.block.state.IBlockState;
|
|||
import net.minecraft.util.EnumFacing;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class IncenseAltarComponent
|
||||
{
|
||||
public class IncenseAltarComponent {
|
||||
public final BlockPos offsetPos;
|
||||
public final Block block;
|
||||
public final IBlockState state;
|
||||
|
||||
public IncenseAltarComponent(BlockPos offsetPos, Block block, IBlockState state)
|
||||
{
|
||||
public IncenseAltarComponent(BlockPos offsetPos, Block block, IBlockState state) {
|
||||
this.offsetPos = offsetPos;
|
||||
this.block = block;
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public boolean doesBlockMatch(Block block, IBlockState state)
|
||||
{
|
||||
public boolean doesBlockMatch(Block block, IBlockState state) {
|
||||
return this.block == block && block.getMetaFromState(state) == this.block.getMetaFromState(this.state);
|
||||
}
|
||||
|
||||
/**
|
||||
* Base rotation is north.
|
||||
*/
|
||||
public BlockPos getOffset(EnumFacing rotation)
|
||||
{
|
||||
public BlockPos getOffset(EnumFacing rotation) {
|
||||
return new BlockPos(this.getX(rotation), offsetPos.getY(), this.getZ(rotation));
|
||||
}
|
||||
|
||||
public int getX(EnumFacing direction)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case EAST:
|
||||
return -this.offsetPos.getZ();
|
||||
case SOUTH:
|
||||
return -this.offsetPos.getX();
|
||||
case WEST:
|
||||
return this.offsetPos.getZ();
|
||||
default:
|
||||
return this.offsetPos.getX();
|
||||
public int getX(EnumFacing direction) {
|
||||
switch (direction) {
|
||||
case EAST:
|
||||
return -this.offsetPos.getZ();
|
||||
case SOUTH:
|
||||
return -this.offsetPos.getX();
|
||||
case WEST:
|
||||
return this.offsetPos.getZ();
|
||||
default:
|
||||
return this.offsetPos.getX();
|
||||
}
|
||||
}
|
||||
|
||||
public int getZ(EnumFacing direction)
|
||||
{
|
||||
switch (direction)
|
||||
{
|
||||
case EAST:
|
||||
return this.offsetPos.getX();
|
||||
case SOUTH:
|
||||
return -this.offsetPos.getZ();
|
||||
case WEST:
|
||||
return -this.offsetPos.getX();
|
||||
default:
|
||||
return this.offsetPos.getZ();
|
||||
public int getZ(EnumFacing direction) {
|
||||
switch (direction) {
|
||||
case EAST:
|
||||
return this.offsetPos.getX();
|
||||
case SOUTH:
|
||||
return -this.offsetPos.getZ();
|
||||
case WEST:
|
||||
return -this.offsetPos.getX();
|
||||
default:
|
||||
return this.offsetPos.getZ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,61 +11,48 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
public class IncenseAltarHandler
|
||||
{
|
||||
public class IncenseAltarHandler {
|
||||
public static Map<Integer, List<IncenseAltarComponent>> incenseComponentMap = new TreeMap<Integer, List<IncenseAltarComponent>>();
|
||||
//Incense bonus maximum applied for the tier of blocks.
|
||||
public static double[] incenseBonuses = new double[] { 0.2, 0.6, 1.2, 2, 3, 4.5 };
|
||||
public static double[] tranquilityRequired = new double[] { 0, 6, 14.14, 28, 44.09, 83.14 };
|
||||
public static int[] roadsRequired = new int[] { 0, 1, 4, 6, 8, 10, 12 }; //TODO: Change for when the roads are fully implemented
|
||||
public static double[] incenseBonuses = new double[]{0.2, 0.6, 1.2, 2, 3, 4.5};
|
||||
public static double[] tranquilityRequired = new double[]{0, 6, 14.14, 28, 44.09, 83.14};
|
||||
public static int[] roadsRequired = new int[]{0, 1, 4, 6, 8, 10, 12}; //TODO: Change for when the roads are fully implemented
|
||||
|
||||
public static void registerIncenseComponent(int altarLevel, IncenseAltarComponent component)
|
||||
{
|
||||
if (incenseComponentMap.containsKey(altarLevel))
|
||||
{
|
||||
public static void registerIncenseComponent(int altarLevel, IncenseAltarComponent component) {
|
||||
if (incenseComponentMap.containsKey(altarLevel)) {
|
||||
incenseComponentMap.get(altarLevel).add(component);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
List<IncenseAltarComponent> list = new ArrayList<IncenseAltarComponent>();
|
||||
list.add(component);
|
||||
incenseComponentMap.put(altarLevel, list);
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerIncenseComponent(int altarLevel, BlockPos offsetPos, Block block, IBlockState state)
|
||||
{
|
||||
public static void registerIncenseComponent(int altarLevel, BlockPos offsetPos, Block block, IBlockState state) {
|
||||
registerIncenseComponent(altarLevel, new IncenseAltarComponent(offsetPos, block, state));
|
||||
}
|
||||
|
||||
public static double getMaxIncenseBonusFromComponents(World world, BlockPos pos)
|
||||
{
|
||||
public static double getMaxIncenseBonusFromComponents(World world, BlockPos pos) {
|
||||
double accumulatedBonus = 0;
|
||||
for (int i = 0; i < incenseBonuses.length; i++)
|
||||
{
|
||||
for (int i = 0; i < incenseBonuses.length; i++) {
|
||||
double previousBonus = (i <= 0 ? 0 : incenseBonuses[i - 1]);
|
||||
double nextBonus = incenseBonuses[i];
|
||||
if (!incenseComponentMap.containsKey(i))
|
||||
{
|
||||
if (!incenseComponentMap.containsKey(i)) {
|
||||
accumulatedBonus += (nextBonus - previousBonus);
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
boolean hasAllComponentsThisTier = true;
|
||||
for (IncenseAltarComponent component : incenseComponentMap.get(i))
|
||||
{
|
||||
for (IncenseAltarComponent component : incenseComponentMap.get(i)) {
|
||||
BlockPos offsetPos = pos.add(component.getOffset(EnumFacing.NORTH));
|
||||
IBlockState state = world.getBlockState(offsetPos);
|
||||
Block block = state.getBlock();
|
||||
if (component.doesBlockMatch(block, state))
|
||||
{
|
||||
if (component.doesBlockMatch(block, state)) {
|
||||
hasAllComponentsThisTier = false;
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
accumulatedBonus += (nextBonus - previousBonus) / incenseComponentMap.get(i).size();
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasAllComponentsThisTier)
|
||||
{
|
||||
if (!hasAllComponentsThisTier) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -74,16 +61,12 @@ public class IncenseAltarHandler
|
|||
return accumulatedBonus;
|
||||
}
|
||||
|
||||
public static double getMaxIncenseBonusFromRoads(int roads)
|
||||
{
|
||||
public static double getMaxIncenseBonusFromRoads(int roads) {
|
||||
double previousBonus = 0;
|
||||
for (int i = 0; i < incenseBonuses.length; i++)
|
||||
{
|
||||
if (roads >= roadsRequired[i])
|
||||
{
|
||||
for (int i = 0; i < incenseBonuses.length; i++) {
|
||||
if (roads >= roadsRequired[i]) {
|
||||
previousBonus = incenseBonuses[i];
|
||||
} else
|
||||
{
|
||||
} else {
|
||||
return previousBonus;
|
||||
}
|
||||
}
|
||||
|
@ -91,18 +74,14 @@ public class IncenseAltarHandler
|
|||
return previousBonus;
|
||||
}
|
||||
|
||||
public static double getIncenseBonusFromComponents(World world, BlockPos pos, double tranquility, int roads)
|
||||
{
|
||||
public static double getIncenseBonusFromComponents(World world, BlockPos pos, double tranquility, int roads) {
|
||||
double maxBonus = Math.min(getMaxIncenseBonusFromComponents(world, pos), getMaxIncenseBonusFromRoads(roads));
|
||||
double possibleBonus = 0;
|
||||
|
||||
for (int i = 0; i < incenseBonuses.length; i++)
|
||||
{
|
||||
if (tranquility >= tranquilityRequired[i])
|
||||
{
|
||||
for (int i = 0; i < incenseBonuses.length; i++) {
|
||||
if (tranquility >= tranquilityRequired[i]) {
|
||||
possibleBonus = incenseBonuses[i];
|
||||
} else if (i >= 1)
|
||||
{
|
||||
} else if (i >= 1) {
|
||||
possibleBonus += (incenseBonuses[i] - possibleBonus) * (tranquility - tranquilityRequired[i - 1]) / (tranquilityRequired[i] - tranquilityRequired[i - 1]);
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -10,16 +10,12 @@ import net.minecraft.init.Blocks;
|
|||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class TranquilityHandlers
|
||||
{
|
||||
public class TranquilityHandlers {
|
||||
|
||||
public static class Plant implements ITranquilityHandler
|
||||
{
|
||||
public static class Plant implements ITranquilityHandler {
|
||||
@Override
|
||||
public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state)
|
||||
{
|
||||
if (block instanceof BlockLeaves)
|
||||
{
|
||||
public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) {
|
||||
if (block instanceof BlockLeaves) {
|
||||
return new TranquilityStack(EnumTranquilityType.PLANT, 1);
|
||||
}
|
||||
|
||||
|
@ -27,13 +23,10 @@ public class TranquilityHandlers
|
|||
}
|
||||
}
|
||||
|
||||
public static class Lava implements ITranquilityHandler
|
||||
{
|
||||
public static class Lava implements ITranquilityHandler {
|
||||
@Override
|
||||
public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state)
|
||||
{
|
||||
if (block == Blocks.LAVA || block == Blocks.FLOWING_LAVA)
|
||||
{
|
||||
public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) {
|
||||
if (block == Blocks.LAVA || block == Blocks.FLOWING_LAVA) {
|
||||
return new TranquilityStack(EnumTranquilityType.LAVA, 1.2);
|
||||
}
|
||||
|
||||
|
@ -41,18 +34,14 @@ public class TranquilityHandlers
|
|||
}
|
||||
}
|
||||
|
||||
public static class Fire implements ITranquilityHandler
|
||||
{
|
||||
public static class Fire implements ITranquilityHandler {
|
||||
@Override
|
||||
public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state)
|
||||
{
|
||||
if (block instanceof BlockFire)
|
||||
{
|
||||
public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) {
|
||||
if (block instanceof BlockFire) {
|
||||
return new TranquilityStack(EnumTranquilityType.FIRE, 1);
|
||||
}
|
||||
|
||||
if (block == Blocks.NETHERRACK)
|
||||
{
|
||||
if (block == Blocks.NETHERRACK) {
|
||||
return new TranquilityStack(EnumTranquilityType.FIRE, 0.5);
|
||||
}
|
||||
|
||||
|
@ -60,23 +49,18 @@ public class TranquilityHandlers
|
|||
}
|
||||
}
|
||||
|
||||
public static class Earth implements ITranquilityHandler
|
||||
{
|
||||
public static class Earth implements ITranquilityHandler {
|
||||
@Override
|
||||
public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state)
|
||||
{
|
||||
if (block == Blocks.DIRT)
|
||||
{
|
||||
public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) {
|
||||
if (block == Blocks.DIRT) {
|
||||
return new TranquilityStack(EnumTranquilityType.EARTHEN, 0.25);
|
||||
}
|
||||
|
||||
if (block instanceof BlockGrass)
|
||||
{
|
||||
if (block instanceof BlockGrass) {
|
||||
return new TranquilityStack(EnumTranquilityType.EARTHEN, 0.5);
|
||||
}
|
||||
|
||||
if (block == Blocks.FARMLAND)
|
||||
{
|
||||
if (block == Blocks.FARMLAND) {
|
||||
return new TranquilityStack(EnumTranquilityType.EARTHEN, 1);
|
||||
}
|
||||
|
||||
|
@ -84,13 +68,10 @@ public class TranquilityHandlers
|
|||
}
|
||||
}
|
||||
|
||||
public static class Crop implements ITranquilityHandler
|
||||
{
|
||||
public static class Crop implements ITranquilityHandler {
|
||||
@Override
|
||||
public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state)
|
||||
{
|
||||
if (block == Blocks.POTATOES || block == Blocks.CARROTS || block == Blocks.WHEAT || block == Blocks.NETHER_WART || block == Blocks.BEETROOTS)
|
||||
{
|
||||
public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) {
|
||||
if (block == Blocks.POTATOES || block == Blocks.CARROTS || block == Blocks.WHEAT || block == Blocks.NETHER_WART || block == Blocks.BEETROOTS) {
|
||||
return new TranquilityStack(EnumTranquilityType.CROP, 1);
|
||||
}
|
||||
|
||||
|
@ -98,13 +79,10 @@ public class TranquilityHandlers
|
|||
}
|
||||
}
|
||||
|
||||
public static class Tree implements ITranquilityHandler
|
||||
{
|
||||
public static class Tree implements ITranquilityHandler {
|
||||
@Override
|
||||
public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state)
|
||||
{
|
||||
if (block instanceof BlockLog)
|
||||
{
|
||||
public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) {
|
||||
if (block instanceof BlockLog) {
|
||||
return new TranquilityStack(EnumTranquilityType.TREE, 1);
|
||||
}
|
||||
|
||||
|
@ -112,18 +90,14 @@ public class TranquilityHandlers
|
|||
}
|
||||
}
|
||||
|
||||
public static class Water implements ITranquilityHandler
|
||||
{
|
||||
public static class Water implements ITranquilityHandler {
|
||||
@Override
|
||||
public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state)
|
||||
{
|
||||
if (block == Blocks.WATER || block == Blocks.FLOWING_WATER)
|
||||
{
|
||||
public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state) {
|
||||
if (block == Blocks.WATER || block == Blocks.FLOWING_WATER) {
|
||||
return new TranquilityStack(EnumTranquilityType.WATER, 1);
|
||||
}
|
||||
|
||||
if (block == RegistrarBloodMagicBlocks.LIFE_ESSENCE)
|
||||
{
|
||||
if (block == RegistrarBloodMagicBlocks.LIFE_ESSENCE) {
|
||||
return new TranquilityStack(EnumTranquilityType.WATER, 1.5);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue