Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix return portal position calculation for dragon respawn #346

Open
wants to merge 2 commits into
base: 1.20.3
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ private void respawnDragon(List<EndCrystal> list) {
@Inject(method = "tryRespawn", at = @At("HEAD"), cancellable = true)
private void be_tryRespawnDragon(CallbackInfo info) {
if (GeneratorOptions.replacePortal() && GeneratorOptions.hasDragonFights() && this.dragonKilled && this.respawnStage == null) {
BlockPos blockPos = portalLocation;
if (blockPos == null) {
if (portalLocation == null) {
LOGGER.debug("Tried to respawn, but need to find the portal first.");
BlockPattern.BlockPatternMatch blockPatternMatch = this.findExitPortal();
if (blockPatternMatch == null) {
Expand All @@ -68,21 +67,37 @@ private void be_tryRespawnDragon(CallbackInfo info) {
}
}

Vec3 center = new Vec3(
portalLocation.getX(),
0,
portalLocation.getZ()
);
LOGGER.debug("Checking around portal centered at {}", center);

List<EndCrystal> crystals = Lists.newArrayList();
for (Direction dir : BlocksHelper.HORIZONTAL) {
BlockPos central = BlockPos.ZERO.relative(dir, 4);
LOGGER.debug("Looking to the {}", dir);
LOGGER.debug("Checking from {} to {}",
center.relative(dir, 4),
center.relative(dir, 4).relative(Direction.UP, 255)
);
List<EndCrystal> crystalList = level.getEntitiesOfClass(
EndCrystal.class,
new AABB(
new Vec3(central.getX() - 1, central.getY() - 255, central.getZ() + 1),
new Vec3(central.getX() - 1, central.getY() + 255, central.getZ() + 1)
center.relative(dir, 4),
center.relative(dir, 4).relative(Direction.UP, 255)
)
);

int count = crystalList.size();
LOGGER.debug("Found {} crystal(s)", count);
for (int n = 0; n < count; n++) {
EndCrystal crystal = crystalList.get(n);
if (!level.getBlockState(crystal.blockPosition().below()).is(Blocks.BEDROCK)) {
LOGGER.debug(
"Crystal at {} is not on top of bedrock",
crystal.blockPosition()
);
crystalList.remove(n);
count--;
n--;
Expand Down