public static boolean onStructure(LivingEntity entity, Structure structure){
Registry<Structure> registry = entity.level.registryAccess().registryOrThrow(Registry.STRUCTURE_REGISTRY);
ServerLevel level = (ServerLevel) entity.level;
for(Structure struct : registry){
if(Objects.equals(struct, structure)){
return level.structureManager().getStructureWithPieceAt(entity.blockPosition(), struct).isValid();
}
}
return false;
}