Move Hull and generic HullHider into HiderCore

Hull no longer depends on FightSystem: plugin, world, region, ground
visibility and hidden blocks are passed in. HullRegion is the common block
box hulls work on. The generic HullHider<K> manages one hull per key and does
the block, entity and REntity tracking; FightHullHider keeps the fight
specific parts (team hulls, viewer rules, state dependent registration).

Entities are now checked against the hull with block coordinates, so entities
in the bottom layer and at the max z edge are handled correctly.
This commit is contained in:
2026-10-31 14:49:00 +01:00
parent a3a97ee102
commit da4b684a4b
10 changed files with 334 additions and 119 deletions
@@ -0,0 +1,97 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2026 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.hullhider;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.bukkit.Location;
/**
* Immutable block box a {@link Hull} covers. The minimum is inclusive, the maximum exclusive.
*/
@Getter
@AllArgsConstructor
public final class HullRegion {
public static HullRegion fromSize(int minX, int minY, int minZ, int sizeX, int sizeY, int sizeZ) {
return new HullRegion(minX, minY, minZ, minX + sizeX, minY + sizeY, minZ + sizeZ);
}
public static HullRegion fromInclusive(int minX, int minY, int minZ, int maxX, int maxY, int maxZ) {
return new HullRegion(minX, minY, minZ, maxX + 1, maxY + 1, maxZ + 1);
}
private final int minX;
private final int minY;
private final int minZ;
private final int maxX;
private final int maxY;
private final int maxZ;
public int getSizeX() {
return maxX - minX;
}
public int getSizeY() {
return maxY - minY;
}
public int getSizeZ() {
return maxZ - minZ;
}
public int volume() {
return getSizeX() * getSizeY() * getSizeZ();
}
public boolean contains(int x, int y, int z) {
return minX <= x && x < maxX && minY <= y && y < maxY && minZ <= z && z < maxZ;
}
public boolean contains(Location location) {
return contains(location.getBlockX(), location.getBlockY(), location.getBlockZ());
}
/**
* @return the index of the block within a bitset of {@link #volume()} bits, only valid for contained blocks
*/
public int toIndex(int x, int y, int z) {
return ((y - minY) * getSizeZ() + (z - minZ)) * getSizeX() + (x - minX);
}
public void forEach(BlockConsumer executor) {
for (int x = minX; x < maxX; x++) {
for (int y = minY; y < maxY; y++) {
for (int z = minZ; z < maxZ; z++) {
executor.accept(x, y, z);
}
}
}
}
public interface BlockConsumer {
void accept(int x, int y, int z);
}
@Override
public String toString() {
return minX + "," + minY + "," + minZ + "->" + maxX + "," + maxY + "," + maxZ;
}
}