Files
SteamWar/HiderCore/src/de/steamwar/techhider/AccessPrivilegeProvider.java
T
YoyoNow d76c396268 Do not hide entities with the BauSystem hullhider
HullHider gets a hideEntities parameter: the fight still hides entities inside
hidden hulls, /hullhider only hides blocks. As the TechHider also dropped
spawn packets at hidden positions, ForPlayer#canAccessEntitySpawn decides
about them now, which the BauTechHider always allows.
2026-10-31 15:57:25 +01:00

70 lines
2.6 KiB
Java

/*
* 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.techhider;
import net.minecraft.world.level.block.Block;
import net.minecraft.world.level.block.entity.BlockEntityType;
import net.minecraft.world.level.block.state.BlockState;
import org.bukkit.entity.Player;
public interface AccessPrivilegeProvider {
/**
* Resolves everything that can change concurrently about this player once.
* The result is used for all decisions of one outgoing packet (including all packets of a bundle).
*/
ForPlayer forPlayer(Player p);
boolean isPlayerPrivilegedToPerformAction(Player p);
/**
* What a single player may access, valid for the processing of one outgoing packet.
*/
interface ForPlayer {
Player getPlayer();
/**
* @return true if nothing within this chunk is restricted for this player, so the chunk may be sent unmodified
*/
boolean canAccessAllDataWithinChunk(int chunkX, int chunkZ);
boolean canAccessPosition(int blockX, int blockY, int blockZ);
boolean canAccessBlock(int blockX, int blockY, int blockZ, Block block);
boolean canAccessBlockState(int blockX, int blockY, int blockZ, BlockState blockState);
boolean canAccessEntity(int entityId);
/**
* @return whether the player may see the entity spawning at this position
*/
default boolean canAccessEntitySpawn(int entityId, int blockX, int blockY, int blockZ) {
return canAccessEntity(entityId) && canAccessPosition(blockX, blockY, blockZ);
}
boolean canAccessBlockEntity(int blockX, int blockY, int blockZ, BlockEntityType<?> type);
/**
* @return the block state sent instead of a block this player may not access at this position
*/
BlockState getObfuscation(int blockX, int blockY, int blockZ);
}
}