Added directionality to rituals.
This commit is contained in:
parent
971d4c4d1e
commit
0e1173ef5d
5 changed files with 34 additions and 11 deletions
|
@ -21,6 +21,7 @@ public class Constants {
|
|||
public static final String CURRENT_RITUAL = "currentRitual";
|
||||
public static final String IS_RUNNING = "isRunning";
|
||||
public static final String RUNTIME = "runtime";
|
||||
public static final String DIRECTION = "direction";
|
||||
public static final String REAGENT_TANKS = "reagentTanks";
|
||||
public static final String CURRENT_INCENSE = "BM:CurrentIncense";
|
||||
public static final String EMPTY = "Empty";
|
||||
|
|
|
@ -37,4 +37,8 @@ public class RitualComponent {
|
|||
return this.getOffset().getZ();
|
||||
}
|
||||
}
|
||||
|
||||
public BlockPos getOffset(EnumFacing direction) {
|
||||
return new BlockPos(getX(direction), offset.getY(), getZ(direction));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,17 +48,30 @@ public class RitualHelper {
|
|||
* @param direction
|
||||
* @return The ID of the valid ritual
|
||||
*/
|
||||
public static String getValidRitual(World world, BlockPos pos, EnumFacing direction) {
|
||||
public static String getValidRitual(World world, BlockPos pos) {
|
||||
for(String key : RitualRegistry.getIds()) {
|
||||
boolean test = checkValidRitual(world, pos, key, direction);
|
||||
if(test) {
|
||||
return key;
|
||||
for(EnumFacing direction : EnumFacing.HORIZONTALS) {
|
||||
boolean test = checkValidRitual(world, pos, key, direction);
|
||||
if(test) {
|
||||
return key;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
|
||||
public static EnumFacing getDirectionOfRitual(World world, BlockPos pos, String key) {
|
||||
for(EnumFacing direction : EnumFacing.HORIZONTALS) {
|
||||
boolean test = checkValidRitual(world, pos, key, direction);
|
||||
if(test) {
|
||||
return direction;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static boolean checkValidRitual(World world, BlockPos pos, String ritualId, EnumFacing direction) {
|
||||
Ritual ritual = RitualRegistry.getRitualForId(ritualId);
|
||||
if(ritual == null) {
|
||||
|
@ -71,7 +84,7 @@ public class RitualHelper {
|
|||
return false;
|
||||
|
||||
for (RitualComponent component : components) {
|
||||
BlockPos newPos = pos.add(component.getOffset());
|
||||
BlockPos newPos = pos.add(component.getOffset(direction));
|
||||
IBlockState worldState = world.getBlockState(newPos);
|
||||
Block block = worldState.getBlock();
|
||||
if (block instanceof BlockRitualStone) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue