only yeet out of subclaim if main claim allows it close #107
This commit is contained in:
parent
40350ca1c3
commit
485a2be455
@ -327,7 +327,8 @@ public class EntityInteractEvents {
|
|||||||
if (!player.isSpectator()) {
|
if (!player.isSpectator()) {
|
||||||
BlockPos.MutableBlockPos bPos = rounded.mutable();
|
BlockPos.MutableBlockPos bPos = rounded.mutable();
|
||||||
if (!currentClaim.canInteract(player, PermissionRegistry.CANSTAY, bPos, true)) {
|
if (!currentClaim.canInteract(player, PermissionRegistry.CANSTAY, bPos, true)) {
|
||||||
Vec3 tp = TeleportUtils.getTeleportPos(player, pos, storage, currentClaim.getDimensions(), bPos, (claim, nPos) -> claim.canInteract(player, PermissionRegistry.CANSTAY, nPos, false));
|
Claim sub = currentClaim.getSubClaim(bPos);
|
||||||
|
Vec3 tp = TeleportUtils.getTeleportPos(player, pos, storage, sub != null ? sub.getDimensions() : currentClaim.getDimensions(), true, bPos, (claim, nPos) -> claim.canInteract(player, PermissionRegistry.CANSTAY, nPos, false));
|
||||||
player.teleportToWithTicket(tp.x(), tp.y(), tp.z());
|
player.teleportToWithTicket(tp.x(), tp.y(), tp.z());
|
||||||
}
|
}
|
||||||
if (player.getAbilities().flying && !player.isCreative() && !currentClaim.canInteract(player, PermissionRegistry.FLIGHT, rounded, true)) {
|
if (player.getAbilities().flying && !player.isCreative() && !currentClaim.canInteract(player, PermissionRegistry.FLIGHT, rounded, true)) {
|
||||||
|
@ -19,9 +19,18 @@ public class TeleportUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static Vec3 getTeleportPos(ServerPlayer player, Vec3 playerPos, ClaimStorage storage, int[] dim, BlockPos.MutableBlockPos bPos, BiFunction<Claim, BlockPos, Boolean> check) {
|
public static Vec3 getTeleportPos(ServerPlayer player, Vec3 playerPos, ClaimStorage storage, int[] dim, BlockPos.MutableBlockPos bPos, BiFunction<Claim, BlockPos, Boolean> check) {
|
||||||
|
return getTeleportPos(player, playerPos, storage, dim, false, bPos, check);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Vec3 getTeleportPos(ServerPlayer player, Vec3 playerPos, ClaimStorage storage, int[] dim, boolean checkSub, BlockPos.MutableBlockPos bPos, BiFunction<Claim, BlockPos, Boolean> check) {
|
||||||
Tuple<Direction, Vec3> pos = nearestOutside(dim, playerPos);
|
Tuple<Direction, Vec3> pos = nearestOutside(dim, playerPos);
|
||||||
bPos.set(pos.getB().x(), pos.getB().y(), pos.getB().z());
|
bPos.set(pos.getB().x(), pos.getB().y(), pos.getB().z());
|
||||||
Claim claim = storage.getClaimAt(bPos);
|
Claim claim = storage.getClaimAt(bPos);
|
||||||
|
if (checkSub) {
|
||||||
|
Claim sub = claim != null ? claim.getSubClaim(bPos) : null;
|
||||||
|
if (sub != null)
|
||||||
|
claim = sub;
|
||||||
|
}
|
||||||
if (claim == null || check.apply(claim, bPos)) {
|
if (claim == null || check.apply(claim, bPos)) {
|
||||||
Vec3 ret = pos.getB();
|
Vec3 ret = pos.getB();
|
||||||
BlockPos rounded = roundedBlockPos(ret);
|
BlockPos rounded = roundedBlockPos(ret);
|
||||||
@ -47,7 +56,7 @@ public class TeleportUtils {
|
|||||||
dim[0] = newDim[0];
|
dim[0] = newDim[0];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return getTeleportPos(player, playerPos, storage, dim, bPos, check);
|
return getTeleportPos(player, playerPos, storage, dim, checkSub, bPos, check);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Tuple<Direction, Vec3> nearestOutside(int[] dim, Vec3 from) {
|
private static Tuple<Direction, Vec3> nearestOutside(int[] dim, Vec3 from) {
|
||||||
|
Loading…
Reference in New Issue
Block a user