用户反馈:地狱门从哪进从哪出的逻辑错了。门被损毁时应当 交还原版逻辑(让 MC 自己在 128 格范围内搜索/生成对应门), 而不是插件带回世界出生点附近自建 obsidian 门框。 修复:findStandAtOverworld 门A被毁分支由 rebuildPortalNear (自建门框+fire)改为返回 null → onPortalCross stand==null 分支不碰事件 → 原版 128 格搜索照常执行。 删除 rebuildPortalNear/buildFrame/placeW/setBlock 死代码。 门A存活分支(probeStandOutside 门前站位)不变。
This commit is contained in:
@@ -36,7 +36,8 @@ import java.util.UUID;
|
|||||||
* · 首次出境:玩家穿越瞬间的位置就是「第1个下界门B」→ 记录基准后立即接管
|
* · 首次出境:玩家穿越瞬间的位置就是「第1个下界门B」→ 记录基准后立即接管
|
||||||
* · 后续出境:玩家所在门与 netherStamp 水平距离≤5 才接管,否则交还原版
|
* · 后续出境:玩家所在门与 netherStamp 水平距离≤5 才接管,否则交还原版
|
||||||
* - 门A存活:取 mainStamp 玩家脚部位置为基础,向门体外侧探测站位(避开 portal 平面,防循环穿越)
|
* - 门A存活:取 mainStamp 玩家脚部位置为基础,向门体外侧探测站位(避开 portal 平面,防循环穿越)
|
||||||
* - 门A被毁(3料无 portal 方块):按原版重建 obsidian 门框 + fire(vanilla 会在玩家靠近时生成门板)
|
* - 门A被毁(3料无 portal 方块):★ 第99批续4起交还原版逻辑——findStandAtOverworld 返回 null,
|
||||||
|
* onPortalCross 不碰事件,让 MC 自己在 128 格范围内搜索/生成对应门,插件不再自建门框
|
||||||
*/
|
*/
|
||||||
public class NetherPortalManager implements Listener {
|
public class NetherPortalManager implements Listener {
|
||||||
|
|
||||||
@@ -143,7 +144,9 @@ public class NetherPortalManager implements Listener {
|
|||||||
/**
|
/**
|
||||||
* 定位主世界门A的安全回程站位:
|
* 定位主世界门A的安全回程站位:
|
||||||
* 1) 门A仍存活(附近 3 格有 portal 方块):从 base 向门体外侧探测安全站位(不在 portal 平面 → 防循环穿越)
|
* 1) 门A仍存活(附近 3 格有 portal 方块):从 base 向门体外侧探测安全站位(不在 portal 平面 → 防循环穿越)
|
||||||
* 2) 门板不在(被毁)→ 按原版结构在站位附近重建 obsidian 门框 + fire,返回门前站位
|
* 2) 门板不在(被毁)→ ★ 第99批续4修复:交还原版逻辑,
|
||||||
|
* 让 MC 自己在 128 格范围内搜索/生成对应门,插件不再自建门框。
|
||||||
|
* 返回 null → onPortalCross 不碰事件 → 原版 128 搜索照常执行。
|
||||||
*/
|
*/
|
||||||
private Location findStandAtOverworld(World w, Location base) {
|
private Location findStandAtOverworld(World w, Location base) {
|
||||||
if (hasPortalNear(w, base, 3)) {
|
if (hasPortalNear(w, base, 3)) {
|
||||||
@@ -151,7 +154,8 @@ public class NetherPortalManager implements Listener {
|
|||||||
plugin.getLogger().info("[地狱门接管] 主世界门A仍存活,门前安全站位: " + stand.toVector());
|
plugin.getLogger().info("[地狱门接管] 主世界门A仍存活,门前安全站位: " + stand.toVector());
|
||||||
return stand;
|
return stand;
|
||||||
}
|
}
|
||||||
return rebuildPortalNear(w, base);
|
plugin.getLogger().info("[地狱门接管] 主世界门A已损毁,交还原版逻辑(MC 在 128 格内自行搜索/造门),不重建");
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -210,108 +214,4 @@ public class NetherPortalManager implements Listener {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 在 loc 附近(半径 1..6)按原版结构重建地狱门(obsidian 门框 内部 3宽×4高)。
|
|
||||||
* 返回玩家在门前的站位(距离触发区,防循环);条件不满足返回 null。
|
|
||||||
*/
|
|
||||||
private Location rebuildPortalNear(World w, Location loc) {
|
|
||||||
int ex = loc.getBlockX(), ey = loc.getBlockY(), ez = loc.getBlockZ();
|
|
||||||
for (int r = 1; r <= 6; r++) {
|
|
||||||
int[][] deltas = {
|
|
||||||
{0, 0}, {r, 0}, {-r, 0}, {0, r}, {0, -r},
|
|
||||||
{r, r}, {r, -r}, {-r, r}, {-r, -r}
|
|
||||||
};
|
|
||||||
for (int[] d : deltas) {
|
|
||||||
int cx = ex + d[0];
|
|
||||||
int cz = ez + d[1];
|
|
||||||
for (boolean widthIsX : new boolean[]{true, false}) {
|
|
||||||
Location stand = buildFrame(w, cx, cz, ey, widthIsX);
|
|
||||||
if (stand != null) {
|
|
||||||
plugin.getLogger().info("[地狱门接管] 主世界门A被毁,在(" + cx + ", " + cz + ")重建原版门框,站位: "
|
|
||||||
+ stand.toVector());
|
|
||||||
return stand;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 在 (cx, cz) 上方搭原版 obsidian 門框(内部 3宽×4高,厚度 1 格)。
|
|
||||||
* widthIsX=true:门沿 x 轴展开;false:沿 z 轴展开。
|
|
||||||
* 返回玩家站立位置;条件不满足返回 null。
|
|
||||||
*/
|
|
||||||
private Location buildFrame(World w, int cx, int cz, int ey, boolean widthIsX) {
|
|
||||||
// 找地板:从记录位置往下找第一个可站立实体方块
|
|
||||||
int floorY = ey;
|
|
||||||
for (int dy = 0; dy <= 12; dy++) {
|
|
||||||
int fy = ey - dy;
|
|
||||||
if (fy < w.getMinHeight()) return null;
|
|
||||||
Block b = w.getBlockAt(cx, fy, cz);
|
|
||||||
Material m = b.getType();
|
|
||||||
if (m != Material.AIR && m != Material.LAVA) {
|
|
||||||
floorY = fy + 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 门框总高 6 格(底行 + 内部4 + 顶行),高度校验
|
|
||||||
if (floorY < w.getMinHeight() + 1 || floorY + 5 > w.getMaxHeight() - 1) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// 门洞检查:内部区不能有 lava
|
|
||||||
for (int i = -1; i <= 1; i++) {
|
|
||||||
for (int dy = 0; dy <= 4; dy++) {
|
|
||||||
Block b = widthIsX
|
|
||||||
? w.getBlockAt(cx + i, floorY + dy, cz)
|
|
||||||
: w.getBlockAt(cx, floorY + dy, cz + i);
|
|
||||||
if (b.getType() == Material.LAVA) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 摆门框 obsidian:底行 + 顶行,各宽轴 -2..+2;左右列在宽轴 ±1、y 1..4
|
|
||||||
for (int i = -2; i <= 2; i++) {
|
|
||||||
placeW(w, widthIsX, cx, cz, i, floorY, Material.OBSIDIAN);
|
|
||||||
placeW(w, widthIsX, cx, cz, i, floorY + 5, Material.OBSIDIAN);
|
|
||||||
}
|
|
||||||
for (int i : new int[]{-1, 1}) {
|
|
||||||
for (int dy = 1; dy <= 4; dy++) {
|
|
||||||
placeW(w, widthIsX, cx, cz, i, floorY + dy, Material.OBSIDIAN);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 顶部 fire(原版生成门框时的顶部布置)
|
|
||||||
placeW(w, widthIsX, cx, cz, -1, floorY + 5, Material.FIRE);
|
|
||||||
placeW(w, widthIsX, cx, cz, 1, floorY + 5, Material.FIRE);
|
|
||||||
placeW(w, widthIsX, cx, cz, 0, floorY + 5, Material.FIRE);
|
|
||||||
placeW(w, widthIsX, cx, cz, -2, floorY + 5, Material.FIRE);
|
|
||||||
placeW(w, widthIsX, cx, cz, 2, floorY + 5, Material.FIRE);
|
|
||||||
|
|
||||||
// 站立位置:门前第 2 格地面中央(不在 portal 平面内,防循环触发)
|
|
||||||
int standX = widthIsX ? cx : cx;
|
|
||||||
int standZ = widthIsX ? cz - 2 : cz;
|
|
||||||
if (!widthIsX) standX = cx - 2;
|
|
||||||
return new Location(w, standX + 0.5D, floorY + 0.5D, standZ + 0.5D);
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 放置到门户宽轴第 i 列(相对中心)、y 行;widthIsX 决定宽轴是 X 还是 Z。 */
|
|
||||||
private static void placeW(World w, boolean widthIsX, int cx, int cz, int i, int y, Material m) {
|
|
||||||
if (widthIsX) {
|
|
||||||
setBlock(w, cx + i, y, cz, m);
|
|
||||||
} else {
|
|
||||||
setBlock(w, cx, y, cz + i, m);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 写方块(静默,不做物理反馈)。 */
|
|
||||||
private static void setBlock(World w, int x, int y, int z, Material m) {
|
|
||||||
Block b = w.getBlockAt(x, y, z);
|
|
||||||
if (b.getType() != m) {
|
|
||||||
b.setType(m, false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user