Added more infrastructure to the incense system.
This commit is contained in:
parent
1242fefc30
commit
f4d0b18521
|
@ -3,6 +3,10 @@ package WayofTime.bloodmagic.api.incense;
|
|||
public enum EnumTranquilityType
|
||||
{
|
||||
PLANT(),
|
||||
CROP(),
|
||||
TREE(),
|
||||
EARTHEN(),
|
||||
WATER(),
|
||||
FIRE();
|
||||
FIRE(),
|
||||
LAVA();
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package WayofTime.bloodmagic.incense;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.api.incense.EnumTranquilityType;
|
||||
import WayofTime.bloodmagic.api.incense.TranquilityHandler;
|
||||
import WayofTime.bloodmagic.api.incense.TranquilityStack;
|
||||
|
||||
public class CropTranquilityHandler extends TranquilityHandler
|
||||
{
|
||||
@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)
|
||||
{
|
||||
return new TranquilityStack(EnumTranquilityType.CROP, 1);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
package WayofTime.bloodmagic.incense;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockGrass;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.api.incense.EnumTranquilityType;
|
||||
import WayofTime.bloodmagic.api.incense.TranquilityHandler;
|
||||
import WayofTime.bloodmagic.api.incense.TranquilityStack;
|
||||
|
||||
public class EarthTranquilityHandler extends TranquilityHandler
|
||||
{
|
||||
@Override
|
||||
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)
|
||||
{
|
||||
return new TranquilityStack(EnumTranquilityType.EARTHEN, 0.5);
|
||||
}
|
||||
|
||||
if (block == Blocks.farmland)
|
||||
{
|
||||
return new TranquilityStack(EnumTranquilityType.EARTHEN, 1);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,30 @@
|
|||
package WayofTime.bloodmagic.incense;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockFire;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.api.incense.EnumTranquilityType;
|
||||
import WayofTime.bloodmagic.api.incense.TranquilityHandler;
|
||||
import WayofTime.bloodmagic.api.incense.TranquilityStack;
|
||||
|
||||
public class FireTranquilityHandler extends TranquilityHandler
|
||||
{
|
||||
@Override
|
||||
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)
|
||||
{
|
||||
return new TranquilityStack(EnumTranquilityType.FIRE, 0.5);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -15,7 +15,8 @@ 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 };
|
||||
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 void registerIncenseComponent(int altarLevel, IncenseAltarComponent component)
|
||||
{
|
||||
|
@ -35,7 +36,7 @@ public class IncenseAltarHandler
|
|||
registerIncenseComponent(altarLevel, new IncenseAltarComponent(offsetPos, block, state));
|
||||
}
|
||||
|
||||
public static double getIncenseBonusFromComponents(World world, BlockPos pos)
|
||||
public static double getMaxIncenseBonusFromComponents(World world, BlockPos pos)
|
||||
{
|
||||
double accumulatedBonus = 0;
|
||||
for (int i = 0; i < incenseBonuses.length; i++)
|
||||
|
@ -71,4 +72,24 @@ public class IncenseAltarHandler
|
|||
|
||||
return accumulatedBonus;
|
||||
}
|
||||
|
||||
public static double getIncenseBonusFromComponents(World world, BlockPos pos, double tranquility)
|
||||
{
|
||||
double maxBonus = getMaxIncenseBonusFromComponents(world, pos);
|
||||
double possibleBonus = 0;
|
||||
|
||||
for (int i = 0; i < incenseBonuses.length; i++)
|
||||
{
|
||||
if (tranquility >= tranquilityRequired[i])
|
||||
{
|
||||
possibleBonus = incenseBonuses[i];
|
||||
} else if (i >= 1)
|
||||
{
|
||||
possibleBonus += (incenseBonuses[i] - possibleBonus) * (tranquility - tranquilityRequired[i - 1]) / (tranquilityRequired[i] - tranquilityRequired[i - 1]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return Math.min(maxBonus, possibleBonus);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package WayofTime.bloodmagic.incense;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.init.Blocks;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.api.incense.EnumTranquilityType;
|
||||
import WayofTime.bloodmagic.api.incense.TranquilityHandler;
|
||||
import WayofTime.bloodmagic.api.incense.TranquilityStack;
|
||||
|
||||
public class LavaTranquilityHandler extends TranquilityHandler
|
||||
{
|
||||
@Override
|
||||
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);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -2,12 +2,9 @@ package WayofTime.bloodmagic.incense;
|
|||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLeaves;
|
||||
import net.minecraft.block.BlockLog;
|
||||
import net.minecraft.block.IGrowable;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraftforge.common.IPlantable;
|
||||
import WayofTime.bloodmagic.api.incense.EnumTranquilityType;
|
||||
import WayofTime.bloodmagic.api.incense.TranquilityHandler;
|
||||
import WayofTime.bloodmagic.api.incense.TranquilityStack;
|
||||
|
@ -17,16 +14,11 @@ public class PlantTranquilityHandler extends TranquilityHandler
|
|||
@Override
|
||||
public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state)
|
||||
{
|
||||
if (block instanceof IGrowable || block instanceof IPlantable)
|
||||
if (block instanceof BlockLeaves)
|
||||
{
|
||||
return new TranquilityStack(EnumTranquilityType.PLANT, 1);
|
||||
}
|
||||
|
||||
if (block instanceof BlockLog || block instanceof BlockLeaves)
|
||||
{
|
||||
return new TranquilityStack(EnumTranquilityType.PLANT, 0.5);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -0,0 +1,24 @@
|
|||
package WayofTime.bloodmagic.incense;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockLog;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import WayofTime.bloodmagic.api.incense.EnumTranquilityType;
|
||||
import WayofTime.bloodmagic.api.incense.TranquilityHandler;
|
||||
import WayofTime.bloodmagic.api.incense.TranquilityStack;
|
||||
|
||||
public class TreeTranquilityHandler extends TranquilityHandler
|
||||
{
|
||||
@Override
|
||||
public TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, IBlockState state)
|
||||
{
|
||||
if (block instanceof BlockLog)
|
||||
{
|
||||
return new TranquilityStack(EnumTranquilityType.TREE, 1);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -22,7 +22,7 @@ public class WaterTranquilityHandler extends TranquilityHandler
|
|||
|
||||
if (block == ModBlocks.lifeEssence)
|
||||
{
|
||||
return new TranquilityStack(EnumTranquilityType.WATER, 2);
|
||||
return new TranquilityStack(EnumTranquilityType.WATER, 1.5);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -1,12 +1,24 @@
|
|||
package WayofTime.bloodmagic.registry;
|
||||
|
||||
import WayofTime.bloodmagic.api.incense.IncenseTranquilityRegistry;
|
||||
import WayofTime.bloodmagic.incense.CropTranquilityHandler;
|
||||
import WayofTime.bloodmagic.incense.EarthTranquilityHandler;
|
||||
import WayofTime.bloodmagic.incense.FireTranquilityHandler;
|
||||
import WayofTime.bloodmagic.incense.LavaTranquilityHandler;
|
||||
import WayofTime.bloodmagic.incense.PlantTranquilityHandler;
|
||||
import WayofTime.bloodmagic.incense.TreeTranquilityHandler;
|
||||
import WayofTime.bloodmagic.incense.WaterTranquilityHandler;
|
||||
|
||||
public class ModTranquilityHandlers
|
||||
{
|
||||
public static void init()
|
||||
{
|
||||
IncenseTranquilityRegistry.registerTranquilityHandler(new PlantTranquilityHandler());
|
||||
IncenseTranquilityRegistry.registerTranquilityHandler(new CropTranquilityHandler());
|
||||
IncenseTranquilityRegistry.registerTranquilityHandler(new WaterTranquilityHandler());
|
||||
IncenseTranquilityRegistry.registerTranquilityHandler(new EarthTranquilityHandler());
|
||||
IncenseTranquilityRegistry.registerTranquilityHandler(new FireTranquilityHandler());
|
||||
IncenseTranquilityRegistry.registerTranquilityHandler(new LavaTranquilityHandler());
|
||||
IncenseTranquilityRegistry.registerTranquilityHandler(new TreeTranquilityHandler());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -136,7 +136,7 @@ public class TileIncenseAltar extends TileInventory implements ITickable
|
|||
double appliedTranquility = 0;
|
||||
for (Entry<EnumTranquilityType, Double> entry : tranquilityMap.entrySet())
|
||||
{
|
||||
appliedTranquility += Math.pow(entry.getValue(), 0.9);
|
||||
appliedTranquility += Math.sqrt(entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue