diff --git a/src/main/java/org/betterx/betterend/BetterEnd.java b/src/main/java/org/betterx/betterend/BetterEnd.java index 276743d6..5c06618f 100644 --- a/src/main/java/org/betterx/betterend/BetterEnd.java +++ b/src/main/java/org/betterx/betterend/BetterEnd.java @@ -37,6 +37,7 @@ public class BetterEnd implements ModInitializer { EndEntities.register(); EndBiomes.register(); EndTags.register(); + EndPoiTypes.register(); EndEnchantments.register(); EndPotions.register(); CraftingRecipes.register(); @@ -58,7 +59,7 @@ public class BetterEnd implements ModInitializer { if (GeneratorOptions.useNewGenerator()) { org.betterx.bclib.api.v2.generator.GeneratorOptions.setFarEndBiomes(GeneratorOptions.getIslandDistBlock()); org.betterx.bclib.api.v2.generator.GeneratorOptions.setEndLandFunction((pos) -> TerrainGenerator.isLand(pos.x, - pos.y)); + pos.y)); } BiomeAPI.registerEndBiomeModification((biomeID, biome) -> { diff --git a/src/main/java/org/betterx/betterend/registry/EndPoiTypes.java b/src/main/java/org/betterx/betterend/registry/EndPoiTypes.java new file mode 100644 index 00000000..d79f185e --- /dev/null +++ b/src/main/java/org/betterx/betterend/registry/EndPoiTypes.java @@ -0,0 +1,28 @@ +package org.betterx.betterend.registry; + +import org.betterx.bclib.api.v2.poi.BCLPoiType; +import org.betterx.bclib.api.v2.poi.PoiRegistry; +import org.betterx.bclib.blocks.BlockProperties; +import org.betterx.betterend.BetterEnd; + +import java.util.stream.Collectors; + +public class EndPoiTypes { + public static final BCLPoiType ETERNAL_PORTAL = PoiRegistry + .register( + BetterEnd.makeID("eternal_portal"), + () -> BCLPoiType + .getBlockStates(EndBlocks.FLAVOLITE_RUNED_ETERNAL) + .stream().filter(state -> !state.getValue(BlockProperties.ACTIVE)) + .collect(Collectors.toSet()), + 0, 1 + ); + + private static void bootstrap() { + //This basically ensures that our static structures are loaded and registered + } + + public static void register() { + PoiRegistry.registerForBootstrap(EndPoiTypes::bootstrap); + } +} diff --git a/src/main/java/org/betterx/betterend/rituals/EternalRitual.java b/src/main/java/org/betterx/betterend/rituals/EternalRitual.java index dae79f4b..642aa58a 100644 --- a/src/main/java/org/betterx/betterend/rituals/EternalRitual.java +++ b/src/main/java/org/betterx/betterend/rituals/EternalRitual.java @@ -35,11 +35,13 @@ import org.betterx.betterend.blocks.RunedFlavolite; import org.betterx.betterend.blocks.entities.EternalPedestalEntity; import org.betterx.betterend.registry.EndBlocks; import org.betterx.betterend.registry.EndFeatures; +import org.betterx.betterend.registry.EndPoiTypes; import org.betterx.betterend.registry.EndPortals; import java.awt.*; import java.util.List; import java.util.Objects; +import java.util.Optional; import java.util.Set; import java.util.function.Predicate; import org.jetbrains.annotations.Nullable; @@ -363,20 +365,29 @@ public class EternalRitual { } @Nullable - private BlockPos findFrame(Level world, BlockPos.MutableBlockPos startPos) { - List foundPos = findAllBlockPos( - world, - startPos, - (SEARCH_RADIUS >> 4) + 1, - FRAME, - blockState -> blockState.is(FRAME) && !blockState.getValue(ACTIVE) - ); - for (BlockPos.MutableBlockPos testPos : foundPos) { - if (checkFrame(world, testPos)) { - return testPos; + private BlockPos findFrame(ServerLevel level, BlockPos.MutableBlockPos startPos) { + Optional foundPos = EndPoiTypes + .ETERNAL_PORTAL.findPoiAround(level, startPos, false, level.getWorldBorder()); + + if (foundPos.isPresent()) { + if (checkFrame(world, foundPos.get())) { + return foundPos.get(); } } return null; +// List foundPos = findAllBlockPos( +// world, +// startPos, +// (SEARCH_RADIUS >> 4) + 1, +// FRAME, +// blockState -> blockState.is(FRAME) && !blockState.getValue(ACTIVE) +// ); +// for (BlockPos.MutableBlockPos testPos : foundPos) { +// if (checkFrame(world, testPos)) { +// return testPos; +// } +// } +// return null; } private BlockPos findPortalPos(int portalId) { @@ -737,6 +748,7 @@ public class EternalRitual { int radius, Block searchBlock, Predicate condition) { + List posFound = Lists.newArrayList(); Direction moveDirection = Direction.EAST; for (int step = 1; step < radius; step++) {