From 7f17b06999aa0fb7a4719c22ba996ec52825dfc9 Mon Sep 17 00:00:00 2001 From: "Gili \"OpenBagTwo\" Barlev" Date: Mon, 5 Feb 2024 08:57:30 -0500 Subject: [PATCH 1/2] Fix return portal position calculation... ...for dragon fight respawn --- .../mixin/common/EndDragonFightMixin.java | 26 +++++++++++++++---- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/betterx/betterend/mixin/common/EndDragonFightMixin.java b/src/main/java/org/betterx/betterend/mixin/common/EndDragonFightMixin.java index a247d3af9..7d5d053ad 100644 --- a/src/main/java/org/betterx/betterend/mixin/common/EndDragonFightMixin.java +++ b/src/main/java/org/betterx/betterend/mixin/common/EndDragonFightMixin.java @@ -1,5 +1,6 @@ package org.betterx.betterend.mixin.common; +import java.util.Arrays; import org.betterx.bclib.util.BlocksHelper; import org.betterx.betterend.world.generator.GeneratorOptions; @@ -56,8 +57,7 @@ private void respawnDragon(List 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) { @@ -68,21 +68,37 @@ private void be_tryRespawnDragon(CallbackInfo info) { } } + Vec3 center = new Vec3( + Math.floor(portalLocation.getX()), + 0, + Math.floor(portalLocation.getZ()) + ); + LOGGER.debug("Assuming portal is centered at {}", center); + List 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 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--; From 9d6017a1a97f98dbd034edc6699ac3baab65079c Mon Sep 17 00:00:00 2001 From: "Gili \"OpenBagTwo\" Barlev" Date: Mon, 5 Feb 2024 09:26:14 -0500 Subject: [PATCH 2/2] Clean up and simplify --- .../betterend/mixin/common/EndDragonFightMixin.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/main/java/org/betterx/betterend/mixin/common/EndDragonFightMixin.java b/src/main/java/org/betterx/betterend/mixin/common/EndDragonFightMixin.java index 7d5d053ad..74464a00c 100644 --- a/src/main/java/org/betterx/betterend/mixin/common/EndDragonFightMixin.java +++ b/src/main/java/org/betterx/betterend/mixin/common/EndDragonFightMixin.java @@ -1,6 +1,5 @@ package org.betterx.betterend.mixin.common; -import java.util.Arrays; import org.betterx.bclib.util.BlocksHelper; import org.betterx.betterend.world.generator.GeneratorOptions; @@ -69,11 +68,11 @@ private void be_tryRespawnDragon(CallbackInfo info) { } Vec3 center = new Vec3( - Math.floor(portalLocation.getX()), + portalLocation.getX(), 0, - Math.floor(portalLocation.getZ()) + portalLocation.getZ() ); - LOGGER.debug("Assuming portal is centered at {}", center); + LOGGER.debug("Checking around portal centered at {}", center); List crystals = Lists.newArrayList(); for (Direction dir : BlocksHelper.HORIZONTAL) {