[Change] Use POI to find EternalPortalFrame

This commit is contained in:
Frank 2022-06-08 12:38:37 +02:00
parent 6d58f088e4
commit 8b845a0a8f
3 changed files with 53 additions and 12 deletions

View file

@ -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) -> {

View file

@ -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);
}
}

View file

@ -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<BlockPos.MutableBlockPos> 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<BlockPos> foundPos = EndPoiTypes
.ETERNAL_PORTAL.findPoiAround(level, startPos, false, level.getWorldBorder());
if (foundPos.isPresent()) {
if (checkFrame(world, foundPos.get())) {
return foundPos.get();
}
}
return null;
// List<BlockPos.MutableBlockPos> 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<BlockState> condition) {
List<BlockPos.MutableBlockPos> posFound = Lists.newArrayList();
Direction moveDirection = Direction.EAST;
for (int step = 1; step < radius; step++) {