Skip to content

Commit

Permalink
Fixes for custom positions, #289
Browse files Browse the repository at this point in the history
  • Loading branch information
NightKosh committed Oct 30, 2018
1 parent 5240058 commit d3feb15
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 9 deletions.
2 changes: 1 addition & 1 deletion api/gravestone
Expand Up @@ -372,9 +372,23 @@ public void setMossy(boolean mossy) {

private static void createOnDeath(Entity entity, World world, BlockPos pos, DeathMessageInfo deathInfo, List<ItemStack> items,
int age, GraveInfoOnDeath graveInfo, DamageSource damageSource) {
EnumFacing direction = EnumFacing.getHorizontal(MathHelper.floor((double) (entity.rotationYaw * 4 / 360F) + 0.5) & 3);
BlockPos newPos = null;
EnumFacing direction = null;

BlockPos newPos = findPlaceForGrave(world, entity, pos, damageSource);
boolean hasCustomLocation = false;
for (IGravePositionHandler position : APIGraveGeneration.GRAVE_POSITION_HANDLERS) {
if (position.condition(world, entity, pos, damageSource)) {
hasCustomLocation = true;
newPos = position.gravePosition(world, entity, pos, damageSource);
direction = position.graveFacing(world, entity, pos, damageSource);
break;
}
}

if (!hasCustomLocation) {
direction = EnumFacing.getHorizontal(MathHelper.floor((double) (entity.rotationYaw * 4 / 360F) + 0.5) & 3);
newPos = findPlaceForGrave(world, entity, pos, damageSource);
}

if (Config.createBackups && entity instanceof EntityPlayer) {
try {
Expand Down Expand Up @@ -677,12 +691,6 @@ public static EnumGraves getGraveTypeByBiomes(World world, BlockPos pos, EnumGra
}

private static BlockPos findPlaceForGrave(World world, Entity entity, BlockPos pos, DamageSource damageSource) {
for (IGravePositionHandler position : APIGraveGeneration.GRAVE_POSITION_HANDLERS) {
if (position.condition(world, entity, pos, damageSource)) {
return position.gravePosition();
}
}

if (world.provider.getDimensionType() == DimensionType.THE_END && pos.getY() <= 0) {
BlockPos groundPos = new BlockPos(pos.getX(), 0, pos.getZ());
if (world.isAirBlock(pos)) {
Expand Down

0 comments on commit d3feb15

Please sign in to comment.