Stop hull rays from passing between occluding blocks

A ray only moves diagonally if it could also reach the block by moving along
the single axes of the direction one after another without passing an
occluding block, so it no longer squeezes between blocks touching at an edge
or corner. When a block stops occluding, the diagonal rays it blocked are
continued, so incremental updates match a full initialisation.

Double slabs now occlude as well, as slab materials do not; block updates
pass the block data instead of the material for that.

To keep the initialisation fast, a ray only checks a diagonal step after the
cheaper checks, and the branch directions are computed once per hull.
This commit is contained in:
2026-10-31 17:07:18 +01:00
parent 9fd2bd17d4
commit 5651455a5f
4 changed files with 119 additions and 28 deletions
@@ -51,7 +51,7 @@ import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.state.BlockState;
import org.bukkit.*;
import org.bukkit.craftbukkit.CraftWorld;
import org.bukkit.craftbukkit.util.CraftMagicNumbers;
import org.bukkit.craftbukkit.block.data.CraftBlockData;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
@@ -473,7 +473,7 @@ public class PacketProcessor implements Listener {
level.removeBlockEntity(pos);
level.setBlock(pos, blockData, blockState1);
level.getChunkSource().blockChanged(pos);
FightSystem.getHullHider().blockUpdate(Config.world.getBlockAt(x, y, z), CraftMagicNumbers.getMaterial(Block.stateById(blockState)).getItemType());
FightSystem.getHullHider().blockUpdate(Config.world.getBlockAt(x, y, z), CraftBlockData.fromData(Block.stateById(blockState)));
});
}
@@ -33,8 +33,8 @@ import de.steamwar.fightsystem.states.StateDependentTask;
import de.steamwar.hullhider.Hull;
import de.steamwar.hullhider.HullHider;
import de.steamwar.hullhider.Viewers;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
@@ -119,8 +119,8 @@ public class FightHullHider {
});
}
public void blockUpdate(Block block, Material changedType) {
hullHider.blockUpdate(block, changedType);
public void blockUpdate(Block block, BlockData changedData) {
hullHider.blockUpdate(block, changedData);
}
public boolean isBlockHidden(Player player, int x, int y, int z) {