Finished implementation of Incense Altar and associated blocks.
Also added the recipe for the Ritual Tinkerer, as well as the finalized book entry for the Incense Altar.
This commit is contained in:
parent
7634404dac
commit
cb2db9bc50
108 changed files with 2197 additions and 81 deletions
|
@ -0,0 +1,12 @@
|
|||
package wayoftime.bloodmagic.incense;
|
||||
|
||||
public enum EnumTranquilityType
|
||||
{
|
||||
PLANT(),
|
||||
CROP(),
|
||||
TREE(),
|
||||
EARTHEN(),
|
||||
WATER(),
|
||||
FIRE(),
|
||||
LAVA(),;
|
||||
}
|
15
src/main/java/wayoftime/bloodmagic/incense/IIncensePath.java
Normal file
15
src/main/java/wayoftime/bloodmagic/incense/IIncensePath.java
Normal file
|
@ -0,0 +1,15 @@
|
|||
package wayoftime.bloodmagic.incense;
|
||||
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface IIncensePath
|
||||
{
|
||||
/**
|
||||
* Goes from 0 to however far this path block can be from the altar while still
|
||||
* functioning. 0 represents a block that can work when it is two blocks
|
||||
* horizontally away from the altar.
|
||||
*/
|
||||
int getLevelOfPath(World world, BlockPos pos, BlockState state);
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package wayoftime.bloodmagic.incense;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public interface ITranquilityHandler
|
||||
{
|
||||
TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, BlockState state);
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
package wayoftime.bloodmagic.incense;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
public class IncenseAltarComponent
|
||||
{
|
||||
public final BlockPos offsetPos;
|
||||
public final Block block;
|
||||
|
||||
public IncenseAltarComponent(BlockPos offsetPos, Block block)
|
||||
{
|
||||
this.offsetPos = offsetPos;
|
||||
this.block = block;
|
||||
}
|
||||
|
||||
public boolean doesBlockMatch(Block block)
|
||||
{
|
||||
return this.block == block;
|
||||
}
|
||||
|
||||
/**
|
||||
* Base rotation is north.
|
||||
*/
|
||||
public BlockPos getOffset(Direction rotation)
|
||||
{
|
||||
return new BlockPos(this.getX(rotation), offsetPos.getY(), this.getZ(rotation));
|
||||
}
|
||||
|
||||
public int getX(Direction 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(Direction 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();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,114 @@
|
|||
package wayoftime.bloodmagic.incense;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.Direction;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class IncenseAltarHandler
|
||||
{
|
||||
public static Map<Integer, List<IncenseAltarComponent>> incenseComponentMap = new TreeMap<>();
|
||||
// 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 void registerIncenseComponent(int altarLevel, IncenseAltarComponent component)
|
||||
{
|
||||
if (incenseComponentMap.containsKey(altarLevel))
|
||||
{
|
||||
incenseComponentMap.get(altarLevel).add(component);
|
||||
} else
|
||||
{
|
||||
List<IncenseAltarComponent> list = new ArrayList<>();
|
||||
list.add(component);
|
||||
incenseComponentMap.put(altarLevel, list);
|
||||
}
|
||||
}
|
||||
|
||||
public static void registerIncenseComponent(int altarLevel, BlockPos offsetPos, Block block, BlockState state)
|
||||
{
|
||||
registerIncenseComponent(altarLevel, new IncenseAltarComponent(offsetPos, block));
|
||||
}
|
||||
|
||||
public static double getMaxIncenseBonusFromComponents(World world, BlockPos pos)
|
||||
{
|
||||
double accumulatedBonus = 0;
|
||||
for (int i = 0; i < incenseBonuses.length; i++)
|
||||
{
|
||||
double previousBonus = (i <= 0 ? 0 : incenseBonuses[i - 1]);
|
||||
double nextBonus = incenseBonuses[i];
|
||||
if (!incenseComponentMap.containsKey(i))
|
||||
{
|
||||
accumulatedBonus += (nextBonus - previousBonus);
|
||||
} else
|
||||
{
|
||||
boolean hasAllComponentsThisTier = true;
|
||||
for (IncenseAltarComponent component : incenseComponentMap.get(i))
|
||||
{
|
||||
BlockPos offsetPos = pos.add(component.getOffset(Direction.NORTH));
|
||||
BlockState state = world.getBlockState(offsetPos);
|
||||
Block block = state.getBlock();
|
||||
if (component.doesBlockMatch(block))
|
||||
{
|
||||
hasAllComponentsThisTier = false;
|
||||
} else
|
||||
{
|
||||
accumulatedBonus += (nextBonus - previousBonus) / incenseComponentMap.get(i).size();
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasAllComponentsThisTier)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return accumulatedBonus;
|
||||
}
|
||||
|
||||
public static double getMaxIncenseBonusFromRoads(int roads)
|
||||
{
|
||||
double previousBonus = 0;
|
||||
for (int i = 0; i < incenseBonuses.length; i++)
|
||||
{
|
||||
if (roads >= roadsRequired[i])
|
||||
{
|
||||
previousBonus = incenseBonuses[i];
|
||||
} else
|
||||
{
|
||||
return previousBonus;
|
||||
}
|
||||
}
|
||||
|
||||
return previousBonus;
|
||||
}
|
||||
|
||||
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])
|
||||
{
|
||||
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,33 @@
|
|||
package wayoftime.bloodmagic.incense;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockState;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
|
||||
public class IncenseTranquilityRegistry
|
||||
{
|
||||
public static List<ITranquilityHandler> handlerList = new ArrayList<>();
|
||||
|
||||
public static void registerTranquilityHandler(ITranquilityHandler handler)
|
||||
{
|
||||
handlerList.add(handler);
|
||||
}
|
||||
|
||||
public static TranquilityStack getTranquilityOfBlock(World world, BlockPos pos, Block block, BlockState state)
|
||||
{
|
||||
for (ITranquilityHandler handler : handlerList)
|
||||
{
|
||||
TranquilityStack tranq = handler.getTranquilityOfBlock(world, pos, block, state);
|
||||
if (tranq != null)
|
||||
{
|
||||
return tranq;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
package wayoftime.bloodmagic.incense;
|
||||
|
||||
public class TranquilityStack
|
||||
{
|
||||
public final EnumTranquilityType type;
|
||||
public double value;
|
||||
|
||||
public TranquilityStack(EnumTranquilityType type, double value)
|
||||
{
|
||||
this.type = type;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue