[Change] Use POI to find EternalPortalFrame
This commit is contained in:
parent
6d58f088e4
commit
8b845a0a8f
3 changed files with 53 additions and 12 deletions
|
@ -37,6 +37,7 @@ public class BetterEnd implements ModInitializer {
|
||||||
EndEntities.register();
|
EndEntities.register();
|
||||||
EndBiomes.register();
|
EndBiomes.register();
|
||||||
EndTags.register();
|
EndTags.register();
|
||||||
|
EndPoiTypes.register();
|
||||||
EndEnchantments.register();
|
EndEnchantments.register();
|
||||||
EndPotions.register();
|
EndPotions.register();
|
||||||
CraftingRecipes.register();
|
CraftingRecipes.register();
|
||||||
|
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
|
@ -35,11 +35,13 @@ import org.betterx.betterend.blocks.RunedFlavolite;
|
||||||
import org.betterx.betterend.blocks.entities.EternalPedestalEntity;
|
import org.betterx.betterend.blocks.entities.EternalPedestalEntity;
|
||||||
import org.betterx.betterend.registry.EndBlocks;
|
import org.betterx.betterend.registry.EndBlocks;
|
||||||
import org.betterx.betterend.registry.EndFeatures;
|
import org.betterx.betterend.registry.EndFeatures;
|
||||||
|
import org.betterx.betterend.registry.EndPoiTypes;
|
||||||
import org.betterx.betterend.registry.EndPortals;
|
import org.betterx.betterend.registry.EndPortals;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Optional;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.function.Predicate;
|
import java.util.function.Predicate;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
@ -363,20 +365,29 @@ public class EternalRitual {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private BlockPos findFrame(Level world, BlockPos.MutableBlockPos startPos) {
|
private BlockPos findFrame(ServerLevel level, BlockPos.MutableBlockPos startPos) {
|
||||||
List<BlockPos.MutableBlockPos> foundPos = findAllBlockPos(
|
Optional<BlockPos> foundPos = EndPoiTypes
|
||||||
world,
|
.ETERNAL_PORTAL.findPoiAround(level, startPos, false, level.getWorldBorder());
|
||||||
startPos,
|
|
||||||
(SEARCH_RADIUS >> 4) + 1,
|
if (foundPos.isPresent()) {
|
||||||
FRAME,
|
if (checkFrame(world, foundPos.get())) {
|
||||||
blockState -> blockState.is(FRAME) && !blockState.getValue(ACTIVE)
|
return foundPos.get();
|
||||||
);
|
|
||||||
for (BlockPos.MutableBlockPos testPos : foundPos) {
|
|
||||||
if (checkFrame(world, testPos)) {
|
|
||||||
return testPos;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return null;
|
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) {
|
private BlockPos findPortalPos(int portalId) {
|
||||||
|
@ -737,6 +748,7 @@ public class EternalRitual {
|
||||||
int radius,
|
int radius,
|
||||||
Block searchBlock,
|
Block searchBlock,
|
||||||
Predicate<BlockState> condition) {
|
Predicate<BlockState> condition) {
|
||||||
|
|
||||||
List<BlockPos.MutableBlockPos> posFound = Lists.newArrayList();
|
List<BlockPos.MutableBlockPos> posFound = Lists.newArrayList();
|
||||||
Direction moveDirection = Direction.EAST;
|
Direction moveDirection = Direction.EAST;
|
||||||
for (int step = 1; step < radius; step++) {
|
for (int step = 1; step < radius; step++) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue